Bug#396570: mdadm: Incorrect error message for insufficient permission

Neil Brown neilb at suse.de
Sun Jan 31 23:24:39 UTC 2010


On Fri, 29 Jan 2010 15:44:27 -0700
Rob Sims <debbugs-z at robsims.com> wrote:
 
> Still not fixed:
> $  mdadm --remove /dev/md0 /dev/sdd1
> mdadm: /dev/md0 does not appear to be an md device
> $ mdadm --version
> mdadm - v3.1.1 - 19th November 2009

Thanks.
I have committed the following fix upstream which should resolve this issue.

NeilBrown

commit 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>

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-devel mailing list