Skip to content

Commit fc5b756

Browse files
committed
Merge #16556: Fix systemd service file configuration directory setup
f3b57f4 Unrecommend making config file owned by bitcoin (setpill) 870d415 Set ProtectHome in systemd service file (setpill) 639a416 Chgrp config dir to bitcoin in systemd service (setpill) aded052 Improve clarity of systemd service file comments (setpill) Pull request description: Rationale: ran into a bug with the systemd service file, fixed it locally and figured I might as well contribute my fix. Also fixed some unrelated confusing phrasing in the comments of the same file, after discussion in IRC. ACKs for top commit: sipsorcery: tACK f3b57f4 (nothing changed since previous tACK). ryanofsky: utACK f3b57f4. Only change since last review is removing ConfigurationDirectoryMode churn in early commits Tree-SHA512: 2188345878925b9e8a5c2c3df8dfba443720e2252a164db54a8e1d8007846721497b2d98c56f1d9b60a9a9ed4fdb1156c7b02c699616b220a9b614671617d32a
2 parents 9546a78 + f3b57f4 commit fc5b756

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

contrib/init/bitcoind.service

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
# See "man systemd.service" for details.
66

77
# Note that almost all daemon options could be specified in
8-
# /etc/bitcoin/bitcoin.conf, except for those explicitly specified as arguments
9-
# in ExecStart=
8+
# /etc/bitcoin/bitcoin.conf, but keep in mind those explicitly
9+
# specified as arguments in ExecStart= will override those in the
10+
# config file.
1011

1112
[Unit]
1213
Description=Bitcoin daemon
@@ -18,6 +19,10 @@ ExecStart=/usr/bin/bitcoind -daemon \
1819
-conf=/etc/bitcoin/bitcoin.conf \
1920
-datadir=/var/lib/bitcoind
2021

22+
# Make sure the config directory is readable by the service user
23+
PermissionsStartOnly=true
24+
ExecStartPre=/bin/chgrp bitcoin /etc/bitcoin
25+
2126
# Process management
2227
####################
2328

@@ -53,6 +58,9 @@ PrivateTmp=true
5358
# Mount /usr, /boot/ and /etc read-only for the process.
5459
ProtectSystem=full
5560

61+
# Deny access to /home, /root and /run/user
62+
ProtectHome=true
63+
5664
# Disallow the process and all of its children to gain
5765
# new privileges through execve().
5866
NoNewPrivileges=true

doc/init.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ Data directory: `/var/lib/bitcoind`
5959
PID file: `/var/run/bitcoind/bitcoind.pid` (OpenRC and Upstart) or `/run/bitcoind/bitcoind.pid` (systemd)
6060
Lock file: `/var/lock/subsys/bitcoind` (CentOS)
6161

62-
The configuration file, PID directory (if applicable) and data directory
63-
should all be owned by the bitcoin user and group. It is advised for security
64-
reasons to make the configuration file and data directory only readable by the
65-
bitcoin user and group. Access to bitcoin-cli and other bitcoind rpc clients
66-
can then be controlled by group membership.
62+
The PID directory (if applicable) and data directory should both be owned by the
63+
bitcoin user and group. It is advised for security reasons to make the
64+
configuration file and data directory only readable by the bitcoin user and
65+
group. Access to bitcoin-cli and other bitcoind rpc clients can then be
66+
controlled by group membership.
6767

6868
NOTE: When using the systemd .service file, the creation of the aforementioned
6969
directories and the setting of their permissions is automatically handled by

0 commit comments

Comments
 (0)