Fix NFS mount options in mount.nfs v3
Subsystems (2)
PATCH 1/1 Fix NFS mount options in mount.nfs v3
AG
Signature · 2 lines
May the source be with you. http://www.cis.ksu.edu/~gud
If the 'user' or 'users' mount option is specified on commandline, verify with /etc/fstab if it is really specified. Setuid bit is still ON and should remain ON since mount drops the root privileges.
I've given this patch a good hammering, but not exhaustive by any means.
Based on 1.0.9.
---
support/include/fstab.h +8 -0
@@ -3,6 +3,10 @@#include "nfs_mntent.h" +#ifndef _PATH_FSTAB +#define _PATH_FSTAB "/etc/fstab" +#endif +int mtab_is_writable (void );int mtab_does_not_exist (void );
@@ -16,6 +20,10 @@ struct mntentchn *getmntoptfile (const cstruct mntentchn *getmntdirbackward (const char *dir,struct mntentchn *mc);struct mntentchn *getmntdevbackward (const char *dev,struct mntentchn *mc); +struct mntentchn *fstab_head (void ); +struct mntentchn *getfsfile (const char *file); +struct mntentchn *getfsspec (const char *spec); +void lock_mtab (void );void unlock_mtab (void );void update_mtab (const char *special,nfs_mntent_t *with);
support/include/nfs_mntent.h +4 -4
@@ -7,10 +7,10 @@#define _NFS_MNTENT_Htypedef struct nfs_mntent_s { -const char *mnt_fsname; -const char *mnt_dir; -const char *mnt_type; -const char *mnt_opts; +char *mnt_fsname; +char *mnt_dir; +char *mnt_type; +char *mnt_opts;int mnt_freq;int mnt_passno; }nfs_mntent_t ;
support/nfs/fstab.c +54 -3
82 lines not on this page · raw message
utils/mount/Makefile.am +4 -3
@@ -14,9 +14,10 @@ MAINTAINERCLEANFILES = Makefile.in install-exec-hook: (cd $(DESTDIR)$(sbindir) && \ - ln -sf $(sbin_PROGRAMS) mount.nfs4 && \ - ln -sf $(sbin_PROGRAMS) umount.nfs && \ - ln -sf $(sbin_PROGRAMS) umount.nfs4) + chmod +s $(sbin_PROGRAMS) && \ + cp -p $(sbin_PROGRAMS) mount.nfs4 && \ + cp -p $(sbin_PROGRAMS) umount.nfs && \ + cp -p $(sbin_PROGRAMS) umount.nfs4) uninstall-hook: (cd $(DESTDIR)$(sbindir) && \ rm -f mount.nfs4 umount.nfs umount.nfs4)
utils/mount/mount.c +123 -18
231 lines not on this page · raw message
utils/mount/nfs_mount.h +2 -0
@@ -80,5 +80,7 @@ struct nfs_mount_data {int nfsmount (const char *,const char *,int *,char **,char **,int *,int );void mount_errors (char *,int ,int ); +int contains (const char *,const char *); +char *get_value (const char *,const char *);#endif /* _NFS_MOUNT_H */
utils/mount/nfsumount.c +18 -1
@@ -23,12 +23,14 @@#include <mntent.h> #include <sys/mount.h> #include <ctype.h> +#include <pwd.h> #include "xcommon.h" #include "fstab.h" #include "nls.h" #include "conn.h" +#include "nfs_mount.h" #include "mount_constants.h" #include "mount.h" #include "nfsumount.h"
@@ -307,7 +309,7 @@ int _nfsumount(const char *spec, const c goto out_bad;return nfs_call_umount (&mnt_server, &dirname); out_bad: -printf ("%s: %s: not found or not mounted\n" , progname, spec); +fprintf (stderr,"%s: %s: not found or not mounted\n" , progname, spec);return 0 ; }
@@ -376,6 +378,21 @@ int nfsumount(int argc, char *argv[])printf (_ ("Could not find %s in mtab\n" ), spec);if (mc) { +if (contains (mc->m.mnt_opts,"user" ) &&getuid () !=0 ) { +struct passwd *pw =getpwuid (getuid ()); +if (!pw ||strcmp (pw->pw_name,get_value (mc->m.mnt_opts,"user=" ))) { +fprintf (stderr,"%s: permission denied to unmount %s\n" , + progname, spec); +exit (1 ); + } + }else { +if (!contains (mc->m.mnt_opts,"users" ) &&getuid () !=0 ) { +fprintf (stderr,"%s: only root can unmount %s from %s\n" , + progname, mc->m.mnt_fsname, mc->m.mnt_dir); +exit (1 ); + } + } + ret =_nfsumount (mc->m.mnt_fsname, mc->m.mnt_opts);if (ret) ret = add_mtab2(mc->m.mnt_fsname, mc->m.mnt_dir,
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs