-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
%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
%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