]>
Commit | Line | Data |
---|---|---|
3d551623 PG |
1 | diff --git a/CHANGELOG b/CHANGELOG |
2 | index 2db9b39..dd08880 100644 | |
3 | --- a/CHANGELOG | |
4 | +++ b/CHANGELOG | |
5 | @@ -31,6 +31,7 @@ | |
6 | - fix forground logging and add option to man page. | |
7 | - remove unjustified, nasty comment about krb5 package. | |
8 | - fix deadlock in submount mount module. | |
9 | +- fix lack of ferror() checking when reading files. | |
10 | ||
11 | 18/06/2007 autofs-5.0.2 | |
12 | ----------------------- | |
13 | diff --git a/daemon/automount.c b/daemon/automount.c | |
14 | index 930b13f..70a3b9d 100644 | |
15 | --- a/daemon/automount.c | |
16 | +++ b/daemon/automount.c | |
17 | @@ -978,7 +978,7 @@ static void *do_read_master(void *arg) | |
18 | if (status) | |
19 | fatal(status); | |
20 | ||
21 | - defaults_read_config(); | |
22 | + defaults_read_config(1); | |
23 | ||
24 | status = master_read_master(master, age, readall); | |
25 | ||
26 | @@ -1465,7 +1465,7 @@ int main(int argc, char *argv[]) | |
27 | ||
28 | program = argv[0]; | |
29 | ||
30 | - defaults_read_config(); | |
31 | + defaults_read_config(0); | |
32 | ||
33 | kpkt_len = get_kpkt_len(); | |
34 | timeout = defaults_get_timeout(); | |
35 | diff --git a/include/defaults.h b/include/defaults.h | |
36 | index 46393d9..0e0e2a5 100644 | |
37 | --- a/include/defaults.h | |
38 | +++ b/include/defaults.h | |
39 | @@ -41,7 +41,7 @@ | |
40 | struct ldap_schema; | |
41 | struct ldap_searchdn; | |
42 | ||
43 | -unsigned int defaults_read_config(void); | |
44 | +unsigned int defaults_read_config(unsigned int); | |
45 | const char *defaults_get_master_map(void); | |
46 | unsigned int defaults_get_timeout(void); | |
47 | unsigned int defaults_get_browse_mode(void); | |
48 | diff --git a/lib/defaults.c b/lib/defaults.c | |
49 | index bf1ceed..2cccf20 100644 | |
50 | --- a/lib/defaults.c | |
51 | +++ b/lib/defaults.c | |
52 | @@ -280,7 +280,7 @@ struct list_head *defaults_get_uris(void) | |
53 | * is valid bourne shell script without spaces around "=" | |
54 | * and that it has valid values. | |
55 | */ | |
56 | -unsigned int defaults_read_config(void) | |
57 | +unsigned int defaults_read_config(unsigned int to_syslog) | |
58 | { | |
59 | FILE *f; | |
60 | char buf[MAX_LINE_LEN]; | |
61 | @@ -312,9 +312,16 @@ unsigned int defaults_read_config(void) | |
62 | ; | |
63 | } | |
64 | ||
65 | - if (!feof(f)) { | |
66 | - fprintf(stderr, "fgets returned error %d while reading %s\n", | |
67 | - ferror(f), DEFAULTS_CONFIG_FILE); | |
68 | + if (!feof(f) || ferror(f)) { | |
69 | + if (!to_syslog) { | |
70 | + fprintf(stderr, | |
71 | + "fgets returned error %d while reading %s\n", | |
72 | + ferror(f), DEFAULTS_CONFIG_FILE); | |
73 | + } else { | |
74 | + error(LOGOPT_ANY, | |
75 | + "fgets returned error %d while reading %s", | |
76 | + ferror(f), DEFAULTS_CONFIG_FILE); | |
77 | + } | |
78 | fclose(f); | |
79 | return 0; | |
80 | } | |
81 | diff --git a/modules/lookup_file.c b/modules/lookup_file.c | |
82 | index 6346602..31ee0fb 100644 | |
83 | --- a/modules/lookup_file.c | |
84 | +++ b/modules/lookup_file.c | |
85 | @@ -442,6 +442,11 @@ int lookup_read_master(struct master *master, time_t age, void *context) | |
86 | if (!entry) { | |
87 | if (feof(f)) | |
88 | break; | |
89 | + if (ferror(f)) { | |
90 | + warn(LOGOPT_ANY, MODPREFIX | |
91 | + "error reading map %s", ctxt->mapname); | |
92 | + break; | |
93 | + } | |
94 | continue; | |
95 | } | |
96 | ||
97 | @@ -683,6 +688,11 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context) | |
98 | if (!entry) { | |
99 | if (feof(f)) | |
100 | break; | |
101 | + if (ferror(f)) { | |
102 | + warn(LOGOPT_ANY, MODPREFIX | |
103 | + "error reading map %s", ctxt->mapname); | |
104 | + break; | |
105 | + } | |
106 | continue; | |
107 | } | |
108 | ||
109 | @@ -848,6 +858,12 @@ static int lookup_one(struct autofs_point *ap, | |
110 | ||
111 | if (feof(f)) | |
112 | break; | |
113 | + | |
114 | + if (ferror(f)) { | |
115 | + warn(LOGOPT_ANY, MODPREFIX | |
116 | + "error reading map %s", ctxt->mapname); | |
117 | + break; | |
118 | + } | |
119 | } | |
120 | ||
121 | fclose(f); | |
122 | @@ -907,6 +923,12 @@ static int lookup_wild(struct autofs_point *ap, struct lookup_context *ctxt) | |
123 | ||
124 | if (feof(f)) | |
125 | break; | |
126 | + | |
127 | + if (ferror(f)) { | |
128 | + warn(LOGOPT_ANY, MODPREFIX | |
129 | + "error reading map %s", ctxt->mapname); | |
130 | + break; | |
131 | + } | |
132 | } | |
133 | ||
134 | fclose(f); |