| 1 | [Unit] |
| 2 | Description=gokrazy rsync server daemon (for serving files) |
| 3 | |
| 4 | [Service] |
| 5 | ExecStart=/usr/bin/gokr-rsync --daemon |
| 6 | |
| 7 | # See also http://0pointer.net/blog/dynamic-users-with-systemd.html |
| 8 | DynamicUser=yes |
| 9 | |
| 10 | # Do not establish any new connections: |
| 11 | PrivateNetwork=yes |
| 12 | |
| 13 | # Remove all capabilities(7), this is a stateless web server: |
| 14 | CapabilityBoundingSet= |
| 15 | |
| 16 | # Ensure the service can never gain new privileges: |
| 17 | NoNewPrivileges=yes |
| 18 | |
| 19 | # Prohibit access to any kind of namespacing: |
| 20 | RestrictNamespaces=yes |
| 21 | |
| 22 | # Prohibit all address families: |
| 23 | # TODO(https://github.com/systemd/systemd/issues/15753): restrict to none |
| 24 | RestrictAddressFamilies=AF_UNIX |
| 25 | RestrictAddressFamilies=~AF_UNIX |
| 26 | |
| 27 | # Make home directories inaccessible: |
| 28 | ProtectHome=true |
| 29 | |
| 30 | # Make device nodes except for /dev/null, /dev/zero, /dev/full, |
| 31 | # /dev/random and /dev/urandom inaccessible: |
| 32 | PrivateDevices=yes |
| 33 | |
| 34 | # Make users other than root and the user for this daemon inaccessible: |
| 35 | PrivateUsers=yes |
| 36 | |
| 37 | # Make cgroup file system hierarchy inaccessible: |
| 38 | ProtectControlGroups=yes |
| 39 | |
| 40 | # Deny kernel module loading: |
| 41 | ProtectKernelModules=yes |
| 42 | |
| 43 | # Make kernel variables (e.g. /proc/sys) read-only: |
| 44 | ProtectKernelTunables=yes |
| 45 | |
| 46 | # Deny hostname changing: |
| 47 | ProtectHostname=yes |
| 48 | |
| 49 | # Deny realtime scheduling: |
| 50 | RestrictRealtime=yes |
| 51 | |
| 52 | # Deny access to other user’s information in /proc: |
| 53 | ProtectProc=invisible |
| 54 | |
| 55 | # Only allow access to /proc pid files, no other files: |
| 56 | ProcSubset=pid |
| 57 | |
| 58 | # Deny access to the kernel log ring buffer |
| 59 | ProtectKernelLogs=yes |
| 60 | |
| 61 | # Deny setting the hardware or system clock: |
| 62 | ProtectClock=yes |
| 63 | |
| 64 | # This daemon must not create any new files, but set the umask to 077 just in case. |
| 65 | UMask=077 |
| 66 | |
| 67 | # Filter dangerous system calls. The following is listed as safe basic choice |
| 68 | # in systemd.exec(5): |
| 69 | SystemCallArchitectures=native |
| 70 | SystemCallFilter=@system-service |
| 71 | SystemCallFilter=~@privileged |
| 72 | SystemCallFilter=~@resources |
| 73 | SystemCallErrorNumber=EPERM |
| 74 | |
| 75 | # Deny kernel execution domain changing: |
| 76 | LockPersonality=yes |
| 77 | |
| 78 | # Deny memory mappings that are writable and executable: |
| 79 | MemoryDenyWriteExecute=yes |
| 80 | |
| 81 | # no-op for a socket-activated unit, but better for systemd-analyze security: |
| 82 | IPAddressDeny=any |