summaryrefslogtreecommitdiffstats
path: root/utils/mount
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2007-03-20 14:18:41 +1100
committerNeil Brown <neilb@suse.de>2007-03-20 14:18:41 +1100
commitb3b111b1bd5fbc678419bf1964b6093045081139 (patch)
tree508a6a898ec45f169834b1a768d1b609e0790088 /utils/mount
parentb8b6a251c372b134e66d0f436bf2c6231cc1c055 (diff)
downloadnfs-utils-b3b111b1bd5fbc678419bf1964b6093045081139.tar.gz
nfs-utils-b3b111b1bd5fbc678419bf1964b6093045081139.tar.xz
nfs-utils-b3b111b1bd5fbc678419bf1964b6093045081139.zip
Build mount.nfs by default, and install setuid
Also fix a few bugs that came up in initial testing.
Diffstat (limited to 'utils/mount')
-rw-r--r--utils/mount/Makefile.am3
-rw-r--r--utils/mount/mount.c13
-rw-r--r--utils/mount/nfsumount.c7
3 files changed, 18 insertions, 5 deletions
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)