https://github.com/devkral/pam_email_extractor
Extract email from multiple sources and add to pam environment
https://github.com/devkral/pam_email_extractor
Last synced: 8 months ago
JSON representation
Extract email from multiple sources and add to pam environment
- Host: GitHub
- URL: https://github.com/devkral/pam_email_extractor
- Owner: devkral
- License: mit
- Created: 2017-10-15T19:45:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-15T15:59:33.000Z (almost 8 years ago)
- Last Synced: 2025-04-03T00:12:35.579Z (11 months ago)
- Language: C
- Homepage:
- Size: 54.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Setup
```sh
cd ./build
cmake ..
make
cp ./src/pam_email_extractor.so
```
in pam service file add:
auth optional pam_email_extractor.so
or
session optional pam_email_extractor.so
(only of them is needed elsewise there could be duplicate ldap requests)
# Usage
In some program (here rpam2, ruby) retrieve the "email" pam environment variable:
```ruby
require 'rpam2'
# 'email' is the pam environment variable set by pam_email_extractor
Rpam2.getenv('', '', '', 'email')
# or easier
# returns hash with entry: 'email' -> email address
Rpam2.listenv('', '', '')
```
# Naming
pam_email as well as pam_mail already existed so I had to rename to pam_email_extractor.
# Configuration
items are position dependent and are seperated by whitespaces
possible items:
* gecos= : extract email from the gecos field of the user
* git=[/.gitignore] : extract email from user .gitconfig (or other file)
* file=[/.email] : extract email from user .email (or other file)
* ldap=<url;dn;emailattribute;filter> : extract email from ldap.
* default=[hostname] : default email domain to add to username; e.g. default=example.org and username is tom => tom@example.org. Defaults to hostname
pam_email_extractor uses following aruments if no arguments were given:
file gecos git default
## ldap
LDAP is always available except if compiled with the NO_LDAP flag
ldap takes following ; seperated arguments:
* url: url to query, needs scheme e.g. ldaps://
* dn: domain of user objects
* emailattribute (default: "email"): name of emailattribute of user object
* filter (default: "(uid=?)"): filter query, ? is replaced by username in filter query
## git & file
note that given path has to start with /.
composition is e.g.:
user tom => prefix: /home/tom
param /.email => combined: /home/tom/.email
## default
Because in default the username is taken in whole I limit the amount of retries when allocating.
It should be used as a fallback and returns if not out of memory always an emailaddress. So it is wise to position it last.
If no hostname is given it uses system gethostname.