From: Neil Brown Date: Tue, 20 Mar 2007 03:18:41 +0000 (+1100) Subject: Build mount.nfs by default, and install setuid X-Git-Tag: nfs-utils-1-1-0-rc1~25 X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=commitdiff_plain;h=b3b111b1bd5fbc678419bf1964b6093045081139 Build mount.nfs by default, and install setuid Also fix a few bugs that came up in initial testing. --- diff --git a/configure.in b/configure.in index ce5e2a0..2a72c1c 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/utils/mount/Makefile.am b/utils/mount/Makefile.am index cdd78d8..07e86e4 100644 --- a/utils/mount/Makefile.am +++ b/utils/mount/Makefile.am @@ -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) diff --git a/utils/mount/mount.c b/utils/mount/mount.c index 9ae66f0..c6644b1 100644 --- a/utils/mount/mount.c +++ b/utils/mount/mount.c @@ -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); diff --git a/utils/mount/nfsumount.c b/utils/mount/nfsumount.c index 81d0d3a..e65f58f 100644 --- a/utils/mount/nfsumount.c +++ b/utils/mount/nfsumount.c @@ -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)