-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcoreconfig-kerberos-settings.sh
74 lines (65 loc) · 1.95 KB
/
coreconfig-kerberos-settings.sh
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
###################################################################
#
# Script to set up a default Kerberos config file and modify
# the PAM configiration so a TGT is requested on login and
# renewed on wake from sleep or screen unlock.
#
# Date: @@DATE
# Version: @@VERSION
# Origin: @@ORIGIN
# Released by JSS User: @@USER
#
##################################################################
KRB5FILE='/etc/krb5.conf'
PAM_AUTHZ='/etc/pam.d/authorization'
PAM_LOGIN='/etc/pam.d/login'
PAM_SCREENSAVER='/etc/pam.d/screensaver'
# Make sure that we have a krb5.conf file that looks as we expect
temp_krb5=`mktemp`
cat > $temp_krb5 <<EOF
# This file is maintained by the Mac Supported Desktop.
# Do not edit it! If you feel you need to alter your Kerberos
# configuration, please contact [email protected]
[libdefaults]
dns_lookup_realm = true
default_realm = ED.AC.UK
[domain_realm]
jabber.is.ed.ac.uk = EASE.ED.AC.UK
.jabber.is.ed.ac.uk = EASE.ED.AC.UK
authorise.is.ed.ac.uk = EASE.ED.AC.UK
.authorise.is.ed.ac.uk = EASE.ED.AC.UK
ecdf.ed.ac.uk = ED.AC.UK
.ecdf.ed.ac.uk = ED.AC.UK
EOF
if [ ! -f "${KRB5FILE}" ]
then
cp "${temp_krb5}" "${KRB5FILE}"
chmod 644 "${KRB5FILE}"
else
# If the files are not the same
if ! cmp "${KRB5FILE}" ${temp_krb5} &> /dev/null
then
echo "Refreshing ${KRB5FILE}"
mv "${KRB5FILE}" "${KRB5FILE}".$(date "+%Y-%m-%d-%H:%M:%S")
cp "${temp_krb5}" "${KRB5FILE}"
echo "Backed up old file"
else
echo "${KRB5FILE} loooks fine. Leaving alone"
fi
fi
for file in ${PAM_AUTHZ} ${PAM_LOGIN} ${PAM_SCREENSAVER}
do
if [ -f "${file}" ]
then
echo "Ensuring ${file} is up to date..."
if egrep '^auth optional pam_krb5\.so.*use_kcminit$' "${file}"
then
sed -E -i.$(date "+%Y-%m-%d-%H:%M:%S") \
's/^auth optional pam_krb5\.so(.*)use_kcminit$/auth optional pam_krb5.so\1use_kcminit default_principal/'\
"${file}"
fi
else
echo "Couldn't find ${file}. Something is very wrong!"
fi
done