diff options
author | Jonathan Bauer | 2011-12-06 17:23:02 +0100 |
---|---|---|
committer | Jonathan Bauer | 2011-12-06 17:47:02 +0100 |
commit | 5d97f33775e539da678d2c893c68520ef3c72618 (patch) | |
tree | 8f0a9174c7f8b22bbcd6eb9c9cd1f8ca8b070d96 /src/os-plugins/plugins/eduroam/files/usr/share/libpam-script/pam_script_auth | |
parent | Merge branch 'master' of openslx.org:openslx/core (diff) | |
download | core-5d97f33775e539da678d2c893c68520ef3c72618.tar.gz core-5d97f33775e539da678d2c893c68520ef3c72618.tar.xz core-5d97f33775e539da678d2c893c68520ef3c72618.zip |
eduroam plugin base (working for kdm)
Diffstat (limited to 'src/os-plugins/plugins/eduroam/files/usr/share/libpam-script/pam_script_auth')
-rwxr-xr-x | src/os-plugins/plugins/eduroam/files/usr/share/libpam-script/pam_script_auth | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/os-plugins/plugins/eduroam/files/usr/share/libpam-script/pam_script_auth b/src/os-plugins/plugins/eduroam/files/usr/share/libpam-script/pam_script_auth new file mode 100755 index 00000000..6f3e7ec6 --- /dev/null +++ b/src/os-plugins/plugins/eduroam/files/usr/share/libpam-script/pam_script_auth @@ -0,0 +1,60 @@ +#!/bin/bash +# pam_script_auth + +# file to write authentification method to +file=/var/run/eduroam_auth_method + +# check given argument +case "$1" in + + "radius" ) + # auth method, write it to file + echo "[$PAM_TYPE] Verifying credentials (through $1)..." + #echo "$1" > $file.$PAM_USER + ;; + + "create_user" ) + # create user + # check if user exists + if [ "x$(cat /etc/passwd | grep ^$PAM_USER | wc -l)" == "x1" ] + then + # user exists + echo "[$PAM_TYPE] User $PAM_USER exists already." + else + # user does not exists, create it. + echo "[$PAM_TYPE] User $PAM_USER does not exist." + echo "[$PAM_TYPE] Creating user $PAM_USER ..." + + uid_file=/var/run/eduroam_lastuid + # check for /var/run/eduroam_lastuid + [ ! -f $uid_file ] && echo "234299000" > $uid_file + + # set user information + uid=$(($(cat $uid_file)+1)) + gid=1001 + homedir=/home/$PAM_USER + uinfo="Eduroam Guest" + ushell=/bin/bash + + # create home directory + mkdir $homedir + chown $uid:$gid $homedir + + # create /etc/passwd entry + echo "$PAM_USER:x:$uid:$gid:$uinfo:$homedir:$ushell" >> /etc/passwd + + # create /etc/shadow entry + # set today's date for last pw change + pwlastchange=$(($(date +%s) / 60 / 60 / 24)) + echo "$PAM_USER:x:$pwlastchange:0:99999:7:::" >> /etc/shadow + + # user creation done, adjust uid_file + echo "$uid" > $uid_file + fi + ;; + + * ) + echo "[$PAM_TYPE] $0 unrecognized parameter: $1 (ignoring)." + ;; + +esac |