4 if test "x$1" = x-P
; then
10 echo "Usage: $0 [-P] <service>" >&2
14 if test -r /etc
/pam.d
/$1 ||
grep "^[ ]*$1[ ]" /etc
/pam.conf
>/dev
/null
2>&1; then
15 echo "PAM service \"$1\" already configured."
19 oi_mods
="pam_(access|env|group|limits|listfile|mkhomedir|nologin|shells|tally|time)"
20 oo_mods
="pam_(securetty|mail|motd|issue|lastlog)"
22 if test -d /etc
/pam.d
; then
23 if test ! -w /etc
/pam.d
; then
24 echo "Error: need write access to /etc/pam.d/ to install PAM service definition!" >&2
27 for sv
in kde login
; do
28 if test -r /etc
/pam.d
/$sv; then
29 echo "Copying PAM service definition file \"$sv\" to \"$1\"."
31 echo "auth required pam_permit.so" > /etc
/pam.d
/$1
32 perl
-p -e "if (/^([ \\t]*\\@include[ \\t]+([^ \\t]+)[ \\t]*)\\n/) { \$l=\$1; \$p=\$2; \$p=~m,^/, || (\$p='/etc/pam.d/'.\$p); print \"#\$l -- start\\n\"; system \"cat \$p\"; \$_ = \"#\$l -- end\\n\"; }" < /etc
/pam.d
/$sv |
33 perl
-p -e "s/^([ \\t]*auth[ \\t]+[a-z]+[ \\t]+([^ \\t]+\\/)?(?!$oi_mods)\\w+\\.so)/#\$1/" >> /etc
/pam.d
/$1
35 perl
-p -e "s/^([ \\t]*[^#].*[ \\t\\/]$oo_mods\\.so)/#\\1/" < /etc
/pam.d
/$sv > /etc
/pam.d
/$1
40 echo "Error: no template PAM service file for \"$1\" found!" >&2
42 elif test -f /etc
/pam.conf
; then
43 if test ! -w /etc
/pam.conf
; then
44 echo "Error: need write access to /etc/pam.conf to install PAM service definition!" >&2
47 for sv
in kde login
; do
48 serv
=`grep "^[ ]*$sv[ ]" /etc/pam.conf`
49 if test -n "$serv"; then
50 echo "Copying service definition entry \"$sv\" to \"$1\"."
52 sb
="s/^[ \\t]*$sv([ \\t])/$1\$1/"
54 echo "$1 auth required pam_permit.so" >>/etc
/pam.conf
55 echo "$serv" | perl
-p -e "$sb;s/^($1[ \\t]+auth[ \\t]+[a-z]+[ \\t]+([^ \\t]+\\/)?(?!$oi_mods)\\w+\\.so)/#\$1/" >>/etc
/pam.conf
57 echo "$serv" | perl
-p -e "$sb;s/^(.*[ \\t\\/]$oo_mods\\.so)/#\$1/" >>/etc
/pam.conf
62 echo "Error: no template PAM service entry for \"$1\" found!" >&2
65 if test "`whoami`" != root
; then
66 echo "Error: need root priviledges to install PAM service definitions!" >&2
68 echo "Error: don't know where to store the PAM service definition for \"$1\"!" >&2