Debian Codegraph @

debian/tests/pam-auth-update

raw
1 #!/bin/bash
2
3 # Copyright 2023, Sam Hartman
4 # This code may be redistributed under the same terms as Linux Pam
5 # itself, or at your pution, under the GNU General Public License,
6 # version 3.
7
8 set -x
9
10 fail() {
11 echo "$@" 2>&1
12 exit 1
13 }
14
15
16 # Confirm enabling pam_mkhomedir updates common-session
17 grep mkhomedir /etc/pam.d/* && fail pam_mkhomedir already enabled
18 pam-auth-update --enable mkhomedir ||fail pam-auth-update enable failed
19 grep mkhomedir /etc/pam.d/common-session ||fail pam_mkhomedir was not enabled
20
21 # and confirm that it makes a home directory
22 useradd -s /bin/bash pam_test
23 su -c date pam_test
24 test -d ~pam_test || fail pam_test home directory not made
25
26 # confirm added options are preserved
27 grep -i rounds /etc/pam.d/common-password &&fail rounds parameter already specified
28 sed -i -e 's/obscure yescrypt/obscure yescrypt rounds=3/' /etc/pam.d/common-password
29 grep rounds /etc/pam.d/common-password ||fail sed did not update common password
30
31 ( echo get libpam-runtime/profiles |debconf-communicate |grep mkhomedir) || fail mkhomedir not in enabled profiles
32
33 # Confirm removing mkhomedir preserves rounds parameter
34 pam-auth-update --disable mkhomedir ||fail pam-auth-update disable failed
35 ( echo get libpam-runtime/profiles |debconf-communicate |grep mkhomedir) && fail mkhomedir still in profiles
36 grep mkhomedir /var/lib/pam/seen || fail mkhomedir removed from seen after disable
37 grep mkhomedir /etc/pam.d/common-session &&fail pam_mkhomedir not removed
38 grep rounds /etc/pam.d/common-password || fail rounds parameter not preserved