]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Build mount.nfs by default, and install setuid
authorNeil Brown <neilb@suse.de>
Tue, 20 Mar 2007 03:18:41 +0000 (14:18 +1100)
committerNeil Brown <neilb@suse.de>
Tue, 20 Mar 2007 03:18:41 +0000 (14:18 +1100)
Also fix a few bugs that came up in initial testing.

configure.in
utils/mount/Makefile.am
utils/mount/mount.c
utils/mount/nfsumount.c

index ce5e2a0174ccae5ff893f2fdd53eaea023a4407b..2a72c1c7f850c99b71245bd28afec264c99c2e67 100644 (file)
@@ -134,7 +134,7 @@ AC_ARG_ENABLE(mount,
        [AC_HELP_STRING([--enable-mount],
                        [Create mount.nfs and don't use the util-linux mount(8) functionality. @<:@default=no@:>@])],
        enable_mount=$enableval,
-       enable_mount=no)
+       enable_mount=yes)
        AM_CONDITIONAL(CONFIG_MOUNT, [test "$enable_mount" = "yes"])
 
 # Check whether user wants TCP wrappers support
index cdd78d8daa0fe90a101ca760c0841f1807100dc2..07e86e4c5e4a1fd3ffe3c9a8470dc5da9824c8d4 100644 (file)
@@ -21,7 +21,8 @@ install-exec-hook:
        (cd $(DESTDIR)$(sbindir) && \
          ln -sf mount.nfs mount.nfs4 && \
          ln -sf mount.nfs umount.nfs && \
-         ln -sf mount.nfs umount.nfs4)
+         ln -sf mount.nfs umount.nfs4 && \
+         chmod 4511 mount.nfs )
 uninstall-hook:
        (cd $(DESTDIR)$(sbindir) && \
            rm -f mount.nfs4 umount.nfs umount.nfs4)
index 9ae66f070503dc9db3b6a3107f983ef34a1fb546..c6644b1cde10b24a2be3c31ac138c21bc29c996f 100644 (file)
@@ -436,12 +436,18 @@ int main(int argc, char *argv[])
 
                if ((mc = getfsfile(mount_point)) == NULL ||
                    strcmp(mc->m.mnt_fsname, spec) != 0 ||
-                   strcmp(mc->m.mnt_type, (nfs_mount_vers == 4 ? "nfs4":"nfs")) != 0 || 
-                   strcmp(mc->m.mnt_opts, mount_opts) != 0) {
+                   strcmp(mc->m.mnt_type, (nfs_mount_vers == 4 ? "nfs4":"nfs")) != 0
+                   ) {
                        fprintf(stderr, "%s: permission died - no match for fstab\n",
                                progname);
                        exit(1);
                }
+               /* 'mount' munges the options from fstab before passing them
+                * to us, so it is non-trivial to test that we have the correct
+                * set of options and we don't want to trust what the user
+                * gave us, so just take whatever is in fstab
+                */
+               mount_opts = strdup(mc->m.mnt_opts);
                mounttype = 0;
        }
 
@@ -479,7 +485,8 @@ int main(int argc, char *argv[])
        if (!fake) {
                mnt_err = do_mount_syscall(spec, mount_point,
                                           nfs_mount_vers == 4 ? "nfs4" : "nfs",
-                                          flags, mount_opts);
+                                          flags & ~(MS_USER|MS_USERS) ,
+                                          mount_opts);
 
                if (mnt_err) {
                        mount_error(mount_point);
index 81d0d3a72c4ea5ca1a1230e3991b33fc38f38164..e65f58f0122374ad92f881d96e7072a9f0fbe03e 100644 (file)
@@ -341,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);
@@ -353,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)