From 5ac4c3155e1598cfdcb7a99bdbf0d40e5b70b866 Mon Sep 17 00:00:00 2001 From: Steve Dickson Date: Jan 27 2010 20:34:05 +0000 Subject: - mount.nfs: Don't fail mounts when /etc/netconfig is nonexistent --- diff --git a/nfs-utils-1.2.1-netconfig.patch b/nfs-utils-1.2.1-netconfig.patch new file mode 100644 index 0000000..18e74ce --- /dev/null +++ b/nfs-utils-1.2.1-netconfig.patch @@ -0,0 +1,120 @@ +diff -up nfs-utils-1.2.1/support/nfs/getport.c.orig nfs-utils-1.2.1/support/nfs/getport.c +--- nfs-utils-1.2.1/support/nfs/getport.c.orig 2010-01-27 13:48:06.136623000 -0500 ++++ nfs-utils-1.2.1/support/nfs/getport.c 2010-01-27 14:02:28.491921000 -0500 +@@ -277,7 +277,7 @@ nfs_get_proto(const char *netid, sa_fami + #ifdef HAVE_LIBTIRPC + char *nfs_get_netid(const sa_family_t family, const unsigned long protocol) + { +- char *nc_protofmly, *nc_proto, *nc_netid; ++ char *nc_protofmly, *nc_proto, *nc_netid = NULL; + struct netconfig *nconf; + struct protoent *proto; + void *handle; +@@ -319,6 +319,19 @@ char *nfs_get_netid(const sa_family_t fa + endnetconfig(handle); + + out: ++ /* ++ * The system configuration files are inaccessible ++ * so see if these are well known protocols ++ */ ++ if (protocol == IPPROTO_TCP) ++ nc_netid = (family == AF_INET6 ? ++ strdup("tcp6") : strdup("tcp")); ++ else if (protocol == IPPROTO_UDP) ++ nc_netid = (family == AF_INET6 ? ++ strdup("udp6") : strdup("udp")); ++ if (nc_netid != NULL) ++ return nc_netid; ++ + rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; + return NULL; + } +diff -up nfs-utils-1.2.1/utils/mount/network.c.orig nfs-utils-1.2.1/utils/mount/network.c +--- nfs-utils-1.2.1/utils/mount/network.c.orig 2010-01-27 13:48:06.141624000 -0500 ++++ nfs-utils-1.2.1/utils/mount/network.c 2010-01-27 14:17:49.098201000 -0500 +@@ -1280,7 +1280,26 @@ nfs_nfs_version(struct mount_options *op + *version = 0; + return 1; + } +- ++/* ++ * Returns TRUE if the option string is a well known protocol ++ */ ++int ++nfs_set_proto(char *option, unsigned long *protocol) ++{ ++ if (strcmp(option, "tcp") == 0 || ++ strcmp(option, "tcp6") == 0) { ++ *protocol = IPPROTO_TCP; ++ return 1; ++ } ++ if (strcmp(option, "udp") == 0 || ++ strcmp(option, "udp6") == 0) { ++ *protocol = IPPROTO_UDP; ++ return 1; ++ } ++ if (verbose) ++ nfs_error(_("%s: unkown protocol: '%s'"), progname, option); ++ return 0; ++} + /* + * Returns TRUE if @protocol contains a valid value for this option, + * or FALSE if the option was specified with an invalid value. +@@ -1300,8 +1319,13 @@ nfs_nfs_protocol(struct mount_options *o + return 1; + case 2: /* proto */ + option = po_get(options, "proto"); +- if (option != NULL) +- return nfs_get_proto(option, &family, protocol); ++ if (option != NULL) { ++ if (nfs_get_proto(option, &family, protocol)) ++ return 1; ++ if (nfs_set_proto(option, protocol)) ++ return 1; ++ return 0; ++ } + } + + /* +@@ -1349,7 +1373,7 @@ nfs_nfs_port(struct mount_options *optio + int nfs_nfs_proto_family(struct mount_options *options, + sa_family_t *family) + { +- unsigned long protocol; ++ unsigned long protocol = 0; + char *option; + + *family = config_default_family; +@@ -1360,8 +1384,13 @@ int nfs_nfs_proto_family(struct mount_op + return 1; + case 2: /* proto */ + option = po_get(options, "proto"); +- if (option != NULL) +- return nfs_get_proto(option, family, &protocol); ++ if (option != NULL){ ++ if (nfs_get_proto(option, family, &protocol)) ++ return 1; ++ if (nfs_set_proto(option, &protocol)) ++ return 1; ++ return 0; ++ } + } + + /* +@@ -1443,8 +1472,13 @@ nfs_mount_protocol(struct mount_options + char *option; + + option = po_get(options, "mountproto"); +- if (option != NULL) +- return nfs_get_proto(option, &family, protocol); ++ if (option != NULL) { ++ if (nfs_get_proto(option, &family, protocol)) ++ return 1; ++ if (nfs_set_proto(option, protocol)) ++ return 1; ++ return 0; ++ } + + /* + * MNT transport protocol wasn't specified. If the NFS diff --git a/nfs-utils.spec b/nfs-utils.spec index 15567c0..9c2de53 100644 --- a/nfs-utils.spec +++ b/nfs-utils.spec @@ -2,7 +2,7 @@ Summary: NFS utilities and supporting clients and daemons for the kernel NFS ser Name: nfs-utils URL: http://sourceforge.net/projects/nfs Version: 1.2.1 -Release: 15%{?dist} +Release: 16%{?dist} Epoch: 1 # group all 32bit related archs @@ -22,6 +22,7 @@ Patch000: nfs-utils-1.2.2-rc9.patch Patch001: nfs-utils-1.2.1-statdpath.patch Patch002: nfs-utils-1.2.1-default-family.patch Patch003: nfs-utils-1.2.1-statd-null-addrs.patch +Patch004: nfs-utils-1.2.1-netconfig.patch Patch100: nfs-utils-1.2.1-statdpath-man.patch Patch101: nfs-utils-1.2.1-exp-subtree-warn-off.patch @@ -77,6 +78,7 @@ This package also contains the mount.nfs and umount.nfs program. %patch001 -p1 %patch002 -p1 %patch003 -p1 +%patch004 -p1 %patch100 -p1 %patch101 -p1 @@ -253,6 +255,9 @@ fi %attr(4755,root,root) /sbin/umount.nfs4 %changelog +* Wed Jan 27 2010 Steve Dickson 1.2.1-16 +- mount.nfs: Don't fail mounts when /etc/netconfig is nonexistent + * Mon Jan 25 2010 Steve Dickson 1.2.1-15 - statd: Teach nfs_compare_sockaddr() to handle NULL arguments