From jmoyer@redhat.com Wed May 5 23:08:14 2004 Date: Tue, 4 May 2004 13:24:29 -0400 From: Jeff Moyer To: autofs@linux.kernel.org Subject: [autofs] [patch] fix SIGSEGV when yp domain not bound Hi Ian, list, If you happen to find your systems unable to communicate with the yp server, the subprocess launched to automount a share will receive a SIGSEGV, because we only check for err == YPERR_KEY in the lookup_yp module. We get a different error, of course, and then go on to do a cache_update with NULL values. Here is a patch which addresses this issue. Comments more than welcome. Oh, and I took the liberty of doing minor reformatting; I hope you don't mind, Ian. -Jeff --- autofs-4.1.2/modules/lookup_yp.c~ 2004-01-29 11:01:22.000000000 -0500 +++ autofs-4.1.2/modules/lookup_yp.c 2004-05-04 13:13:05.000000000 -0400 @@ -195,19 +195,26 @@ } if (!me) { - /* For reasons unknown, the standard YP definitions doesn't define input - strings as const char *. However, my understanding is that they will - not be modified by the library. */ + /* For reasons unknown, the standard YP definitions doesn't + define input strings as const char *. However, my + understanding is that they will not be modified by the + library. */ err = yp_match((char *) ctxt->domainname, (char *) ctxt->mapname, (char *) name, name_len, &mapent, &mapent_len); - if (err == YPERR_KEY) { + if (err != YPERR_SUCCESS) { + if (err != YPERR_KEY) + goto out_err; + /* See if there is an entry "root/name" */ key_len = sprintf(key, "%s/%s", root, name); - err = yp_match((char *) ctxt->domainname, (char *) ctxt->mapname, + err = yp_match((char *) ctxt->domainname, + (char *) ctxt->mapname, key, key_len, &mapent, &mapent_len); - if (err == YPERR_KEY) { + if (err != YPERR_SUCCESS) { + if (err != YPERR_KEY) + goto out_err; /* * Try to get the "*" entry if there is one i * - note that we *don't* modify "name" so @@ -215,18 +222,13 @@ */ err = yp_match((char *) ctxt->domainname, - (char *) ctxt->mapname, "*", 1, &mapent, - &mapent_len); + (char *) ctxt->mapname, "*", 1, + &mapent, &mapent_len); } else cache_update(key, mapent, age); - if (err) { - warn(MODPREFIX "lookup for %s failed: %s", name, - yperr_string(err)); - if (mapent) - free(mapent); - return 1; - } + if (err) + goto out_err; } else cache_update(name, mapent, age); } @@ -238,6 +240,12 @@ rv = ctxt->parse->parse_mount(root, name, name_len, mapent, ctxt->parse->context); free(mapent); return rv; + +out_err: + warn(MODPREFIX "lookup for %s failed: %s", name, yperr_string(err)); + if (mapent) + free(mapent); + return 1; } int lookup_done(void *context) _______________________________________________ autofs mailing list autofs@linux.kernel.org http://linux.kernel.org/mailman/listinfo/autofs