From 17569a9e0de56b6b6e3cdf058c6f201c46060ab5 Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Thu, 9 Feb 2012 17:53:45 +0800 Subject: [PATCH 01/10] * Thu Feb 9 2012 Ian Kent - 1:5.0.6-11 - fix fuzz in CHANGELOG hunk when applying patch26. --- ...0.6-teach-automount-about-sss-source.patch | 38 +++++++------------ autofs.spec | 5 ++- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/autofs-5.0.6-teach-automount-about-sss-source.patch b/autofs-5.0.6-teach-automount-about-sss-source.patch index 44df13a..63bfa41 100644 --- a/autofs-5.0.6-teach-automount-about-sss-source.patch +++ b/autofs-5.0.6-teach-automount-about-sss-source.patch @@ -17,23 +17,19 @@ the lookup module. 5 files changed, 8 insertions(+), 4 deletions(-) -diff --git a/CHANGELOG b/CHANGELOG -index ba6f90c..e276396 100644 ---- a/CHANGELOG -+++ b/CHANGELOG -@@ -24,6 +24,7 @@ +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -22,6 +22,7 @@ - fix improve mount location error reporting. - - fix fix wait for master source mutex. + - fix rpc build error. - add sss lookup module. +- teach automount about sss source. 28/06/2011 autofs-5.0.6 ----------------------- -diff --git a/daemon/lookup.c b/daemon/lookup.c -index 098588c..de7c817 100644 ---- a/daemon/lookup.c -+++ b/daemon/lookup.c -@@ -177,6 +177,7 @@ int lookup_nss_read_master(struct master *master, time_t age) +--- autofs-5.0.6.orig/daemon/lookup.c ++++ autofs-5.0.6/daemon/lookup.c +@@ -177,6 +177,7 @@ int lookup_nss_read_master(struct master !strncmp(name, "nisplus:", 8) || !strncmp(name, "ldap:", 5) || !strncmp(name, "ldaps:", 6) || @@ -41,10 +37,8 @@ index 098588c..de7c817 100644 !strncmp(name, "dir:", 4)) { strncpy(source, name, tmp - name); -diff --git a/lib/master_tok.l b/lib/master_tok.l -index 77e9a26..0d6edb7 100644 ---- a/lib/master_tok.l -+++ b/lib/master_tok.l +--- autofs-5.0.6.orig/lib/master_tok.l ++++ autofs-5.0.6/lib/master_tok.l @@ -118,7 +118,7 @@ DNNAMESTR2 ([[:alnum:]_.\-]+) INTMAP (-hosts|-null) MULTI ((multi)(,(sun|hesiod))?(:{OPTWS}|{WS})) @@ -54,10 +48,8 @@ index 77e9a26..0d6edb7 100644 OPTTOUT (-t{OPTWS}|-t{OPTWS}={OPTWS}|--timeout{OPTWS}|--timeout{OPTWS}={OPTWS}) -diff --git a/lib/nss_parse.y b/lib/nss_parse.y -index 3bda6b3..a39fda4 100644 ---- a/lib/nss_parse.y -+++ b/lib/nss_parse.y +--- autofs-5.0.6.orig/lib/nss_parse.y ++++ autofs-5.0.6/lib/nss_parse.y @@ -82,7 +82,8 @@ nss_source: SOURCE { if (!strcmp($1, "files") || !strcmp($1, "yp") || @@ -78,11 +70,9 @@ index 3bda6b3..a39fda4 100644 src = add_source(nss_list, $1); for (a = 0; a < NSS_STATUS_MAX; a++) { if (act[a].action != NSS_ACTION_UNKNOWN) { -diff --git a/modules/parse_sun.c b/modules/parse_sun.c -index e9d94c7..d7e74e2 100644 ---- a/modules/parse_sun.c -+++ b/modules/parse_sun.c -@@ -880,7 +880,7 @@ static int validate_location(unsigned int logopt, char *loc) +--- autofs-5.0.6.orig/modules/parse_sun.c ++++ autofs-5.0.6/modules/parse_sun.c +@@ -880,7 +880,7 @@ static int validate_location(unsigned in !strncmp(ptr, "file:", 5) || !strncmp(ptr, "yp:", 3) || !strncmp(ptr, "nis:", 4) || !strncmp(ptr, "nisplus:", 8) || !strncmp(ptr, "ldap:", 5) || !strncmp(ptr, "ldaps:", 6) || diff --git a/autofs.spec b/autofs.spec index 7d179ca..a1af347 100644 --- a/autofs.spec +++ b/autofs.spec @@ -8,7 +8,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.0.6 -Release: 10%{?dist} +Release: 11%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -203,6 +203,9 @@ fi %dir /etc/auto.master.d %changelog +* Thu Feb 9 2012 Ian Kent - 1:5.0.6-11 +- fix fuzz in CHANGELOG hunk when applying patch26. + * Tue Feb 7 2012 Ian Kent - 1:5.0.6-10 - fix rpc build error. - add sss lookup module. From 1003b152370da8f84f6cb64fdebfb6b08fbf92e1 Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Fri, 24 Feb 2012 11:17:41 +0800 Subject: [PATCH 02/10] * Fri Feb 24 2012 Ian Kent - 1:5.0.6-12 - ignore duplicate exports in auto.net. - add kernel verion check function. - add function to check mount.nfs version. - reinstate singleton mount probe. - rework error return handling in rpc code. - catch EHOSTUNREACH and bail out early. - systemd support fixes. - fix segmentation fault in do_remount_indirect(). --- ...-function-to-check-mount-nfs-version.patch | 323 +++++++++ ...0.6-add-kernel-verion-check-function.patch | 55 ++ ...atch-EHOSTUNREACH-and-bail-out-early.patch | 166 +++++ ...ntation-fault-in-do-remount-indirect.patch | 86 +++ ...ignore-duplicate-exports-in-auto-net.patch | 33 + ....0.6-reinstate-singleton-mount-probe.patch | 105 +++ ...rk-error-return-handling-in-rpc-code.patch | 618 ++++++++++++++++++ autofs-5.0.6-systemd-support-fixes.patch | 110 ++++ autofs.spec | 68 +- 9 files changed, 1552 insertions(+), 12 deletions(-) create mode 100644 autofs-5.0.6-add-function-to-check-mount-nfs-version.patch create mode 100644 autofs-5.0.6-add-kernel-verion-check-function.patch create mode 100644 autofs-5.0.6-catch-EHOSTUNREACH-and-bail-out-early.patch create mode 100644 autofs-5.0.6-fix-segmentation-fault-in-do-remount-indirect.patch create mode 100644 autofs-5.0.6-ignore-duplicate-exports-in-auto-net.patch create mode 100644 autofs-5.0.6-reinstate-singleton-mount-probe.patch create mode 100644 autofs-5.0.6-rework-error-return-handling-in-rpc-code.patch create mode 100644 autofs-5.0.6-systemd-support-fixes.patch diff --git a/autofs-5.0.6-add-function-to-check-mount-nfs-version.patch b/autofs-5.0.6-add-function-to-check-mount-nfs-version.patch new file mode 100644 index 0000000..c95d6d1 --- /dev/null +++ b/autofs-5.0.6-add-function-to-check-mount-nfs-version.patch @@ -0,0 +1,323 @@ +autofs-5.0.6 - add function to check mount.nfs version + +From: Ian Kent + +Add a function to check if the mount.nfs version is greater than or +equal to a given version. +--- + + CHANGELOG | 1 + configure | 62 +++++++++++++++++++++ + configure.in | 1 + include/config.h.in | 6 ++ + include/mounts.h | 7 ++ + lib/mounts.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 6 files changed, 224 insertions(+) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -25,6 +25,7 @@ + - teach automount about sss source. + - ignore duplicate exports in auto.net. + - add kernel verion check function. ++- add function to check mount.nfs version. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/configure ++++ autofs-5.0.6/configure +@@ -645,6 +645,8 @@ HAVE_E2FSCK + E2FSCK + HAVE_UMOUNT + UMOUNT ++HAVE_MOUNT_NFS ++MOUNT_NFS + HAVE_MOUNT + MOUNT + DMALLOCLIB +@@ -3248,6 +3250,66 @@ else + HAVE_MOUNT=0 + fi + ++for ac_prog in mount.nfs ++do ++ # Extract the first word of "$ac_prog", so it can be a program name with args. ++set dummy $ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_path_MOUNT_NFS+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ case $MOUNT_NFS in ++ [\\/]* | ?:[\\/]*) ++ ac_cv_path_MOUNT_NFS="$MOUNT_NFS" # Let the user override the test with a path. ++ ;; ++ *) ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $searchpath ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_path_MOUNT_NFS="$as_dir/$ac_word$ac_exec_ext" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++ ;; ++esac ++fi ++MOUNT_NFS=$ac_cv_path_MOUNT_NFS ++if test -n "$MOUNT_NFS"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MOUNT_NFS" >&5 ++$as_echo "$MOUNT_NFS" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$MOUNT_NFS" && break ++done ++test -n "$MOUNT_NFS" || MOUNT_NFS="/sbin/mount.nfs " ++ ++if test -n "$MOUNT_NFS"; then ++ ++$as_echo "#define HAVE_MOUNT_NFS 1" >>confdefs.h ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define PATH_MOUNT_NFS "$MOUNT_NFS" ++_ACEOF ++ ++ HAVE_MOUNT_NFS=1 ++else ++ HAVE_MOUNT_NFS=0 ++fi ++ + for ac_prog in umount + do + # Extract the first word of "$ac_prog", so it can be a program name with args. +--- autofs-5.0.6.orig/configure.in ++++ autofs-5.0.6/configure.in +@@ -137,6 +137,7 @@ AC_SUBST(DMALLOCLIB) + # Programs needed for various system functions or modules + # + AF_PATH_INCLUDE(MOUNT, mount, /bin/mount, $searchpath) ++AF_PATH_INCLUDE(MOUNT_NFS, mount.nfs, /sbin/mount.nfs , $searchpath) + AF_PATH_INCLUDE(UMOUNT, umount, /bin/umount, $searchpath) + AF_PATH_INCLUDE(E2FSCK, fsck.ext2 e2fsck, , $searchpath) + AF_PATH_INCLUDE(E3FSCK, fsck.ext3 e3fsck, , $searchpath) +--- autofs-5.0.6.orig/include/config.h.in ++++ autofs-5.0.6/include/config.h.in +@@ -45,6 +45,9 @@ + /* define if you have MOUNT */ + #undef HAVE_MOUNT + ++/* define if you have MOUNT_NFS */ ++#undef HAVE_MOUNT_NFS ++ + /* define if the mount command supports the -s option */ + #undef HAVE_SLOPPY_MOUNT + +@@ -111,6 +114,9 @@ + /* define if you have MOUNT */ + #undef PATH_MOUNT + ++/* define if you have MOUNT_NFS */ ++#undef PATH_MOUNT_NFS ++ + /* define if you have RANLIB */ + #undef PATH_RANLIB + +--- autofs-5.0.6.orig/include/mounts.h ++++ autofs-5.0.6/include/mounts.h +@@ -89,6 +89,13 @@ static inline unsigned int linux_version + return KERNEL_VERSION(p, q, r); + } + ++struct nfs_mount_vers { ++ unsigned int major; ++ unsigned int minor; ++ unsigned int fix; ++}; ++int check_nfs_mount_version(struct nfs_mount_vers *, struct nfs_mount_vers *); ++ + unsigned int query_kproto_ver(void); + unsigned int get_kver_major(void); + unsigned int get_kver_minor(void); +--- autofs-5.0.6.orig/lib/mounts.c ++++ autofs-5.0.6/lib/mounts.c +@@ -19,6 +19,8 @@ + #include + #include + #include ++#include ++#include + #include + #include + #include +@@ -30,6 +32,8 @@ + #define MAX_OPTIONS_LEN 80 + #define MAX_MNT_NAME_LEN 30 + ++#define EBUFSIZ 1024 ++ + const unsigned int t_indirect = AUTOFS_TYPE_INDIRECT; + const unsigned int t_direct = AUTOFS_TYPE_DIRECT; + const unsigned int t_offset = AUTOFS_TYPE_OFFSET; +@@ -131,6 +135,149 @@ unsigned int get_kver_minor(void) + return kver.minor; + } + ++#ifdef HAVE_MOUNT_NFS ++static int extract_version(char *start, struct nfs_mount_vers *vers) ++{ ++ char *s_ver = strchr(start, ' '); ++ while (*s_ver && !isdigit(*s_ver)) { ++ s_ver++; ++ if (!*s_ver) ++ return 0; ++ break; ++ } ++ vers->major = atoi(strtok(s_ver, ".")); ++ vers->minor = (unsigned int) atoi(strtok(NULL, ".")); ++ vers->fix = (unsigned int) atoi(strtok(NULL, ".")); ++ return 1; ++} ++ ++int check_nfs_mount_version(struct nfs_mount_vers *vers, ++ struct nfs_mount_vers *check) ++{ ++ pid_t f; ++ int ret, status, pipefd[2]; ++ char errbuf[EBUFSIZ + 1], *p, *sp; ++ int errp, errn; ++ sigset_t allsigs, tmpsig, oldsig; ++ char *s_ver; ++ int cancel_state; ++ ++ if (pipe(pipefd)) ++ return -1; ++ ++ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_state); ++ ++ sigfillset(&allsigs); ++ pthread_sigmask(SIG_BLOCK, &allsigs, &oldsig); ++ ++ f = fork(); ++ if (f == 0) { ++ reset_signals(); ++ close(pipefd[0]); ++ dup2(pipefd[1], STDOUT_FILENO); ++ dup2(pipefd[1], STDERR_FILENO); ++ close(pipefd[1]); ++ ++ execl(PATH_MOUNT_NFS, PATH_MOUNT_NFS, "-V", (char *) NULL); ++ _exit(255); /* execv() failed */ ++ } ++ ++ ret = 0; ++ ++ tmpsig = oldsig; ++ ++ sigaddset(&tmpsig, SIGCHLD); ++ pthread_sigmask(SIG_SETMASK, &tmpsig, NULL); ++ ++ close(pipefd[1]); ++ ++ if (f < 0) { ++ close(pipefd[0]); ++ pthread_sigmask(SIG_SETMASK, &oldsig, NULL); ++ pthread_setcancelstate(cancel_state, NULL); ++ return -1; ++ } ++ ++ errp = 0; ++ do { ++ while (1) { ++ errn = read(pipefd[0], errbuf + errp, EBUFSIZ - errp); ++ if (errn == -1 && errno == EINTR) ++ continue; ++ break; ++ } ++ ++ if (errn > 0) { ++ errp += errn; ++ ++ sp = errbuf; ++ while (errp && (p = memchr(sp, '\n', errp))) { ++ *p++ = '\0'; ++ errp -= (p - sp); ++ sp = p; ++ } ++ ++ if (errp && sp != errbuf) ++ memmove(errbuf, sp, errp); ++ ++ if (errp >= EBUFSIZ) { ++ /* Line too long, split */ ++ errbuf[errp] = '\0'; ++ if ((s_ver = strstr(errbuf, "nfs-utils"))) { ++ if (extract_version(s_ver, vers)) ++ ret = 1; ++ } ++ errp = 0; ++ } ++ ++ if ((s_ver = strstr(errbuf, "nfs-utils"))) { ++ if (extract_version(s_ver, vers)) ++ ret = 1; ++ } ++ } ++ } while (errn > 0); ++ ++ close(pipefd[0]); ++ ++ if (errp > 0) { ++ /* End of file without \n */ ++ errbuf[errp] = '\0'; ++ if ((s_ver = strstr(errbuf, "nfs-utils"))) { ++ if (extract_version(s_ver, vers)) ++ ret = 1; ++ } ++ } ++ ++ if (ret) { ++ if (vers->major == check->major && ++ vers->minor == check->minor && ++ vers->fix == check->fix) ++ ; ++ else { ++ if (vers->major < check->major) ++ ret = 0; ++ else if (vers->minor < check->minor) ++ ret = 0; ++ else if (vers->fix < check->fix) ++ ret = 0; ++ } ++ } ++ ++ if (waitpid(f, &status, 0) != f) ; ++ ++ pthread_sigmask(SIG_SETMASK, &oldsig, NULL); ++ pthread_setcancelstate(cancel_state, NULL); ++ ++ return ret; ++} ++#else ++int check_nfs_mount_version(struct nfs_mount_vers *vers, ++ struct nfs_mount_vers *check) ++{ ++ return 0; ++} ++#endif ++ + /* + * Make common autofs mount options string + */ diff --git a/autofs-5.0.6-add-kernel-verion-check-function.patch b/autofs-5.0.6-add-kernel-verion-check-function.patch new file mode 100644 index 0000000..7309178 --- /dev/null +++ b/autofs-5.0.6-add-kernel-verion-check-function.patch @@ -0,0 +1,55 @@ +autofs-5.0.6 - add kernel verion check function + +From: Ian Kent + +Add a function to check kernel version. +--- + + CHANGELOG | 1 + + include/mounts.h | 17 +++++++++++++++++ + 2 files changed, 18 insertions(+) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -24,6 +24,7 @@ + - add sss lookup module. + - teach automount about sss source. + - ignore duplicate exports in auto.net. ++- add kernel verion check function. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/include/mounts.h ++++ autofs-5.0.6/include/mounts.h +@@ -16,6 +16,9 @@ + #ifndef MOUNTS_H + #define MOUNTS_H + ++#include ++#include ++ + #ifndef AUTOFS_TYPE_ANY + #define AUTOFS_TYPE_ANY 0x0000 + #endif +@@ -72,6 +75,20 @@ struct mnt_list { + struct list_head ordered; + }; + ++static inline unsigned int linux_version_code(void) ++{ ++ struct utsname my_utsname; ++ unsigned int p, q, r; ++ ++ if (uname(&my_utsname)) ++ return 0; ++ ++ p = (unsigned int)atoi(strtok(my_utsname.release, ".")); ++ q = (unsigned int)atoi(strtok(NULL, ".")); ++ r = (unsigned int)atoi(strtok(NULL, ".")); ++ return KERNEL_VERSION(p, q, r); ++} ++ + unsigned int query_kproto_ver(void); + unsigned int get_kver_major(void); + unsigned int get_kver_minor(void); diff --git a/autofs-5.0.6-catch-EHOSTUNREACH-and-bail-out-early.patch b/autofs-5.0.6-catch-EHOSTUNREACH-and-bail-out-early.patch new file mode 100644 index 0000000..1847b5c --- /dev/null +++ b/autofs-5.0.6-catch-EHOSTUNREACH-and-bail-out-early.patch @@ -0,0 +1,166 @@ +autofs-5.0.6 - catch EHOSTUNREACH and bail out early + +From: Ian Kent + +Now that the lower layers of the rpc code has been reworked +to propogate error returns up to the top level code we can +catch the EHOSTUNREACH return and stop the probe since the +host isn't responding. + +Also, since UDP is a broadcast protocol we don't get the +EHOSTUNREACH and always have to wait, so change the probe +order to try TCP first. Using UDP first was originally +done to reduce reserved port usage but autofs probing uses +higher numbered ports now so this shouldn't introduce +problem even for older implementations. +--- + + CHANGELOG | 1 + include/replicated.h | 3 ++ + modules/replicated.c | 55 +++++++++++++++++++++++++++++++++++++-------------- + 3 files changed, 44 insertions(+), 15 deletions(-) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -28,6 +28,7 @@ + - add function to check mount.nfs version. + - reinstate singleton mount probe. + - rework error return handling in rpc code. ++- catch EHOSTUNREACH and bail out early. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/include/replicated.h ++++ autofs-5.0.6/include/replicated.h +@@ -48,6 +48,9 @@ + #define TCP_SELECTED_MASK 0x00FF + #define UDP_SELECTED_MASK 0xFF00 + ++#define IS_ERR(supported) (0x8000 & supported) ++#define ERR(supported) (IS_ERR(supported) ? (~supported + 1) : supported) ++ + #define RPC_TIMEOUT 5 + + struct host { +--- autofs-5.0.6.orig/modules/replicated.c ++++ autofs-5.0.6/modules/replicated.c +@@ -563,7 +563,9 @@ static unsigned int get_nfs_info(unsigne + status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS4_VERSION); + else + status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS4_VERSION); +- if (!status) { ++ if (status == -EHOSTUNREACH) ++ return (unsigned int) status; ++ else if (!status) { + gettimeofday(&start, &tz); + status = rpc_ping_proto(rpc_info); + gettimeofday(&end, &tz); +@@ -589,7 +591,10 @@ v3_ver: + status = rpc_portmap_getclient(pm_info, + host->name, host->addr, host->addr_len, + proto, RPC_CLOSE_DEFAULT); +- if (status) ++ if (status == -EHOSTUNREACH) { ++ supported = status; ++ goto done_ver; ++ } else if (status) + goto done_ver; + } + +@@ -602,16 +607,23 @@ v3_ver: + } else { + parms.pm_prot = rpc_info->proto->p_proto; + parms.pm_vers = NFS3_VERSION; +- rpc_info->port = rpc_portmap_getport(pm_info, &parms); +- if (rpc_info->port < 0) ++ status = rpc_portmap_getport(pm_info, &parms); ++ if (status == -EHOSTUNREACH) { ++ supported = status; ++ goto done_ver; ++ } else if (status < 0) + goto v2_ver; ++ rpc_info->port = status; + } + + if (rpc_info->proto->p_proto == IPPROTO_UDP) + status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS3_VERSION); + else + status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS3_VERSION); +- if (!status) { ++ if (status == -EHOSTUNREACH) { ++ supported = status; ++ goto done_ver; ++ } else if (!status) { + gettimeofday(&start, &tz); + status = rpc_ping_proto(rpc_info); + gettimeofday(&end, &tz); +@@ -643,15 +655,23 @@ v2_ver: + parms.pm_prot = rpc_info->proto->p_proto; + parms.pm_vers = NFS2_VERSION; + rpc_info->port = rpc_portmap_getport(pm_info, &parms); +- if (rpc_info->port < 0) ++ status = rpc_portmap_getport(pm_info, &parms); ++ if (status == -EHOSTUNREACH) { ++ supported = status; ++ goto done_ver; ++ } else if (status < 0) + goto done_ver; ++ rpc_info->port = status; + } + + if (rpc_info->proto->p_proto == IPPROTO_UDP) + status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS2_VERSION); + else + status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS2_VERSION); +- if (!status) { ++ if (status == -EHOSTUNREACH) { ++ supported = status; ++ goto done_ver; ++ } else if (!status) { + gettimeofday(&start, &tz); + status = rpc_ping_proto(rpc_info); + gettimeofday(&end, &tz); +@@ -728,21 +748,24 @@ static int get_vers_and_cost(unsigned lo + + vers &= version; + +- if (version & UDP_REQUESTED) { ++ if (version & TCP_REQUESTED) { + supported = get_nfs_info(logopt, host, +- &pm_info, &rpc_info, "udp", vers, options); +- if (supported) { ++ &pm_info, &rpc_info, "tcp", vers, options); ++ if (IS_ERR(supported)) { ++ if (ERR(supported) == EHOSTUNREACH) ++ return ret; ++ } else if (supported) { + ret = 1; +- host->version |= (supported << 8); ++ host->version |= supported; + } + } + +- if (version & TCP_REQUESTED) { ++ if (version & UDP_REQUESTED) { + supported = get_nfs_info(logopt, host, +- &pm_info, &rpc_info, "tcp", vers, options); ++ &pm_info, &rpc_info, "udp", vers, options); + if (supported) { + ret = 1; +- host->version |= supported; ++ host->version |= (supported << 8); + } + } + +@@ -848,7 +871,9 @@ static int get_supported_ver_and_cost(un + status = rpc_udp_getclient(&rpc_info, NFS_PROGRAM, parms.pm_vers); + else + status = rpc_tcp_getclient(&rpc_info, NFS_PROGRAM, parms.pm_vers); +- if (!status) { ++ if (status == -EHOSTUNREACH) ++ goto done; ++ else if (!status) { + gettimeofday(&start, &tz); + status = rpc_ping_proto(&rpc_info); + gettimeofday(&end, &tz); diff --git a/autofs-5.0.6-fix-segmentation-fault-in-do-remount-indirect.patch b/autofs-5.0.6-fix-segmentation-fault-in-do-remount-indirect.patch new file mode 100644 index 0000000..9b16a97 --- /dev/null +++ b/autofs-5.0.6-fix-segmentation-fault-in-do-remount-indirect.patch @@ -0,0 +1,86 @@ +autofs-5.0.6 - fix segmentation fault in do_remount_indirect() + +From: Leonardo Chiquitto + +In some rare circumstance, it's possible that automount will crash +on startup while trying to reconnect to a "half-broken" NFS mount +point. + +The segmentation fault happens because we're not testing scandir()'s +return value in do_remount_indirect(): + +lib/mounts.c: +1210 i = j = scandir(buf, &de2, 0, alphasort); +1211 while (i--) +1212 free(de2[i]); + +So, if scandir() returns -1, it will try to free de2[-1], de2[-2], etc. + +Here's the call trace, for reference: + +Program terminated with signal 11, Segmentation fault. +#0 0x00007ffff7fe2425 in do_remount_indirect (ap=0x7ffff821e070, fd=15, + path=0x7ffff821e150 "/nfs/iil") at mounts.c:1212 +1212 free(de2[i]); +(gdb) print j +$1 = -1 +(gdb) print de2 +$3 = (struct dirent **) 0x0 + +#0 0x00007ffff7fe2425 in do_remount_indirect (ap=0x7ffff821e070, fd=15, + path=0x7ffff821e150 "/nfs/iil") at mounts.c:1212 +#1 0x00007ffff7fe2a48 in remount_active_mount (ap=0x7ffff821e070, mc=0x0, + path=0x7ffff821e150 "/nfs/iil", devid=20, type=, + ioctlfd=0x7ffff6e5babc) at mounts.c:1327 +#2 0x00007ffff7fe2ac6 in try_remount (ap=0x7ffff821e070, me=0x0, type=1) + at mounts.c:1357 +#3 0x00007ffff7fd35e0 in do_mount_autofs_indirect (root=, + ap=) at indirect.c:103 +#4 mount_autofs_indirect (ap=0x7ffff821e070, root=0x7ffff8202d50 "/nfs/iil") + at indirect.c:213 +#5 0x00007ffff7fd1473 in mount_autofs (root=, + ap=) at automount.c:1005 +#6 handle_mounts (arg=0x7fffffffdfd0) at automount.c:1526 +#7 0x00007ffff7b8e5f0 in start_thread (arg=) + at pthread_create.c:297 +#8 0x00007ffff6f3187d in clone () + at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112 +#9 0x0000000000000000 in ?? () + +Suggested fix: + +Check scandir() return value + +In some rare circumstance, it's possible that automount will crash +on startup while trying to reconnect to a "half-broken" NFS mount +point. +--- + + CHANGELOG | 1 + + lib/mounts.c | 4 ++++ + 2 files changed, 5 insertions(+) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -30,6 +30,7 @@ + - rework error return handling in rpc code. + - catch EHOSTUNREACH and bail out early. + - systemd support fixes. ++- check scandir() return value. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/lib/mounts.c ++++ autofs-5.0.6/lib/mounts.c +@@ -1355,6 +1355,10 @@ static int do_remount_indirect(struct au + int i, j; + + i = j = scandir(buf, &de2, 0, alphasort); ++ if (i < 0) { ++ free(de[n]); ++ continue; ++ } + while (i--) + free(de2[i]); + free(de2); diff --git a/autofs-5.0.6-ignore-duplicate-exports-in-auto-net.patch b/autofs-5.0.6-ignore-duplicate-exports-in-auto-net.patch new file mode 100644 index 0000000..66a91aa --- /dev/null +++ b/autofs-5.0.6-ignore-duplicate-exports-in-auto-net.patch @@ -0,0 +1,33 @@ +autofs-5.0.6 - ignore duplicate exports in auto.net + +From: Paul Smith + + +--- + + CHANGELOG | 1 + + samples/auto.net | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -23,6 +23,7 @@ + - fix rpc build error. + - add sss lookup module. + - teach automount about sss source. ++- ignore duplicate exports in auto.net. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/samples/auto.net ++++ autofs-5.0.6/samples/auto.net +@@ -35,7 +35,7 @@ done + # Newer distributions get this right + SHOWMOUNT="$SMNT --no-headers -e $key" + +-$SHOWMOUNT | LC_ALL=C sort -k 1 | \ ++$SHOWMOUNT | LC_ALL=C cut -d' ' -f1 | LC_ALL=C sort -u | \ + awk -v key="$key" -v opts="$opts" -- ' + BEGIN { ORS=""; first=1 } + { if (first) { print opts; first=0 }; print " \\\n\t" $1, key ":" $1 } diff --git a/autofs-5.0.6-reinstate-singleton-mount-probe.patch b/autofs-5.0.6-reinstate-singleton-mount-probe.patch new file mode 100644 index 0000000..4e9a078 --- /dev/null +++ b/autofs-5.0.6-reinstate-singleton-mount-probe.patch @@ -0,0 +1,105 @@ +autofs-5.0.6 - reinstate singleton mount probe + +From: Ian Kent + +The change to have the kernel process text based mount options can +introduce lengthy timeout waits when attempting a mount to a host +that is not available. + +To avoid these waits autofs should probe singleton mounts if it +thinks mount.nfs will pass text options to the kernel (which of +course implies the kernel supports this). +--- + + CHANGELOG | 1 + + daemon/automount.c | 7 +++++++ + include/mounts.h | 1 + + modules/replicated.c | 18 ++++++++++++++++-- + 4 files changed, 25 insertions(+), 2 deletions(-) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -26,6 +26,7 @@ + - ignore duplicate exports in auto.net. + - add kernel verion check function. + - add function to check mount.nfs version. ++- reinstate singleton mount probe. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/daemon/automount.c ++++ autofs-5.0.6/daemon/automount.c +@@ -51,6 +51,9 @@ const char *libdir = AUTOFS_LIB_DIR; /* + const char *mapdir = AUTOFS_MAP_DIR; /* Location of mount maps */ + const char *confdir = AUTOFS_CONF_DIR; /* Location of autofs config file */ + ++unsigned int nfs_mount_uses_string_options = 0; ++static struct nfs_mount_vers vers, check = {1, 1, 1}; ++ + /* autofs fifo name prefix */ + const char *fifodir = AUTOFS_FIFO_DIR "/autofs.fifo"; + +@@ -1273,6 +1276,8 @@ static int do_hup_signal(struct master * + if (status) + fatal(status); + ++ nfs_mount_uses_string_options = check_nfs_mount_version(&vers, &check); ++ + master_mutex_lock(); + if (master->reading) { + status = pthread_mutex_unlock(&mrc.mutex); +@@ -1936,6 +1941,8 @@ int main(int argc, char *argv[]) + + defaults_read_config(0); + ++ nfs_mount_uses_string_options = check_nfs_mount_version(&vers, &check); ++ + kpkt_len = get_kpkt_len(); + timeout = defaults_get_timeout(); + ghost = defaults_get_browse_mode(); +--- autofs-5.0.6.orig/include/mounts.h ++++ autofs-5.0.6/include/mounts.h +@@ -95,6 +95,7 @@ struct nfs_mount_vers { + unsigned int fix; + }; + int check_nfs_mount_version(struct nfs_mount_vers *, struct nfs_mount_vers *); ++extern unsigned int nfs_mount_uses_string_options; + + unsigned int query_kproto_ver(void); + unsigned int get_kver_major(void); +--- autofs-5.0.6.orig/modules/replicated.c ++++ autofs-5.0.6/modules/replicated.c +@@ -901,6 +901,7 @@ int prune_host_list(unsigned logopt, str + unsigned int v2_udp_count, v3_udp_count, v4_udp_count; + unsigned int max_udp_count, max_tcp_count, max_count; + int status; ++ int kern_vers; + + if (!*list) + return 0; +@@ -920,9 +921,22 @@ int prune_host_list(unsigned logopt, str + * or a single host entry whose proximity isn't local. If so + * return immediately as we don't want to add probe latency for + * the common case of a single filesystem mount request. ++ * ++ * But, if the kernel understands text nfs mount options then ++ * mount.nfs most likely bypasses its probing and lets the kernel ++ * do all the work. This can lead to long timeouts for hosts that ++ * are not available so check the kernel version and mount.nfs ++ * version and probe singleton mounts if the kernel version is ++ * greater than 2.6.22 and mount.nfs version is greater than 1.1.1. + */ +- if (!this || !this->next) +- return 1; ++ if (nfs_mount_uses_string_options && ++ (kern_vers = linux_version_code()) > KERNEL_VERSION(2, 6, 22)) { ++ if (!this) ++ return 1; ++ } else { ++ if (!this || !this->next) ++ return 1; ++ } + + proximity = this->proximity; + while (this) { diff --git a/autofs-5.0.6-rework-error-return-handling-in-rpc-code.patch b/autofs-5.0.6-rework-error-return-handling-in-rpc-code.patch new file mode 100644 index 0000000..81be29c --- /dev/null +++ b/autofs-5.0.6-rework-error-return-handling-in-rpc-code.patch @@ -0,0 +1,618 @@ +autofs-5.0.6 - rework error return handling in rpc code + +From: Ian Kent + +With the changes to the way mount.nfs performs nfs mounts for +kernels that support passing of text based options mounts to +hosts that are down or unreachable can take a long time to +fail due to lengthy timeouts. The kernel rpc code is duty +bound to honour these timeouts so we need to find a way to +catch EHOSTUNREACH errors during host probing. + +The first thing to do is to rework the lower level autofs +rpc code to propogate error returns up to the higher levels. +--- + + CHANGELOG | 1 + lib/rpc_subs.c | 178 ++++++++++++++++++++++++++++----------------------- + modules/replicated.c | 26 +++---- + 3 files changed, 114 insertions(+), 91 deletions(-) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -27,6 +27,7 @@ + - add kernel verion check function. + - add function to check mount.nfs version. + - reinstate singleton mount probe. ++- rework error return handling in rpc code. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/lib/rpc_subs.c ++++ autofs-5.0.6/lib/rpc_subs.c +@@ -76,11 +76,11 @@ static int connect_nb(int fd, struct soc + + flags = fcntl(fd, F_GETFL, 0); + if (flags < 0) +- return -1; ++ return -errno; + + ret = fcntl(fd, F_SETFL, flags | O_NONBLOCK); + if (ret < 0) +- return -1; ++ return -errno; + + /* + * From here on subsequent sys calls could change errno so +@@ -150,14 +150,16 @@ done: + } + + #ifndef WITH_LIBTIRPC +-static CLIENT *rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, int *fd) ++static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, int *fd, CLIENT **client) + { +- CLIENT *client = NULL; ++ CLIENT *clnt = NULL; + struct sockaddr_in in4_laddr; + struct sockaddr_in *in4_raddr; + int type, proto; + socklen_t slen; + ++ *client = NULL; ++ + proto = info->proto->p_proto; + if (proto == IPPROTO_UDP) + type = SOCK_DGRAM; +@@ -179,11 +181,11 @@ static CLIENT *rpc_do_create_client(stru + + *fd = open_sock(addr->sa_family, type, proto); + if (*fd < 0) +- return NULL; ++ return -errno; + + laddr = (struct sockaddr *) &in4_laddr; + if (bind(*fd, laddr, slen) < 0) +- return NULL; ++ return -errno; + } + + in4_raddr = (struct sockaddr_in *) addr; +@@ -191,26 +193,29 @@ static CLIENT *rpc_do_create_client(stru + + switch (info->proto->p_proto) { + case IPPROTO_UDP: +- client = clntudp_bufcreate(in4_raddr, +- info->program, info->version, +- info->timeout, fd, +- info->send_sz, info->recv_sz); ++ clnt = clntudp_bufcreate(in4_raddr, ++ info->program, info->version, ++ info->timeout, fd, ++ info->send_sz, info->recv_sz); + break; + + case IPPROTO_TCP: +- if (connect_nb(*fd, addr, slen, &info->timeout) < 0) +- break; +- +- client = clnttcp_create(in4_raddr, +- info->program, info->version, fd, +- info->send_sz, info->recv_sz); ++ int ret = connect_nb(*fd, addr, slen, &info->timeout); ++ if (ret < 0) ++ return ret; ++ ++ clnt = clnttcp_create(in4_raddr, ++ info->program, info->version, fd, ++ info->send_sz, info->recv_sz); + break; + + default: + break; + } + +- return client; ++ *client = clnt; ++ ++ return 0; + } + #else + struct netconfig *find_netconf(void *handle, char *family, char *proto) +@@ -226,9 +231,9 @@ struct netconfig *find_netconf(void *han + return nconf; + } + +-static CLIENT *rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, int *fd) ++static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, int *fd, CLIENT **client) + { +- CLIENT *client = NULL; ++ CLIENT *clnt = NULL; + struct sockaddr_in in4_laddr; + struct sockaddr_in6 in6_laddr; + struct sockaddr *laddr = NULL; +@@ -238,6 +243,9 @@ static CLIENT *rpc_do_create_client(stru + char *nc_family, *nc_proto; + void *handle; + size_t slen; ++ int ret; ++ ++ *client = NULL; + + proto = info->proto->p_proto; + if (proto == IPPROTO_UDP) { +@@ -272,16 +280,16 @@ static CLIENT *rpc_do_create_client(stru + slen = sizeof(struct sockaddr_in6); + nc_family = NC_INET6; + } else +- return NULL; ++ return -EINVAL; + + handle = setnetconfig(); + if (!handle) +- return NULL; ++ return -EINVAL; + + nconf = find_netconf(handle, nc_family, nc_proto); + if (!nconf) { + endnetconfig(handle); +- return NULL; ++ return -EINVAL; + } + + /* +@@ -292,13 +300,15 @@ static CLIENT *rpc_do_create_client(stru + if (!info->client) { + *fd = open_sock(addr->sa_family, type, proto); + if (*fd < 0) { ++ ret = -errno; + endnetconfig(handle); +- return NULL; ++ return ret; + } + + if (bind(*fd, laddr, slen) < 0) { ++ ret = -errno; + endnetconfig(handle); +- return NULL; ++ return ret; + } + } + +@@ -306,28 +316,30 @@ static CLIENT *rpc_do_create_client(stru + nb_addr.buf = addr; + + if (info->proto->p_proto == IPPROTO_TCP) { +- if (connect_nb(*fd, addr, slen, &info->timeout) < 0) { ++ ret = connect_nb(*fd, addr, slen, &info->timeout); ++ if (ret < 0) { + endnetconfig(handle); +- return NULL; ++ return ret; + } + } + +- client = clnt_tli_create(*fd, nconf, &nb_addr, +- info->program, info->version, +- info->send_sz, info->recv_sz); ++ clnt = clnt_tli_create(*fd, nconf, &nb_addr, ++ info->program, info->version, ++ info->send_sz, info->recv_sz); + + endnetconfig(handle); + +- return client; ++ *client = clnt; ++ ++ return 0; + } + #endif + + /* + * Create an RPC client + */ +-static CLIENT *create_client(struct conn_info *info) ++static int create_client(struct conn_info *info, CLIENT **client) + { +- CLIENT *client = NULL; + struct addrinfo *ai, *haddr; + struct addrinfo hints; + int fd, ret; +@@ -346,9 +358,11 @@ static CLIENT *create_client(struct conn + } + + if (info->addr) { +- client = rpc_do_create_client(info->addr, info, &fd); +- if (client) ++ ret = rpc_do_create_client(info->addr, info, &fd, client); ++ if (ret == 0) + goto done; ++ if (ret == -EHOSTUNREACH) ++ goto out_close; + + if (!info->client && fd != RPC_ANYSOCK) { + close(fd); +@@ -376,9 +390,11 @@ static CLIENT *create_client(struct conn + continue; + } + +- client = rpc_do_create_client(haddr->ai_addr, info, &fd); +- if (client) ++ ret = rpc_do_create_client(haddr->ai_addr, info, &fd, client); ++ if (ret == 0) + break; ++ if (ret == -EHOSTUNREACH) ++ goto out_close; + + if (!info->client && fd != RPC_ANYSOCK) { + close(fd); +@@ -390,24 +406,26 @@ static CLIENT *create_client(struct conn + + freeaddrinfo(ai); + +- if (!client) { ++ if (!*client) { + info->client = NULL; ++ ret = -ENOTCONN; + goto out_close; + } + done: + /* Close socket fd on destroy, as is default for rpcowned fds */ +- if (!clnt_control(client, CLSET_FD_CLOSE, NULL)) { +- clnt_destroy(client); ++ if (!clnt_control(*client, CLSET_FD_CLOSE, NULL)) { ++ clnt_destroy(*client); + info->client = NULL; ++ ret = -ENOTCONN; + goto out_close; + } + +- return client; ++ return 0; + + out_close: + if (fd != -1) + close(fd); +- return NULL; ++ return ret; + } + + int rpc_udp_getclient(struct conn_info *info, +@@ -415,11 +433,12 @@ int rpc_udp_getclient(struct conn_info * + { + struct protoent *pe_proto; + CLIENT *client; ++ int ret; + + if (!info->client) { + pe_proto = getprotobyname("udp"); + if (!pe_proto) +- return 0; ++ return -ENOENT; + + info->proto = pe_proto; + info->send_sz = UDPMSGSIZE; +@@ -429,14 +448,13 @@ int rpc_udp_getclient(struct conn_info * + info->program = program; + info->version = version; + +- client = create_client(info); +- +- if (!client) +- return 0; ++ ret = create_client(info, &client); ++ if (ret < 0) ++ return ret; + + info->client = client; + +- return 1; ++ return 0; + } + + void rpc_destroy_udp_client(struct conn_info *info) +@@ -454,11 +472,12 @@ int rpc_tcp_getclient(struct conn_info * + { + struct protoent *pe_proto; + CLIENT *client; ++ int ret; + + if (!info->client) { + pe_proto = getprotobyname("tcp"); + if (!pe_proto) +- return 0; ++ return -ENOENT; + + info->proto = pe_proto; + info->send_sz = 0; +@@ -468,14 +487,13 @@ int rpc_tcp_getclient(struct conn_info * + info->program = program; + info->version = version; + +- client = create_client(info); +- +- if (!client) +- return 0; ++ ret = create_client(info, &client); ++ if (ret < 0) ++ return ret; + + info->client = client; + +- return 1; ++ return 0; + } + + void rpc_destroy_tcp_client(struct conn_info *info) +@@ -509,10 +527,11 @@ int rpc_portmap_getclient(struct conn_in + { + struct protoent *pe_proto; + CLIENT *client; ++ int ret; + + pe_proto = getprotobyname(proto); + if (!pe_proto) +- return 0; ++ return -ENOENT; + + info->host = host; + info->addr = addr; +@@ -530,13 +549,14 @@ int rpc_portmap_getclient(struct conn_in + + if (pe_proto->p_proto == IPPROTO_TCP) + info->timeout.tv_sec = PMAP_TOUT_TCP; +- client = create_client(info); +- if (!client) +- return 0; ++ ++ ret = create_client(info, &client); ++ if (ret < 0) ++ return ret; + + info->client = client; + +- return 1; ++ return 0; + } + + unsigned short rpc_portmap_getport(struct conn_info *info, struct pmap *parms) +@@ -546,6 +566,7 @@ unsigned short rpc_portmap_getport(struc + CLIENT *client; + enum clnt_stat status; + int proto = info->proto->p_proto; ++ int ret; + + memset(&pmap_info, 0, sizeof(struct conn_info)); + +@@ -567,9 +588,9 @@ unsigned short rpc_portmap_getport(struc + pmap_info.send_sz = RPCSMALLMSGSIZE; + pmap_info.recv_sz = RPCSMALLMSGSIZE; + +- client = create_client(&pmap_info); +- if (!client) +- return 0; ++ ret = create_client(&pmap_info, &client); ++ if (ret < 0) ++ return ret; + } + + /* +@@ -611,7 +632,7 @@ unsigned short rpc_portmap_getport(struc + } + + if (status != RPC_SUCCESS) +- return 0; ++ return -EIO; + + return port; + } +@@ -621,6 +642,7 @@ int rpc_ping_proto(struct conn_info *inf + CLIENT *client; + enum clnt_stat status; + int proto = info->proto->p_proto; ++ int ret; + + if (info->client) + client = info->client; +@@ -629,9 +651,9 @@ int rpc_ping_proto(struct conn_info *inf + info->send_sz = UDPMSGSIZE; + info->recv_sz = UDPMSGSIZE; + } +- client = create_client(info); +- if (!client) +- return 0; ++ ret = create_client(info, &client); ++ if (ret < 0) ++ return ret; + } + + clnt_control(client, CLSET_TIMEOUT, (char *) &info->timeout); +@@ -665,7 +687,7 @@ int rpc_ping_proto(struct conn_info *inf + } + + if (status != RPC_SUCCESS) +- return 0; ++ return -EIO; + + return 1; + } +@@ -704,7 +726,7 @@ static unsigned int __rpc_ping(const cha + parms.pm_port = 0; + + info.port = rpc_portmap_getport(&info, &parms); +- if (!info.port) ++ if (info.port < 0) + return status; + + status = rpc_ping_proto(&info); +@@ -719,19 +741,19 @@ int rpc_ping(const char *host, long seco + unsigned int status; + + status = __rpc_ping(host, vers2, "udp", seconds, micros, option); +- if (status) ++ if (status > 0) + return RPC_PING_V2 | RPC_PING_UDP; + + status = __rpc_ping(host, vers3, "udp", seconds, micros, option); +- if (status) ++ if (status > 0) + return RPC_PING_V3 | RPC_PING_UDP; + + status = __rpc_ping(host, vers2, "tcp", seconds, micros, option); +- if (status) ++ if (status > 0) + return RPC_PING_V2 | RPC_PING_TCP; + + status = __rpc_ping(host, vers3, "tcp", seconds, micros, option); +- if (status) ++ if (status > 0) + return RPC_PING_V3 | RPC_PING_TCP; + + return status; +@@ -760,9 +782,8 @@ int rpc_time(const char *host, + status = __rpc_ping(host, vers, proto, seconds, micros, option); + gettimeofday(&end, &tz); + +- if (!status) { +- return 0; +- } ++ if (status == RPC_PING_FAIL || status < 0) ++ return status; + + taken = elapsed(start, end); + +@@ -779,13 +800,14 @@ static int rpc_get_exports_proto(struct + int proto = info->proto->p_proto; + unsigned int option = info->close_option; + int vers_entry; ++ int ret; + + if (info->proto->p_proto == IPPROTO_UDP) { + info->send_sz = UDPMSGSIZE; + info->recv_sz = UDPMSGSIZE; + } +- client = create_client(info); +- if (!client) ++ ret = create_client(info, &client); ++ if (ret < 0) + return 0; + + clnt_control(client, CLSET_TIMEOUT, (char *) &info->timeout); +@@ -894,7 +916,7 @@ exports rpc_get_exports(const char *host + parms.pm_prot = info.proto->p_proto; + + info.port = rpc_portmap_getport(&info, &parms); +- if (!info.port) ++ if (info.port < 0) + goto try_tcp; + + memset(&exportlist, '\0', sizeof(exportlist)); +@@ -911,7 +933,7 @@ try_tcp: + parms.pm_prot = info.proto->p_proto; + + info.port = rpc_portmap_getport(&info, &parms); +- if (!info.port) ++ if (info.port < 0) + return NULL; + + memset(&exportlist, '\0', sizeof(exportlist)); +--- autofs-5.0.6.orig/modules/replicated.c ++++ autofs-5.0.6/modules/replicated.c +@@ -563,11 +563,11 @@ static unsigned int get_nfs_info(unsigne + status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS4_VERSION); + else + status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS4_VERSION); +- if (status) { ++ if (!status) { + gettimeofday(&start, &tz); + status = rpc_ping_proto(rpc_info); + gettimeofday(&end, &tz); +- if (status) { ++ if (status > 0) { + double reply; + if (random_selection) { + /* Random value between 0 and 1 */ +@@ -589,7 +589,7 @@ v3_ver: + status = rpc_portmap_getclient(pm_info, + host->name, host->addr, host->addr_len, + proto, RPC_CLOSE_DEFAULT); +- if (!status) ++ if (status) + goto done_ver; + } + +@@ -603,7 +603,7 @@ v3_ver: + parms.pm_prot = rpc_info->proto->p_proto; + parms.pm_vers = NFS3_VERSION; + rpc_info->port = rpc_portmap_getport(pm_info, &parms); +- if (!rpc_info->port) ++ if (rpc_info->port < 0) + goto v2_ver; + } + +@@ -611,11 +611,11 @@ v3_ver: + status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS3_VERSION); + else + status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS3_VERSION); +- if (status) { ++ if (!status) { + gettimeofday(&start, &tz); + status = rpc_ping_proto(rpc_info); + gettimeofday(&end, &tz); +- if (status) { ++ if (status > 0) { + double reply; + if (random_selection) { + /* Random value between 0 and 1 */ +@@ -643,7 +643,7 @@ v2_ver: + parms.pm_prot = rpc_info->proto->p_proto; + parms.pm_vers = NFS2_VERSION; + rpc_info->port = rpc_portmap_getport(pm_info, &parms); +- if (!rpc_info->port) ++ if (rpc_info->port < 0) + goto done_ver; + } + +@@ -651,11 +651,11 @@ v2_ver: + status = rpc_udp_getclient(rpc_info, NFS_PROGRAM, NFS2_VERSION); + else + status = rpc_tcp_getclient(rpc_info, NFS_PROGRAM, NFS2_VERSION); +- if (status) { ++ if (!status) { + gettimeofday(&start, &tz); + status = rpc_ping_proto(rpc_info); + gettimeofday(&end, &tz); +- if (status) { ++ if (status > 0) { + double reply; + if (random_selection) { + /* Random value between 0 and 1 */ +@@ -835,12 +835,12 @@ static int get_supported_ver_and_cost(un + int ret = rpc_portmap_getclient(&pm_info, + host->name, host->addr, host->addr_len, + proto, RPC_CLOSE_DEFAULT); +- if (!ret) ++ if (ret) + return 0; + + parms.pm_prot = rpc_info.proto->p_proto; + rpc_info.port = rpc_portmap_getport(&pm_info, &parms); +- if (!rpc_info.port) ++ if (rpc_info.port < 0) + goto done; + } + +@@ -848,11 +848,11 @@ static int get_supported_ver_and_cost(un + status = rpc_udp_getclient(&rpc_info, NFS_PROGRAM, parms.pm_vers); + else + status = rpc_tcp_getclient(&rpc_info, NFS_PROGRAM, parms.pm_vers); +- if (status) { ++ if (!status) { + gettimeofday(&start, &tz); + status = rpc_ping_proto(&rpc_info); + gettimeofday(&end, &tz); +- if (status) { ++ if (status > 0) { + if (random_selection) { + /* Random value between 0 and 1 */ + taken = ((float) random())/((float) RAND_MAX+1); diff --git a/autofs-5.0.6-systemd-support-fixes.patch b/autofs-5.0.6-systemd-support-fixes.patch new file mode 100644 index 0000000..2d784ea --- /dev/null +++ b/autofs-5.0.6-systemd-support-fixes.patch @@ -0,0 +1,110 @@ +autofs-5.0.6 - systemd support fixes + +From: Ian Kent + +Fix up some of in spec file systemd scriptlets. + +The pre-system package verion uninstall scriptlet has been commented +out in the tar spec file. It's is an example of what might need to +be done in a distro spec file. +--- + + CHANGELOG | 1 + + autofs.spec | 41 ++++++++++++++++++++++++++++++----------- + samples/autofs.service.in | 1 + + 3 files changed, 32 insertions(+), 11 deletions(-) + + +diff --git a/CHANGELOG b/CHANGELOG +index 69ade49..b9c3149 100644 +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -32,6 +32,7 @@ + - reinstate singleton mount probe. + - rework error return handling in rpc code. + - catch EHOSTUNREACH and bail out early. ++- systemd support fixes. + + 28/06/2011 autofs-5.0.6 + ----------------------- +diff --git a/autofs.spec b/autofs.spec +index d854b1f..a73fefb 100644 +--- a/autofs.spec ++++ b/autofs.spec +@@ -105,34 +105,53 @@ install -m 644 redhat/autofs.sysconfig $RPM_BUILD_ROOT/etc/sysconfig/autofs + + %post + %if %{with_systemd} +-/bin/systemctl daemon-reload >/dev/null 2>&1 || : ++if [ $1 -eq 1 ]; then ++ %{_bindir}/systemctl daemon-reload >/dev/null 2>&1 || : ++ # autofs has been approved to be enabled by default ++ %{_bindir}/systemctl enable %{name}.service >/dev/null 2>&1 || : ++fi + %else +-chkconfig --add autofs ++if [ $1 -eq 1 ]; then ++ %{_sbindir}/chkconfig --add autofs ++fi + %endif + + %preun +-if [ "$1" = 0 ] ; then + %if %{with_systemd} +- /bin/systemctl --no-reload disable autofs.service > /dev/null 2>&1 || : +- /bin/systemctl stop autofs.service > /dev/null 2>&1 || : ++if [ $1 -eq 0 ] ; then ++ %{_bindir}/systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || : ++ %{_bindir}/systemctl stop %{name}.service > /dev/null 2>&1 || : ++fi + %else +- /sbin/service autofs stop > /dev/null 2>&1 || : +- /sbin/chkconfig --del autofs +-%endif ++if [ $1 -eq 0 ] ; then ++ %{_sbindir}/service autofs stop > /dev/null 2>&1 || : ++ %{_sbindir}/chkconfig --del autofs + fi ++%endif + + %postun + %if %{with_systemd} +-/bin/systemctl daemon-reload >/dev/null 2>&1 || : ++%{_bindir}/systemctl daemon-reload >/dev/null 2>&1 || : + if [ $1 -ge 1 ] ; then +- /bin/systemctl try-restart autofs.service >/dev/null 2>&1 || : ++ # Package upgrade, not removal ++ %{_bindir}/systemctl try-restart %{name}.service >/dev/null 2>&1 || : + fi + %else + if [ $1 -ge 1 ] ; then +- /sbin/service autofs condrestart > /dev/null 2>&1 || : ++ %{_sbindir}/service autofs condrestart > /dev/null 2>&1 || : + fi + %endif + ++#%triggerun -- %{name} < $bla release ++## Save the current service runlevel info ++## User must manually run systemd-sysv-convert --apply %{name} ++## to migrate them to systemd targets ++#%{_bindir}/systemd-sysv-convert --save %{name} >/dev/null 2>&1 ||: ++# ++## Run these because the SysV package being removed won't do them ++#%{_sbindir}/chkconfig --del %{name} >/dev/null 2>&1 || : ++#%{_bindir}/systemctl try-restart %{name}.service >/dev/null 2>&1 || : ++ + %files + %defattr(-,root,root) + %doc CREDITS CHANGELOG INSTALL COPY* README* samples/ldap* samples/autofs.schema samples/autofs_ldap_auth.conf +diff --git a/samples/autofs.service.in b/samples/autofs.service.in +index 3756078..879b47b 100644 +--- a/samples/autofs.service.in ++++ b/samples/autofs.service.in +@@ -7,6 +7,7 @@ Type=forking + PIDFile=@@autofspiddir@@/autofs.pid + EnvironmentFile=-@@autofsconfdir@@/autofs + ExecStart=@@sbindir@@/automount ${OPTIONS} --pid-file @@autofspiddir@@/autofs.pid ++ExecReload=/usr/bin/kill -HUP $MAINPID + + [Install] + WantedBy=multi-user.target diff --git a/autofs.spec b/autofs.spec index a1af347..8eaaeb8 100644 --- a/autofs.spec +++ b/autofs.spec @@ -8,7 +8,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.0.6 -Release: 11%{?dist} +Release: 12%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -39,6 +39,14 @@ Patch23: autofs-5.0.6-fix-improve-mount-location-error-reporting.patch Patch24: autofs-5.0.6-fix-rpc-build-error.patch Patch25: autofs-5.0.6-add-sss-lookup-module.patch Patch26: autofs-5.0.6-teach-automount-about-sss-source.patch +Patch27: autofs-5.0.6-ignore-duplicate-exports-in-auto-net.patch +Patch28: autofs-5.0.6-add-kernel-verion-check-function.patch +Patch29: autofs-5.0.6-add-function-to-check-mount-nfs-version.patch +Patch30: autofs-5.0.6-reinstate-singleton-mount-probe.patch +Patch31: autofs-5.0.6-rework-error-return-handling-in-rpc-code.patch +Patch32: autofs-5.0.6-catch-EHOSTUNREACH-and-bail-out-early.patch +Patch33: autofs-5.0.6-systemd-support-fixes.patch +Patch34: autofs-5.0.6-fix-segmentation-fault-in-do-remount-indirect.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %if %{with_systemd} BuildRequires: systemd-units @@ -120,6 +128,14 @@ echo %{version}-%{release} > .version %patch24 -p1 %patch25 -p1 %patch26 -p1 +%patch27 -p1 +%patch28 -p1 +%patch29 -p1 +%patch30 -p1 +%patch31 -p1 +%patch32 -p1 +%patch33 -p1 +%patch34 -p1 %build #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir} @@ -156,33 +172,51 @@ rm -rf $RPM_BUILD_ROOT %post %if %{with_systemd} /bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -eq 1 ]; then + %{_bindir}/systemctl daemon-reload >/dev/null 2>&1 || : + # autofs has been approved to be enabled by default + %{_bindir}/systemctl enable %{name}.service >/dev/null 2>&1 || : %else -/sbin/chkconfig --add autofs +if [ $1 -eq 1 ]; then + %{_sbindir}/sbin/chkconfig --add autofs +fi %endif %preun -if [ "$1" = 0 ] ; then %if %{with_systemd} - /bin/systemctl --no-reload disable autofs.service > /dev/null 2>&1 || : - /bin/systemctl stop autofs.service > /dev/null 2>&1 || : -%else - /sbin/service autofs stop > /dev/null 2>&1 || : - /sbin/chkconfig --del autofs -%endif +if [ $1 -eq 0 ] ; then + %{_bindir}/systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || : + %{_bindir}/systemctl stop %{name}.service > /dev/null 2>&1 || : fi +%else +if [ $1 -eq 0 ] ; then + %{_sbindir}/service autofs stop > /dev/null 2>&1 || : + %{_sbindir}/chkconfig --del autofs +fi +%endif %postun %if %{with_systemd} -/bin/systemctl daemon-reload >/dev/null 2>&1 || : +%{_bindir}/systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then - /bin/systemctl try-restart autofs.service >/dev/null 2>&1 || : + %{_bindir}/systemctl try-restart %{name}.service >/dev/null 2>&1 || : fi %else if [ $1 -ge 1 ] ; then - /sbin/service autofs condrestart > /dev/null 2>&1 || : + %{_sbindir}/sbin/service autofs condrestart > /dev/null 2>&1 || : fi %endif +%triggerun -- %{name} < 5.0.6-5 +# Save the current service runlevel info +# User must manually run systemd-sysv-convert --apply %{name} +# to migrate them to systemd targets +%{_bindir}/systemd-sysv-convert --save %{name} >/dev/null 2>&1 ||: + +# Run these because the SysV package being removed won't do them +%{_sbindir}/chkconfig --del %{name} >/dev/null 2>&1 || : +%{_bindir}/systemctl try-restart %{name}.service >/dev/null 2>&1 || : + %files %defattr(-,root,root,-) %doc CREDITS INSTALL COPY* README* patches/* samples/ldap* samples/autofs.schema @@ -203,6 +237,16 @@ fi %dir /etc/auto.master.d %changelog +* Fri Feb 24 2012 Ian Kent - 1:5.0.6-12 +- ignore duplicate exports in auto.net. +- add kernel verion check function. +- add function to check mount.nfs version. +- reinstate singleton mount probe. +- rework error return handling in rpc code. +- catch EHOSTUNREACH and bail out early. +- systemd support fixes. +- fix segmentation fault in do_remount_indirect(). + * Thu Feb 9 2012 Ian Kent - 1:5.0.6-11 - fix fuzz in CHANGELOG hunk when applying patch26. From 5cc6fcc0312ebbaca5d6199875c02f54e069a957 Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Sun, 26 Feb 2012 14:57:40 +0800 Subject: [PATCH 03/10] * Sun Feb 26 2012 Ian Kent - 1:5.0.6-13 - fix error in %post scriplet. --- autofs.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autofs.spec b/autofs.spec index 8eaaeb8..7d671fa 100644 --- a/autofs.spec +++ b/autofs.spec @@ -8,7 +8,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.0.6 -Release: 12%{?dist} +Release: 13%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -176,6 +176,7 @@ if [ $1 -eq 1 ]; then %{_bindir}/systemctl daemon-reload >/dev/null 2>&1 || : # autofs has been approved to be enabled by default %{_bindir}/systemctl enable %{name}.service >/dev/null 2>&1 || : +fi %else if [ $1 -eq 1 ]; then %{_sbindir}/sbin/chkconfig --add autofs @@ -237,6 +238,9 @@ fi %dir /etc/auto.master.d %changelog +* Sun Feb 26 2012 Ian Kent - 1:5.0.6-13 +- fix error in %post scriplet. + * Fri Feb 24 2012 Ian Kent - 1:5.0.6-12 - ignore duplicate exports in auto.net. - add kernel verion check function. From 4865913fb4be5781126057d946693c96ddf01bbc Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Wed, 29 Feb 2012 11:12:21 +0800 Subject: [PATCH 04/10] * Wed Feb 29 2012 Ian Kent - 1:5.0.6-14 - fix function to check mount.nfs version. --- ...-function-to-check-mount_nfs-version.patch | 52 +++++++++++++++++++ autofs.spec | 19 ++++--- 2 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 autofs-5.0.6-fix-function-to-check-mount_nfs-version.patch diff --git a/autofs-5.0.6-fix-function-to-check-mount_nfs-version.patch b/autofs-5.0.6-fix-function-to-check-mount_nfs-version.patch new file mode 100644 index 0000000..4246df3 --- /dev/null +++ b/autofs-5.0.6-fix-function-to-check-mount_nfs-version.patch @@ -0,0 +1,52 @@ +autofs-5.0.6 - fix function to check mount.nfs version + +From: Leonardo Chiquitto + +The function check_nfs_mount_version() compares the version +of mount.nfs to decide whether a feature is available or not. + +There's a bug in the version comparison code that causes +1.3.0 to be considered less than 1.1.1. This patch fixes it. +--- + + CHANGELOG | 1 + + lib/mounts.c | 17 +++++------------ + 2 files changed, 6 insertions(+), 12 deletions(-) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -31,6 +31,7 @@ + - catch EHOSTUNREACH and bail out early. + - systemd support fixes. + - check scandir() return value. ++- fix function to check mount.nfs version. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/lib/mounts.c ++++ autofs-5.0.6/lib/mounts.c +@@ -249,18 +249,11 @@ int check_nfs_mount_version(struct nfs_m + } + + if (ret) { +- if (vers->major == check->major && +- vers->minor == check->minor && +- vers->fix == check->fix) +- ; +- else { +- if (vers->major < check->major) +- ret = 0; +- else if (vers->minor < check->minor) +- ret = 0; +- else if (vers->fix < check->fix) +- ret = 0; +- } ++ if ((vers->major < check->major) || ++ ((vers->major == check->major) && (vers->minor < check->minor)) || ++ ((vers->major == check->major) && (vers->minor == check->minor) && ++ (vers->fix < check->fix))) ++ ret = 0; + } + + if (waitpid(f, &status, 0) != f) ; diff --git a/autofs.spec b/autofs.spec index 7d671fa..b6a80f4 100644 --- a/autofs.spec +++ b/autofs.spec @@ -8,7 +8,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.0.6 -Release: 13%{?dist} +Release: 14%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -47,6 +47,7 @@ Patch31: autofs-5.0.6-rework-error-return-handling-in-rpc-code.patch Patch32: autofs-5.0.6-catch-EHOSTUNREACH-and-bail-out-early.patch Patch33: autofs-5.0.6-systemd-support-fixes.patch Patch34: autofs-5.0.6-fix-segmentation-fault-in-do-remount-indirect.patch +Patch35: autofs-5.0.6-fix-function-to-check-mount_nfs-version.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %if %{with_systemd} BuildRequires: systemd-units @@ -136,6 +137,7 @@ echo %{version}-%{release} > .version %patch32 -p1 %patch33 -p1 %patch34 -p1 +%patch35 -p1 %build #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir} @@ -238,10 +240,13 @@ fi %dir /etc/auto.master.d %changelog -* Sun Feb 26 2012 Ian Kent - 1:5.0.6-13 +* Wed Feb 29 2012 Ian Kent - 1:5.0.6-14 +- fix function to check mount.nfs version. + +* Sun Feb 26 2012 Ian Kent - 1:5.0.6-13 - fix error in %post scriplet. -* Fri Feb 24 2012 Ian Kent - 1:5.0.6-12 +* Fri Feb 24 2012 Ian Kent - 1:5.0.6-12 - ignore duplicate exports in auto.net. - add kernel verion check function. - add function to check mount.nfs version. @@ -251,19 +256,19 @@ fi - systemd support fixes. - fix segmentation fault in do_remount_indirect(). -* Thu Feb 9 2012 Ian Kent - 1:5.0.6-11 +* Thu Feb 9 2012 Ian Kent - 1:5.0.6-11 - fix fuzz in CHANGELOG hunk when applying patch26. -* Tue Feb 7 2012 Ian Kent - 1:5.0.6-10 +* Tue Feb 7 2012 Ian Kent - 1:5.0.6-10 - fix rpc build error. - add sss lookup module. - teach automount about sss source. -* Mon Jan 23 2012 Ian Kent - 1:5.0.6-9 +* Mon Jan 23 2012 Ian Kent - 1:5.0.6-9 - add correct patch for "fix improve mount location error reporting". - add correct patch for "fix fix wait for master source mutex". -* Mon Jan 23 2012 Ian Kent - 1:5.0.6-8 +* Mon Jan 23 2012 Ian Kent - 1:5.0.6-8 - fix fix wait for master source mutex. - fix improve mount location error reporting (bz783496). From 654088a8be963c130b8a6530ddbf9818078a4e1e Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Tue, 1 May 2012 13:34:24 +0800 Subject: [PATCH 05/10] * Tue May 1 2012 Ian Kent - 1:5.0.6-15 - fix typo in libtirpc file name. - fix rework error return handling in rpc code. - allow MOUNT_WAIT to override probe. - improve UDP RPC timeout handling. - fix segfault in get_query_dn(). - use strtok_r() in linux_version_code(). - fix sss wildcard match. - fix dlopen() error handling in sss module. - fix configure string length tests for sss library. --- ...6-allow-MOUNT_WAIT-to-override-probe.patch | 38 ++ ....6-fix-configure-string-length-tests.patch | 69 ++++ ...-dlopen-error-handling-in-sss-module.patch | 36 ++ ...rk-error-return-handling-in-rpc-code.patch | 45 +++ ...s-5.0.6-fix-segfault-in-get_query_dn.patch | 58 +++ autofs-5.0.6-fix-sss-wildcard-match.patch | 41 ++ ...5.0.6-fix-typo-in-libtirpc-file-name.patch | 36 ++ ...0.6-improve-UDP_RPC-timeout-handling.patch | 372 ++++++++++++++++++ ...6-use-strtok_r-in-linux_version_code.patch | 51 +++ autofs.spec | 31 +- 10 files changed, 776 insertions(+), 1 deletion(-) create mode 100644 autofs-5.0.6-allow-MOUNT_WAIT-to-override-probe.patch create mode 100644 autofs-5.0.6-fix-configure-string-length-tests.patch create mode 100644 autofs-5.0.6-fix-dlopen-error-handling-in-sss-module.patch create mode 100644 autofs-5.0.6-fix-rework-error-return-handling-in-rpc-code.patch create mode 100644 autofs-5.0.6-fix-segfault-in-get_query_dn.patch create mode 100644 autofs-5.0.6-fix-sss-wildcard-match.patch create mode 100644 autofs-5.0.6-fix-typo-in-libtirpc-file-name.patch create mode 100644 autofs-5.0.6-improve-UDP_RPC-timeout-handling.patch create mode 100644 autofs-5.0.6-use-strtok_r-in-linux_version_code.patch diff --git a/autofs-5.0.6-allow-MOUNT_WAIT-to-override-probe.patch b/autofs-5.0.6-allow-MOUNT_WAIT-to-override-probe.patch new file mode 100644 index 0000000..7eefce3 --- /dev/null +++ b/autofs-5.0.6-allow-MOUNT_WAIT-to-override-probe.patch @@ -0,0 +1,38 @@ +autofs-5.0.6 - allow MOUNT_WAIT to override probe + +From: Ian Kent + +Allow the use of MOUNT_WAIT to override the probe of singleton +map entries. This can allow for quicker fails to hosts that are +not reachable. +--- + + CHANGELOG | 1 + + modules/replicated.c | 3 +++ + 2 files changed, 4 insertions(+) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -34,6 +34,7 @@ + - fix function to check mount.nfs version. + - fix typo in libtirpc file name. + - fix rework error return handling in rpc code. ++- allow MOUNT_WAIT to override probe. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/modules/replicated.c ++++ autofs-5.0.6/modules/replicated.c +@@ -953,8 +953,11 @@ int prune_host_list(unsigned logopt, str + * are not available so check the kernel version and mount.nfs + * version and probe singleton mounts if the kernel version is + * greater than 2.6.22 and mount.nfs version is greater than 1.1.1. ++ * But also allow the MOUNT_WAIT configuration parameter to override ++ * the probing. + */ + if (nfs_mount_uses_string_options && ++ defaults_get_mount_wait() == -1 && + (kern_vers = linux_version_code()) > KERNEL_VERSION(2, 6, 22)) { + if (!this) + return 1; diff --git a/autofs-5.0.6-fix-configure-string-length-tests.patch b/autofs-5.0.6-fix-configure-string-length-tests.patch new file mode 100644 index 0000000..53cb6e3 --- /dev/null +++ b/autofs-5.0.6-fix-configure-string-length-tests.patch @@ -0,0 +1,69 @@ +autofs-5.0.6 - fix configure string length tests + +From: Ian Kent + +Checks for sss library directory were missing quotes around +the library variable. +--- + + CHANGELOG | 1 + + aclocal.m4 | 6 +++--- + configure | 6 +++--- + 3 files changed, 7 insertions(+), 6 deletions(-) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -39,6 +39,7 @@ + - use strtok_r() in linux_version_code(). + - fix sss wildcard match. + - fix dlopen() error handling in sss module. ++- fix configure string length tests for sss library. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/aclocal.m4 ++++ autofs-5.0.6/aclocal.m4 +@@ -37,16 +37,16 @@ dnl + dnl Check if a sss autofs library exists. + dnl -------------------------------------------------------------------------- + AC_DEFUN(AF_CHECK_SSS_LIB, +-[if test -z $sssldir; then ++[if test -z "$sssldir"; then + AC_MSG_CHECKING(for sssd autofs library) + for libd in /usr/lib64 /usr/lib; do +- if test -z $sssldir; then ++ if test -z "$sssldir"; then + if test -e "$libd/sssd/modules/$2"; then + sssldir=$libd/sssd/modules + fi + fi + done +- if test -n $sssldir; then ++ if test -n "$sssldir"; then + HAVE_$1=1 + AC_MSG_RESULT(yes) + else +--- autofs-5.0.6.orig/configure ++++ autofs-5.0.6/configure +@@ -3832,17 +3832,17 @@ else + fi + + +-if test -z $sssldir; then ++if test -z "$sssldir"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sssd autofs library" >&5 + $as_echo_n "checking for sssd autofs library... " >&6; } + for libd in /usr/lib64 /usr/lib; do +- if test -z $sssldir; then ++ if test -z "$sssldir"; then + if test -e "$libd/sssd/modules/libsss_autofs.so"; then + sssldir=$libd/sssd/modules + fi + fi + done +- if test -n $sssldir; then ++ if test -n "$sssldir"; then + HAVE_SSS_AUTOFS=1 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + $as_echo "yes" >&6; } diff --git a/autofs-5.0.6-fix-dlopen-error-handling-in-sss-module.patch b/autofs-5.0.6-fix-dlopen-error-handling-in-sss-module.patch new file mode 100644 index 0000000..5054f7c --- /dev/null +++ b/autofs-5.0.6-fix-dlopen-error-handling-in-sss-module.patch @@ -0,0 +1,36 @@ +autofs-5.0.6 - fix dlopen() error handling in sss module + +From: Ian Kent + +If dlopen(3) fails during initialization of the sss module the +error message is incorrect since dlerror(3) must be used, not +errno. +--- + + CHANGELOG | 1 + + modules/lookup_sss.c | 3 +-- + 2 files changed, 2 insertions(+), 2 deletions(-) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -38,6 +38,7 @@ + - improve UDP RPC timeout handling. + - use strtok_r() in linux_version_code(). + - fix sss wildcard match. ++- fix dlopen() error handling in sss module. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/modules/lookup_sss.c ++++ autofs-5.0.6/modules/lookup_sss.c +@@ -94,8 +94,7 @@ int lookup_init(const char *mapfmt, int + + dh = dlopen(dlbuf, RTLD_LAZY); + if (!dh) { +- estr = strerror_r(errno, buf, MAX_ERR_BUF); +- logerr(MODPREFIX "dlopen: %s", estr); ++ logerr(MODPREFIX "failed to open %s: %s", dlbuf, dlerror()); + free(ctxt); + return 1; + } diff --git a/autofs-5.0.6-fix-rework-error-return-handling-in-rpc-code.patch b/autofs-5.0.6-fix-rework-error-return-handling-in-rpc-code.patch new file mode 100644 index 0000000..c2eba23 --- /dev/null +++ b/autofs-5.0.6-fix-rework-error-return-handling-in-rpc-code.patch @@ -0,0 +1,45 @@ +autofs-5.0.6 - fix rework error return handling in rpc code + +From: Dustin Polke + +This fixes the following error: +rpc_subs.c: In function ‘rpc_do_create_client’: +rpc_subs.c:203:3: error: a label can only be part of a statement and a +declaration is not a statement +--- + + CHANGELOG | 1 + + lib/rpc_subs.c | 4 ++-- + 2 files changed, 3 insertions(+), 2 deletions(-) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -33,6 +33,7 @@ + - check scandir() return value. + - fix function to check mount.nfs version. + - fix typo in libtirpc file name. ++- fix rework error return handling in rpc code. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/lib/rpc_subs.c ++++ autofs-5.0.6/lib/rpc_subs.c +@@ -155,7 +155,7 @@ static int rpc_do_create_client(struct s + CLIENT *clnt = NULL; + struct sockaddr_in in4_laddr; + struct sockaddr_in *in4_raddr; +- int type, proto; ++ int type, proto, ret; + socklen_t slen; + + *client = NULL; +@@ -200,7 +200,7 @@ static int rpc_do_create_client(struct s + break; + + case IPPROTO_TCP: +- int ret = connect_nb(*fd, addr, slen, &info->timeout); ++ ret = connect_nb(*fd, addr, slen, &info->timeout); + if (ret < 0) + return ret; + diff --git a/autofs-5.0.6-fix-segfault-in-get_query_dn.patch b/autofs-5.0.6-fix-segfault-in-get_query_dn.patch new file mode 100644 index 0000000..7f49038 --- /dev/null +++ b/autofs-5.0.6-fix-segfault-in-get_query_dn.patch @@ -0,0 +1,58 @@ +autofs-5.0.6 - fix segfault in get_query_dn() + +From: Leonardo Chiquitto + +Automount will segfault when two threads run get_query_dn() +simultaneously and $SEARCH_BASE is defined in sysconfig. +This happens because a thread tries to dereference ctxt->sdns +while another thread running the same function frees the +memory. + +I believe we don't need to reread $SEARCH_BASE every time +get_query_dn() is called. + +edit: Ian Kent +move the read of configured search dns to lookup_init(). +edit end +--- + + modules/lookup_ldap.c | 13 +++---------- + 1 file changed, 3 insertions(+), 10 deletions(-) + + +--- autofs-5.0.6.orig/modules/lookup_ldap.c ++++ autofs-5.0.6/modules/lookup_ldap.c +@@ -281,7 +281,6 @@ static int get_query_dn(unsigned logopt, + char buf[MAX_ERR_BUF]; + char *query, *dn, *qdn; + LDAPMessage *result, *e; +- struct ldap_searchdn *sdns = NULL; + char *attrs[2]; + struct berval **value; + int scope; +@@ -330,15 +329,6 @@ static int get_query_dn(unsigned logopt, + scope = LDAP_SCOPE_SUBTREE; + } + +- if (!ctxt->base) { +- sdns = defaults_get_searchdns(); +- if (sdns) { +- if (ctxt->sdns) +- defaults_free_searchdns(ctxt->sdns); +- ctxt->sdns = sdns; +- } +- } +- + dn = NULL; + if (!ctxt->sdns) { + rv = ldap_search_s(ldap, ctxt->base, +@@ -1467,6 +1457,9 @@ int lookup_init(const char *mapfmt, int + return 1; + } + ++ if (!ctxt->base) ++ ctxt->sdns = defaults_get_searchdns(); ++ + ctxt->timeout = defaults_get_ldap_timeout(); + ctxt->network_timeout = defaults_get_ldap_network_timeout(); + diff --git a/autofs-5.0.6-fix-sss-wildcard-match.patch b/autofs-5.0.6-fix-sss-wildcard-match.patch new file mode 100644 index 0000000..4669304 --- /dev/null +++ b/autofs-5.0.6-fix-sss-wildcard-match.patch @@ -0,0 +1,41 @@ +autofs-5.0.6 - fix sss wildcard match + +From: Ian Kent + +Check for a wildcard map entry on sss map read and convert to +the usual '*' befone adding to the map entry cache. +--- + + CHANGELOG | 1 + + modules/lookup_sss.c | 9 +++++++++ + 2 files changed, 10 insertions(+) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -37,6 +37,7 @@ + - allow MOUNT_WAIT to override probe. + - improve UDP RPC timeout handling. + - use strtok_r() in linux_version_code(). ++- fix sss wildcard match. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/modules/lookup_sss.c ++++ autofs-5.0.6/modules/lookup_sss.c +@@ -325,6 +325,15 @@ int lookup_read_map(struct autofs_point + continue; + } + ++ if (*key == '/' && strlen(key) == 1) { ++ if (ap->type == LKP_DIRECT) { ++ free(key); ++ free(value); ++ continue; ++ } ++ *key = '*'; ++ } ++ + /* + * TODO: implement sun % hack for key translation for + * mixed case keys in schema that are single case only. diff --git a/autofs-5.0.6-fix-typo-in-libtirpc-file-name.patch b/autofs-5.0.6-fix-typo-in-libtirpc-file-name.patch new file mode 100644 index 0000000..e871db1 --- /dev/null +++ b/autofs-5.0.6-fix-typo-in-libtirpc-file-name.patch @@ -0,0 +1,36 @@ +autofs-5.0.6 - fix typo in libtirpc file name + +From: Leonardo Chiquitto + +The library file name was misspelled as libitirpc.so. +--- + + CHANGELOG | 1 + + daemon/automount.c | 4 ++-- + 2 files changed, 3 insertions(+), 2 deletions(-) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -32,6 +32,7 @@ + - systemd support fixes. + - check scandir() return value. + - fix function to check mount.nfs version. ++- fix typo in libtirpc file name. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/daemon/automount.c ++++ autofs-5.0.6/daemon/automount.c +@@ -2232,9 +2232,9 @@ int main(int argc, char *argv[]) + xmlInitParser(); + #endif + #ifdef TIRPC_WORKAROUND +- void *dh_tirpc = dlopen("libitirpc.so", RTLD_NOW); ++ void *dh_tirpc = dlopen("libtirpc.so", RTLD_NOW); + if (!dh_tirpc) +- dh_tirpc = dlopen("libitirpc.so.1", RTLD_NOW); ++ dh_tirpc = dlopen("libtirpc.so.1", RTLD_NOW); + #endif + + if (!master_read_master(master_list, age, 0)) { diff --git a/autofs-5.0.6-improve-UDP_RPC-timeout-handling.patch b/autofs-5.0.6-improve-UDP_RPC-timeout-handling.patch new file mode 100644 index 0000000..c6899ec --- /dev/null +++ b/autofs-5.0.6-improve-UDP_RPC-timeout-handling.patch @@ -0,0 +1,372 @@ +autofs-5.0.6 - improve UDP RPC timeout handling + +From: Ian Kent + +The RPC code still doesn't control timeout quite right. Change that +to take control of the UDP timeout too. +--- + + CHANGELOG | 1 + include/rpc_subs.h | 5 ++ + lib/rpc_subs.c | 93 +++++++++++++++++++-------------------------------- + modules/replicated.c | 36 ++++++++++++------- + 4 files changed, 63 insertions(+), 72 deletions(-) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -35,6 +35,7 @@ + - fix typo in libtirpc file name. + - fix rework error return handling in rpc code. + - allow MOUNT_WAIT to override probe. ++- improve UDP RPC timeout handling. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/include/rpc_subs.h ++++ autofs-5.0.6/include/rpc_subs.h +@@ -42,6 +42,9 @@ + #define PMAP_TOUT_UDP 3 + #define PMAP_TOUT_TCP 5 + ++#define RPC_TOUT_UDP PMAP_TOUT_UDP ++#define RPC_TOUT_TCP PMAP_TOUT_TCP ++ + #define HOST_ENT_BUF_SIZE 2048 + + struct conn_info { +@@ -64,7 +67,7 @@ void rpc_destroy_udp_client(struct conn_ + int rpc_tcp_getclient(struct conn_info *, unsigned int, unsigned int); + void rpc_destroy_tcp_client(struct conn_info *); + int rpc_portmap_getclient(struct conn_info *, const char *, struct sockaddr *, size_t, const char *, unsigned int); +-unsigned short rpc_portmap_getport(struct conn_info *, struct pmap *); ++int rpc_portmap_getport(struct conn_info *, struct pmap *, unsigned short *); + int rpc_ping_proto(struct conn_info *); + int rpc_ping(const char *, long, long, unsigned int); + double elapsed(struct timeval, struct timeval); +--- autofs-5.0.6.orig/lib/rpc_subs.c ++++ autofs-5.0.6/lib/rpc_subs.c +@@ -218,43 +218,24 @@ static int rpc_do_create_client(struct s + return 0; + } + #else +-struct netconfig *find_netconf(void *handle, char *family, char *proto) +-{ +- struct netconfig *nconf; +- +- while ((nconf = getnetconfig(handle))) { +- if ((strcmp(nconf->nc_protofmly, family) == 0) && +- (strcmp(nconf->nc_proto, proto) == 0)) +- break; +- } +- +- return nconf; +-} +- + static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, int *fd, CLIENT **client) + { + CLIENT *clnt = NULL; + struct sockaddr_in in4_laddr; + struct sockaddr_in6 in6_laddr; + struct sockaddr *laddr = NULL; +- struct netconfig *nconf; + struct netbuf nb_addr; + int type, proto; +- char *nc_family, *nc_proto; +- void *handle; + size_t slen; + int ret; + + *client = NULL; + + proto = info->proto->p_proto; +- if (proto == IPPROTO_UDP) { ++ if (proto == IPPROTO_UDP) + type = SOCK_DGRAM; +- nc_proto = NC_UDP; +- } else { ++ else + type = SOCK_STREAM; +- nc_proto = NC_TCP; +- } + + /* + * bind to any unused port. If we left this up to the rpc +@@ -269,7 +250,6 @@ static int rpc_do_create_client(struct s + laddr = (struct sockaddr *) &in4_laddr; + in4_raddr->sin_port = htons(info->port); + slen = sizeof(struct sockaddr_in); +- nc_family = NC_INET; + } else if (addr->sa_family == AF_INET6) { + struct sockaddr_in6 *in6_raddr = (struct sockaddr_in6 *) addr; + in6_laddr.sin6_family = AF_INET6; +@@ -278,20 +258,9 @@ static int rpc_do_create_client(struct s + laddr = (struct sockaddr *) &in6_laddr; + in6_raddr->sin6_port = htons(info->port); + slen = sizeof(struct sockaddr_in6); +- nc_family = NC_INET6; + } else + return -EINVAL; + +- handle = setnetconfig(); +- if (!handle) +- return -EINVAL; +- +- nconf = find_netconf(handle, nc_family, nc_proto); +- if (!nconf) { +- endnetconfig(handle); +- return -EINVAL; +- } +- + /* + * bind to any unused port. If we left this up to the rpc layer, + * it would bind to a reserved port, which has been shown to +@@ -301,13 +270,11 @@ static int rpc_do_create_client(struct s + *fd = open_sock(addr->sa_family, type, proto); + if (*fd < 0) { + ret = -errno; +- endnetconfig(handle); + return ret; + } + + if (bind(*fd, laddr, slen) < 0) { + ret = -errno; +- endnetconfig(handle); + return ret; + } + } +@@ -315,19 +282,23 @@ static int rpc_do_create_client(struct s + nb_addr.maxlen = nb_addr.len = slen; + nb_addr.buf = addr; + +- if (info->proto->p_proto == IPPROTO_TCP) { ++ if (info->proto->p_proto == IPPROTO_UDP) ++ clnt = clnt_dg_create(*fd, &nb_addr, ++ info->program, info->version, ++ info->send_sz, info->recv_sz); ++ else if (info->proto->p_proto == IPPROTO_TCP) { + ret = connect_nb(*fd, addr, slen, &info->timeout); +- if (ret < 0) { +- endnetconfig(handle); ++ if (ret < 0) + return ret; +- } +- } +- +- clnt = clnt_tli_create(*fd, nconf, &nb_addr, +- info->program, info->version, +- info->send_sz, info->recv_sz); ++ clnt = clnt_vc_create(*fd, &nb_addr, ++ info->program, info->version, ++ info->send_sz, info->recv_sz); ++ } else ++ return -EINVAL; + +- endnetconfig(handle); ++ /* Our timeout is in seconds */ ++ if (clnt && info->timeout.tv_sec) ++ clnt_control(clnt, CLSET_TIMEOUT, (void *) &info->timeout); + + *client = clnt; + +@@ -441,6 +412,8 @@ int rpc_udp_getclient(struct conn_info * + return -ENOENT; + + info->proto = pe_proto; ++ info->timeout.tv_sec = RPC_TOUT_UDP; ++ info->timeout.tv_usec = 0; + info->send_sz = UDPMSGSIZE; + info->recv_sz = UDPMSGSIZE; + } +@@ -480,6 +453,8 @@ int rpc_tcp_getclient(struct conn_info * + return -ENOENT; + + info->proto = pe_proto; ++ info->timeout.tv_sec = RPC_TOUT_TCP; ++ info->timeout.tv_usec = 0; + info->send_sz = 0; + info->recv_sz = 0; + } +@@ -559,10 +534,10 @@ int rpc_portmap_getclient(struct conn_in + return 0; + } + +-unsigned short rpc_portmap_getport(struct conn_info *info, struct pmap *parms) ++int rpc_portmap_getport(struct conn_info *info, ++ struct pmap *parms, unsigned short *port) + { + struct conn_info pmap_info; +- unsigned short port = 0; + CLIENT *client; + enum clnt_stat status; + int proto = info->proto->p_proto; +@@ -604,7 +579,7 @@ unsigned short rpc_portmap_getport(struc + if (status == RPC_SUCCESS) { + status = clnt_call(client, PMAPPROC_GETPORT, + (xdrproc_t) xdr_pmap, (caddr_t) parms, +- (xdrproc_t) xdr_u_short, (caddr_t) &port, ++ (xdrproc_t) xdr_u_short, (caddr_t) port, + pmap_info.timeout); + } + +@@ -631,10 +606,12 @@ unsigned short rpc_portmap_getport(struc + clnt_destroy(client); + } + +- if (status != RPC_SUCCESS) ++ if (status == RPC_TIMEDOUT) ++ return -ETIMEDOUT; ++ else if (status != RPC_SUCCESS) + return -EIO; + +- return port; ++ return 0; + } + + int rpc_ping_proto(struct conn_info *info) +@@ -686,7 +663,9 @@ int rpc_ping_proto(struct conn_info *inf + clnt_destroy(client); + } + +- if (status != RPC_SUCCESS) ++ if (status == RPC_TIMEDOUT) ++ return -ETIMEDOUT; ++ else if (status != RPC_SUCCESS) + return -EIO; + + return 1; +@@ -725,8 +704,8 @@ static unsigned int __rpc_ping(const cha + parms.pm_prot = info.proto->p_proto; + parms.pm_port = 0; + +- info.port = rpc_portmap_getport(&info, &parms); +- if (info.port < 0) ++ status = rpc_portmap_getport(&info, &parms, &info.port); ++ if (status < 0) + return status; + + status = rpc_ping_proto(&info); +@@ -915,8 +894,8 @@ exports rpc_get_exports(const char *host + + parms.pm_prot = info.proto->p_proto; + +- info.port = rpc_portmap_getport(&info, &parms); +- if (info.port < 0) ++ status = rpc_portmap_getport(&info, &parms, &info.port); ++ if (status < 0) + goto try_tcp; + + memset(&exportlist, '\0', sizeof(exportlist)); +@@ -932,8 +911,8 @@ try_tcp: + + parms.pm_prot = info.proto->p_proto; + +- info.port = rpc_portmap_getport(&info, &parms); +- if (info.port < 0) ++ status = rpc_portmap_getport(&info, &parms, &info.port); ++ if (status < 0) + return NULL; + + memset(&exportlist, '\0', sizeof(exportlist)); +--- autofs-5.0.6.orig/modules/replicated.c ++++ autofs-5.0.6/modules/replicated.c +@@ -569,7 +569,9 @@ static unsigned int get_nfs_info(unsigne + gettimeofday(&start, &tz); + status = rpc_ping_proto(rpc_info); + gettimeofday(&end, &tz); +- if (status > 0) { ++ if (status == -ETIMEDOUT) ++ return (unsigned int) status; ++ else if (status > 0) { + double reply; + if (random_selection) { + /* Random value between 0 and 1 */ +@@ -607,13 +609,12 @@ v3_ver: + } else { + parms.pm_prot = rpc_info->proto->p_proto; + parms.pm_vers = NFS3_VERSION; +- status = rpc_portmap_getport(pm_info, &parms); +- if (status == -EHOSTUNREACH) { ++ status = rpc_portmap_getport(pm_info, &parms, &rpc_info->port); ++ if (status == -EHOSTUNREACH || status == -ETIMEDOUT) { + supported = status; + goto done_ver; + } else if (status < 0) + goto v2_ver; +- rpc_info->port = status; + } + + if (rpc_info->proto->p_proto == IPPROTO_UDP) +@@ -627,7 +628,10 @@ v3_ver: + gettimeofday(&start, &tz); + status = rpc_ping_proto(rpc_info); + gettimeofday(&end, &tz); +- if (status > 0) { ++ if (status == -ETIMEDOUT) { ++ supported = status; ++ goto done_ver; ++ } else if (status > 0) { + double reply; + if (random_selection) { + /* Random value between 0 and 1 */ +@@ -654,14 +658,12 @@ v2_ver: + } else { + parms.pm_prot = rpc_info->proto->p_proto; + parms.pm_vers = NFS2_VERSION; +- rpc_info->port = rpc_portmap_getport(pm_info, &parms); +- status = rpc_portmap_getport(pm_info, &parms); +- if (status == -EHOSTUNREACH) { ++ status = rpc_portmap_getport(pm_info, &parms, &rpc_info->port); ++ if (status == -EHOSTUNREACH || status == -ETIMEDOUT) { + supported = status; + goto done_ver; + } else if (status < 0) + goto done_ver; +- rpc_info->port = status; + } + + if (rpc_info->proto->p_proto == IPPROTO_UDP) +@@ -675,7 +677,9 @@ v2_ver: + gettimeofday(&start, &tz); + status = rpc_ping_proto(rpc_info); + gettimeofday(&end, &tz); +- if (status > 0) { ++ if (status == -ETIMEDOUT) ++ supported = status; ++ else if (status > 0) { + double reply; + if (random_selection) { + /* Random value between 0 and 1 */ +@@ -752,7 +756,8 @@ static int get_vers_and_cost(unsigned lo + supported = get_nfs_info(logopt, host, + &pm_info, &rpc_info, "tcp", vers, options); + if (IS_ERR(supported)) { +- if (ERR(supported) == EHOSTUNREACH) ++ if (ERR(supported) == EHOSTUNREACH || ++ ERR(supported) == ETIMEDOUT) + return ret; + } else if (supported) { + ret = 1; +@@ -763,7 +768,10 @@ static int get_vers_and_cost(unsigned lo + if (version & UDP_REQUESTED) { + supported = get_nfs_info(logopt, host, + &pm_info, &rpc_info, "udp", vers, options); +- if (supported) { ++ if (IS_ERR(supported)) { ++ if (ERR(supported) == ETIMEDOUT) ++ return ret; ++ } else if (supported) { + ret = 1; + host->version |= (supported << 8); + } +@@ -862,8 +870,8 @@ static int get_supported_ver_and_cost(un + return 0; + + parms.pm_prot = rpc_info.proto->p_proto; +- rpc_info.port = rpc_portmap_getport(&pm_info, &parms); +- if (rpc_info.port < 0) ++ ret = rpc_portmap_getport(&pm_info, &parms, &rpc_info.port); ++ if (ret < 0) + goto done; + } + diff --git a/autofs-5.0.6-use-strtok_r-in-linux_version_code.patch b/autofs-5.0.6-use-strtok_r-in-linux_version_code.patch new file mode 100644 index 0000000..d05dd75 --- /dev/null +++ b/autofs-5.0.6-use-strtok_r-in-linux_version_code.patch @@ -0,0 +1,51 @@ +autofs-5.0.6 - use strtok_r() in linux_version_code() + +From: Ian Kent + +Use re-entrant version of strtok() in linux_version_code() function. +Also fix tab formatting. +--- + + CHANGELOG | 1 + + include/mounts.h | 17 +++++++++-------- + 2 files changed, 10 insertions(+), 8 deletions(-) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -36,6 +36,7 @@ + - fix rework error return handling in rpc code. + - allow MOUNT_WAIT to override probe. + - improve UDP RPC timeout handling. ++- use strtok_r() in linux_version_code(). + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/include/mounts.h ++++ autofs-5.0.6/include/mounts.h +@@ -77,16 +77,17 @@ struct mnt_list { + + static inline unsigned int linux_version_code(void) + { +- struct utsname my_utsname; +- unsigned int p, q, r; ++ struct utsname my_utsname; ++ unsigned int p, q, r; ++ char *save; + +- if (uname(&my_utsname)) +- return 0; ++ if (uname(&my_utsname)) ++ return 0; + +- p = (unsigned int)atoi(strtok(my_utsname.release, ".")); +- q = (unsigned int)atoi(strtok(NULL, ".")); +- r = (unsigned int)atoi(strtok(NULL, ".")); +- return KERNEL_VERSION(p, q, r); ++ p = (unsigned int) atoi(strtok_r(my_utsname.release, ".", &save)); ++ q = (unsigned int) atoi(strtok_r(NULL, ".", &save)); ++ r = (unsigned int) atoi(strtok_r(NULL, ".", &save)); ++ return KERNEL_VERSION(p, q, r); + } + + struct nfs_mount_vers { diff --git a/autofs.spec b/autofs.spec index b6a80f4..b5dfb65 100644 --- a/autofs.spec +++ b/autofs.spec @@ -8,7 +8,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.0.6 -Release: 14%{?dist} +Release: 15%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -48,6 +48,15 @@ Patch32: autofs-5.0.6-catch-EHOSTUNREACH-and-bail-out-early.patch Patch33: autofs-5.0.6-systemd-support-fixes.patch Patch34: autofs-5.0.6-fix-segmentation-fault-in-do-remount-indirect.patch Patch35: autofs-5.0.6-fix-function-to-check-mount_nfs-version.patch +Patch36: autofs-5.0.6-fix-typo-in-libtirpc-file-name.patch +Patch37: autofs-5.0.6-fix-rework-error-return-handling-in-rpc-code.patch +Patch38: autofs-5.0.6-allow-MOUNT_WAIT-to-override-probe.patch +Patch39: autofs-5.0.6-improve-UDP_RPC-timeout-handling.patch +Patch40: autofs-5.0.6-use-strtok_r-in-linux_version_code.patch +Patch41: autofs-5.0.6-fix-segfault-in-get_query_dn.patch +Patch42: autofs-5.0.6-fix-sss-wildcard-match.patch +Patch43: autofs-5.0.6-fix-dlopen-error-handling-in-sss-module.patch +Patch44: autofs-5.0.6-fix-configure-string-length-tests.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %if %{with_systemd} BuildRequires: systemd-units @@ -138,6 +147,15 @@ echo %{version}-%{release} > .version %patch33 -p1 %patch34 -p1 %patch35 -p1 +%patch36 -p1 +%patch37 -p1 +%patch38 -p1 +%patch39 -p1 +%patch40 -p1 +%patch41 -p1 +%patch42 -p1 +%patch43 -p1 +%patch44 -p1 %build #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir} @@ -240,6 +258,17 @@ fi %dir /etc/auto.master.d %changelog +* Tue May 1 2012 Ian Kent - 1:5.0.6-15 +- fix typo in libtirpc file name. +- fix rework error return handling in rpc code. +- allow MOUNT_WAIT to override probe. +- improve UDP RPC timeout handling. +- fix segfault in get_query_dn(). +- use strtok_r() in linux_version_code(). +- fix sss wildcard match. +- fix dlopen() error handling in sss module. +- fix configure string length tests for sss library. + * Wed Feb 29 2012 Ian Kent - 1:5.0.6-14 - fix function to check mount.nfs version. From 60b4f5cf9a5abdc5f00973d82c9fb4f0688e5db1 Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Tue, 1 May 2012 17:49:14 +0800 Subject: [PATCH 06/10] * Tue May 1 2012 Ian Kent - 1:5.0.6-16 - add libsss_autofs as a build dependency. --- autofs.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autofs.spec b/autofs.spec index b5dfb65..345eadc 100644 --- a/autofs.spec +++ b/autofs.spec @@ -8,7 +8,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.0.6 -Release: 15%{?dist} +Release: 16%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -62,6 +62,7 @@ Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: systemd-units %endif BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel module-init-tools util-linux nfs-utils e2fsprogs libtirpc-devel +BuildRequires: libsss_autofs Conflicts: cyrus-sasl-lib < 2.1.23-9 Requires: kernel >= 2.6.17 Requires: bash coreutils sed gawk textutils sh-utils grep module-init-tools /bin/ps @@ -258,6 +259,9 @@ fi %dir /etc/auto.master.d %changelog +* Tue May 1 2012 Ian Kent - 1:5.0.6-16 +- add libsss_autofs as a build dependency. + * Tue May 1 2012 Ian Kent - 1:5.0.6-15 - fix typo in libtirpc file name. - fix rework error return handling in rpc code. From 465c67deba3a653ed9f6a92edc273b779e3c8914 Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Wed, 16 May 2012 12:44:46 +0800 Subject: [PATCH 07/10] * Wed May 16 2012 Ian Kent - 1:5.0.6-17 - [abrt] autofs-5.0.6-16.fc17: clnt_dg_control: Process /usr/sbin/automount was killed by signal 11 (SIGSEGV) - fix initialization in rpc create_client() (bz821660). --- ...-initialization-in-rpc-create_client.patch | 40 +++++++++++++++++++ autofs.spec | 9 ++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 autofs-5.0.6-fix-initialization-in-rpc-create_client.patch diff --git a/autofs-5.0.6-fix-initialization-in-rpc-create_client.patch b/autofs-5.0.6-fix-initialization-in-rpc-create_client.patch new file mode 100644 index 0000000..6b1574d --- /dev/null +++ b/autofs-5.0.6-fix-initialization-in-rpc-create_client.patch @@ -0,0 +1,40 @@ +autofs-5.0.6 - fix initialization in rpc create_client() + +From: Ian Kent + +Sometimes the RPC function create_client() function gets a +non-null stack variable passed in which can cause a SEGV. +Fix it by initializing the passed in variable. +--- + + lib/rpc_subs.c | 4 +++- + 1 files changed, 3 insertions(+), 1 deletions(-) + + +diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c +index f051e43..85796d1 100644 +--- a/lib/rpc_subs.c ++++ b/lib/rpc_subs.c +@@ -316,6 +316,7 @@ static int create_client(struct conn_info *info, CLIENT **client) + int fd, ret; + + fd = RPC_ANYSOCK; ++ *client = NULL; + + if (info->client) { + if (!clnt_control(info->client, CLGET_FD, (char *) &fd)) { +@@ -377,12 +378,13 @@ static int create_client(struct conn_info *info, CLIENT **client) + + freeaddrinfo(ai); + ++done: + if (!*client) { + info->client = NULL; + ret = -ENOTCONN; + goto out_close; + } +-done: ++ + /* Close socket fd on destroy, as is default for rpcowned fds */ + if (!clnt_control(*client, CLSET_FD_CLOSE, NULL)) { + clnt_destroy(*client); diff --git a/autofs.spec b/autofs.spec index 345eadc..340ca30 100644 --- a/autofs.spec +++ b/autofs.spec @@ -8,7 +8,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.0.6 -Release: 16%{?dist} +Release: 17%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -57,6 +57,7 @@ Patch41: autofs-5.0.6-fix-segfault-in-get_query_dn.patch Patch42: autofs-5.0.6-fix-sss-wildcard-match.patch Patch43: autofs-5.0.6-fix-dlopen-error-handling-in-sss-module.patch Patch44: autofs-5.0.6-fix-configure-string-length-tests.patch +Patch45: autofs-5.0.6-fix-initialization-in-rpc-create_client.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %if %{with_systemd} BuildRequires: systemd-units @@ -157,6 +158,7 @@ echo %{version}-%{release} > .version %patch42 -p1 %patch43 -p1 %patch44 -p1 +%patch45 -p1 %build #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir} @@ -259,6 +261,11 @@ fi %dir /etc/auto.master.d %changelog +* Wed May 16 2012 Ian Kent - 1:5.0.6-17 +- [abrt] autofs-5.0.6-16.fc17: clnt_dg_control: + Process /usr/sbin/automount was killed by signal 11 (SIGSEGV) + - fix initialization in rpc create_client() (bz821660). + * Tue May 1 2012 Ian Kent - 1:5.0.6-16 - add libsss_autofs as a build dependency. From 251f556ce1fccee574953ecbc5102821c7c14d7f Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Tue, 22 May 2012 12:43:57 +0800 Subject: [PATCH 08/10] - update patch fix initialization in rpc create_client() (bz821660). --- ...-initialization-in-rpc-create_client.patch | 52 +++++++++++++++---- autofs.spec | 7 ++- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/autofs-5.0.6-fix-initialization-in-rpc-create_client.patch b/autofs-5.0.6-fix-initialization-in-rpc-create_client.patch index 6b1574d..0131132 100644 --- a/autofs-5.0.6-fix-initialization-in-rpc-create_client.patch +++ b/autofs-5.0.6-fix-initialization-in-rpc-create_client.patch @@ -2,20 +2,29 @@ autofs-5.0.6 - fix initialization in rpc create_client() From: Ian Kent -Sometimes the RPC function create_client() function gets a -non-null stack variable passed in which can cause a SEGV. -Fix it by initializing the passed in variable. +Sometimes the RPC function create_client() gets a non-null stack +variable passed in which can cause a SEGV. Fix it by initializing +the passed in variable. --- - lib/rpc_subs.c | 4 +++- - 1 files changed, 3 insertions(+), 1 deletions(-) + CHANGELOG | 1 + + lib/rpc_subs.c | 11 ++++++++--- + 2 files changed, 9 insertions(+), 3 deletions(-) -diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c -index f051e43..85796d1 100644 ---- a/lib/rpc_subs.c -+++ b/lib/rpc_subs.c -@@ -316,6 +316,7 @@ static int create_client(struct conn_info *info, CLIENT **client) +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -40,6 +40,7 @@ + - fix sss wildcard match. + - fix dlopen() error handling in sss module. + - fix configure string length tests for sss library. ++- fix initialization in rpc create_client(). + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/lib/rpc_subs.c ++++ autofs-5.0.6/lib/rpc_subs.c +@@ -316,6 +316,7 @@ static int create_client(struct conn_inf int fd, ret; fd = RPC_ANYSOCK; @@ -23,7 +32,19 @@ index f051e43..85796d1 100644 if (info->client) { if (!clnt_control(info->client, CLGET_FD, (char *) &fd)) { -@@ -377,12 +378,13 @@ static int create_client(struct conn_info *info, CLIENT **client) +@@ -344,7 +345,10 @@ static int create_client(struct conn_inf + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_ADDRCONFIG; + hints.ai_family = AF_UNSPEC; +- hints.ai_socktype = SOCK_DGRAM; ++ if (info->proto->p_proto == IPPROTO_UDP) ++ hints.ai_socktype = SOCK_DGRAM; ++ else ++ hints.ai_socktype = SOCK_STREAM; + + ret = getaddrinfo(info->host, NULL, &hints, &ai); + if (ret) { +@@ -377,12 +381,13 @@ static int create_client(struct conn_inf freeaddrinfo(ai); @@ -38,3 +59,12 @@ index f051e43..85796d1 100644 /* Close socket fd on destroy, as is default for rpcowned fds */ if (!clnt_control(*client, CLSET_FD_CLOSE, NULL)) { clnt_destroy(*client); +@@ -800,7 +805,7 @@ static int rpc_get_exports_proto(struct + (xdrproc_t) xdr_void, NULL, + (xdrproc_t) xdr_exports, (caddr_t) exp, + info->timeout); +- if (status != RPC_PROGVERSMISMATCH) ++ if (status == RPC_SUCCESS) + break; + if (++vers_entry > 2) + break; diff --git a/autofs.spec b/autofs.spec index 340ca30..11da9bf 100644 --- a/autofs.spec +++ b/autofs.spec @@ -8,7 +8,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.0.6 -Release: 17%{?dist} +Release: 18%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -261,6 +261,11 @@ fi %dir /etc/auto.master.d %changelog +* Tue May 22 2012 Ian Kent - 1:5.0.6-18 +- [abrt] autofs-5.0.6-16.fc17: clnt_dg_control: + Process /usr/sbin/automount was killed by signal 11 (SIGSEGV) + - update patch fix initialization in rpc create_client() (bz821660). + * Wed May 16 2012 Ian Kent - 1:5.0.6-17 - [abrt] autofs-5.0.6-16.fc17: clnt_dg_control: Process /usr/sbin/automount was killed by signal 11 (SIGSEGV) From 0a4a36b3de71a8cfc65af7d36f927f7907c714e0 Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Tue, 22 May 2012 17:46:29 +0800 Subject: [PATCH 09/10] - fix libtirpc name clash (bz821660). --- autofs-5.0.6-fix-libtirpc-name-clash.patch | 45 ++++++++++++++++++++++ autofs.spec | 9 ++++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 autofs-5.0.6-fix-libtirpc-name-clash.patch diff --git a/autofs-5.0.6-fix-libtirpc-name-clash.patch b/autofs-5.0.6-fix-libtirpc-name-clash.patch new file mode 100644 index 0000000..2cbc299 --- /dev/null +++ b/autofs-5.0.6-fix-libtirpc-name-clash.patch @@ -0,0 +1,45 @@ +autofs-5.0.6 - fix libtirpc name clash + +From: Ian Kent + +The tirpc function auth_destroy() is a macro definition in tirpc/rpc/auth.h +which includes an unconditional call to a function log_debug() which clashes +with an autofs function of the same name and has a different call signature. + +To fix it redefine auth_destroy() and exclude the debug log call. +--- + + CHANGELOG | 1 + + lib/rpc_subs.c | 10 ++++++++++ + 2 files changed, 11 insertions(+) + + +--- autofs-5.0.6.orig/CHANGELOG ++++ autofs-5.0.6/CHANGELOG +@@ -41,6 +41,7 @@ + - fix dlopen() error handling in sss module. + - fix configure string length tests for sss library. + - fix initialization in rpc create_client(). ++- fix libtirpc name clash. + + 28/06/2011 autofs-5.0.6 + ----------------------- +--- autofs-5.0.6.orig/lib/rpc_subs.c ++++ autofs-5.0.6/lib/rpc_subs.c +@@ -34,6 +34,16 @@ + #include + #include + ++#ifdef WITH_LIBTIRPC ++#undef auth_destroy ++#define auth_destroy(auth) \ ++ do { \ ++ int refs; \ ++ if ((refs = auth_put((auth))) == 0) \ ++ ((*((auth)->ah_ops->ah_destroy))(auth));\ ++ } while (0) ++#endif ++ + #include "mount.h" + #include "rpc_subs.h" + #include "automount.h" diff --git a/autofs.spec b/autofs.spec index 11da9bf..68b4144 100644 --- a/autofs.spec +++ b/autofs.spec @@ -8,7 +8,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.0.6 -Release: 18%{?dist} +Release: 19%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -58,6 +58,7 @@ Patch42: autofs-5.0.6-fix-sss-wildcard-match.patch Patch43: autofs-5.0.6-fix-dlopen-error-handling-in-sss-module.patch Patch44: autofs-5.0.6-fix-configure-string-length-tests.patch Patch45: autofs-5.0.6-fix-initialization-in-rpc-create_client.patch +Patch46: autofs-5.0.6-fix-libtirpc-name-clash.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %if %{with_systemd} BuildRequires: systemd-units @@ -159,6 +160,7 @@ echo %{version}-%{release} > .version %patch43 -p1 %patch44 -p1 %patch45 -p1 +%patch46 -p1 %build #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir} @@ -261,6 +263,11 @@ fi %dir /etc/auto.master.d %changelog +* Tue May 22 2012 Ian Kent - 1:5.0.6-19 +- [abrt] autofs-5.0.6-16.fc17: clnt_dg_control: + Process /usr/sbin/automount was killed by signal 11 (SIGSEGV) + - fix libtirpc name clash (bz821660). + * Tue May 22 2012 Ian Kent - 1:5.0.6-18 - [abrt] autofs-5.0.6-16.fc17: clnt_dg_control: Process /usr/sbin/automount was killed by signal 11 (SIGSEGV) From fd5354912c0e4c2d77127f409abf713fe724e4ee Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Wed, 23 May 2012 11:05:12 +0800 Subject: [PATCH 10/10] - update changelog to reflect the bug (821847) in which the problem was solved. --- autofs.spec | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/autofs.spec b/autofs.spec index 68b4144..147e60f 100644 --- a/autofs.spec +++ b/autofs.spec @@ -264,19 +264,13 @@ fi %changelog * Tue May 22 2012 Ian Kent - 1:5.0.6-19 -- [abrt] autofs-5.0.6-16.fc17: clnt_dg_control: - Process /usr/sbin/automount was killed by signal 11 (SIGSEGV) - - fix libtirpc name clash (bz821660). +- fix libtirpc name clash (bz821847). * Tue May 22 2012 Ian Kent - 1:5.0.6-18 -- [abrt] autofs-5.0.6-16.fc17: clnt_dg_control: - Process /usr/sbin/automount was killed by signal 11 (SIGSEGV) - - update patch fix initialization in rpc create_client() (bz821660). +- update patch fix initialization in rpc create_client() (bz821847). * Wed May 16 2012 Ian Kent - 1:5.0.6-17 -- [abrt] autofs-5.0.6-16.fc17: clnt_dg_control: - Process /usr/sbin/automount was killed by signal 11 (SIGSEGV) - - fix initialization in rpc create_client() (bz821660). +- fix initialization in rpc create_client() (bz821847). * Tue May 1 2012 Ian Kent - 1:5.0.6-16 - add libsss_autofs as a build dependency.