-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
systemd: enable systemd hardening features #7286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Stebalien
merged 1 commit into
ipfs:master
from
RubenKelevra:feat/systemd-service-hardening
Jun 10, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# This file will be overwritten on package upgrades, avoid customizations here. | ||
# | ||
# To make persistant changes, create file in | ||
# "/etc/systemd/system/ipfs.service.d/overwrite.conf" with | ||
# `systemctl edit ipfs.service`. This file will be parsed after this | ||
# file has been parsed. | ||
# | ||
# To overwrite a variable, like ExecStart you have to specify it once | ||
# blank and a second time with a new value, like: | ||
# ExecStart= | ||
# ExecStart=/usr/bin/ipfs daemon --flag1 --flag2 | ||
# | ||
# For more info about custom unit files see systemd.unit(5). | ||
|
||
# This service file enables systemd-hardening features compatible with IPFS, | ||
# while breaking compability with the fuse-mount function. Use this one only | ||
# if you don't need the fuse-mount functionality. | ||
|
||
[Unit] | ||
Description=InterPlanetary File System (IPFS) daemon | ||
Documentation=https://docs.ipfs.io/ | ||
After=network.target | ||
|
||
[Service] | ||
# hardening | ||
ReadWritePaths="/var/lib/ipfs/" | ||
NoNewPrivileges=true | ||
ProtectSystem=strict | ||
ProtectKernelTunables=true | ||
ProtectKernelModules=true | ||
ProtectKernelLogs=true | ||
PrivateDevices=true | ||
DevicePolicy=closed | ||
ProtectControlGroups=true | ||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK | ||
ProtectHostname=true | ||
PrivateTmp=true | ||
ProtectClock=true | ||
LockPersonality=true | ||
RestrictNamespaces=true | ||
RestrictRealtime=true | ||
MemoryDenyWriteExecute=true | ||
SystemCallArchitectures=native | ||
SystemCallFilter=@system-service | ||
SystemCallFilter=~@privileged | ||
ProtectHome=true | ||
RemoveIPC=true | ||
RestrictSUIDSGID=true | ||
CapabilityBoundingSet=CAP_NET_BIND_SERVICE | ||
|
||
# enable for 1-1024 port listening | ||
#AmbientCapabilities=CAP_NET_BIND_SERVICE | ||
# enable to specify a custom path see docs/environment-variables.md for further documentations | ||
#Environment=IPFS_PATH=/custom/ipfs/path | ||
# enable to specify a higher limit for open files/connections | ||
#LimitNOFILE=1000000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given all these restrictions, will IPFS be able to set it's own file descriptor limits? If not, we should probably set this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it can. |
||
|
||
#don't use swap | ||
MemorySwapMax=0 | ||
|
||
Type=notify | ||
User=ipfs | ||
Group=ipfs | ||
StateDirectory=ipfs | ||
ExecStart=/usr/bin/ipfs daemon --init --migrate | ||
Restart=on-failure | ||
KillSignal=SIGINT | ||
|
||
[Install] | ||
WantedBy=default.target |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is implied by PrivateDevices, right?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PrivateDevices
will setDevicePolicy=closed
, the reasoning for setting it explicitly is some older systemd-versions might support just the simplerDevicePolicy=closed
but doesn't yet supportPrivateDevices
.In this case
PrivateDevices
would be ignored andDevicePolicy=closed
not set.