CASA/c_micasad/startup/casacfgpam

45 lines
1.1 KiB
Plaintext
Executable File

# Adding CASA pam entries to pam files.
for file in "/etc/pam.d/login" "/etc/pam.d/sshd" "/etc/pam.d/xdm" "/etc/pam.d/gdm" "/etc/pam.d/kdm"
do
if [ -f $file ]
then
sed -i '/pam_micasa/d' $file
var=`grep pam_unix2.so $file`
entry=`echo -e "auth\t required\tpam_micasa.so"`
entry2=`echo -e "session\t required\tpam_micasa.so"`
cnt=0
if [ "$var" != "" ]
then
sed -i "/^auth.*required.*pam_unix2.so/a$entry" $file
sed -i "/^session.*required.*pam_unix2.so/a$entry2" $file
else
let ' cnt = cnt + 1'
fi
var2=`grep common-auth $file`
if [ "$var2" != "" ]
then
sed -i "/^auth.*include.*common-auth/a$entry" $file
sed -i "/^session.*include.*common-session/a$entry2" $file
else
let ' cnt = cnt + 1'
fi
if [ $cnt -eq 2 ]
then
awk '
/auth/ { authSeen++; }
/account/ {
if (!acctSeen && authSeen)
{
print "auth\trequired\tpam_micasa.so\n";}
acctSeen++;
}
/session/ { sesSeen++; }
// {print $0; }
END { if (sesSeen)
print "session\trequired\tpam_micasa.so\n"; }
' $file > $file.sav
mv $file.sav $file
fi
fi
done