summaryrefslogtreecommitdiffstats
path: root/src/os-plugins/plugins/eduroam/files/usr/share/libpam-script/pam_script_auth
diff options
context:
space:
mode:
Diffstat (limited to 'src/os-plugins/plugins/eduroam/files/usr/share/libpam-script/pam_script_auth')
-rwxr-xr-xsrc/os-plugins/plugins/eduroam/files/usr/share/libpam-script/pam_script_auth60
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