[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] clvmd init exit 4 when executed by non-root user

Once again and hopefully for the last time..

clvmd daemon itself does the right thing when invoked as non-root, by
returning 4.

The patch removes the use daemon function from
/etc/rc.d/init.d/functions that´s unnecessary and has the bad habit to
mask the return codes from the real daemon.

Add a simple and generic check to see if clvmd is executed by root or not.

Our stop/reload/restart paths in the init script are complex and not all
the tools involved in the process are guaranteed to return 4 if executed
by non-root against a process that´s running as root (for example kill
-TERM will return -1 and parsing the output to catch the error is
suboptimal at best).

? aclocal.m4
Index: scripts/clvmd_init_red_hat.in
RCS file: /cvs/lvm2/LVM2/scripts/clvmd_init_red_hat.in,v
retrieving revision 1.9
diff -u -r1.9 clvmd_init_red_hat.in
--- scripts/clvmd_init_red_hat.in	23 Jun 2010 16:24:14 -0000	1.9
+++ scripts/clvmd_init_red_hat.in	12 Aug 2010 08:50:16 -0000
@@ -66,7 +66,7 @@
 	if ! rh_status_q; then
 		echo -n "Starting $DAEMON: "
-		daemon $DAEMON $CLVMDOPTS || return $?
+		$DAEMON $CLVMDOPTS || return $?
@@ -165,6 +165,11 @@
+[ "$EUID" != "0" ] && {
+	echo "clvmd init script can only be executed as root user"
+	exit 4
 # See how we were called.
 case "$1" in

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]