Improve systemd service file #19513
pull Flowdalic wants to merge 2 commits into bitcoin:master from Flowdalic:systemd changing 1 files +1 −3-
Flowdalic commented at 8:54 am on July 14, 2020: contributorThis removes the redundant ‘Group=’ directive and replaces the deprecated ‘PermissionsStartOnly’ directive.
-
fanquake added the label Scripts and tools on Jul 14, 2020
-
in contrib/init/bitcoind.service:44 in 026a558647 outdated
34@@ -36,7 +35,6 @@ TimeoutStopSec=600 35 36 # Run as bitcoin:bitcoin 37 User=bitcoin 38-Group=bitcoin
hebasto commented at 1:06 pm on July 14, 2020:This group is useful to access thebitcoin
user’s stuff via group permissions.
Flowdalic commented at 1:14 pm on July 14, 2020:That reads like you assume I’ve removed the group, which is not entirely true. Systemd will run the process under the user’s default group if no group is explicitly specified. And the default group will most likely be the right group (and it definitely should be).in contrib/init/bitcoind.service:23 in 026a558647 outdated
19@@ -20,8 +20,7 @@ ExecStart=/usr/bin/bitcoind -daemon \ 20 -datadir=/var/lib/bitcoind 21 22 # Make sure the config directory is readable by the service user 23-PermissionsStartOnly=true 24-ExecStartPre=/bin/chgrp bitcoin /etc/bitcoin 25+ExecStartPre=+/bin/chgrp bitcoin /etc/bitcoin
hebasto commented at 1:06 pm on July 14, 2020:Is this syntax available on all of the supported platforms?
Flowdalic commented at 1:20 pm on July 14, 2020:Is there list of supported platforms?
Irregardless if there is a list or not, I assume that we do not run in series problems. Older Linux distribution versions with older systemd, tend to only package older bitcoin versions. The syntax was deprecated with systemd 241, which is currently in Debian stable. Likely the replacement syntax was established multiple releases before that. And even considering the rare (and very unlikely) case that you run this new bitcoin version under a very old systemd version, then the distribution package maintainer can remedy this (or the user itself).
hebasto changes_requestedhebasto commented at 7:44 am on July 15, 2020: memberAgree on “init: remove Group= as it will default to the user’s default group” commit.
https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Credentials:
If no group is set, the default group of the user is used.
As
ExecStart=+
syntax is used since v231, and basing on discussion in #16994, I suggest to follow @laanwj’s comment until CentOS 7 EOL at least as it shipssystemd
v219 only.Flowdalic commented at 7:54 am on July 15, 2020: contributorI’d argue that (upstream) software’s contributed configuration files should contain best-practices, and not worry about compatibility with arcane third-party software. I’d expect the CentOS/RedHat 7 bitcoind packager to test the package and fix any compatibility issues.Flowdalic force-pushed on Jul 15, 2020laanwj commented at 1:31 pm on July 17, 2020: memberThe init files are only there as example / documentation of how to use bitcoind as a service, there is no strict requirement for compatibility with everything under the sun, but also no reason to break compatibility for no good reason. It’s there as a convenience to people, not as a display of systemd best practices.
That said I’m neutral on this.
init: remove Group= as it will default to the user's default group
Setting Group=bitcoin is redundant. It is typically the default group of the user and if not explicitly specified, systemd will run the service with the default group of the user.
init: replace deprecated PermissionsStartOnly systemd directive
PermissionsStartOnly is deprecated [1]. This removes the directives and instead we prefixes the value of the ExecStartPre directive with '+', which means the executable, 'chgrp' in this case, is run with full privileges and able to change the group of /etc/bitcoin. 1: https://github.com/systemd/systemd/blob/60b45a80c1f98bad000bd902d97ecf6c4e3fc315/NEWS#L2434
Flowdalic force-pushed on Nov 16, 2021Flowdalic commented at 8:45 am on November 16, 2021: contributorRebased on the latest master, please consider for inclusion.achow101 commented at 6:11 pm on October 12, 2022: memberClosing this as it has not had any activity in a while. If you are interested in continuing work on this, please leave a comment so that it can be reopened.achow101 closed this on Oct 12, 2022
bitcoin locked this on Oct 12, 2023maflcko added the label Up for grabs on Jul 23, 2025fanquake removed the label Up for grabs on Jul 23, 2025
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-08-08 15:13 UTC
More mirrored repositories can be found on mirror.b10c.me