blob: 2b27b1a485f41cf0c74a21db32e7349fc740b1e6 (
plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
_update_ssh_config() {
local restore=$1
local ssh_client_system_conf='/etc/ssh/ssh_config'
if [ -f "$ssh_client_system_conf" ]; then
echo 'Updating ssh config.'
sed -E --in-place=.orig 's/^(HostKeyAlgorithms ssh-rsa,ssh-dss)$/# disabled by ipa-client update\n# \1/' "$ssh_client_system_conf"
# https://pagure.io/freeipa/issue/9536
# replace sss_ssh_knownhostsproxy with sss_ssh_knownhosts
if [ -f '/usr/bin/sss_ssh_knownhosts' ]; then
if grep -E -q 'Include' $ssh_client_system_conf 2>/dev/null ; then
ssh_client_system_conf="/etc/ssh/ssh_config.d/04-ipa.conf"
fi
sed -E --in-place=.orig 's/^(GlobalKnownHostsFile \/var\/lib\/sss\/pubconf\/known_hosts)$/# disabled by ipa-client update\n# \1/' $ssh_client_system_conf
sed -E --in-place=.orig 's/(ProxyCommand \/usr\/bin\/sss_ssh_knownhostsproxy -p \%p \%h)/# replaced by ipa-client update\n KnownHostsCommand \/usr\/bin\/sss_ssh_knownhosts \%H/' $ssh_client_system_conf
fi
fi
local sshd_client_system_conf='/etc/ssh/sshd_config'
if [ -f "$sshd_client_system_conf" -a $restore -ge 2 ]; then
# If the snippet already exists, skip
if [ ! -f "$sshd_client_system_conf.d/04-ipa.conf" ]; then
echo 'Creating sshd ipa config.'
# Take the values from /etc/ssh/sshd_config and put them in 04-ipa.conf
grep -E '^(PubkeyAuthentication|KerberosAuthentication|GSSAPIAuthentication|UsePAM|ChallengeResponseAuthentication|AuthorizedKeysCommand|AuthorizedKeysCommandUser)' "$sshd_client_system_conf" 2>/dev/null > "$sshd_client_system_conf.d/04-ipa.conf"
# Remove the values from sshd_conf
sed -ri '
/^(PubkeyAuthentication|KerberosAuthentication|GSSAPIAuthentication|UsePAM|ChallengeResponseAuthentication|AuthorizedKeysCommand|AuthorizedKeysCommandUser)[ \t]/ d
' "$sshd_client_system_conf"
systemctl condrestart sshd.service 2>&1 || :
fi
# If the snippet has been created, ensure that it is included
# either by /etc/ssh/sshd_config.d/*.conf or directly
if [ -f "$sshd_client_system_conf.d/04-ipa.conf" ]; then
if ! grep -E -q '^\s*Include\s*/etc/ssh/sshd_config.d/\*\.conf' "$sshd_client_system_conf" 2> /dev/null ; then
if ! grep -E -q '^\s*Include\s*/etc/ssh/sshd_config.d/04-ipa\.conf' "$sshd_client_system_conf" 2> /dev/null ; then
echo 'Making sure sshd ipa config is included.'
# Include the snippet
echo "Include $sshd_client_system_conf.d/04-ipa.conf" > "$sshd_client_system_conf.ipanew"
cat "$sshd_client_system_conf" >> "$sshd_client_system_conf.ipanew"
mv -fZ --backup=existing --suffix .ipaold "$sshd_client_system_conf.ipanew" "$sshd_client_system_conf"
fi
fi
fi
fi
}
_is_restore() {
if test -f '/var/lib/ipa-client/sysrestore/sysrestore.index'; then
wc -l '/var/lib/ipa-client/sysrestore/sysrestore.index' | awk '{print $1}'
else
echo 0;
fi
}
post_upgrade() {
# Has the client been configured?
local restore=$(_is_restore)
if [ -f '/etc/sssd/sssd.conf' -a $restore -ge 2 ]; then
if ! grep -E -q '/var/lib/sss/pubconf/krb5.include.d/' /etc/krb5.conf 2>/dev/null ; then
echo 'Updating krb5 config.'
echo "includedir /var/lib/sss/pubconf/krb5.include.d/" > /etc/krb5.conf.ipanew
cat /etc/krb5.conf >> /etc/krb5.conf.ipanew
mv -Z /etc/krb5.conf.ipanew /etc/krb5.conf
fi
fi
if [ $restore -ge 2 ]; then
if grep -E -q '\s*pkinit_anchors = FILE:/etc/ipa/ca.crt$' /etc/krb5.conf 2>/dev/null; then
echo 'Updating ca anchors.'
sed -E 's|(\s*)pkinit_anchors = FILE:/etc/ipa/ca.crt$|\1pkinit_anchors = FILE:/var/lib/ipa-client/pki/kdc-ca-bundle.pem\n\1pkinit_pool = FILE:/var/lib/ipa-client/pki/ca-bundle.pem|' /etc/krb5.conf >/etc/krb5.conf.ipanew
mv -Z /etc/krb5.conf.ipanew /etc/krb5.conf
cp /etc/ipa/ca.crt /var/lib/ipa-client/pki/kdc-ca-bundle.pem
cp /etc/ipa/ca.crt /var/lib/ipa-client/pki/ca-bundle.pem
fi
python -c 'from ipaclient.install.client import configure_krb5_snippet; configure_krb5_snippet()' >>/var/log/ipaupgrade.log 2>&1
python -c 'from ipaclient.install.client import update_ipa_nssdb; update_ipa_nssdb()' >>/var/log/ipaupgrade.log 2>&1
chmod 0600 /var/log/ipaupgrade.log
fi
_update_ssh_config $restore
}
post_install() {
post_upgrade
}
|