| 1 |
# It's not recommended to modify this file in-place, because it will be |
| 2 |
# overwritten during upgrades. If you want to customize, the best |
| 3 |
# way is to use the "systemctl edit" command to create an override unit. |
| 4 |
# |
| 5 |
# For example, to pass additional options, create an override unit |
| 6 |
# (as is done by systemctl edit) and enter the following: |
| 7 |
# |
| 8 |
# [Service] |
| 9 |
# Environment=OPTIONS="-l 127.0.0.1,::1" |
| 10 |
|
| 11 |
|
| 12 |
[Unit] |
| 13 |
Description=memcached daemon |
| 14 |
After=network.target |
| •15 |
Documentation=man:memcached(1) |
| 16 |
|
| 17 |
[Service] |
| •18 |
ExecStart=/usr/share/memcached/scripts/systemd-memcached-wrapper /etc/memcached.conf |
| 19 |
|
| 20 |
# Set up a new file system namespace and mounts private /tmp and /var/tmp |
| 21 |
# directories so this service cannot access the global directories and |
| 22 |
# other processes cannot access this service's directories. |
| 23 |
PrivateTmp=true |
| 24 |
|
| 25 |
# Mounts the /usr, /boot, and /etc directories read-only for processes |
| 26 |
# invoked by this unit. |
| 27 |
ProtectSystem=full |
| 28 |
|
| 29 |
# Ensures that the service process and all its children can never gain new |
| 30 |
# privileges |
| 31 |
NoNewPrivileges=true |
| 32 |
|
| 33 |
# Sets up a new /dev namespace for the executed processes and only adds API |
| 34 |
# pseudo devices such as /dev/null, /dev/zero or /dev/random (as well as |
| 35 |
# the pseudo TTY subsystem) to it, but no physical devices such as /dev/sda. |
| 36 |
PrivateDevices=true |
| 37 |
|
| 38 |
# Required for dropping privileges and running as a different user |
| 39 |
CapabilityBoundingSet=CAP_SETGID CAP_SETUID CAP_SYS_RESOURCE |
| 40 |
|
| 41 |
# Restricts the set of socket address families accessible to the processes |
| 42 |
# of this unit. Protects against vulnerabilities such as CVE-2016-8655 |
| 43 |
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX |
| 44 |
|
| 45 |
# Attempts to create memory mappings that are writable and executable at |
| 46 |
# the same time, or to change existing memory mappings to become executable |
| 47 |
# are prohibited. |
| •48 |
MemoryDenyWriteExecute=true |
| 49 |
|
| 50 |
# Explicit module loading will be denied. This allows to turn off module |
| 51 |
# load and unload operations on modular kernels. It is recommended to turn |
| 52 |
# this on for most services that do not need special file systems or extra |
| 53 |
# kernel modules to work. |
| •54 |
ProtectKernelModules=true |
| 55 |
|
| 56 |
# Kernel variables accessible through /proc/sys, /sys, /proc/sysrq-trigger, |
| 57 |
# /proc/latency_stats, /proc/acpi, /proc/timer_stats, /proc/fs and /proc/irq |
| 58 |
# will be made read-only to all processes of the unit. Usually, tunable |
| 59 |
# kernel variables should only be written at boot-time, with the sysctl.d(5) |
| 60 |
# mechanism. Almost no services need to write to these at runtime; it is hence |
| 61 |
# recommended to turn this on for most services. |
| •62 |
ProtectKernelTunables=true |
| 63 |
|
| 64 |
# The Linux Control Groups (cgroups(7)) hierarchies accessible through |
| 65 |
# /sys/fs/cgroup will be made read-only to all processes of the unit. |
| 66 |
# Except for container managers no services should require write access |
| 67 |
# to the control groups hierarchies; it is hence recommended to turn this |
| 68 |
# on for most services |
| •69 |
ProtectControlGroups=true |
| 70 |
|
| 71 |
# Any attempts to enable realtime scheduling in a process of the unit are |
| 72 |
# refused. |
| •73 |
RestrictRealtime=true |
| 74 |
|
| 75 |
# Takes away the ability to create or manage any kind of namespace |
| •76 |
RestrictNamespaces=true |
| 77 |
|
| •78 |
PIDFile=/run/memcached/memcached.pid |
| 79 |
|
| 80 |
# try to restart if errors encountered |
| 81 |
Restart=always |
| 82 |
|
| 83 |
[Install] |
| 84 |
WantedBy=multi-user.target |