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 7, 2023
1 parent d54ebf8 commit 47e3106
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Vcs-Browser: https://github.com/codership/galera
Package: galera-4
Architecture: any
Section: libs
Pre-Depends: adduser
Depends: ${misc:Depends},
${shlibs:Depends}
Conflicts: galera-3,
Expand Down
15 changes: 15 additions & 0 deletions debian/galera-4.lintian-overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#Teemu Ollakka Nov 17th, 2020:
# SONAME is useful only for libraries which are intended to be linked
# against, but not so much for libraries which are loaded dynamically
# during runtime.
#
# Debian policy about shared libraries:
# https://www.debian.org/doc/debian-policy/ch-sharedlibs.html
#
# "Shared libraries that are internal to a particular package or that are
# only loaded as dynamic modules are not covered by this section and are
# not subject to its requirements."
#
# This seems also be the approach CMake has taken, see for example
# https://stackoverflow.com/a/42186654
galera-4: sharedobject-in-library-directory-missing-soname [usr/lib/libgalera_smm.so]
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 --force-badname _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 47e3106

Please sign in to comment.