Commit 46a8da3b authored by René Nussbaumer's avatar René Nussbaumer

Let daemon-utils fix the owners for ganeti-rapi

This is a workaround until we fully switched to user separation and fixes the
owners of directories/log files so ganeti-rapi will start flawlessly. This is
right now run for every daemon but as it operates on a relatively small subset
its impact is small.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent bbfd0568
......@@ -32,6 +32,7 @@
# daemons
/daemons/daemon-util
/daemons/ensure-dirs
/daemons/ganeti-cleaner
# devel
......
......@@ -64,6 +64,7 @@ CLEANFILES = \
$(addsuffix /*.py[co],$(DIRS)) \
autotools/replace_vars.sed \
daemons/daemon-util \
daemons/ensure-dirs \
daemons/ganeti-cleaner \
devel/upload \
doc/examples/bash_completion \
......@@ -257,6 +258,7 @@ pkglib_python_scripts = \
pkglib_SCRIPTS = \
daemons/daemon-util \
daemons/ensure-dirs \
$(pkglib_python_scripts)
EXTRA_DIST = \
......@@ -270,6 +272,7 @@ EXTRA_DIST = \
autotools/testrunner \
$(RUN_IN_TEMPDIR) \
daemons/daemon-util.in \
daemons/ensure-dirs.in \
daemons/ganeti-cleaner.in \
$(pkglib_python_scripts) \
devel/upload.in \
......@@ -541,6 +544,7 @@ $(REPLACE_VARS_SED): Makefile
echo 's#@GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
echo 's#@GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
} > $@
# We need to create symlinks because "make distcheck" will not install Python
......
......@@ -149,6 +149,8 @@ start() {
# Read $<daemon>_ARGS and $EXTRA_<daemon>_ARGS
eval local args="\"\$${ucname}_ARGS \$EXTRA_${ucname}_ARGS\""
@PKGLIBDIR@/ensure-dirs
start-stop-daemon --start --quiet --oknodo \
--pidfile $(_daemon_pidfile $name) \
--startas $(_daemon_executable $name) \
......
#!/bin/bash
set -e
LIBDIR="@LOCALSTATEDIR@/lib"
DATADIR="${LIBDIR}/ganeti"
RUNDIR="@LOCALSTATEDIR@/run"
GNTRUNDIR="${RUNDIR}/ganeti"
LOGDIR="@LOCALSTATEDIR@/log"
GNTLOGDIR="${LOGDIR}/ganeti"
_fileset_owner() {
case "$1" in
masterd)
echo "@GNTMASTERUSER@:@GNTMASTERDGROUP@"
;;
confd)
echo "@GNTCONFDUSER@:@GNTCONFDGROUP@"
;;
rapi)
echo "@GNTRAPIUSER@:@GNTRAPIGROUP@"
;;
daemons)
echo "@GNTMASTERUSER@:@GNTDAEMONSGROUP@"
;;
*)
echo "root:root"
;;
esac
}
_ensure_dir() {
local dir="$1"
local perm="$2"
local owner="$3"
[ -d "${dir}" ] || mkdir "${dir}"
chmod ${perm} "${dir}"
chown ${owner} "${dir}"
}
_ensure_rundir() {
_ensure_dir "${GNTRUNDIR}" 0775 "$(_fileset_owner "daemons")"
_ensure_dir "${GNTRUNDIR}/socket" 0750 "$(_fileset_owner "daemons")"
}
_ensure_logdir() {
_ensure_dir "${GNTLOGDIR}" 0770 "$(_fileset_owner "daemons")"
chown $(_fileset_owner "rapi") "${GNTLOGDIR}/rapi-daemon.log"
}
_operate_while_hold() {
local fn=$1
local path=$2
shift 2
(cd "${path}";
${fn} "$@")
}
main() {
_operate_while_hold "_ensure_rundir" "${RUNDIR}"
_operate_while_hold "_ensure_logdir" "${LOGDIR}"
}
main "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment