Skip to content

Commit

Permalink
Running daemon under nobody user is not recommended (Closes: #970045)
Browse files Browse the repository at this point in the history
Create a galera user that will run the daemon instead.

See: https://github.com/systemd/systemd/blob/v246/NEWS#L106-L113
  • Loading branch information
fauust committed Feb 6, 2023
1 parent d54ebf8 commit 0b57e36
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions debian/galera-4.preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e
set -o nounset
set -o pipefail
set -o posix

# creating _galera user, note that the '_' (underscore) before the name of the
# user is a recommendation from
# https://www.debian.org/doc/debian-policy/ch-opersys.html#users-and-groups
getent passwd _galera >/dev/null 2>&1 ||
adduser --system --no-create-home --home /nonexistent \
--disabled-password --disabled-login --allow-bad-names _galera

#DEBHELPER#
2 changes: 1 addition & 1 deletion garb/files/garb.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ WantedBy=multi-user.target
Alias=garbd.service

[Service]
User=nobody
User=_galera
ExecStart=/usr/bin/garb-systemd start

# Use SIGINT because with the default SIGTERM
Expand Down
4 changes: 2 additions & 2 deletions garb/files/garb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ program_start() {
local rcode
if [ -f /etc/redhat-release ]; then
echo -n $"Starting $prog: "
daemon --user nobody $prog "$@" >/dev/null
daemon --user _galera $prog "$@" >/dev/null
rcode=$?
if [ $rcode -eq 0 ]; then
pidof $prog > $PIDFILE || rcode=$?
Expand All @@ -58,7 +58,7 @@ program_start() {
echo
else
log_daemon_msg "Starting $prog: "
start-stop-daemon --start --quiet -c nobody --background \
start-stop-daemon --start --quiet -c _galera --background \
--exec $prog -- "$@"
rcode=$?
# Hack: sleep a bit to give garbd some time to fork
Expand Down

0 comments on commit 0b57e36

Please sign in to comment.