autofs/autofs-5.0.2-add-ferror-check.patch
Ian Kent 36ee8299b4 - fix schema selection in LDAP schema discovery.
- check for "*" when looking up wildcard in LDAP.
- fix couple of edge case parse fails of timeout option.
- add SEARCH_BASE configuration option.
- add random selection as a master map entry option.
- re-read config on HUP signal.
- add LDAP_URI, LDAP_TIMEOUT and LDAP_NETWORK_TIMEOUT configuration
    options.
- fix deadlock in submount mount module.
- fix lack of ferror() checking when reading files.
- fix typo in autofs(5) man page.
- fix map entry expansion when undefined macro is present.
- remove unused export validation code.
- add dynamic logging (adapted from v4 patch from Jeff Moyer).
- fix recursive loopback mounts (Matthias Koenig).
- add map re-load to verbose logging.
- fix handling of LDAP base dns with spaces.
- handle MTAB_NOTUPDATED status return from mount.
- when default master map, auto.master, is used also check for auto_master.
- update negative mount timeout handling.
- fix large group handling (Ryan Thomas).
- fix for dynamic logging breaking non-sasl build (Guillaume Rousse).
- eliminate NULL proc ping for singleton host or local mounts.
2007-11-20 07:34:21 +00:00

123 lines
3.0 KiB
Diff

diff --git a/daemon/automount.c b/daemon/automount.c
index 930b13f..70a3b9d 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -978,7 +978,7 @@ static void *do_read_master(void *arg)
if (status)
fatal(status);
- defaults_read_config();
+ defaults_read_config(1);
status = master_read_master(master, age, readall);
@@ -1465,7 +1465,7 @@ int main(int argc, char *argv[])
program = argv[0];
- defaults_read_config();
+ defaults_read_config(0);
kpkt_len = get_kpkt_len();
timeout = defaults_get_timeout();
diff --git a/include/defaults.h b/include/defaults.h
index 46393d9..0e0e2a5 100644
--- a/include/defaults.h
+++ b/include/defaults.h
@@ -41,7 +41,7 @@
struct ldap_schema;
struct ldap_searchdn;
-unsigned int defaults_read_config(void);
+unsigned int defaults_read_config(unsigned int);
const char *defaults_get_master_map(void);
unsigned int defaults_get_timeout(void);
unsigned int defaults_get_browse_mode(void);
diff --git a/lib/defaults.c b/lib/defaults.c
index bf1ceed..2cccf20 100644
--- a/lib/defaults.c
+++ b/lib/defaults.c
@@ -280,7 +280,7 @@ struct list_head *defaults_get_uris(void)
* is valid bourne shell script without spaces around "="
* and that it has valid values.
*/
-unsigned int defaults_read_config(void)
+unsigned int defaults_read_config(unsigned int to_syslog)
{
FILE *f;
char buf[MAX_LINE_LEN];
@@ -312,9 +312,16 @@ unsigned int defaults_read_config(void)
;
}
- if (!feof(f)) {
- fprintf(stderr, "fgets returned error %d while reading %s\n",
- ferror(f), DEFAULTS_CONFIG_FILE);
+ if (!feof(f) || ferror(f)) {
+ if (!to_syslog) {
+ fprintf(stderr,
+ "fgets returned error %d while reading %s\n",
+ ferror(f), DEFAULTS_CONFIG_FILE);
+ } else {
+ error(LOGOPT_ANY,
+ "fgets returned error %d while reading %s",
+ ferror(f), DEFAULTS_CONFIG_FILE);
+ }
fclose(f);
return 0;
}
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
index 6346602..31ee0fb 100644
--- a/modules/lookup_file.c
+++ b/modules/lookup_file.c
@@ -442,6 +442,11 @@ int lookup_read_master(struct master *master, time_t age, void *context)
if (!entry) {
if (feof(f))
break;
+ if (ferror(f)) {
+ warn(LOGOPT_ANY, MODPREFIX
+ "error reading map %s", ctxt->mapname);
+ break;
+ }
continue;
}
@@ -683,6 +688,11 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
if (!entry) {
if (feof(f))
break;
+ if (ferror(f)) {
+ warn(LOGOPT_ANY, MODPREFIX
+ "error reading map %s", ctxt->mapname);
+ break;
+ }
continue;
}
@@ -848,6 +858,12 @@ static int lookup_one(struct autofs_point *ap,
if (feof(f))
break;
+
+ if (ferror(f)) {
+ warn(LOGOPT_ANY, MODPREFIX
+ "error reading map %s", ctxt->mapname);
+ break;
+ }
}
fclose(f);
@@ -907,6 +923,12 @@ static int lookup_wild(struct autofs_point *ap, struct lookup_context *ctxt)
if (feof(f))
break;
+
+ if (ferror(f)) {
+ warn(LOGOPT_ANY, MODPREFIX
+ "error reading map %s", ctxt->mapname);
+ break;
+ }
}
fclose(f);