- Fixed -o remount (bz 210346)

- fix memory leak in rpc.idmapd (bz 212547)
- fix use after free bug in dirscancb (bz 212547)
- Made no_subtree_check a default export option (bz 212218)
This commit is contained in:
Steve Dickson 2006-10-31 16:38:58 +00:00
parent 65049c36a9
commit 6173722673
2 changed files with 129 additions and 1 deletions

View File

@ -0,0 +1,114 @@
--- nfs-utils-1.0.9/utils/mount/mount.c.orig 2006-10-25 10:52:32.000000000 -0400
+++ nfs-utils-1.0.9/utils/mount/mount.c 2006-10-25 12:09:52.000000000 -0400
@@ -163,16 +163,29 @@ static char * fix_opts_string (int flags
return new_opts;
}
-void copy_mntent(struct mntent *ment, nfs_mntent_t *nment)
+static inline void dup_mntent(struct mntent *ment, nfs_mntent_t *nment)
{
/* Not sure why nfs_mntent_t should exist */
- strcpy(nment->mnt_fsname, ment->mnt_fsname);
- strcpy(nment->mnt_dir, ment->mnt_dir);
- strcpy(nment->mnt_type, ment->mnt_type);
- strcpy(nment->mnt_opts, ment->mnt_opts);
+ nment->mnt_fsname = strdup(ment->mnt_fsname);
+ nment->mnt_dir = strdup(ment->mnt_dir);
+ nment->mnt_type = strdup(ment->mnt_type);
+ nment->mnt_opts = strdup(ment->mnt_opts);
nment->mnt_freq = ment->mnt_freq;
nment->mnt_passno = ment->mnt_passno;
}
+static inline void
+free_mntent(struct mntent *ment, int remount)
+{
+ free(ment->mnt_fsname);
+ free(ment->mnt_dir);
+ free(ment->mnt_type);
+ /*
+ * Note: free(ment->mnt_opts) happens in discard_mntentchn()
+ * via update_mtab() on remouts
+ */
+ if (!remount)
+ free(ment->mnt_opts);
+}
int add_mtab(char *fsname, char *mount_point, char *fstype, int flags, char *opts, int freq, int passno)
{
@@ -190,8 +203,9 @@ int add_mtab(char *fsname, char *mount_p
if(flags & MS_REMOUNT) {
nfs_mntent_t nment;
- copy_mntent(&ment, &nment);
+ dup_mntent(&ment, &nment);
update_mtab(nment.mnt_dir, &nment);
+ free_mntent(&nment, 1);
return 0;
}
@@ -341,10 +355,11 @@ static void mount_error(char *node)
fprintf(stderr, "%s: %s\n", progname, strerror(errno));
}
}
+#define NFS_MOUNT_VERS_DEFAULT 3
int main(int argc, char *argv[])
{
- int c, flags = 0, nfs_mount_vers = 0, mnt_err = 1, fake = 0;
+ int c, flags = 0, nfs_mount_vers, mnt_err = 1, fake = 0;
char *spec, *mount_point, *extra_opts = NULL;
char *mount_opts = NULL, *p;
struct mntentchn *mc;
@@ -375,6 +390,10 @@ int main(int argc, char *argv[])
return 0;
}
+ nfs_mount_vers = NFS_MOUNT_VERS_DEFAULT;
+ if (!strcmp(progname, "mount.nfs4"))
+ nfs_mount_vers = 4;
+
while ((c = getopt_long (argc - 2, argv + 2, "rt:vVwfno:hs",
longopts, NULL)) != -1) {
switch (c) {
@@ -465,9 +484,9 @@ int main(int argc, char *argv[])
}
}
- if (!strcmp(progname, "mount.nfs4") || nfs_mount_vers == 4) {
- nfs_mount_vers = 4;
- mnt_err = nfs4mount(spec, mount_point, &flags, &extra_opts, &mount_opts, 0);
+ if (nfs_mount_vers == 4) {
+ mnt_err = nfs4mount(spec, mount_point, &flags,
+ &extra_opts, &mount_opts, 0);
}
else {
if (!strcmp(progname, "mount.nfs")) {
@@ -475,21 +494,19 @@ int main(int argc, char *argv[])
&extra_opts, &mount_opts, &nfs_mount_vers, 0);
}
}
-
if (fake)
return 0;
if (mnt_err)
exit(EX_FAIL);
- if(!(flags & MS_REMOUNT)) {
- mnt_err = do_mount_syscall(spec, mount_point,
- nfs_mount_vers == 4 ? "nfs4" : "nfs", flags, mount_opts);
-
- if(mnt_err) {
- mount_error(mount_point);
- exit(EX_FAIL);
- }
+ mnt_err = do_mount_syscall(spec, mount_point,
+ nfs_mount_vers == 4 ? "nfs4" : "nfs", flags, mount_opts);
+
+ if(mnt_err) {
+ mount_error(mount_point);
+ exit(EX_FAIL);
}
+
if(!nomtab) {
add_mtab(spec, mount_point, nfs_mount_vers == 4 ? "nfs4" : "nfs",
flags, extra_opts, 0, 0);

View File

@ -1,7 +1,7 @@
Summary: NFS utlilities and supporting clients and daemons for the kernel NFS server.
Name: nfs-utils
Version: 1.0.10
Release: 1%{?dist}
Release: 2%{?dist}
Epoch: 1
# group all 32bit related archs
@ -31,6 +31,8 @@ Patch52: nfs-utils-1.0.6-idmap.conf.patch
Patch53: nfs-utils-1.0.6-gssd_mixed_case.patch
Patch54: nfs-utils-1.0.8-privports.patch
Patch55: nfs-utils-1.0.9-krb5-memory.patch
Patch56: nfs-utils-1.0.9-idmapd-scandir-leak.patch
Patch57: nfs-utils-1.0.9-idmap-dirscancb-listloop.patch
%if %{enablemount}
Patch70: nfs-utils-1.0.9-mount-options-v3.patch
@ -39,6 +41,8 @@ Patch72: nfs-utils-1.0.9-mount-sloppy.patch
Patch73: nfs-utils-1.0.9-mount-man-nfs.patch
Patch74: nfs-utils-1.0.9-return-mount-error.patch
Patch75: nfs-utils-1.0.9-nfsmount-authnone.patch
Patch76: nfs-utils-1.0.9-mount-remount.patch
Patch77: nfs-utils-1.0.10-export-nosubtree.patch
%if %{enablefscache}
Patch90: nfs-utils-1.0.9-mount-fsc.patch
@ -92,6 +96,8 @@ This package also contains the mount.nfs and umount.nfs program.
%patch53 -p1
%patch54 -p1
%patch55 -p1
%patch57 -p1
%patch56 -p1
%if %{enablemount}
%patch70 -p1
%patch71 -p1
@ -99,6 +105,8 @@ This package also contains the mount.nfs and umount.nfs program.
%patch73 -p1
%patch74 -p1
%patch75 -p1
%patch76 -p1
%patch77 -p1
%if %{enablefscache}
%patch90 -p1
%endif
@ -276,6 +284,12 @@ fi
%endif
%changelog
* Tue Oct 31 2006 Steve Dickson <steved@redhat.com> 1.0.10-2
- Fixed -o remount (bz 210346)
- fix memory leak in rpc.idmapd (bz 212547)
- fix use after free bug in dirscancb (bz 212547)
- Made no_subtree_check a default export option (bz 212218)
* Wed Oct 25 2006 Steve Dickson <steved@redhat.com> 1.0.10-1
- Upgraded to 1.0.10