blob: 6f3e7ec6d8bb89b5b917f122dbdc51f17c61cc7c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
|