Improve systemd service file #19513

pull Flowdalic wants to merge 2 commits into bitcoin:master from Flowdalic:systemd changing 1 files +1 −3
  1. Flowdalic commented at 8:54 am on July 14, 2020: contributor
    This removes the redundant ‘Group=’ directive and replaces the deprecated ‘PermissionsStartOnly’ directive.
  2. fanquake added the label Scripts and tools on Jul 14, 2020
  3. 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 the bitcoin 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).
  4. 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).

  5. hebasto commented at 7:09 am on July 15, 2020: member
    The replacement of deprecated PermissionsStartOnly was also suggested in #16994.
  6. hebasto changes_requested
  7. hebasto commented at 7:44 am on July 15, 2020: member

    Agree 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 ships systemd v219 only.

  8. Flowdalic commented at 7:54 am on July 15, 2020: contributor
    I’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.
  9. Flowdalic force-pushed on Jul 15, 2020
  10. laanwj commented at 1:31 pm on July 17, 2020: member

    The 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.

  11. 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.
    b0bec21338
  12. 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
    06ca6ea68b
  13. Flowdalic force-pushed on Nov 16, 2021
  14. Flowdalic commented at 8:45 am on November 16, 2021: contributor
    Rebased on the latest master, please consider for inclusion.
  15. achow101 commented at 6:11 pm on October 12, 2022: member
    Closing 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.
  16. achow101 closed this on Oct 12, 2022

  17. bitcoin locked this on Oct 12, 2023
  18. maflcko added the label Up for grabs on Jul 23, 2025
  19. fanquake removed the label Up for grabs on Jul 23, 2025
  20. fanquake commented at 1:35 pm on July 23, 2025: member
    PIcked up in #33044.

github-metadata-mirror

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

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me