1 diff --git a/CHANGELOG b/CHANGELOG
2 index 933b1a1..0340940 100644
6 - work around segv at exit due to libxml2 tsd usage.
7 - re-read config on HUP signal.
8 - add LDAP_URI, LDAP_TIMEOUT and LDAP_NETWORK_TIMEOUT configuration options.
9 +- fix forground logging and add option to man page.
11 18/06/2007 autofs-5.0.2
12 -----------------------
13 diff --git a/daemon/automount.c b/daemon/automount.c
14 index 58f1901..51f6a8b 100644
15 --- a/daemon/automount.c
16 +++ b/daemon/automount.c
17 @@ -58,14 +58,13 @@ unsigned int global_random_selection; /* use random policy when selecting
18 static int start_pipefd[2];
19 static int st_stat = 0;
20 static int *pst_stat = &st_stat;
21 +static pthread_t state_mach_thid;
23 /* Pre-calculated kernel packet length */
24 static size_t kpkt_len;
26 /* Attribute to create detached thread */
27 pthread_attr_t thread_attr;
28 -/* Attribute to create normal thread */
29 -pthread_attr_t thread_attr_nodetach;
31 struct master_readmap_cond mrc = {
32 PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, NULL, 0, 0, 0, 0};
33 @@ -75,9 +74,6 @@ struct startup_cond suc = {
35 pthread_key_t key_thread_stdenv_vars;
37 -/* re-entrant syslog default context data */
38 -#define AUTOFS_SYSLOG_CONTEXT {-1, 0, 0, LOG_PID, (const char *)0, LOG_DAEMON, 0xff};
40 #define MAX_OPEN_FILES 10240
42 static int umount_all(struct autofs_point *ap, int force);
43 @@ -792,7 +788,6 @@ static void become_daemon(unsigned foreground)
46 char buf[MAX_ERR_BUF];
47 - unsigned to_stderr = 0;
50 /* Don't BUSY any directories unnecessarily */
51 @@ -809,7 +804,9 @@ static void become_daemon(unsigned foreground)
54 /* Detach from foreground process */
62 @@ -834,13 +831,8 @@ static void become_daemon(unsigned foreground)
63 fprintf(stderr, "setsid: %s", estr);
75 /* Write pid file if requested */
77 @@ -929,7 +921,7 @@ static pthread_t do_signals(struct master *master, int sig)
81 - status = pthread_create(&thid, &thread_attr_nodetach, do_notify_state, &r_sig);
82 + status = pthread_create(&thid, &thread_attr, do_notify_state, &r_sig);
84 error(master->default_logging,
85 "mount state notify thread create failed");
86 @@ -1045,7 +1037,6 @@ static int do_hup_signal(struct master *master, time_t age)
87 /* Deal with all the signal-driven events in the state machine */
88 static void *statemachine(void *arg)
94 @@ -1058,15 +1049,12 @@ static void *statemachine(void *arg)
100 + if (master_list_empty(master_list))
103 - thid = do_signals(master_list, sig);
105 - pthread_join(thid, NULL);
106 - if (master_list_empty(master_list))
110 + do_signals(master_list, sig);
114 @@ -1181,6 +1169,10 @@ static void handle_mounts_cleanup(void *arg)
116 msg("shut down path %s", path);
118 + /* If we are the last tell the state machine to shutdown */
119 + if (!submount && master_list_empty(master_list))
120 + pthread_kill(state_mach_thid, SIGTERM);
125 @@ -1375,7 +1367,7 @@ static void usage(void)
126 " -v --verbose be verbose\n"
127 " -d --debug log debuging info\n"
128 " -D --define define global macro variable\n"
129 - /*" -f --foreground do not fork into background\n" */
130 + " -f --foreground do not fork into background\n"
131 " -r --random-multimount-selection\n"
132 " use ramdom replicated server selection\n"
133 " -O --global-options\n"
134 @@ -1650,14 +1642,6 @@ int main(int argc, char *argv[])
138 - if (pthread_attr_init(&thread_attr_nodetach)) {
140 - "%s: failed to init thread attribute struct!",
142 - close(start_pipefd[1]);
146 msg("Starting automounter version %s, master map %s",
147 version, master_list->name);
148 msg("using kernel protocol version %d.%02d",
149 @@ -1702,6 +1686,7 @@ int main(int argc, char *argv[])
150 res = write(start_pipefd[1], pst_stat, sizeof(pst_stat));
151 close(start_pipefd[1]);
153 + state_mach_thid = pthread_self();
156 master_kill(master_list);
157 diff --git a/lib/log.c b/lib/log.c
158 index e639e60..b747e12 100644
163 #include "automount.h"
165 -/* re-entrant syslog default context data */
166 -#define AUTOFS_SYSLOG_CONTEXT {-1, 0, 0, LOG_PID, (const char *) 0, LOG_DAEMON, 0xff};
169 struct syslog_data syslog_context = AUTOFS_SYSLOG_CONTEXT;
170 struct syslog_data *slc = &syslog_context;
171 @@ -134,30 +131,40 @@ static void syslog_debug(unsigned int logopt, const char *msg, ...)
175 +static void to_stderr(unsigned int logopt, const char *msg, ...)
179 + vfprintf(stderr, msg, ap);
180 + fputc('\n',stderr);
184 void set_mnt_logging(struct autofs_point *ap)
186 unsigned int opt_verbose = ap->logopt & LOGOPT_VERBOSE;
187 unsigned int opt_debug = ap->logopt & LOGOPT_DEBUG;
190 - log_debug = syslog_debug;
192 + if (logging_to_syslog)
193 + log_debug = syslog_debug;
195 + log_debug = to_stderr;
198 if (opt_verbose || opt_debug) {
199 - log_info = syslog_info;
200 - log_notice = syslog_notice;
201 - log_warn = syslog_warn;
202 + if (logging_to_syslog) {
203 + log_info = syslog_info;
204 + log_notice = syslog_notice;
205 + log_warn = syslog_warn;
207 + log_info = to_stderr;
208 + log_notice = to_stderr;
209 + log_warn = to_stderr;
214 -static void to_stderr(unsigned int logopt, const char *msg, ...)
218 - vfprintf(stderr, msg, ap);
219 - fputc('\n',stderr);
223 void log_to_syslog(void)
225 char buf[MAX_ERR_BUF];
226 diff --git a/lib/master.c b/lib/master.c
227 index 637ce04..abc3bc2 100644
230 @@ -954,6 +954,7 @@ void master_notify_state_change(struct master *master, int sig)
235 if (ap->state != ST_SHUTDOWN_PENDING &&
236 ap->state != ST_SHUTDOWN_FORCE) {
237 next = ST_SHUTDOWN_PENDING;
238 diff --git a/man/automount.8 b/man/automount.8
239 index da67a5c..e203a3e 100644
240 --- a/man/automount.8
241 +++ b/man/automount.8
242 @@ -47,6 +47,9 @@ Define a global macro substitution variable. Global definitions
243 are over-ridden macro definitions of the same name specified in
246 +.I "\-f, \-\-foreground"
247 +Run the daemon in the forground and log to stderr instead of syslog."
249 .I "\-r, \-\-random-multimount-selection"
250 Enables the use of ramdom selection when choosing a host from a
251 list of replicated servers.
252 diff --git a/modules/cyrus-sasl.c b/modules/cyrus-sasl.c
253 index 9aac792..68e5dd7 100644
254 --- a/modules/cyrus-sasl.c
255 +++ b/modules/cyrus-sasl.c
256 @@ -197,7 +197,7 @@ get_server_SASL_mechanisms(LDAP *ld)
257 if (mechanisms == NULL) {
258 /* Well, that was a waste of time. */
259 msg("No SASL authentication mechanisms are supported"
260 - " by the LDAP server.\n");
261 + " by the LDAP server.");
265 diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
266 index 4068561..c0f228b 100644
267 --- a/modules/lookup_ldap.c
268 +++ b/modules/lookup_ldap.c
269 @@ -857,17 +857,17 @@ int parse_ldap_config(struct lookup_context *ctxt)
270 ctxt->client_princ = client_princ;
273 - "ldap authentication configured with the following options:\n");
274 + "ldap authentication configured with the following options:");
278 "auth_required: %u, "
281 use_tls, tls_required, auth_required, authtype);
285 - "client principal: %s\n",
286 + "client principal: %s",
287 user, secret ? "specified" : "unspecified",