commit:     f9aa2491329e3b770bfa24a8139c8fde245f1867
Author:     Marc Schiffbauer <mschiff <AT> gentoo <DOT> org>
AuthorDate: Mon Feb  7 07:23:25 2022 +0000
Commit:     Marc Schiffbauer <mschiff <AT> gentoo <DOT> org>
CommitDate: Mon Feb  7 07:30:14 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f9aa2491

app-backup/bareos: fix pid file creation

Closes: https://bugs.gentoo.org/832805
Signed-off-by: Marc Schiffbauer <mschiff <AT> gentoo.org>

 ...eos-21.0.0-r1.ebuild => bareos-21.0.0-r2.ebuild} | 11 +++--------
 app-backup/bareos/files/bareos-dir-21.confd         |  2 +-
 app-backup/bareos/files/bareos-dir-21.initd         | 17 ++++-------------
 app-backup/bareos/files/bareos-fd-21.confd          |  7 +++++++
 app-backup/bareos/files/bareos-fd-21.initd          | 21 +++++++++++++++++++++
 app-backup/bareos/files/bareos-sd-21.confd          | 10 ++++++++++
 app-backup/bareos/files/bareos-sd-21.initd          | 21 +++++++++++++++++++++
 7 files changed, 67 insertions(+), 22 deletions(-)

diff --git a/app-backup/bareos/bareos-21.0.0-r1.ebuild 
b/app-backup/bareos/bareos-21.0.0-r2.ebuild
similarity index 96%
rename from app-backup/bareos/bareos-21.0.0-r1.ebuild
rename to app-backup/bareos/bareos-21.0.0-r2.ebuild
index 787a7074b9fc..4baeaaf6c0ec 100644
--- a/app-backup/bareos/bareos-21.0.0-r1.ebuild
+++ b/app-backup/bareos/bareos-21.0.0-r2.ebuild
@@ -332,21 +332,16 @@ src_install() {
        myscripts="bareos-fd"
        if ! use clientonly; then
                if use director; then
-                       myscripts+=" bareos-dir-21"
+                       myscripts+=" bareos-dir"
                fi
                if use storage-daemon; then
                        myscripts+=" bareos-sd"
                fi
        fi
        for script in ${myscripts}; do
-               # copy over init script and config to a temporary location
-               # so we can modify them as needed
-               cp "${FILESDIR}/${script}".confd "${T}/${script}".confd || die 
"failed to copy ${script}.confd"
-               cp "${FILESDIR}/${script}".initd "${T}/${script}".initd || die 
"failed to copy ${script}.initd"
-
                # install init script and config
-               newinitd "${T}/${script}".initd "${script/-21/}"
-               newconfd "${T}/${script}".confd "${script/-21/}"
+               newinitd "${FILESDIR}/${script}-21".initd "${script}"
+               newconfd "${FILESDIR}/${script}-21".confd "${script}"
        done
 
        # install systemd unit files

diff --git a/app-backup/bareos/files/bareos-dir-21.confd 
b/app-backup/bareos/files/bareos-dir-21.confd
index 3ad4b7482f93..4e2ee55d8924 100644
--- a/app-backup/bareos/files/bareos-dir-21.confd
+++ b/app-backup/bareos/files/bareos-dir-21.confd
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # Config file for /etc/init.d/bareos-dir

diff --git a/app-backup/bareos/files/bareos-dir-21.initd 
b/app-backup/bareos/files/bareos-dir-21.initd
index 7100b615105c..916ee13b36ce 100644
--- a/app-backup/bareos/files/bareos-dir-21.initd
+++ b/app-backup/bareos/files/bareos-dir-21.initd
@@ -1,5 +1,5 @@
 #!/sbin/openrc-run
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 depend() {
@@ -9,23 +9,14 @@ depend() {
 
 start() {
        ebegin "Starting bareos director"
-       # g+w until #631598 is resolved
-       checkpath -d -m 0770 -o root:bareos /run/bareos
+       checkpath -d -m 0750 -o root:bareos /run/bareos
        start-stop-daemon --start --quiet --exec /usr/sbin/bareos-dir \
-               -- ${DIR_OPTIONS}
-       # harden pid file until #631598 is resolved
-       ewaitfile 10 /run/bareos/bareos-dir.9101.pid
-       chown root:bareos /run/bareos/bareos-dir.9101.pid
+               -- -p /run/bareos/bareos-dir.9101.pid ${DIR_OPTIONS}
        eend $?
 }
 
 stop() {
        ebegin "Stopping bareos director"
-       # check pid file until #631598 is resolved
-       if [[ $(stat -c %U /run/bareos/bareos-dir.9101.pid) != "root" ]]; then
-               eerror "SECURITY ALERT: pid file is not root owned anymore?! 
(see #631598)"
-       else
-               start-stop-daemon --stop --quiet --pidfile 
/run/bareos/bareos-dir.9101.pid
-       fi
+       start-stop-daemon --stop --quiet --pidfile 
/run/bareos/bareos-dir.9101.pid
        eend $?
 }

diff --git a/app-backup/bareos/files/bareos-fd-21.confd 
b/app-backup/bareos/files/bareos-fd-21.confd
new file mode 100644
index 000000000000..407f2a8828eb
--- /dev/null
+++ b/app-backup/bareos/files/bareos-fd-21.confd
@@ -0,0 +1,7 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Config file for /etc/init.d/bareos-fd
+
+# Options for the file daemon.
+FD_OPTIONS="-u root -g bareos"

diff --git a/app-backup/bareos/files/bareos-fd-21.initd 
b/app-backup/bareos/files/bareos-fd-21.initd
new file mode 100644
index 000000000000..f0632261a0c5
--- /dev/null
+++ b/app-backup/bareos/files/bareos-fd-21.initd
@@ -0,0 +1,21 @@
+#!/sbin/openrc-run
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+       use dns
+}
+
+start() {
+       ebegin "Starting bareos file daemon"
+       checkpath -d -m 0750 -o root:bareos /run/bareos
+       start-stop-daemon --start --quiet --exec /usr/sbin/bareos-fd \
+               -- -p /run/bareos/bareos-fd.9102.pid ${FD_OPTIONS}
+       eend $?
+}
+
+stop() {
+       ebegin "Stopping bareos file daemon"
+       start-stop-daemon --stop --quiet --pidfile 
/run/bareos/bareos-fd.9102.pid
+       eend $?
+}

diff --git a/app-backup/bareos/files/bareos-sd-21.confd 
b/app-backup/bareos/files/bareos-sd-21.confd
new file mode 100644
index 000000000000..2a67ae2b5523
--- /dev/null
+++ b/app-backup/bareos/files/bareos-sd-21.confd
@@ -0,0 +1,10 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Config file for /etc/init.d/bareos-sd
+
+# Options for the storage daemon.
+# The storage daemon can be run as a non-root user, however
+# please ensure that this user has proper permissions to
+# access your backup devices.
+SD_OPTIONS="-u bareos -g bareos"

diff --git a/app-backup/bareos/files/bareos-sd-21.initd 
b/app-backup/bareos/files/bareos-sd-21.initd
new file mode 100644
index 000000000000..07091dbd74c5
--- /dev/null
+++ b/app-backup/bareos/files/bareos-sd-21.initd
@@ -0,0 +1,21 @@
+#!/sbin/openrc-run
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+       use dns
+}
+
+start() {
+       ebegin "Starting bareos storage daemon"
+       checkpath -d -m 0750 -o root:bareos /run/bareos
+       start-stop-daemon --start --quiet --exec /usr/sbin/bareos-sd \
+               -- -p /run/bareos/bareos-sd.9103.pid ${SD_OPTIONS}
+       eend $?
+}
+
+stop() {
+       ebegin "Stopping bareos storage daemon"
+       start-stop-daemon --stop --quiet --pidfile 
/run/bareos/bareos-sd.9103.pid
+       eend $?
+}

Reply via email to