FS#49881 - [dnscrypt-proxy] Consider adding a separate system user
Attached to Project:
Community Packages
Opened by Alif (alive4ever) - Wednesday, 29 June 2016, 04:01 GMT
Last edited by Eli Schwartz (eschwartz) - Thursday, 05 April 2018, 02:39 GMT
Opened by Alif (alive4ever) - Wednesday, 29 June 2016, 04:01 GMT
Last edited by Eli Schwartz (eschwartz) - Thursday, 05 April 2018, 02:39 GMT
|
Details
Description:
The upstream provided dnscrypt-proxy.server did not include a separate user. It would be safer to drop root privilege after starting dnscrypt-proxy service. This is available with '-u' switch. Additional info: * package version(s): dnscrypt-proxy 1.6.1-1 * config and/or log files etc. Steps to reproduce: 1. Install dnscrypt-proxy. 2. Terminate/kill any dns forwarder/server process listening on 127.0.0.1 port 53 3. Start dnscrypt-proxy.service 4. Run ps and search for dnscrypt-proxy process. 'ps aux | grep dnscrypt-proxy' 5. dnscrypt-proxy doesn't drop root privilege. I've attached some diff files to fix this problem. Tested and build fine in clean systemd-nspawn container chroot. |
This task depends upon
Closed by Eli Schwartz (eschwartz)
Thursday, 05 April 2018, 02:39 GMT
Reason for closing: Won't implement
Additional comments about closing: FS#57027
obsoletes this
Thursday, 05 April 2018, 02:39 GMT
Reason for closing: Won't implement
Additional comments about closing:
pkgbuild-fix.diff : this patch is to be applied on PKGBUILD
add-dnscrypt-user.diff : this patch is to be applied on dnscrypt-proxy.install
dnscrypt-userstart.diff : this patch is part of source files (see patched PKGBUILD), automatically applied in the prepare() stage of makepkg.
The install file can be based on other packages doing similar things, e.g. pdnsd: https://git.archlinux.org/svntogit/community.git/tree/trunk/pdnsd.install?h=packages/pdnsd
Let the package maintainer choose the required UID/GID.
I suppose root is only needed for binding to port 53, but as explained in its man page, dnscript-proxy isn't meant to run as a name server since it doesn't do caching,we should simply change the port :53 to some unprivileged port in dnscript-proxy.socket && we don't need to run it as root ever.
And then, we can add `User=dnscrypt` to the [Service] section in the service file instead.
I think it would be great to have a proper systemd integration, although it doesn't seem to play nice with the current dnscrypt-proxy config file.
If a separate user in the service file is used, the "User" setting in the configuration file can't be used.
Making port 5353 the default for dnscrypt is a good choice, too, as direct access doesn't make sense.
[Service]
User=dnscrypt
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
Although many users will change the port (to an unprivileged one) so they can use a local dns cache, but this will mean that the service will work with the default settings (once the user is added).
The current configuration uses a systemd socket, so no privileges/capabilities are necessary for it to bind to the associated port (53 by default) if it's started under another user.
The new DynamicUser=yes option in systemd seems suitable here to me.
So, it appears that now the only change needed is to add the following line to the [Service] section of dnscrypt-proxy.service:
DynamicUser=yes
FS#57027?