-
Notifications
You must be signed in to change notification settings - Fork 1
/
mkpamserv
executable file
·54 lines (50 loc) · 1.46 KB
/
mkpamserv
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
#! /bin/sh
if test -z "$sysconfdir"; then
if test -n "$etc"; then
sysconfdir=$etc
else
sysconfdir=$prefix/etc
fi
fi
if test -z "$1"; then
echo "Usage: $0 <service>"
exit 1
fi
if test -r $sysconfdir/pam.d/$1 || grep "^$1" $sysconfdir/pam.conf >/dev/null 2>&1; then
echo "PAM service \"$1\" already configured."
exit 0
fi
if test -d $sysconfdir/pam.d; then
if test ! -w $sysconfdir/pam.d; then
echo "Error: need write access to $sysconfdir/pam.d/ to install PAM service definition!"
exit 1
fi
for sv in kde login; do
if test -r $sysconfdir/pam.d/$sv; then
echo "Copying PAM service definition file \"$sv\" to \"$1\"."
cp $sysconfdir/pam.d/"$sv" $sysconfdir/pam.d/$1
exit 0
fi
done
echo "No template PAM service file for \"$1\" found!"
exit 1
elif test -f $sysconfdir/pam.conf; then
if test ! -w $sysconfdir/pam.conf; then
echo "Error: need write access to $sysconfdir/pam.conf to install PAM service definition!"
exit 1
fi
for sv in kde login; do
serv=`grep "^$sv[ ]" $sysconfdir/pam.conf`
if test -n "$serv"; then
echo "Copying service definition entry \"$sv\" to \"$1\"."
echo >>$sysconfdir/pam.conf
echo "$serv" | sed -e "s/^$sv\\([ ]\\)/$1\\1/" >>$sysconfdir/pam.conf
exit 0
fi
done
echo "No template PAM service entry for \"$1\" found!"
exit 1
else
echo "Error: don't know where to store the PAM service definition for \"$1\"!"
exit 1
fi