From a90ab135bcf7bd134d38374c50f36fa256d6f5b6 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 22 Apr 2024 11:28:52 +0200 Subject: [PATCH] rec: Change home directory to /var/lib/pdns-recursor on EL-based OSs --- builder-support/specs/pdns-recursor.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/builder-support/specs/pdns-recursor.spec b/builder-support/specs/pdns-recursor.spec index df4b6b9682..227121ab26 100644 --- a/builder-support/specs/pdns-recursor.spec +++ b/builder-support/specs/pdns-recursor.spec @@ -91,6 +91,8 @@ sed -i \ -e 's!# include-dir=.*!&\ninclude-dir=%{_sysconfdir}/%{name}/recursor.d!' \ %{buildroot}%{_sysconfdir}/%{name}/recursor.conf +%{__install } -d %{buildroot}/%{_sharedstatedir}/%{name} + # The EL7 and 8 systemd actually supports %t, but its version number is older than that, so we do use seperate runtime dirs, but don't rely on RUNTIME_DIRECTORY %if 0%{?rhel} < 9 sed -e 's!/pdns_recursor!& --socket-dir=%t/pdns-recursor!' -i %{buildroot}/%{_unitdir}/pdns-recursor.service @@ -102,8 +104,12 @@ sed -e 's!/pdns_recursor!& --socket-dir=%t/pdns-recursor-%i!' -e 's!RuntimeDirec %pre getent group pdns-recursor > /dev/null || groupadd -r pdns-recursor getent passwd pdns-recursor > /dev/null || \ - useradd -r -g pdns-recursor -d / -s /sbin/nologin \ + useradd -r -g pdns-recursor -d /var/lib/pdns-recursor -s /sbin/nologin \ -c "PowerDNS Recursor user" pdns-recursor +# Change home directory to /var/lib/pdns +if [[ $(getent passwd pdns-recursor | cut -d: -f6) == "/" ]]; then + usermod -d /var/lib/pdns-recursor pdns-recursor +fi exit 0 %post @@ -127,4 +133,5 @@ systemctl daemon-reload ||: %dir %{_sysconfdir}/%{name}/recursor.d %config(noreplace) %{_sysconfdir}/%{name}/recursor.conf %config %{_sysconfdir}/%{name}/recursor.yml-dist +%dir %attr(-,pdns-recursor,pdns-recursor) %{_sharedstatedir}/%{name} %doc README -- 2.47.2