From ac5678dd9b67995a84bf2348d82e641d7895415e Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 1 Feb 2010 10:22:38 +1100 Subject: [PATCH] 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 --- mdadm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mdadm.c b/mdadm.c index be4fbf6d..eb124d53 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; -- 2.47.2