]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-46-HOMED: Check for sshd pam snippet in /usr/lib/pam.d as well
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 30 Apr 2024 12:01:53 +0000 (14:01 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 30 Apr 2024 20:10:05 +0000 (22:10 +0200)
opensuse ships pam snippets in /usr/lib/pam.d.

test/units/testsuite-46.sh

index d9ba83aa8255d379cfb82929998e045c2360234e..7d84b0d04d1f607112fa9c6e45e7fc6e4c1d5048 100755 (executable)
@@ -511,7 +511,11 @@ if command -v ssh &>/dev/null && command -v sshd &>/dev/null && ! [[ -v ASAN_OPT
         rm -f /tmp/homed.id_ecdsa /run/systemd/system/mysshserver{@.service,.socket}
         systemctl daemon-reload
         homectl remove homedsshtest
-        mv /etc/pam.d/sshd.bak /etc/pam.d/sshd
+        for dir in /etc /usr/lib; do
+            if [[ -f "$dir/pam.d/sshd.bak" ]]; then
+                mv "$dir/pam.d/sshd.bak" "$dir/pam.d/sshd"
+            fi
+        done
     }
 
     trap at_exit EXIT
@@ -538,8 +542,10 @@ if command -v ssh &>/dev/null && command -v sshd &>/dev/null && ! [[ -v ASAN_OPT
     # are aware of distros use
     mkdir -p /usr/share/empty.sshd /var/empty /var/empty/sshd /run/sshd
 
-    mv /etc/pam.d/sshd /etc/pam.d/sshd.bak
-    cat >/etc/pam.d/sshd <<EOF
+    for dir in /etc /usr/lib; do
+        if [[ -f "$dir/pam.d/sshd" ]]; then
+            mv "$dir/pam.d/sshd" "$dir/pam.d/sshd.bak"
+            cat >"$dir/pam.d/sshd" <<EOF
 auth    sufficient pam_unix.so nullok
 auth    sufficient pam_systemd_home.so debug
 auth    required   pam_deny.so
@@ -550,6 +556,9 @@ session optional   pam_systemd_home.so debug
 session optional   pam_systemd.so
 session required   pam_unix.so
 EOF
+            break
+        fi
+    done
 
     mkdir -p /etc/sshd/
     cat >/etc/ssh/sshd_config <<EOF