NeilBrown: Add test for "are we running as root".

Martin F. Krafft madduck at alioth.debian.org
Mon May 24 09:20:44 UTC 2010


Module: mdadm
Branch: upstream
Commit: ac5678dd9b67995a84bf2348d82e641d7895415e
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=ac5678dd9b67995a84bf2348d82e641d7895415e

Author: NeilBrown <neilb at suse.de>
Date:   Mon Feb  1 10:22:38 2010 +1100

Add test for "are we running as root".

Most operations require root access.  Rather than ensure we generate
the right error message when something fails because we aren't root,
check early.
Note that "--examine" does not necessarily require root, so test
for that first.

Resolves-Debian-bug: 396570
Signed-off-by: NeilBrown <neilb at suse.de>

---

 mdadm.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/mdadm.c b/mdadm.c
index be4fbf6..eb124d5 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1046,6 +1046,12 @@ int main(int argc, char *argv[])
 		}
 	}
 
+	if ((mode != MISC || devmode != 'E') &&
+	    geteuid() != 0) {
+		fprintf(stderr, Name ": must be super-user to perform this action\n");
+		exit(1);
+	}
+
 	ident.autof = autof;
 
 	rv = 0;




More information about the pkg-mdadm-commits mailing list