]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - builder-support/specs/pdns-recursor.spec
Merge pull request #14083 from rgacogne/fix-dnsdist-and-rec-home-dirs
[thirdparty/pdns.git] / builder-support / specs / pdns-recursor.spec
index df4b6b9682340483b238cec0789894ad6a3fc4d2..cbb5c1942661d3f825901c09831166be7914e294 100644 (file)
@@ -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-recursor if needed
+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