dash/contrib/init/dashd.service
Ryan Ofsky c4a147cfea
Merge bitcoin/bitcoin#28340: security: restrict abis in bitcoind.service
0244416aacbad03e4ebe8f2c95c7861a318916ea security: restrict abis in bitcoind.service (Charlie)

Pull request description:

  [As noted here](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#MemoryDenyWriteExecute=), it's a good idea to pair `MemoryDenyWriteExecute=true` with `SystemCallArchitectures=native` because `MemoryDenyWriteExecute` can be circumvented in some operating systems which support multiple ABIs like x86/x86-64.
  This helps restrict the possible application binary interfaces (ABIs) that can be used when running bitcoind through systemd, reducing the attack surface area.

ACKs for top commit:
  laanwj:
    ACK 0244416aacbad03e4ebe8f2c95c7861a318916ea . This is a sensible security feature.
  0xB10C:
    ACK 0244416aacbad03e4ebe8f2c95c7861a318916ea

Tree-SHA512: 77a35b0674d8d67d857cd20ae1b8cd011f82d6f5ed21bc106cbe45bfa937e786ddc1bf7261e3bdb8c289df1224e91658760905d2c8f37cc4c6506ef8037ad158
2024-10-26 12:29:51 -05:00

86 lines
2.3 KiB
Desktop File

# It is not recommended to modify this file in-place, because it will
# be overwritten during package upgrades. If you want to add further
# options or overwrite existing ones then use
# $ systemctl edit dashd.service
# See "man systemd.service" for details.
# Note that almost all daemon options could be specified in
# /etc/dash/dash.conf, but keep in mind those explicitly
# specified as arguments in ExecStart= will override those in the
# config file.
[Unit]
Description=Dash daemon
Documentation=https://github.com/dashpay/dash/blob/master/doc/init.md
# https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/bin/dashd -daemonwait \
-pid=/run/dashd/dashd.pid \
-conf=/etc/dash/dash.conf \
-datadir=/var/lib/dashd
# Make sure the config directory is readable by the service user
PermissionsStartOnly=true
ExecStartPre=/bin/chgrp dashcore /etc/dash
# Process management
####################
Type=forking
PIDFile=/run/dashd/dashd.pid
Restart=on-failure
TimeoutStartSec=infinity
TimeoutStopSec=600
# Directory creation and permissions
####################################
# Run as dash:dash
User=dashcore
Group=dashcore
# /run/dashd
RuntimeDirectory=dashd
RuntimeDirectoryMode=0710
# /etc/dash
ConfigurationDirectory=dash
ConfigurationDirectoryMode=0710
# /var/lib/dashd
StateDirectory=dashd
StateDirectoryMode=0710
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Deny access to /home, /root and /run/user
ProtectHome=true
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
# Restrict ABIs to help ensure MemoryDenyWriteExecute is enforced
SystemCallArchitectures=native
[Install]
WantedBy=multi-user.target