]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/nfsumount.c
Build mount.nfs by default, and install setuid
[nfs-utils.git] / utils / mount / nfsumount.c
index e101105268d3bdd9bd42a49ca3649b3b17250383..e65f58f0122374ad92f881d96e7072a9f0fbe03e 100644 (file)
@@ -288,6 +288,7 @@ int nfsumount(int argc, char *argv[])
        argv += 1;
        argc -= 1;
 
+       argv[0] = argv[-1]; /* So that getopt error messages are correct */
        while ((c = getopt_long (argc, argv, "fvnrlh",
                                umount_longopts, NULL)) != -1) {
 
@@ -340,6 +341,11 @@ int nfsumount(int argc, char *argv[])
        if (getuid() != 0) {
                /* only permitted if "user=" or "users" is in mount options */
                if (!mc) {
+                       /* umount might call us twice.  The second time there will
+                        * be no entry in mtab and we should just exit quietly
+                        */
+                       return 0;
+
                only_root:
                        fprintf(stderr,"%s: You are not permitted to unmount %s\n",
                                progname, spec);
@@ -352,7 +358,7 @@ int nfsumount(int argc, char *argv[])
                        int len;
                        if (!opt)
                                goto only_root;
-                       if (opt[5] != '=')
+                       if (opt[4] != '=')
                                goto only_root;
                        comma = strchr(opt, ',');
                        if (comma)