1 diff --git a/CHANGELOG b/CHANGELOG
2 index ca171a4..a7ac9fb 100644
6 - fix typo in autofs(5) man page.
7 - fix map entry expansion when undefined macro is present.
8 - remove unused export validation code.
9 +- add dynamic logging (adapted from v4 patch from Jeff Moyer).
11 18/06/2007 autofs-5.0.2
12 -----------------------
13 diff --git a/daemon/automount.c b/daemon/automount.c
14 index 70a3b9d..9ec6923 100644
15 --- a/daemon/automount.c
16 +++ b/daemon/automount.c
17 @@ -173,7 +173,7 @@ int rmdir_path(struct autofs_point *ap, const char *path, dev_t dev)
19 memset(&st, 0, sizeof(st));
20 if (lstat(buf, &st) != 0) {
21 - crit(ap->logopt, "lstat of %s failed.", buf);
22 + crit(ap->logopt, "lstat of %s failed", buf);
26 @@ -234,14 +234,15 @@ int rmdir_path(struct autofs_point *ap, const char *path, dev_t dev)
27 /* Like ftw, except fn gets called twice: before a directory is
28 entered, and after. If the before call returns 0, the directory
30 -static int walk_tree(const char *base, int (*fn) (const char *file,
31 +static int walk_tree(const char *base, int (*fn) (unsigned logopt,
33 const struct stat * st,
34 - int, void *), int incl, void *arg)
35 + int, void *), int incl, unsigned logopt, void *arg)
37 char buf[PATH_MAX + 1];
40 - if (lstat(base, &st) != -1 && (fn) (base, &st, 0, arg)) {
41 + if (lstat(base, &st) != -1 && (fn) (logopt, base, &st, 0, arg)) {
42 if (S_ISDIR(st.st_mode)) {
45 @@ -269,18 +270,18 @@ static int walk_tree(const char *base, int (*fn) (const char *file,
49 - walk_tree(buf, fn, 1, arg);
50 + walk_tree(buf, fn, 1, logopt, arg);
56 - (fn) (base, &st, 1, arg);
57 + (fn) (logopt, base, &st, 1, arg);
62 -static int rm_unwanted_fn(const char *file, const struct stat *st, int when, void *arg)
63 +static int rm_unwanted_fn(unsigned logopt, const char *file, const struct stat *st, int when, void *arg)
65 dev_t dev = *(dev_t *) arg;
66 char buf[MAX_ERR_BUF];
67 @@ -293,41 +294,38 @@ static int rm_unwanted_fn(const char *file, const struct stat *st, int when, voi
70 if (lstat(file, &newst)) {
72 - "unable to stat file, possible race condition");
73 + crit(logopt, "unable to stat file, possible race condition");
77 if (newst.st_dev != dev) {
79 - "file %s has the wrong device, possible race condition",
80 + crit(logopt, "file %s has the wrong device, possible race condition",
85 if (S_ISDIR(newst.st_mode)) {
86 - debug(LOGOPT_ANY, "removing directory %s", file);
87 + debug(logopt, "removing directory %s", file);
89 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
92 "unable to remove directory %s: %s", file, estr);
95 } else if (S_ISREG(newst.st_mode)) {
97 - "attempting to remove files from a mounted "
98 + crit(logopt, "attempting to remove files from a mounted "
99 "directory. file %s", file);
101 } else if (S_ISLNK(newst.st_mode)) {
102 - debug(LOGOPT_ANY, "removing symlink %s", file);
103 + debug(logopt, "removing symlink %s", file);
109 -void rm_unwanted(const char *path, int incl, dev_t dev)
110 +void rm_unwanted(unsigned logopt, const char *path, int incl, dev_t dev)
112 - walk_tree(path, rm_unwanted_fn, incl, &dev);
113 + walk_tree(path, rm_unwanted_fn, incl, logopt, &dev);
116 struct counter_args {
117 @@ -335,7 +333,7 @@ struct counter_args {
121 -static int counter_fn(const char *file, const struct stat *st, int when, void *arg)
122 +static int counter_fn(unsigned logopt, const char *file, const struct stat *st, int when, void *arg)
124 struct counter_args *counter = (struct counter_args *) arg;
126 @@ -349,14 +347,14 @@ static int counter_fn(const char *file, const struct stat *st, int when, void *a
129 /* Count mounted filesystems and symlinks */
130 -int count_mounts(const char *path, dev_t dev)
131 +int count_mounts(unsigned logopt, const char *path, dev_t dev)
133 struct counter_args counter;
138 - if (walk_tree(path, counter_fn, 0, &counter) == -1)
139 + if (walk_tree(path, counter_fn, 0, logopt, &counter) == -1)
142 return counter.count;
143 @@ -368,9 +366,9 @@ static void check_rm_dirs(struct autofs_point *ap, const char *path, int incl)
144 (ap->state == ST_SHUTDOWN_PENDING ||
145 ap->state == ST_SHUTDOWN_FORCE ||
146 ap->state == ST_SHUTDOWN))
147 - rm_unwanted(path, incl, ap->dev);
148 + rm_unwanted(ap->logopt, path, incl, ap->dev);
149 else if (ap->ghost && (ap->type == LKP_INDIRECT))
150 - rm_unwanted(path, 0, ap->dev);
151 + rm_unwanted(ap->logopt, path, 0, ap->dev);
154 /* Try to purge cache entries kept around due to existing mounts */
155 @@ -466,7 +464,7 @@ static int umount_subtree_mounts(struct autofs_point *ap, const char *path, unsi
156 cache_multi_lock(me->parent);
157 if (umount_multi_triggers(ap, root, me, base)) {
159 - "could not umount some offsets under %s", path);
160 + "some offset mounts still present under %s", path);
163 cache_multi_unlock(me->parent);
164 @@ -483,7 +481,7 @@ static int umount_subtree_mounts(struct autofs_point *ap, const char *path, unsi
165 * it already to ensure it's ok to remove any offset triggers.
167 if (!is_mm_root && is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) {
168 - msg("unmounting dir = %s", path);
169 + info(ap->logopt, "unmounting dir = %s", path);
170 if (umount_ent(ap, path)) {
171 warn(ap->logopt, "could not umount dir %s", path);
173 @@ -576,35 +574,35 @@ int umount_autofs(struct autofs_point *ap, int force)
177 -int send_ready(int ioctlfd, unsigned int wait_queue_token)
178 +int send_ready(unsigned logopt, int ioctlfd, unsigned int wait_queue_token)
180 char buf[MAX_ERR_BUF];
182 if (wait_queue_token == 0)
185 - debug(LOGOPT_NONE, "token = %d", wait_queue_token);
186 + debug(logopt, "token = %d", wait_queue_token);
188 if (ioctl(ioctlfd, AUTOFS_IOC_READY, wait_queue_token) < 0) {
189 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
190 - error(LOGOPT_ANY, "AUTOFS_IOC_READY: error %s", estr);
191 + logerr("AUTOFS_IOC_READY: error %s", estr);
197 -int send_fail(int ioctlfd, unsigned int wait_queue_token)
198 +int send_fail(unsigned logopt, int ioctlfd, unsigned int wait_queue_token)
200 char buf[MAX_ERR_BUF];
202 if (wait_queue_token == 0)
205 - debug(LOGOPT_NONE, "token = %d", wait_queue_token);
206 + debug(logopt, "token = %d", wait_queue_token);
208 if (ioctl(ioctlfd, AUTOFS_IOC_FAIL, wait_queue_token) < 0) {
209 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
210 - error(LOGOPT_ANY, "AUTOFS_IOC_FAIL: error %s", estr);
211 + logerr("AUTOFS_IOC_FAIL: error %s", estr);
215 @@ -649,23 +647,245 @@ static int fullread(int fd, void *ptr, size_t len)
219 +static char *automount_path_to_fifo(unsigned logopt, const char *path)
221 + char *fifo_name, *p;
222 + int name_len = strlen(path) + strlen(AUTOFS_LOGPRI_FIFO) + 1;
225 + fifo_name = malloc(name_len);
228 + ret = snprintf(fifo_name, name_len, "%s%s",
229 + AUTOFS_LOGPRI_FIFO, path);
230 + if (ret >= name_len) {
232 + "fifo path for \"%s\" truncated to \"%s\". This may "
233 + "lead to --set-log-priority commands being sent to the "
234 + "wrong automount daemon.", path, fifo_name);
238 + * An automount path can be made up of subdirectories. So, to
239 + * create the fifo name, we will just replace instances of '/' with
242 + p = fifo_name + strlen(AUTOFS_LOGPRI_FIFO);
243 + while (*p != '\0') {
249 + debug(logopt, "fifo name %s",fifo_name);
254 +static int create_logpri_fifo(struct autofs_point *ap)
260 + fifo_name = automount_path_to_fifo(ap->logopt, ap->path);
262 + crit(ap->logopt, "Failed to allocate memory!");
263 + goto out_free; /* free(NULL) is okay */
266 + ret = unlink(fifo_name);
267 + if (ret != 0 && errno != ENOENT) {
269 + "Failed to unlink FIFO. Is the automount daemon "
270 + "already running?");
274 + ret = mkfifo(fifo_name, S_IRUSR|S_IWUSR);
277 + "mkfifo for %s returned %d", fifo_name, errno);
281 + fd = open(fifo_name, O_RDWR|O_NONBLOCK);
284 + "Failed to open %s, errno %d", fifo_name, errno);
288 + ap->logpri_fifo = fd;
295 +static int destroy_logpri_fifo(struct autofs_point *ap)
298 + int fd = ap->logpri_fifo;
301 + fifo_name = automount_path_to_fifo(ap->logopt, ap->path);
303 + crit(ap->logopt, "Failed to allocate memory!");
304 + goto out_free; /* free(NULL) is okay */
307 + ap->logpri_fifo = -1;
312 + "close for fifo %s returned %d", fifo_name, errno);
315 + ret = unlink(fifo_name);
318 + "Failed to unlink FIFO. Was the fifo created OK?");
326 +static void handle_fifo_message(struct autofs_point *ap, int fd)
329 + char buffer[PIPE_BUF];
333 + memset(buffer, 0, sizeof(buffer));
334 + ret = read(fd, &buffer, sizeof(buffer));
336 + warn(ap->logopt, "read on fifo returned error %d", errno);
341 + debug(ap->logopt, "expected 2 bytes, received %d.", ret);
346 + pri = strtol(buffer, &end, 10);
347 + if ((pri == LONG_MIN || pri == LONG_MAX) && errno == ERANGE) {
348 + debug(ap->logopt, "strtol reported an %s. Failed to set "
349 + "log priority.", pri == LONG_MIN ? "underflow" : "overflow");
352 + if ((pri == 0 && errno == EINVAL) || end == buffer) {
353 + debug(ap->logopt, "priority is expected to be an integer "
354 + "in the range 0-7 inclusive.");
358 + if (pri > LOG_DEBUG || pri < LOG_EMERG) {
359 + debug(ap->logopt, "invalid log priority (%ld) received "
365 + * OK, the message passed all of the sanity checks. The
366 + * automounter actually only supports three log priorities.
367 + * Everything is logged at log level debug, deamon messages
368 + * and everything except debug messages are logged with the
369 + * verbose setting and only error and critical messages are
370 + * logged when debugging isn't enabled.
372 + if (pri >= LOG_WARNING) {
373 + if (pri == LOG_DEBUG) {
374 + set_log_debug_ap(ap);
375 + info(ap->logopt, "Debug logging set for %s", ap->path);
377 + set_log_verbose_ap(ap);
378 + info(ap->logopt, "Verbose logging set for %s", ap->path);
381 + if (ap->logopt & LOGOPT_ANY)
382 + info(ap->logopt, "Basic logging set for %s", ap->path);
383 + set_log_norm_ap(ap);
387 +static int set_log_priority(const char *path, int priority)
393 + if (priority > LOG_DEBUG || priority < LOG_EMERG) {
394 + fprintf(stderr, "Log priority %d is invalid.\n", priority);
395 + fprintf(stderr, "Please spcify a number in the range 0-7.\n");
400 + * This is an ascii based protocol, so we want the string
401 + * representation of the integer log priority.
403 + snprintf(buf, sizeof(buf), "%d", priority);
405 + fifo_name = automount_path_to_fifo(LOGOPT_NONE, path);
407 + fprintf(stderr, "%s: Failed to allocate memory!\n",
413 + * Specify O_NONBLOCK so that the open will fail if there is no
414 + * daemon reading from the other side of the FIFO.
416 + fd = open(fifo_name, O_WRONLY|O_NONBLOCK);
418 + fprintf(stderr, "%s: open of %s failed with %d\n",
419 + __FUNCTION__, fifo_name, errno);
424 + if (write(fd, buf, sizeof(buf)) != sizeof(buf)) {
425 + fprintf(stderr, "Failed to change logging priority. ");
426 + fprintf(stderr, "write to fifo failed with errno %d.\n",
434 + fprintf(stdout, "Successfully set log priority for %s.\n", path);
439 static int get_pkt(struct autofs_point *ap, union autofs_packet_union *pkt)
441 - struct pollfd fds[2];
442 + struct pollfd fds[3];
443 char buf[MAX_ERR_BUF];
445 fds[0].fd = ap->pipefd;
446 fds[0].events = POLLIN;
447 fds[1].fd = ap->state_pipe[0];
448 fds[1].events = POLLIN;
449 + fds[2].fd = ap->logpri_fifo;
450 + fds[2].events = POLLIN;
453 - if (poll(fds, 2, -1) == -1) {
454 + if (poll(fds, 3, -1) == -1) {
458 estr = strerror_r(errno, buf, MAX_ERR_BUF);
459 - error(ap->logopt, "poll failed: %s", estr);
460 + logerr("poll failed: %s", estr);
464 @@ -709,6 +929,11 @@ static int get_pkt(struct autofs_point *ap, union autofs_packet_union *pkt)
466 if (fds[0].revents & POLLIN)
467 return fullread(ap->pipefd, pkt, kpkt_len);
469 + if (fds[2].revents & POLLIN) {
470 + debug(ap->logopt, "message pending on control fifo.");
471 + handle_fifo_message(ap, fds[2].fd);
476 @@ -730,21 +955,93 @@ int do_expire(struct autofs_point *ap, const char *name, int namelen)
480 - msg("expiring path %s", buf);
481 + info(ap->logopt, "expiring path %s", buf);
483 ret = umount_multi(ap, buf, 1);
485 - msg("expired %s", buf);
486 + info(ap->logopt, "expired %s", buf);
488 warn(ap->logopt, "couldn't complete expire of %s", buf);
493 +static int autofs_init_ap(struct autofs_point *ap)
495 + int pipefd[2], cl_flags;
497 + if ((ap->state != ST_INIT)) {
498 + /* This can happen if an autofs process is already running*/
499 + error(ap->logopt, "bad state %d", ap->state);
503 + ap->pipefd = ap->kpipefd = ap->ioctlfd = -1;
505 + /* Pipe for kernel communications */
506 + if (pipe(pipefd) < 0) {
508 + "failed to create commumication pipe for autofs path %s",
514 + ap->pipefd = pipefd[0];
515 + ap->kpipefd = pipefd[1];
517 + if ((cl_flags = fcntl(ap->pipefd, F_GETFD, 0)) != -1) {
518 + cl_flags |= FD_CLOEXEC;
519 + fcntl(ap->pipefd, F_SETFD, cl_flags);
522 + if ((cl_flags = fcntl(ap->kpipefd, F_GETFD, 0)) != -1) {
523 + cl_flags |= FD_CLOEXEC;
524 + fcntl(ap->kpipefd, F_SETFD, cl_flags);
527 + /* Pipe state changes from signal handler to main loop */
528 + if (pipe(ap->state_pipe) < 0) {
530 + "failed create state pipe for autofs path %s", ap->path);
532 + close(ap->kpipefd); /* Close kernel pipe end */
537 + if ((cl_flags = fcntl(ap->state_pipe[0], F_GETFD, 0)) != -1) {
538 + cl_flags |= FD_CLOEXEC;
539 + fcntl(ap->state_pipe[0], F_SETFD, cl_flags);
542 + if ((cl_flags = fcntl(ap->state_pipe[1], F_GETFD, 0)) != -1) {
543 + cl_flags |= FD_CLOEXEC;
544 + fcntl(ap->state_pipe[1], F_SETFD, cl_flags);
547 + if (create_logpri_fifo(ap) < 0) {
549 + "failed to create FIFO for path %s\n", ap->path);
550 + destroy_logpri_fifo(ap);
552 + close(ap->kpipefd);
554 + close(ap->state_pipe[0]);
555 + close(ap->state_pipe[1]);
562 static int mount_autofs(struct autofs_point *ap)
566 + if (autofs_init_ap(ap) != 0)
569 if (ap->type == LKP_DIRECT)
570 status = mount_autofs_direct(ap);
572 @@ -841,9 +1138,8 @@ static void become_daemon(unsigned foreground)
575 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
577 - "failed to write pid file %s: %s",
579 + logerr("failed to write pid file %s: %s",
584 @@ -889,12 +1185,12 @@ static void *do_notify_state(void *arg)
588 - debug(master->default_logging, "signal %d", sig);
589 + debug(master->logopt, "signal %d", sig);
592 status = pthread_cond_signal(&mrc.cond);
594 - error(master->default_logging,
595 + error(master->logopt,
596 "failed to signal state notify condition");
597 status = pthread_mutex_unlock(&mrc.mutex);
599 @@ -923,7 +1219,7 @@ static pthread_t do_signals(struct master *master, int sig)
601 status = pthread_create(&thid, &thread_attr, do_notify_state, &r_sig);
603 - error(master->default_logging,
604 + error(master->logopt,
605 "mount state notify thread create failed");
606 status = pthread_mutex_unlock(&mrc.mutex);
608 @@ -951,6 +1247,7 @@ static pthread_t do_signals(struct master *master, int sig)
609 static void *do_read_master(void *arg)
611 struct master *master;
612 + unsigned int logopt;
616 @@ -961,11 +1258,12 @@ static void *do_read_master(void *arg)
620 + logopt = master->logopt;
623 status = pthread_cond_signal(&mrc.cond);
625 - error(master->default_logging,
627 "failed to signal master read map condition");
629 status = pthread_mutex_unlock(&mrc.mutex);
630 @@ -989,6 +1287,7 @@ static void *do_read_master(void *arg)
632 static int do_hup_signal(struct master *master, time_t age)
634 + unsigned int logopt = master->logopt;
638 @@ -1007,7 +1306,7 @@ static int do_hup_signal(struct master *master, time_t age)
640 status = pthread_create(&thid, &thread_attr, do_read_master, NULL);
642 - error(master->default_logging,
644 "master read map thread create failed");
646 status = pthread_mutex_unlock(&mrc.mutex);
647 @@ -1062,8 +1361,7 @@ static void *statemachine(void *arg)
651 - error(master_list->default_logging,
652 - "got unexpected signal %d!", sig);
653 + logerr("got unexpected signal %d!", sig);
657 @@ -1134,10 +1432,11 @@ static void handle_mounts_cleanup(void *arg)
658 struct autofs_point *ap;
659 char path[PATH_MAX + 1];
660 char buf[MAX_ERR_BUF];
661 - unsigned int clean = 0, submount;
662 + unsigned int clean = 0, submount, logopt;
664 ap = (struct autofs_point *) arg;
666 + logopt = ap->logopt;
667 submount = ap->submount;
669 strcpy(path, ap->path);
670 @@ -1152,6 +1451,7 @@ static void handle_mounts_cleanup(void *arg)
672 umount_autofs(ap, 1);
674 + destroy_logpri_fifo(ap);
675 master_signal_submount(ap, MASTER_SUBMNT_JOIN);
676 master_remove_mapent(ap->entry);
677 master_free_mapent_sources(ap->entry, 1);
678 @@ -1162,12 +1462,12 @@ static void handle_mounts_cleanup(void *arg)
680 if (rmdir(path) == -1) {
681 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
682 - warn(LOGOPT_NONE, "failed to remove dir %s: %s",
683 + warn(logopt, "failed to remove dir %s: %s",
688 - msg("shut down path %s", path);
689 + info(logopt, "shut down path %s", path);
691 /* If we are the last tell the state machine to shutdown */
692 if (!submount && master_list_empty(master_list))
693 @@ -1190,7 +1490,7 @@ void *handle_mounts(void *arg)
695 status = pthread_mutex_lock(&suc.mutex);
697 - crit(ap->logopt, "failed to lock startup condition mutex!");
698 + logerr("failed to lock startup condition mutex!");
702 @@ -1204,7 +1504,7 @@ void *handle_mounts(void *arg)
705 if (ap->ghost && ap->type != LKP_DIRECT)
706 - msg("ghosting enabled");
707 + info(ap->logopt, "ghosting enabled");
710 pthread_cleanup_pop(1);
711 @@ -1356,6 +1656,8 @@ static void usage(void)
712 " use ramdom replicated server selection\n"
713 " -O --global-options\n"
714 " specify global mount options\n"
715 + " -l --set-log-priority priority path [path,...]\n"
716 + " set daemon log verbosity\n"
717 " -V --version print version, build config and exit\n"
720 @@ -1437,9 +1739,45 @@ static void show_build_info(void)
724 +typedef struct _code {
729 +CODE prioritynames[] = {
730 + { "alert", LOG_ALERT },
731 + { "crit", LOG_CRIT },
732 + { "debug", LOG_DEBUG },
733 + { "emerg", LOG_EMERG },
734 + { "err", LOG_ERR },
735 + { "error", LOG_ERR }, /* DEPRECATED */
736 + { "info", LOG_INFO },
737 + { "notice", LOG_NOTICE },
738 + { "panic", LOG_EMERG }, /* DEPRECATED */
739 + { "warn", LOG_WARNING }, /* DEPRECATED */
740 + { "warning", LOG_WARNING },
744 +static int convert_log_priority(char *priority_name)
746 + CODE *priority_mapping;
748 + for (priority_mapping = prioritynames;
749 + priority_mapping->c_name != NULL;
750 + priority_mapping++) {
752 + if (!strcasecmp(priority_name, priority_mapping->c_name))
753 + return priority_mapping->c_val;
759 int main(int argc, char *argv[])
761 int res, opt, status;
763 unsigned ghost, logging;
764 unsigned foreground, have_global_options;
766 @@ -1457,6 +1795,7 @@ int main(int argc, char *argv[])
767 {"random-multimount-selection", 0, 0, 'r'},
768 {"global-options", 1, 0, 'O'},
769 {"version", 0, 0, 'V'},
770 + {"set-log-priority", 1, 0, 'l'},
774 @@ -1477,7 +1816,7 @@ int main(int argc, char *argv[])
778 - while ((opt = getopt_long(argc, argv, "+hp:t:vdD:fVrO:", long_options, NULL)) != EOF) {
779 + while ((opt = getopt_long(argc, argv, "+hp:t:vdD:fVrO:l:", long_options, NULL)) != EOF) {
783 @@ -1525,6 +1864,23 @@ int main(int argc, char *argv[])
788 + if (isalpha(*optarg)) {
789 + logpri = convert_log_priority(optarg);
791 + fprintf(stderr, "Invalid log priority:"
795 + } else if (isdigit(*optarg)) {
796 + logpri = getnumopt(optarg, opt);
798 + fprintf(stderr, "non-alphanumeric character "
799 + "found in log priority. Aborting.\n");
806 printf("%s: Ambiguous or unknown options\n", program);
807 @@ -1548,6 +1904,26 @@ int main(int argc, char *argv[])
816 + * The remaining argv elements are the paths for which
817 + * log priorities must be changed.
819 + for (i = 0; i < argc; i++) {
820 + if (set_log_priority(argv[i], logpri) < 0)
825 + "--set-log-priority requires a path.\n");
831 if (is_automount_running() > 0) {
832 fprintf(stderr, "%s: program is already running.\n",
834 @@ -1572,7 +1948,7 @@ int main(int argc, char *argv[])
835 rlim.rlim_max = MAX_OPEN_FILES;
836 res = setrlimit(RLIMIT_NOFILE, &rlim);
840 "can't increase open file limit - continuing");
843 @@ -1580,7 +1956,7 @@ int main(int argc, char *argv[])
844 rlim.rlim_max = RLIM_INFINITY;
845 res = setrlimit(RLIMIT_CORE, &rlim);
849 "can't increase core file limit - continuing");
852 @@ -1592,15 +1968,14 @@ int main(int argc, char *argv[])
853 master_list = master_new(argv[0], timeout, ghost);
856 - crit(LOGOPT_ANY, "%s: can't create master map %s",
857 + logerr("%s: can't create master map %s",
859 close(start_pipefd[1]);
863 if (pthread_attr_init(&thread_attr)) {
865 - "%s: failed to init thread attribute struct!",
866 + logerr("%s: failed to init thread attribute struct!",
868 close(start_pipefd[1]);
870 @@ -1608,8 +1983,7 @@ int main(int argc, char *argv[])
872 if (pthread_attr_setdetachstate(
873 &thread_attr, PTHREAD_CREATE_DETACHED)) {
875 - "%s: failed to set detached thread attribute!",
876 + logerr("%s: failed to set detached thread attribute!",
878 close(start_pipefd[1]);
880 @@ -1618,38 +1992,37 @@ int main(int argc, char *argv[])
881 #ifdef _POSIX_THREAD_ATTR_STACKSIZE
882 if (pthread_attr_setstacksize(
883 &thread_attr, PTHREAD_STACK_MIN*64)) {
885 - "%s: failed to set stack size thread attribute!",
887 + logerr("%s: failed to set stack size thread attribute!",
889 close(start_pipefd[1]);
894 - msg("Starting automounter version %s, master map %s",
895 + info(logging, "Starting automounter version %s, master map %s",
896 version, master_list->name);
897 - msg("using kernel protocol version %d.%02d",
898 + info(logging, "using kernel protocol version %d.%02d",
899 get_kver_major(), get_kver_minor());
901 status = pthread_key_create(&key_thread_stdenv_vars,
902 key_thread_stdenv_vars_destroy);
905 - "failed to create thread data key for std env vars!");
906 + logerr("%s: failed to create thread data key for std env vars!",
908 master_kill(master_list);
909 close(start_pipefd[1]);
913 if (!alarm_start_handler()) {
914 - crit(LOGOPT_ANY, "failed to create alarm handler thread!");
915 + logerr("%s: failed to create alarm handler thread!", program);
916 master_kill(master_list);
917 close(start_pipefd[1]);
921 if (!st_start_handler()) {
922 - crit(LOGOPT_ANY, "failed to create FSM handler thread!");
923 + logerr("%s: failed to create FSM handler thread!", program);
924 master_kill(master_list);
925 close(start_pipefd[1]);
927 @@ -1685,5 +2058,7 @@ int main(int argc, char *argv[])
931 + info(logging, "autofs stopped");
935 diff --git a/daemon/direct.c b/daemon/direct.c
936 index 9a39a6f..4ab4204 100644
937 --- a/daemon/direct.c
938 +++ b/daemon/direct.c
939 @@ -86,61 +86,6 @@ static void mnts_cleanup(void *arg)
943 -static int autofs_init_direct(struct autofs_point *ap)
945 - int pipefd[2], cl_flags;
947 - if ((ap->state != ST_INIT)) {
948 - /* This can happen if an autofs process is already running*/
949 - error(ap->logopt, "bad state %d", ap->state);
953 - ap->pipefd = ap->kpipefd = ap->ioctlfd = -1;
955 - /* Pipe for kernel communications */
956 - if (pipe(pipefd) < 0) {
958 - "failed to create commumication pipe for autofs path %s",
963 - ap->pipefd = pipefd[0];
964 - ap->kpipefd = pipefd[1];
966 - if ((cl_flags = fcntl(ap->pipefd, F_GETFD, 0)) != -1) {
967 - cl_flags |= FD_CLOEXEC;
968 - fcntl(ap->pipefd, F_SETFD, cl_flags);
971 - if ((cl_flags = fcntl(ap->kpipefd, F_GETFD, 0)) != -1) {
972 - cl_flags |= FD_CLOEXEC;
973 - fcntl(ap->kpipefd, F_SETFD, cl_flags);
976 - /* Pipe state changes from signal handler to main loop */
977 - if (pipe(ap->state_pipe) < 0) {
978 - crit(ap->logopt, "failed create state pipe for autofs path %s",
981 - close(ap->kpipefd);
985 - if ((cl_flags = fcntl(ap->state_pipe[0], F_GETFD, 0)) != -1) {
986 - cl_flags |= FD_CLOEXEC;
987 - fcntl(ap->state_pipe[0], F_SETFD, cl_flags);
990 - if ((cl_flags = fcntl(ap->state_pipe[1], F_GETFD, 0)) != -1) {
991 - cl_flags |= FD_CLOEXEC;
992 - fcntl(ap->state_pipe[1], F_SETFD, cl_flags);
998 int do_umount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me)
1000 char buf[MAX_ERR_BUF];
1001 @@ -241,10 +186,10 @@ int do_umount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, stru
1005 - msg("forcing umount of direct mount %s", me->key);
1006 + info(ap->logopt, "forcing umount of direct mount %s", me->key);
1007 rv = umount2(me->key, MNT_DETACH);
1009 - msg("umounted direct mount %s", me->key);
1010 + info(ap->logopt, "umounted direct mount %s", me->key);
1012 if (!rv && me->dir_created) {
1013 if (rmdir(me->key) == -1) {
1014 @@ -326,7 +271,7 @@ static int unlink_mount_tree(struct autofs_point *ap, struct list_head *list)
1017 if (strcmp(mnt->fs_type, "autofs"))
1018 - rv = spawn_umount(log_debug, "-l", mnt->path, NULL);
1019 + rv = spawn_umount(ap->logopt, "-l", mnt->path, NULL);
1021 rv = umount2(mnt->path, MNT_DETACH);
1023 @@ -475,13 +420,15 @@ int do_mount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struc
1024 ioctl(ioctlfd, AUTOFS_IOC_SETTIMEOUT, &timeout);
1026 if (ap->exp_timeout)
1027 - msg("mounted direct mount on %s "
1029 + "mounted direct mount on %s "
1030 "with timeout %u, freq %u seconds", me->key,
1031 (unsigned int) ap->exp_timeout,
1032 (unsigned int) ap->exp_runfreq);
1034 - msg("mounted direct mount on %s with timeouts disabled",
1037 + "mounted direct mount on %s with timeouts disabled",
1040 ret = fstat(ioctlfd, &st);
1042 @@ -522,9 +469,6 @@ int mount_autofs_direct(struct autofs_point *ap)
1046 - if (autofs_init_direct(ap))
1049 /* TODO: check map type */
1050 if (lookup_nss_read_map(ap, NULL, now))
1051 lookup_prune_cache(ap, now);
1052 @@ -607,7 +551,7 @@ int umount_autofs_offset(struct autofs_point *ap, struct mapent *me)
1053 /* offset isn't mounted, return success and try to recover */
1054 if (!is_mounted(_PROC_MOUNTS, me->key, MNTS_AUTOFS)) {
1056 - "offset %s unexpectedly not mounted",
1057 + "offset %s not mounted",
1061 @@ -627,7 +571,7 @@ int umount_autofs_offset(struct autofs_point *ap, struct mapent *me)
1062 rv = ioctl(ioctlfd, AUTOFS_IOC_ASKUMOUNT, &status);
1064 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1065 - error(ap->logopt, "ioctl failed: %s", estr);
1066 + logerr("ioctl failed: %s", estr);
1068 } else if (!status) {
1069 if (ap->state != ST_SHUTDOWN_FORCE) {
1070 @@ -692,10 +636,10 @@ int umount_autofs_offset(struct autofs_point *ap, struct mapent *me)
1074 - msg("forcing umount of offset mount %s", me->key);
1075 + info(ap->logopt, "forcing umount of offset mount %s", me->key);
1076 rv = umount2(me->key, MNT_DETACH);
1078 - msg("umounted offset mount %s", me->key);
1079 + info(ap->logopt, "umounted offset mount %s", me->key);
1081 if (!rv && me->dir_created) {
1082 if (rmdir(me->key) == -1) {
1083 @@ -868,7 +812,7 @@ static int expire_direct(int ioctlfd, const char *path, unsigned int when, unsig
1087 - retries = (count_mounts(path, st.st_dev) + 1) * EXPIRE_RETRIES;
1088 + retries = (count_mounts(logopt, path, st.st_dev) + 1) * EXPIRE_RETRIES;
1091 struct timespec tm = {0, 100000000};
1092 @@ -1018,7 +962,7 @@ void *expire_proc_direct(void *arg)
1094 if (me->ioctlfd != -1 &&
1095 fstat(ioctlfd, &st) != -1 &&
1096 - !count_mounts(next->path, st.st_dev)) {
1097 + !count_mounts(ap->logopt, next->path, st.st_dev)) {
1101 @@ -1049,6 +993,9 @@ void *expire_proc_direct(void *arg)
1103 pthread_cleanup_pop(1);
1106 + info(ap->logopt, "%d remaining in %s", left, ap->path);
1110 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
1111 @@ -1072,7 +1019,7 @@ static void pending_cond_destroy(void *arg)
1112 static void expire_send_fail(void *arg)
1114 struct pending_args *mt = arg;
1115 - send_fail(mt->ioctlfd, mt->wait_queue_token);
1116 + send_fail(mt->ap->logopt, mt->ioctlfd, mt->wait_queue_token);
1119 static void free_pending_args(void *arg)
1120 @@ -1124,14 +1071,14 @@ static void *do_expire_direct(void *arg)
1121 status = do_expire(ap, mt->name, len);
1122 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
1124 - send_fail(mt->ioctlfd, mt->wait_queue_token);
1125 + send_fail(ap->logopt, mt->ioctlfd, mt->wait_queue_token);
1128 cache_readlock(mt->mc);
1129 me = cache_lookup_distinct(mt->mc, mt->name);
1131 cache_unlock(mt->mc);
1132 - send_ready(mt->ioctlfd, mt->wait_queue_token);
1133 + send_ready(ap->logopt, mt->ioctlfd, mt->wait_queue_token);
1136 pthread_setcancelstate(state, NULL);
1137 @@ -1194,7 +1141,7 @@ int handle_packet_expire_direct(struct autofs_point *ap, autofs_packet_expire_di
1139 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1140 error(ap->logopt, "malloc: %s", estr);
1141 - send_fail(me->ioctlfd, pkt->wait_queue_token);
1142 + send_fail(ap->logopt, me->ioctlfd, pkt->wait_queue_token);
1144 pthread_setcancelstate(state, NULL);
1146 @@ -1223,7 +1170,7 @@ int handle_packet_expire_direct(struct autofs_point *ap, autofs_packet_expire_di
1147 status = pthread_create(&thid, &thread_attr, do_expire_direct, mt);
1149 error(ap->logopt, "expire thread create failed");
1150 - send_fail(mt->ioctlfd, pkt->wait_queue_token);
1151 + send_fail(ap->logopt, mt->ioctlfd, pkt->wait_queue_token);
1153 expire_mutex_unlock(NULL);
1154 pending_cond_destroy(mt);
1155 @@ -1252,7 +1199,7 @@ int handle_packet_expire_direct(struct autofs_point *ap, autofs_packet_expire_di
1156 static void mount_send_fail(void *arg)
1158 struct pending_args *mt = arg;
1159 - send_fail(mt->ioctlfd, mt->wait_queue_token);
1160 + send_fail(mt->ap->logopt, mt->ioctlfd, mt->wait_queue_token);
1164 @@ -1319,7 +1266,7 @@ static void *do_mount_direct(void *arg)
1166 pthread_setcancelstate(state, NULL);
1168 - msg("attempting to mount entry %s", mt->name);
1169 + info(ap->logopt, "attempting to mount entry %s", mt->name);
1172 * Setup thread specific data values for macro
1173 @@ -1445,16 +1392,16 @@ cont:
1174 cache_unlock(mt->mc);
1176 me->ioctlfd = mt->ioctlfd;
1177 - send_ready(mt->ioctlfd, mt->wait_queue_token);
1178 + send_ready(ap->logopt, mt->ioctlfd, mt->wait_queue_token);
1180 - send_ready(mt->ioctlfd, mt->wait_queue_token);
1181 + send_ready(ap->logopt, mt->ioctlfd, mt->wait_queue_token);
1184 - msg("mounted %s", mt->name);
1185 + info(ap->logopt, "mounted %s", mt->name);
1187 - send_fail(mt->ioctlfd, mt->wait_queue_token);
1188 + send_fail(mt->ap->logopt, mt->ioctlfd, mt->wait_queue_token);
1190 - msg("failed to mount %s", mt->name);
1191 + info(ap->logopt, "failed to mount %s", mt->name);
1193 pthread_setcancelstate(state, NULL);
1195 @@ -1505,7 +1452,7 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_
1196 * Shouldn't happen as the kernel is telling us
1197 * someone has walked on our mount point.
1199 - crit(ap->logopt, "can't find map entry for (%lu,%lu)",
1200 + logerr("can't find map entry for (%lu,%lu)",
1201 (unsigned long) pkt->dev, (unsigned long) pkt->ino);
1202 pthread_setcancelstate(state, NULL);
1204 @@ -1538,7 +1485,7 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_
1205 if (ap->state == ST_SHUTDOWN_PENDING ||
1206 ap->state == ST_SHUTDOWN_FORCE ||
1207 ap->state == ST_SHUTDOWN) {
1208 - send_fail(ioctlfd, pkt->wait_queue_token);
1209 + send_fail(ap->logopt, ioctlfd, pkt->wait_queue_token);
1212 pthread_setcancelstate(state, NULL);
1213 @@ -1549,7 +1496,7 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_
1215 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1216 error(ap->logopt, "malloc: %s", estr);
1217 - send_fail(ioctlfd, pkt->wait_queue_token);
1218 + send_fail(ap->logopt, ioctlfd, pkt->wait_queue_token);
1221 pthread_setcancelstate(state, NULL);
1222 @@ -1578,7 +1525,7 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_
1223 status = pthread_create(&thid, &thread_attr, do_mount_direct, mt);
1225 error(ap->logopt, "missing mount thread create failed");
1226 - send_fail(ioctlfd, pkt->wait_queue_token);
1227 + send_fail(ap->logopt, ioctlfd, pkt->wait_queue_token);
1230 mount_mutex_unlock(NULL);
1231 diff --git a/daemon/indirect.c b/daemon/indirect.c
1232 index 02e7045..5c422c8 100644
1233 --- a/daemon/indirect.c
1234 +++ b/daemon/indirect.c
1235 @@ -43,63 +43,6 @@ extern pthread_attr_t thread_attr;
1236 static pthread_mutex_t ma_mutex = PTHREAD_MUTEX_INITIALIZER;
1237 static pthread_mutex_t ea_mutex = PTHREAD_MUTEX_INITIALIZER;
1239 -static int autofs_init_indirect(struct autofs_point *ap)
1241 - int pipefd[2], cl_flags;
1243 - if ((ap->state != ST_INIT)) {
1244 - /* This can happen if an autofs process is already running*/
1245 - error(ap->logopt, "bad state %d", ap->state);
1249 - ap->pipefd = ap->kpipefd = ap->ioctlfd = -1;
1251 - /* Pipe for kernel communications */
1252 - if (pipe(pipefd) < 0) {
1254 - "failed to create commumication pipe for autofs path %s",
1260 - ap->pipefd = pipefd[0];
1261 - ap->kpipefd = pipefd[1];
1263 - if ((cl_flags = fcntl(ap->pipefd, F_GETFD, 0)) != -1) {
1264 - cl_flags |= FD_CLOEXEC;
1265 - fcntl(ap->pipefd, F_SETFD, cl_flags);
1268 - if ((cl_flags = fcntl(ap->kpipefd, F_GETFD, 0)) != -1) {
1269 - cl_flags |= FD_CLOEXEC;
1270 - fcntl(ap->kpipefd, F_SETFD, cl_flags);
1273 - /* Pipe state changes from signal handler to main loop */
1274 - if (pipe(ap->state_pipe) < 0) {
1276 - "failed create state pipe for autofs path %s", ap->path);
1277 - close(ap->pipefd);
1278 - close(ap->kpipefd); /* Close kernel pipe end */
1283 - if ((cl_flags = fcntl(ap->state_pipe[0], F_GETFD, 0)) != -1) {
1284 - cl_flags |= FD_CLOEXEC;
1285 - fcntl(ap->state_pipe[0], F_SETFD, cl_flags);
1288 - if ((cl_flags = fcntl(ap->state_pipe[1], F_GETFD, 0)) != -1) {
1289 - cl_flags |= FD_CLOEXEC;
1290 - fcntl(ap->state_pipe[1], F_SETFD, cl_flags);
1296 static int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts)
1298 struct mnt_list *this;
1299 @@ -118,7 +61,7 @@ static int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts)
1302 if (strcmp(this->fs_type, "autofs"))
1303 - rv = spawn_umount(log_debug, "-l", this->path, NULL);
1304 + rv = spawn_umount(ap->logopt, "-l", this->path, NULL);
1306 rv = umount2(this->path, MNT_DETACH);
1308 @@ -222,12 +165,14 @@ static int do_mount_autofs_indirect(struct autofs_point *ap)
1309 ioctl(ap->ioctlfd, AUTOFS_IOC_SETTIMEOUT, &timeout);
1311 if (ap->exp_timeout)
1312 - msg("mounted indirect mount on %s "
1314 + "mounted indirect mount on %s "
1315 "with timeout %u, freq %u seconds", ap->path,
1316 - (unsigned int) ap->exp_timeout,
1317 - (unsigned int) ap->exp_runfreq);
1318 + (unsigned int) ap->exp_timeout,
1319 + (unsigned int) ap->exp_runfreq);
1321 - msg("mounted indirect mount on %s with timeouts disabled",
1323 + "mounted indirect mount on %s with timeouts disabled",
1326 fstat(ap->ioctlfd, &st);
1327 @@ -257,9 +202,6 @@ int mount_autofs_indirect(struct autofs_point *ap)
1331 - if (autofs_init_indirect(ap))
1334 /* TODO: read map, determine map type is OK */
1335 if (lookup_nss_read_map(ap, NULL, now))
1336 lookup_prune_cache(ap, now);
1337 @@ -309,7 +251,7 @@ int umount_autofs_indirect(struct autofs_point *ap)
1338 rv = ioctl(ap->ioctlfd, AUTOFS_IOC_ASKUMOUNT, &ret);
1340 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1341 - error(ap->logopt, "ioctl failed: %s", estr);
1342 + logerr("ioctl failed: %s", estr);
1345 error(ap->logopt, "ask umount returned busy %s", ap->path);
1346 @@ -370,9 +312,9 @@ force_umount:
1347 "forcing umount of indirect mount %s", ap->path);
1348 rv = umount2(ap->path, MNT_DETACH);
1350 - msg("umounted indirect mount %s", ap->path);
1351 + info(ap->logopt, "umounted indirect mount %s", ap->path);
1353 - rm_unwanted(ap->path, 1, ap->dev);
1354 + rm_unwanted(ap->logopt, ap->path, 1, ap->dev);
1358 @@ -390,7 +332,7 @@ static int expire_indirect(struct autofs_point *ap, int ioctlfd, const char *pat
1362 - retries = (count_mounts(path, st.st_dev) + 1) * EXPIRE_RETRIES;
1363 + retries = (count_mounts(ap->logopt, path, st.st_dev) + 1) * EXPIRE_RETRIES;
1366 struct timespec tm = {0, 100000000};
1367 @@ -559,13 +501,7 @@ void *expire_proc_indirect(void *arg)
1368 * words) the umounts are done by the time we reach here
1371 - debug(ap->logopt, "%d remaining in %s", count, ap->path);
1373 - /* If we are trying to shutdown make sure we can umount */
1374 - if (!ioctl(ap->ioctlfd, AUTOFS_IOC_ASKUMOUNT, &ret)) {
1376 - msg("mount still busy %s", ap->path);
1378 + info(ap->logopt, "%d remaining in %s", count, ap->path);
1382 @@ -590,7 +526,7 @@ static void pending_cond_destroy(void *arg)
1383 static void expire_send_fail(void *arg)
1385 struct pending_args *mt = arg;
1386 - send_fail(mt->ap->ioctlfd, mt->wait_queue_token);
1387 + send_fail(mt->ap->logopt, mt->ap->ioctlfd, mt->wait_queue_token);
1390 static void free_pending_args(void *arg)
1391 @@ -634,9 +570,9 @@ static void *do_expire_indirect(void *arg)
1392 status = do_expire(mt->ap, mt->name, mt->len);
1393 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
1395 - send_fail(ap->ioctlfd, mt->wait_queue_token);
1396 + send_fail(ap->logopt, ap->ioctlfd, mt->wait_queue_token);
1398 - send_ready(ap->ioctlfd, mt->wait_queue_token);
1399 + send_ready(ap->logopt, ap->ioctlfd, mt->wait_queue_token);
1400 pthread_setcancelstate(state, NULL);
1402 pthread_cleanup_pop(0);
1403 @@ -661,8 +597,8 @@ int handle_packet_expire_indirect(struct autofs_point *ap, autofs_packet_expire_
1404 mt = malloc(sizeof(struct pending_args));
1406 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1407 - error(ap->logopt, "malloc: %s", estr);
1408 - send_fail(ap->ioctlfd, pkt->wait_queue_token);
1409 + logerr("malloc: %s", estr);
1410 + send_fail(ap->logopt, ap->ioctlfd, pkt->wait_queue_token);
1411 pthread_setcancelstate(state, NULL);
1414 @@ -684,7 +620,7 @@ int handle_packet_expire_indirect(struct autofs_point *ap, autofs_packet_expire_
1415 status = pthread_create(&thid, &thread_attr, do_expire_indirect, mt);
1417 error(ap->logopt, "expire thread create failed");
1418 - send_fail(ap->ioctlfd, pkt->wait_queue_token);
1419 + send_fail(ap->logopt, ap->ioctlfd, pkt->wait_queue_token);
1420 expire_mutex_unlock(NULL);
1421 pending_cond_destroy(mt);
1422 free_pending_args(mt);
1423 @@ -710,7 +646,7 @@ int handle_packet_expire_indirect(struct autofs_point *ap, autofs_packet_expire_
1424 static void mount_send_fail(void *arg)
1426 struct pending_args *mt = arg;
1427 - send_fail(mt->ap->ioctlfd, mt->wait_queue_token);
1428 + send_fail(mt->ap->logopt, mt->ap->ioctlfd, mt->wait_queue_token);
1431 static void mount_mutex_unlock(void *arg)
1432 @@ -775,7 +711,7 @@ static void *do_mount_indirect(void *arg)
1434 pthread_setcancelstate(state, NULL);
1436 - msg("attempting to mount entry %s", buf);
1437 + info(ap->logopt, "attempting to mount entry %s", buf);
1440 * Setup thread specific data values for macro
1441 @@ -887,11 +823,11 @@ cont:
1442 status = lookup_nss_mount(ap, NULL, mt->name, mt->len);
1443 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
1445 - send_ready(ap->ioctlfd, mt->wait_queue_token);
1446 - msg("mounted %s", buf);
1447 + send_ready(ap->logopt, ap->ioctlfd, mt->wait_queue_token);
1448 + info(ap->logopt, "mounted %s", buf);
1450 - send_fail(ap->ioctlfd, mt->wait_queue_token);
1451 - msg("failed to mount %s", buf);
1452 + send_fail(ap->logopt, ap->ioctlfd, mt->wait_queue_token);
1453 + info(ap->logopt, "failed to mount %s", buf);
1455 pthread_setcancelstate(state, NULL);
1457 @@ -918,7 +854,7 @@ int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missin
1458 if (ap->state == ST_SHUTDOWN_PENDING ||
1459 ap->state == ST_SHUTDOWN_FORCE ||
1460 ap->state == ST_SHUTDOWN) {
1461 - send_fail(ap->ioctlfd, pkt->wait_queue_token);
1462 + send_fail(ap->logopt, ap->ioctlfd, pkt->wait_queue_token);
1463 pthread_setcancelstate(state, NULL);
1466 @@ -926,8 +862,8 @@ int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missin
1467 mt = malloc(sizeof(struct pending_args));
1469 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1470 - error(ap->logopt, "malloc: %s", estr);
1471 - send_fail(ap->ioctlfd, pkt->wait_queue_token);
1472 + logerr("malloc: %s", estr);
1473 + send_fail(ap->logopt, ap->ioctlfd, pkt->wait_queue_token);
1474 pthread_setcancelstate(state, NULL);
1477 @@ -953,7 +889,7 @@ int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missin
1478 status = pthread_create(&thid, &thread_attr, do_mount_indirect, mt);
1480 error(ap->logopt, "expire thread create failed");
1481 - send_fail(ap->ioctlfd, pkt->wait_queue_token);
1482 + send_fail(ap->logopt, ap->ioctlfd, pkt->wait_queue_token);
1483 mount_mutex_unlock(NULL);
1484 pending_cond_destroy(mt);
1485 free_pending_args(mt);
1486 diff --git a/daemon/lookup.c b/daemon/lookup.c
1487 index 4f2b318..fd99cf2 100644
1488 --- a/daemon/lookup.c
1489 +++ b/daemon/lookup.c
1490 @@ -103,6 +103,7 @@ static int do_read_master(struct master *master, char *type, time_t age)
1492 static int read_master_map(struct master *master, char *type, time_t age)
1494 + unsigned int logopt = master->logopt;
1495 char *path, *save_name;
1498 @@ -117,7 +118,7 @@ static int read_master_map(struct master *master, char *type, time_t age)
1501 if (strchr(master->name, '/')) {
1502 - error(LOGOPT_ANY, "relative path invalid in files map name");
1503 + error(logopt, "relative path invalid in files map name");
1504 return NSS_STATUS_NOTFOUND;
1507 @@ -142,6 +143,7 @@ static int read_master_map(struct master *master, char *type, time_t age)
1509 int lookup_nss_read_master(struct master *master, time_t age)
1511 + unsigned int logopt = master->logopt;
1512 struct list_head nsslist;
1513 struct list_head *head, *p;
1514 int result = NSS_STATUS_UNKNOWN;
1515 @@ -149,12 +151,10 @@ int lookup_nss_read_master(struct master *master, time_t age)
1516 /* If it starts with a '/' it has to be a file or LDAP map */
1517 if (*master->name == '/') {
1518 if (*(master->name + 1) == '/') {
1519 - debug(LOGOPT_NONE,
1520 - "reading master ldap %s", master->name);
1521 + debug(logopt, "reading master ldap %s", master->name);
1522 result = do_read_master(master, "ldap", age);
1524 - debug(LOGOPT_NONE,
1525 - "reading master file %s", master->name);
1526 + debug(logopt, "reading master file %s", master->name);
1527 result = do_read_master(master, "file", age);
1530 @@ -184,13 +184,11 @@ int lookup_nss_read_master(struct master *master, time_t age)
1532 if (strncmp(name, "ldap", 4)) {
1533 master->name = tmp + 1;
1534 - debug(LOGOPT_NONE,
1535 - "reading master %s %s",
1536 + debug(logopt, "reading master %s %s",
1537 source, master->name);
1539 master->name = name;
1540 - debug(LOGOPT_NONE,
1541 - "reading master %s %s",
1542 + debug(logopt, "reading master %s %s",
1546 @@ -208,7 +206,7 @@ int lookup_nss_read_master(struct master *master, time_t age)
1548 if (!list_empty(&nsslist))
1549 free_sources(&nsslist);
1550 - error(LOGOPT_ANY, "can't to read name service switch config.");
1551 + error(logopt, "can't to read name service switch config.");
1555 @@ -220,13 +218,12 @@ int lookup_nss_read_master(struct master *master, time_t age)
1557 this = list_entry(p, struct nss_source, list);
1559 - debug(LOGOPT_NONE,
1561 "reading master %s %s", this->source, master->name);
1563 result = read_master_map(master, this->source, age);
1564 if (result == NSS_STATUS_UNKNOWN) {
1565 - debug(LOGOPT_NONE,
1566 - "no map - continuing to next source");
1567 + debug(logopt, "no map - continuing to next source");
1571 @@ -1008,9 +1005,10 @@ int lookup_prune_cache(struct autofs_point *ap, time_t age)
1572 if (this->ioctlfd == -1)
1573 status = cache_delete(mc, key);
1574 if (status != CHE_FAIL) {
1575 - if (ap->type == LKP_INDIRECT)
1576 - rmdir_path(ap, path, ap->dev);
1578 + if (ap->type == LKP_INDIRECT) {
1580 + rmdir_path(ap, path, ap->dev);
1582 rmdir_path(ap, path, this->dev);
1585 diff --git a/daemon/module.c b/daemon/module.c
1586 index e83c929..36eca00 100644
1587 --- a/daemon/module.c
1588 +++ b/daemon/module.c
1589 @@ -33,7 +33,7 @@ int load_autofs4_module(void)
1591 fp = fopen("/proc/filesystems", "r");
1593 - error(LOGOPT_ANY, "cannot open /proc/filesystems\n");
1594 + logerr("cannot open /proc/filesystems\n");
1598 @@ -45,7 +45,7 @@ int load_autofs4_module(void)
1602 - ret = spawnl(log_debug, PATH_MODPROBE, PATH_MODPROBE,
1603 + ret = spawnl(LOGOPT_NONE, PATH_MODPROBE, PATH_MODPROBE,
1604 "-q", FS_MODULE_NAME, NULL);
1607 @@ -72,7 +72,7 @@ struct lookup_mod *open_lookup(const char *name, const char *err_prefix,
1610 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1611 - crit(LOGOPT_ANY, "%s%s", err_prefix, estr);
1612 + logerr("%s%s", err_prefix, estr);
1616 @@ -83,7 +83,7 @@ struct lookup_mod *open_lookup(const char *name, const char *err_prefix,
1619 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1620 - crit(LOGOPT_ANY, "%s%s", err_prefix, estr);
1621 + logerr("%s%s", err_prefix, estr);
1625 @@ -91,7 +91,7 @@ struct lookup_mod *open_lookup(const char *name, const char *err_prefix,
1627 if (!(dh = dlopen(fnbuf, RTLD_NOW))) {
1629 - crit(LOGOPT_ANY, "%scannot open lookup module %s (%s)",
1630 + logerr("%scannot open lookup module %s (%s)",
1631 err_prefix, name, dlerror());
1634 @@ -100,8 +100,7 @@ struct lookup_mod *open_lookup(const char *name, const char *err_prefix,
1635 if (!(ver = (int *) dlsym(dh, "lookup_version"))
1636 || *ver != AUTOFS_LOOKUP_VERSION) {
1639 - "%slookup module %s version mismatch",
1640 + logerr("%slookup module %s version mismatch",
1644 @@ -114,7 +113,7 @@ struct lookup_mod *open_lookup(const char *name, const char *err_prefix,
1645 !(mod->lookup_mount = (lookup_mount_t) dlsym(dh, "lookup_mount")) ||
1646 !(mod->lookup_done = (lookup_done_t) dlsym(dh, "lookup_done"))) {
1648 - crit(LOGOPT_ANY, "%slookup module %s corrupt", err_prefix, name);
1649 + logerr("%slookup module %s corrupt", err_prefix, name);
1653 @@ -156,7 +155,7 @@ struct parse_mod *open_parse(const char *name, const char *err_prefix,
1656 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1657 - crit(LOGOPT_ANY, "%s%s", err_prefix, estr);
1658 + logerr("%s%s", err_prefix, estr);
1662 @@ -167,7 +166,7 @@ struct parse_mod *open_parse(const char *name, const char *err_prefix,
1665 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1666 - crit(LOGOPT_ANY, "%s%s", err_prefix, estr);
1667 + logerr("%s%s", err_prefix, estr);
1671 @@ -175,8 +174,7 @@ struct parse_mod *open_parse(const char *name, const char *err_prefix,
1673 if (!(dh = dlopen(fnbuf, RTLD_NOW))) {
1676 - "%scannot open parse module %s (%s)",
1677 + logerr("%scannot open parse module %s (%s)",
1678 err_prefix, name, dlerror());
1681 @@ -185,8 +183,7 @@ struct parse_mod *open_parse(const char *name, const char *err_prefix,
1682 if (!(ver = (int *) dlsym(dh, "parse_version"))
1683 || *ver != AUTOFS_PARSE_VERSION) {
1686 - "%sparse module %s version mismatch",
1687 + logerr("%sparse module %s version mismatch",
1691 @@ -197,8 +194,7 @@ struct parse_mod *open_parse(const char *name, const char *err_prefix,
1692 !(mod->parse_mount = (parse_mount_t) dlsym(dh, "parse_mount")) ||
1693 !(mod->parse_done = (parse_done_t) dlsym(dh, "parse_done"))) {
1696 - "%sparse module %s corrupt",
1697 + logerr("%sparse module %s corrupt",
1701 @@ -240,7 +236,7 @@ struct mount_mod *open_mount(const char *name, const char *err_prefix)
1704 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1705 - crit(LOGOPT_ANY, "%s%s", err_prefix, estr);
1706 + logerr("%s%s", err_prefix, estr);
1710 @@ -251,7 +247,7 @@ struct mount_mod *open_mount(const char *name, const char *err_prefix)
1713 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1714 - crit(LOGOPT_ANY, "%s%s", err_prefix, estr);
1715 + logerr("%s%s", err_prefix, estr);
1719 @@ -259,8 +255,7 @@ struct mount_mod *open_mount(const char *name, const char *err_prefix)
1721 if (!(dh = dlopen(fnbuf, RTLD_NOW))) {
1724 - "%scannot open mount module %s (%s)",
1725 + logerr("%scannot open mount module %s (%s)",
1726 err_prefix, name, dlerror());
1729 @@ -269,8 +264,7 @@ struct mount_mod *open_mount(const char *name, const char *err_prefix)
1730 if (!(ver = (int *) dlsym(dh, "mount_version"))
1731 || *ver != AUTOFS_MOUNT_VERSION) {
1734 - "%smount module %s version mismatch",
1735 + logerr("%smount module %s version mismatch",
1739 @@ -281,8 +275,7 @@ struct mount_mod *open_mount(const char *name, const char *err_prefix)
1740 !(mod->mount_mount = (mount_mount_t) dlsym(dh, "mount_mount")) ||
1741 !(mod->mount_done = (mount_done_t) dlsym(dh, "mount_done"))) {
1744 - "%smount module %s corrupt",
1745 + logerr("%smount module %s corrupt",
1749 diff --git a/daemon/spawn.c b/daemon/spawn.c
1750 index 271d37e..3d5ea56 100644
1751 --- a/daemon/spawn.c
1752 +++ b/daemon/spawn.c
1753 @@ -88,7 +88,7 @@ void reset_signals(void)
1755 #define ERRBUFSIZ 2047 /* Max length of error string excl \0 */
1757 -static int do_spawn(logger *log, unsigned int options, const char *prog, const char *const *argv)
1758 +static int do_spawn(unsigned logopt, unsigned int options, const char *prog, const char *const *argv)
1761 int ret, status, pipefd[2];
1762 @@ -195,7 +195,7 @@ static int do_spawn(logger *log, unsigned int options, const char *prog, const c
1763 while (errp && (p = memchr(sp, '\n', errp))) {
1765 if (sp[0]) /* Don't output empty lines */
1766 - log(LOGOPT_ANY, ">> %s", sp);
1767 + warn(logopt, ">> %s", sp);
1771 @@ -206,7 +206,7 @@ static int do_spawn(logger *log, unsigned int options, const char *prog, const c
1772 if (errp >= ERRBUFSIZ) {
1773 /* Line too long, split */
1774 errbuf[errp] = '\0';
1775 - log(LOGOPT_ANY, ">> %s", errbuf);
1776 + warn(logopt, ">> %s", errbuf);
1780 @@ -217,7 +217,7 @@ static int do_spawn(logger *log, unsigned int options, const char *prog, const c
1782 /* End of file without \n */
1783 errbuf[errp] = '\0';
1784 - log(LOGOPT_ANY, ">> %s", errbuf);
1785 + warn(logopt, ">> %s", errbuf);
1788 if (waitpid(f, &ret, 0) != f)
1789 @@ -235,12 +235,12 @@ static int do_spawn(logger *log, unsigned int options, const char *prog, const c
1793 -int spawnv(logger *log, const char *prog, const char *const *argv)
1794 +int spawnv(unsigned logopt, const char *prog, const char *const *argv)
1796 - return do_spawn(log, SPAWN_OPT_NONE, prog, argv);
1797 + return do_spawn(logopt, SPAWN_OPT_NONE, prog, argv);
1800 -int spawnl(logger *log, const char *prog, ...)
1801 +int spawnl(unsigned logopt, const char *prog, ...)
1805 @@ -258,10 +258,10 @@ int spawnl(logger *log, const char *prog, ...)
1806 while ((*p++ = va_arg(arg, char *)));
1809 - return do_spawn(log, SPAWN_OPT_NONE, prog, (const char **) argv);
1810 + return do_spawn(logopt, SPAWN_OPT_NONE, prog, (const char **) argv);
1813 -int spawn_mount(logger *log, ...)
1814 +int spawn_mount(unsigned logopt, ...)
1818 @@ -279,7 +279,7 @@ int spawn_mount(logger *log, ...)
1819 options = SPAWN_OPT_NONE;
1822 - va_start(arg, log);
1823 + va_start(arg, logopt);
1824 for (argc = 1; va_arg(arg, char *); argc++);
1827 @@ -288,13 +288,13 @@ int spawn_mount(logger *log, ...)
1831 - va_start(arg, log);
1832 + va_start(arg, logopt);
1834 while ((*p++ = va_arg(arg, char *)));
1838 - ret = do_spawn(log, options, prog, (const char **) argv);
1839 + ret = do_spawn(logopt, options, prog, (const char **) argv);
1840 if (ret & MTAB_NOTUPDATED)
1843 @@ -311,7 +311,7 @@ int spawn_mount(logger *log, ...)
1844 * NOTE: If mount locking is enabled this type of recursive mount cannot
1847 -int spawn_bind_mount(logger *log, ...)
1848 +int spawn_bind_mount(unsigned logopt, ...)
1852 @@ -330,7 +330,7 @@ int spawn_bind_mount(logger *log, ...)
1853 options = SPAWN_OPT_ACCESS;
1856 - va_start(arg, log);
1857 + va_start(arg, logopt);
1858 for (argc = 1; va_arg(arg, char *); argc++);
1861 @@ -340,13 +340,13 @@ int spawn_bind_mount(logger *log, ...)
1865 - va_start(arg, log);
1866 + va_start(arg, logopt);
1868 while ((*p++ = va_arg(arg, char *)));
1872 - ret = do_spawn(log, options, prog, (const char **) argv);
1873 + ret = do_spawn(logopt, options, prog, (const char **) argv);
1874 if (ret & MTAB_NOTUPDATED)
1877 @@ -355,7 +355,7 @@ int spawn_bind_mount(logger *log, ...)
1881 -int spawn_umount(logger *log, ...)
1882 +int spawn_umount(unsigned logopt, ...)
1886 @@ -372,7 +372,7 @@ int spawn_umount(logger *log, ...)
1887 options = SPAWN_OPT_NONE;
1890 - va_start(arg, log);
1891 + va_start(arg, logopt);
1892 for (argc = 1; va_arg(arg, char *); argc++);
1895 @@ -381,13 +381,13 @@ int spawn_umount(logger *log, ...)
1899 - va_start(arg, log);
1900 + va_start(arg, logopt);
1902 while ((*p++ = va_arg(arg, char *)));
1906 - ret = do_spawn(log, options, prog, (const char **) argv);
1907 + ret = do_spawn(logopt, options, prog, (const char **) argv);
1908 if (ret & MTAB_NOTUPDATED)
1911 diff --git a/daemon/state.c b/daemon/state.c
1912 index 39f4497..a2da762 100644
1913 --- a/daemon/state.c
1914 +++ b/daemon/state.c
1915 @@ -58,22 +58,20 @@ void dump_state_queue(void)
1916 struct list_head *head = &state_queue;
1917 struct list_head *p, *q;
1919 - debug(LOGOPT_ANY, "dumping queue");
1920 + logmsg("dumping queue");
1922 list_for_each(p, head) {
1923 struct state_queue *entry;
1925 entry = list_entry(p, struct state_queue, list);
1927 - "queue list head path %s state %d busy %d",
1928 + logmsg("queue list head path %s state %d busy %d",
1929 entry->ap->path, entry->state, entry->busy);
1931 list_for_each(q, &entry->pending) {
1932 struct state_queue *this;
1934 this = list_entry(q, struct state_queue, pending);
1936 - "queue list entry path %s state %d busy %d",
1937 + logmsg("queue list entry path %s state %d busy %d",
1938 this->ap->path, this->state, this->busy);
1941 @@ -85,7 +83,7 @@ void nextstate(int statefd, enum states next)
1943 if (write(statefd, &next, sizeof(next)) != sizeof(next)) {
1944 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
1945 - error(LOGOPT_ANY, "write failed %s", estr);
1946 + logerr("write failed %s", estr);
1950 diff --git a/include/automount.h b/include/automount.h
1951 index d55ba5c..37a3c0a 100644
1952 --- a/include/automount.h
1953 +++ b/include/automount.h
1954 @@ -131,6 +131,7 @@ struct mapent_cache {
1956 pthread_mutex_t ino_index_mutex;
1957 struct list_head *ino_index;
1958 + struct autofs_point *ap;
1959 struct map_source *map;
1960 struct mapent **hash;
1962 @@ -164,7 +165,7 @@ void cache_readlock(struct mapent_cache *mc);
1963 void cache_writelock(struct mapent_cache *mc);
1964 int cache_try_writelock(struct mapent_cache *mc);
1965 void cache_unlock(struct mapent_cache *mc);
1966 -struct mapent_cache *cache_init(struct map_source *map);
1967 +struct mapent_cache *cache_init(struct autofs_point *ap, struct map_source *map);
1968 struct mapent_cache *cache_init_null_cache(struct master *master);
1969 int cache_set_ino_index(struct mapent_cache *mc, const char *key, dev_t dev, ino_t ino);
1970 /* void cache_set_ino(struct mapent *me, dev_t dev, ino_t ino); */
1971 @@ -200,11 +201,11 @@ int free_argv(int argc, const char **argv);
1972 inline void dump_core(void);
1973 int aquire_lock(void);
1974 void release_lock(void);
1975 -int spawnl(logger *log, const char *prog, ...);
1976 -int spawnv(logger *log, const char *prog, const char *const *argv);
1977 -int spawn_mount(logger *log, ...);
1978 -int spawn_bind_mount(logger *log, ...);
1979 -int spawn_umount(logger *log, ...);
1980 +int spawnl(unsigned logopt, const char *prog, ...);
1981 +int spawnv(unsigned logopt, const char *prog, const char *const *argv);
1982 +int spawn_mount(unsigned logopt, ...);
1983 +int spawn_bind_mount(unsigned logopt, ...);
1984 +int spawn_umount(unsigned logopt, ...);
1985 void reset_signals(void);
1986 int do_mount(struct autofs_point *ap, const char *root, const char *name,
1987 int name_len, const char *what, const char *fstype,
1988 @@ -222,6 +223,8 @@ int rmdir_path(struct autofs_point *ap, const char *path, dev_t dev);
1989 #define MAPENT_MAX_LEN 4095
1990 #define PARSE_MAX_BUF KEY_MAX_LEN + MAPENT_MAX_LEN + 2
1992 +#define AUTOFS_LOGPRI_FIFO "/tmp/autofs.fifo"
1994 int lookup_nss_read_master(struct master *master, time_t age);
1995 int lookup_nss_read_map(struct autofs_point *ap, struct map_source *source, time_t age);
1996 int lookup_enumerate(struct autofs_point *ap,
1997 @@ -435,6 +438,7 @@ struct autofs_point {
1998 int pipefd; /* File descriptor for pipe */
1999 int kpipefd; /* Kernel end descriptor for pipe */
2000 int ioctlfd; /* File descriptor for ioctls */
2001 + int logpri_fifo; /* FIFO used for changing log levels */
2002 dev_t dev; /* "Device" number assigned by kernel */
2003 struct master_mapent *entry; /* Master map entry for this mount */
2004 unsigned int type; /* Type of map direct or indirect */
2005 @@ -464,8 +468,8 @@ struct autofs_point {
2007 void *handle_mounts(void *arg);
2008 int umount_multi(struct autofs_point *ap, const char *path, int incl);
2009 -int send_ready(int ioctlfd, unsigned int wait_queue_token);
2010 -int send_fail(int ioctlfd, unsigned int wait_queue_token);
2011 +int send_ready(unsigned logopt, int ioctlfd, unsigned int wait_queue_token);
2012 +int send_fail(unsigned logopt, int ioctlfd, unsigned int wait_queue_token);
2013 int do_expire(struct autofs_point *ap, const char *name, int namelen);
2014 void *expire_proc_indirect(void *);
2015 void *expire_proc_direct(void *);
2016 @@ -483,8 +487,8 @@ int handle_packet_expire_indirect(struct autofs_point *ap, autofs_packet_expire_
2017 int handle_packet_expire_direct(struct autofs_point *ap, autofs_packet_expire_direct_t *pkt);
2018 int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missing_indirect_t *pkt);
2019 int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_direct_t *pkt);
2020 -void rm_unwanted(const char *path, int incl, dev_t dev);
2021 -int count_mounts(const char *path, dev_t dev);
2022 +void rm_unwanted(unsigned logopt, const char *path, int incl, dev_t dev);
2023 +int count_mounts(unsigned logopt, const char *path, dev_t dev);
2025 #define state_mutex_lock(ap) \
2027 diff --git a/include/log.h b/include/log.h
2028 index 3276cca..6a4a942 100644
2032 /* Define logging functions */
2034 #define LOGOPT_NONE 0x0000
2035 +#define LOGOPT_ERROR 0x0000
2036 #define LOGOPT_DEBUG 0x0001
2037 #define LOGOPT_VERBOSE 0x0002
2038 #define LOGOPT_ANY (LOGOPT_DEBUG | LOGOPT_VERBOSE)
2039 @@ -29,34 +30,33 @@ struct autofs_point;
2040 extern void set_log_norm(void);
2041 extern void set_log_verbose(void);
2042 extern void set_log_debug(void);
2043 -extern void set_mnt_logging(struct autofs_point *);
2044 +extern void set_log_norm_ap(struct autofs_point *ap);
2045 +extern void set_log_verbose_ap(struct autofs_point *ap);
2046 +extern void set_log_debug_ap(struct autofs_point *ap);
2047 +extern void set_mnt_logging(unsigned global_logopt);
2049 extern void log_to_syslog(void);
2050 extern void log_to_stderr(void);
2052 -typedef void logger(unsigned int logopt, const char* msg, ...);
2054 -extern void (*log_info)(unsigned int, const char* msg, ...);
2055 -extern void (*log_notice)(unsigned int, const char* msg, ...);
2056 -extern void (*log_warn)(unsigned int, const char* msg, ...);
2057 -extern void (*log_error)(unsigned int, const char* msg, ...);
2058 -extern void (*log_crit)(unsigned int, const char* msg, ...);
2059 -extern void (*log_debug)(unsigned int, const char* msg, ...);
2061 -#define msg(msg, args...) \
2062 - do { log_info(LOGOPT_NONE, msg, ##args); } while (0)
2063 +extern void log_info(unsigned int, const char* msg, ...);
2064 +extern void log_notice(unsigned int, const char* msg, ...);
2065 +extern void log_warn(unsigned int, const char* msg, ...);
2066 +extern void log_error(unsigned, const char* msg, ...);
2067 +extern void log_crit(unsigned, const char* msg, ...);
2068 +extern void log_debug(unsigned int, const char* msg, ...);
2069 +extern void logmsg(const char* msg, ...);
2071 #define debug(opt, msg, args...) \
2072 do { log_debug(opt, "%s: " msg, __FUNCTION__, ##args); } while (0)
2074 -#define info(opt, msg, args...) \
2075 - do { log_info(opt, "%s: " msg, __FUNCTION__, ##args); } while (0)
2076 +#define info(opt, msg, args...) \
2077 + do { log_info(opt, msg, ##args); } while (0)
2079 #define notice(opt, msg, args...) \
2080 - do { log_notice(opt, "%s: " msg, __FUNCTION__, ##args); } while (0)
2081 + do { log_notice(opt, msg, ##args); } while (0)
2083 -#define warn(opt, msg, args...) \
2084 - do { log_warn(opt, "%s: " msg, __FUNCTION__, ##args); } while (0)
2085 +#define warn(opt, msg, args...) \
2086 + do { log_warn(opt, msg, ##args); } while (0)
2088 #define error(opt, msg, args...) \
2089 do { log_error(opt, "%s: " msg, __FUNCTION__, ##args); } while (0)
2090 @@ -64,17 +64,18 @@ extern void (*log_debug)(unsigned int, const char* msg, ...);
2091 #define crit(opt, msg, args...) \
2092 do { log_crit(opt, "%s: " msg, __FUNCTION__, ##args); } while (0)
2094 +#define logerr(msg, args...) \
2095 + do { logmsg("%s:%d: " msg, __FUNCTION__, __LINE__, ##args); } while (0)
2097 #define fatal(status) \
2099 if (status == EDEADLK) { \
2100 - log_crit(LOGOPT_ANY, \
2101 - "%s: deadlock detected " \
2102 + logmsg("deadlock detected " \
2103 "at line %d in %s, dumping core.", \
2104 - __FUNCTION__, __LINE__, __FILE__); \
2105 + __LINE__, __FILE__); \
2108 - log_crit(LOGOPT_ANY, \
2109 - "unexpected pthreads error: %d at %d " \
2110 + logmsg("unexpected pthreads error: %d at %d " \
2111 "in %s", status, __LINE__, __FILE__); \
2114 @@ -83,7 +84,7 @@ extern void (*log_debug)(unsigned int, const char* msg, ...);
2118 - log_crit(LOGOPT_ANY, __FILE__ \
2120 ":%d: assertion failed: " #x, __LINE__); \
2123 diff --git a/include/lookup_ldap.h b/include/lookup_ldap.h
2124 index ca8d658..5b5c475 100644
2125 --- a/include/lookup_ldap.h
2126 +++ b/include/lookup_ldap.h
2127 @@ -94,13 +94,13 @@ struct lookup_context {
2128 #define LDAP_AUTH_AUTODETECT 0x0004
2131 -LDAP *init_ldap_connection(const char *uri, struct lookup_context *ctxt);
2132 -int unbind_ldap_connection(LDAP *ldap, struct lookup_context *ctxt);
2133 +LDAP *init_ldap_connection(unsigned logopt, const char *uri, struct lookup_context *ctxt);
2134 +int unbind_ldap_connection(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt);
2135 int authtype_requires_creds(const char *authtype);
2138 -int autofs_sasl_init(LDAP *ldap, struct lookup_context *ctxt);
2139 -int autofs_sasl_bind(LDAP *ldap, struct lookup_context *ctxt);
2140 +int autofs_sasl_init(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt);
2141 +int autofs_sasl_bind(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt);
2142 void autofs_sasl_unbind(struct lookup_context *ctxt);
2143 void autofs_sasl_done(struct lookup_context *ctxt);
2145 diff --git a/include/master.h b/include/master.h
2146 index 8470bb1..5f10d1f 100644
2147 --- a/include/master.h
2148 +++ b/include/master.h
2149 @@ -62,6 +62,7 @@ struct master {
2150 unsigned int default_ghost;
2151 unsigned int default_logging;
2152 unsigned int default_timeout;
2153 + unsigned int logopt;
2154 struct mapent_cache *nc;
2155 struct list_head mounts;
2157 @@ -106,6 +107,7 @@ int master_notify_submount(struct autofs_point *, const char *path, enum states)
2158 void master_signal_submount(struct autofs_point *, unsigned int);
2159 void master_notify_state_change(struct master *, int);
2160 int master_mount_mounts(struct master *, time_t, int);
2161 +extern inline unsigned int master_get_logopt(void);
2162 int master_list_empty(struct master *);
2163 int master_kill(struct master *);
2165 diff --git a/include/replicated.h b/include/replicated.h
2166 index 3afe9f7..672f853 100644
2167 --- a/include/replicated.h
2168 +++ b/include/replicated.h
2169 @@ -62,8 +62,8 @@ struct host {
2171 void seed_random(void);
2172 void free_host_list(struct host **);
2173 -int parse_location(struct host **, const char *);
2174 -int prune_host_list(struct host **, unsigned int, const char *, unsigned int);
2175 +int parse_location(unsigned, struct host **, const char *);
2176 +int prune_host_list(unsigned, struct host **, unsigned int, const char *, unsigned int);
2177 void dump_host_list(struct host *);
2180 diff --git a/lib/alarm.c b/lib/alarm.c
2181 index 90bf7aa..6a70ed1 100755
2184 @@ -51,7 +51,7 @@ void dump_alarms(void)
2187 this = list_entry(p, struct alarm, list);
2188 - msg("alarm time = %d", this->time);
2189 + logmsg("alarm time = %d", this->time);
2191 pthread_mutex_unlock(&mutex);
2193 diff --git a/lib/args.c b/lib/args.c
2194 index fbfb004..9616598 100644
2197 @@ -37,7 +37,7 @@ char **add_argv(int argc, char **argv, char *str)
2199 vector[i] = strdup(argv[i]);
2201 - error(LOGOPT_ANY, "failed to strdup arg");
2202 + logerr("failed to strdup arg");
2206 @@ -81,7 +81,7 @@ char **append_argv(int argc1, char **argv1, int argc2, char **argv2)
2208 vector[i] = strdup(argv2[j]);
2210 - error(LOGOPT_ANY, "failed to strdup arg");
2211 + logerr("failed to strdup arg");
2215 @@ -116,7 +116,7 @@ const char **copy_argv(int argc, const char **argv)
2217 vector[i] = strdup(argv[i]);
2219 - error(LOGOPT_ANY, "failed to strdup arg");
2220 + logerr("failed to strdup arg");
2224 diff --git a/lib/cache.c b/lib/cache.c
2225 index 06bb461..55586a3 100644
2228 @@ -34,7 +34,7 @@ void cache_dump_multi(struct list_head *list)
2230 list_for_each(p, list) {
2231 me = list_entry(p, struct mapent, multi_list);
2232 - msg("key=%s", me->key);
2233 + logmsg("key=%s", me->key);
2237 @@ -48,7 +48,7 @@ void cache_dump_cache(struct mapent_cache *mc)
2241 - msg("me->key=%s me->multi=%p dev=%ld ino=%ld",
2242 + logmsg("me->key=%s me->multi=%p dev=%ld ino=%ld",
2243 me->key, me->multi, me->dev, me->ino);
2246 @@ -61,7 +61,7 @@ void cache_readlock(struct mapent_cache *mc)
2248 status = pthread_rwlock_rdlock(&mc->rwlock);
2250 - error(LOGOPT_ANY, "mapent cache rwlock lock failed");
2251 + logmsg("mapent cache rwlock lock failed");
2255 @@ -73,7 +73,7 @@ void cache_writelock(struct mapent_cache *mc)
2257 status = pthread_rwlock_wrlock(&mc->rwlock);
2259 - error(LOGOPT_ANY, "mapent cache rwlock lock failed");
2260 + logmsg("mapent cache rwlock lock failed");
2264 @@ -85,7 +85,7 @@ int cache_try_writelock(struct mapent_cache *mc)
2266 status = pthread_rwlock_trywrlock(&mc->rwlock);
2268 - debug(LOGOPT_ANY, "mapent cache rwlock busy");
2269 + logmsg("mapent cache rwlock busy");
2273 @@ -97,7 +97,7 @@ void cache_unlock(struct mapent_cache *mc)
2275 status = pthread_rwlock_unlock(&mc->rwlock);
2277 - error(LOGOPT_ANY, "mapent cache rwlock unlock failed");
2278 + logmsg("mapent cache rwlock unlock failed");
2282 @@ -120,7 +120,7 @@ void cache_multi_lock(struct mapent *me)
2284 status = pthread_mutex_lock(&me->multi_mutex);
2286 - error(LOGOPT_ANY, "mapent cache multi mutex lock failed");
2287 + logmsg("mapent cache multi mutex lock failed");
2291 @@ -135,7 +135,7 @@ void cache_multi_unlock(struct mapent *me)
2293 status = pthread_mutex_unlock(&me->multi_mutex);
2295 - error(LOGOPT_ANY, "mapent cache multi mutex unlock failed");
2296 + logmsg("mapent cache multi mutex unlock failed");
2300 @@ -164,7 +164,7 @@ static inline void ino_index_unlock(struct mapent_cache *mc)
2304 -struct mapent_cache *cache_init(struct map_source *map)
2305 +struct mapent_cache *cache_init(struct autofs_point *ap, struct map_source *map)
2307 struct mapent_cache *mc;
2309 @@ -207,6 +207,7 @@ struct mapent_cache *cache_init(struct map_source *map)
2310 INIT_LIST_HEAD(&mc->ino_index[i]);
2317 @@ -257,6 +258,9 @@ struct mapent_cache *cache_init_null_cache(struct master *master)
2318 INIT_LIST_HEAD(&mc->ino_index[i]);
2327 @@ -608,6 +612,7 @@ static void cache_add_ordered_offset(struct mapent *me, struct list_head *head)
2328 /* cache must be write locked by caller */
2329 int cache_add_offset(struct mapent_cache *mc, const char *mkey, const char *key, const char *mapent, time_t age)
2331 + unsigned logopt = mc->ap ? mc->ap->logopt : master_get_logopt();
2332 struct mapent *me, *owner;
2335 @@ -621,7 +626,7 @@ int cache_add_offset(struct mapent_cache *mc, const char *mkey, const char *key,
2337 ret = cache_add(mc, owner->source, key, mapent, age);
2338 if (ret == CHE_FAIL) {
2339 - warn(LOGOPT_ANY, "failed to add key %s to cache", key);
2340 + warn(logopt, "failed to add key %s to cache", key);
2344 @@ -689,6 +694,7 @@ int cache_set_parents(struct mapent *mm)
2345 /* cache must be write locked by caller */
2346 int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key, const char *mapent, time_t age)
2348 + unsigned logopt = mc->ap ? mc->ap->logopt : master_get_logopt();
2349 struct mapent *me = NULL;
2352 @@ -697,7 +703,7 @@ int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key
2353 if (!me || (*me->key == '*' && *key != '*')) {
2354 ret = cache_add(mc, ms, key, mapent, age);
2356 - debug(LOGOPT_NONE, "failed for %s", key);
2357 + debug(logopt, "failed for %s", key);
2361 @@ -796,6 +802,7 @@ done:
2362 /* cache must be write locked by caller */
2363 int cache_delete_offset_list(struct mapent_cache *mc, const char *key)
2365 + unsigned logopt = mc->ap ? mc->ap->logopt : master_get_logopt();
2367 struct mapent *this;
2368 struct list_head *head, *next;
2369 @@ -816,7 +823,7 @@ int cache_delete_offset_list(struct mapent_cache *mc, const char *key)
2370 this = list_entry(next, struct mapent, multi_list);
2372 if (this->ioctlfd != -1) {
2375 "active offset mount key %s", this->key);
2378 @@ -829,10 +836,10 @@ int cache_delete_offset_list(struct mapent_cache *mc, const char *key)
2380 list_del_init(&this->multi_list);
2382 - debug(LOGOPT_NONE, "deleting offset key %s", this->key);
2383 + debug(logopt, "deleting offset key %s", this->key);
2384 status = cache_delete(mc, this->key);
2385 if (status == CHE_FAIL) {
2388 "failed to delete offset %s", this->key);
2390 /* TODO: add list back in */
2391 diff --git a/lib/defaults.c b/lib/defaults.c
2392 index 2cccf20..94885e8 100644
2393 --- a/lib/defaults.c
2394 +++ b/lib/defaults.c
2395 @@ -105,17 +105,22 @@ static int get_env_yesno(const char *name)
2396 * We've changed the key names so we need to check for the
2397 * config key and it's old name for backward conpatibility.
2399 -static int check_set_config_value(const char *res, const char *name, const char *value)
2400 +static int check_set_config_value(const char *res, const char *name, const char *value, unsigned to_syslog)
2405 if (!strcasecmp(res, name)) {
2406 ret = setenv(name, value, 0);
2409 - "can't set config value for %s, "
2410 - "error %d", name, ret);
2414 + "can't set config value for %s, "
2415 + "error %d\n", name, ret);
2417 + logmsg("can't set config value for %s, "
2418 + "error %d", name, ret);
2423 @@ -125,10 +130,15 @@ static int check_set_config_value(const char *res, const char *name, const char
2425 if (!strcasecmp(res, old_name)) {
2426 ret = setenv(name, value, 0);
2429 - "can't set config value for %s, "
2430 - "error %d", name, ret);
2434 + "can't set config value for %s, "
2435 + "error %d\n", name, ret);
2437 + logmsg("can't set config value for %s, "
2438 + "error %d\n", name, ret);
2443 @@ -296,19 +306,19 @@ unsigned int defaults_read_config(unsigned int to_syslog)
2444 if (!parse_line(res, &key, &value))
2447 - if (check_set_config_value(key, ENV_NAME_MASTER_MAP, value) ||
2448 - check_set_config_value(key, ENV_NAME_TIMEOUT, value) ||
2449 - check_set_config_value(key, ENV_NAME_BROWSE_MODE, value) ||
2450 - check_set_config_value(key, ENV_NAME_LOGGING, value) ||
2451 - check_set_config_value(key, ENV_LDAP_TIMEOUT, value) ||
2452 - check_set_config_value(key, ENV_LDAP_NETWORK_TIMEOUT, value) ||
2453 - check_set_config_value(key, ENV_NAME_MAP_OBJ_CLASS, value) ||
2454 - check_set_config_value(key, ENV_NAME_ENTRY_OBJ_CLASS, value) ||
2455 - check_set_config_value(key, ENV_NAME_MAP_ATTR, value) ||
2456 - check_set_config_value(key, ENV_NAME_ENTRY_ATTR, value) ||
2457 - check_set_config_value(key, ENV_NAME_VALUE_ATTR, value) ||
2458 - check_set_config_value(key, ENV_APPEND_OPTIONS, value) ||
2459 - check_set_config_value(key, ENV_AUTH_CONF_FILE, value))
2460 + if (check_set_config_value(key, ENV_NAME_MASTER_MAP, value, to_syslog) ||
2461 + check_set_config_value(key, ENV_NAME_TIMEOUT, value, to_syslog) ||
2462 + check_set_config_value(key, ENV_NAME_BROWSE_MODE, value, to_syslog) ||
2463 + check_set_config_value(key, ENV_NAME_LOGGING, value, to_syslog) ||
2464 + check_set_config_value(key, ENV_LDAP_TIMEOUT, value, to_syslog) ||
2465 + check_set_config_value(key, ENV_LDAP_NETWORK_TIMEOUT, value, to_syslog) ||
2466 + check_set_config_value(key, ENV_NAME_MAP_OBJ_CLASS, value, to_syslog) ||
2467 + check_set_config_value(key, ENV_NAME_ENTRY_OBJ_CLASS, value, to_syslog) ||
2468 + check_set_config_value(key, ENV_NAME_MAP_ATTR, value, to_syslog) ||
2469 + check_set_config_value(key, ENV_NAME_ENTRY_ATTR, value, to_syslog) ||
2470 + check_set_config_value(key, ENV_NAME_VALUE_ATTR, value, to_syslog) ||
2471 + check_set_config_value(key, ENV_APPEND_OPTIONS, value, to_syslog) ||
2472 + check_set_config_value(key, ENV_AUTH_CONF_FILE, value, to_syslog))
2476 @@ -318,8 +328,7 @@ unsigned int defaults_read_config(unsigned int to_syslog)
2477 "fgets returned error %d while reading %s\n",
2478 ferror(f), DEFAULTS_CONFIG_FILE);
2481 - "fgets returned error %d while reading %s",
2482 + logmsg("fgets returned error %d while reading %s",
2483 ferror(f), DEFAULTS_CONFIG_FILE);
2486 diff --git a/lib/log.c b/lib/log.c
2487 index b747e12..65e8ad2 100644
2492 #include "automount.h"
2495 -struct syslog_data syslog_context = AUTOFS_SYSLOG_CONTEXT;
2496 -struct syslog_data *slc = &syslog_context;
2499 static unsigned int syslog_open = 0;
2500 static unsigned int logging_to_syslog = 0;
2502 @@ -39,32 +34,44 @@ static unsigned int logging_to_syslog = 0;
2503 static unsigned int do_verbose = 0; /* Verbose feedback option */
2504 static unsigned int do_debug = 0; /* Full debug output */
2506 -static void null(unsigned int logopt, const char *msg, ...) { }
2508 -void (*log_info)(unsigned int logopt, const char* msg, ...) = null;
2509 -void (*log_notice)(unsigned int logopt, const char* msg, ...) = null;
2510 -void (*log_warn)(unsigned int logopt, const char* msg, ...) = null;
2511 -void (*log_error)(unsigned int logopt, const char* msg, ...) = null;
2512 -void (*log_crit)(unsigned int logopt, const char* msg, ...) = null;
2513 -void (*log_debug)(unsigned int logopt, const char* msg, ...) = null;
2515 void set_log_norm(void)
2522 void set_log_verbose(void)
2528 void set_log_debug(void)
2534 +void set_log_norm_ap(struct autofs_point *ap)
2536 + ap->logopt = LOGOPT_ERROR;
2540 +void set_log_verbose_ap(struct autofs_point *ap)
2542 + ap->logopt = LOGOPT_VERBOSE;
2546 +void set_log_debug_ap(struct autofs_point *ap)
2548 + ap->logopt = LOGOPT_DEBUG;
2552 -static void syslog_info(unsigned int logopt, const char *msg, ...)
2553 +void log_info(unsigned int logopt, const char *msg, ...)
2555 unsigned int opt_log = logopt & (LOGOPT_DEBUG | LOGOPT_VERBOSE);
2557 @@ -73,11 +80,18 @@ static void syslog_info(unsigned int logopt, const char *msg, ...)
2561 - vsyslog(LOG_INFO, msg, ap);
2562 + if (logging_to_syslog)
2563 + vsyslog(LOG_INFO, msg, ap);
2565 + vfprintf(stderr, msg, ap);
2566 + fputc('\n', stderr);
2573 -static void syslog_notice(unsigned int logopt, const char *msg, ...)
2574 +void log_notice(unsigned int logopt, const char *msg, ...)
2576 unsigned int opt_log = logopt & (LOGOPT_DEBUG | LOGOPT_VERBOSE);
2578 @@ -86,11 +100,18 @@ static void syslog_notice(unsigned int logopt, const char *msg, ...)
2582 - vsyslog(LOG_NOTICE, msg, ap);
2583 + if (logging_to_syslog)
2584 + vsyslog(LOG_NOTICE, msg, ap);
2586 + vfprintf(stderr, msg, ap);
2587 + fputc('\n', stderr);
2594 -static void syslog_warn(unsigned int logopt, const char *msg, ...)
2595 +void log_warn(unsigned int logopt, const char *msg, ...)
2597 unsigned int opt_log = logopt & (LOGOPT_DEBUG | LOGOPT_VERBOSE);
2599 @@ -99,70 +120,79 @@ static void syslog_warn(unsigned int logopt, const char *msg, ...)
2603 - vsyslog(LOG_WARNING, msg, ap);
2604 + if (logging_to_syslog)
2605 + vsyslog(LOG_WARNING, msg, ap);
2607 + vfprintf(stderr, msg, ap);
2608 + fputc('\n', stderr);
2615 -static void syslog_err(unsigned int logopt, const char *msg, ...)
2616 +void log_error(unsigned logopt, const char *msg, ...)
2621 - vsyslog(LOG_ERR, msg, ap);
2622 + if (logging_to_syslog)
2623 + vsyslog(LOG_ERR, msg, ap);
2625 + vfprintf(stderr, msg, ap);
2626 + fputc('\n', stderr);
2632 -static void syslog_crit(unsigned int logopt, const char *msg, ...)
2633 +void log_crit(unsigned logopt, const char *msg, ...)
2638 - vsyslog(LOG_CRIT, msg, ap);
2639 + if (logging_to_syslog)
2640 + vsyslog(LOG_CRIT, msg, ap);
2642 + vfprintf(stderr, msg, ap);
2643 + fputc('\n', stderr);
2649 -static void syslog_debug(unsigned int logopt, const char *msg, ...)
2650 +void log_debug(unsigned int logopt, const char *msg, ...)
2652 + unsigned int opt_log = logopt & LOGOPT_DEBUG;
2655 - if (!do_debug && !(logopt & LOGOPT_DEBUG))
2656 + if (!do_debug && !opt_log)
2660 - vsyslog(LOG_DEBUG, msg, ap);
2661 + if (logging_to_syslog)
2662 + vsyslog(LOG_WARNING, msg, ap);
2664 + vfprintf(stderr, msg, ap);
2665 + fputc('\n', stderr);
2672 -static void to_stderr(unsigned int logopt, const char *msg, ...)
2673 +void logmsg(const char *msg, ...)
2677 - vfprintf(stderr, msg, ap);
2678 - fputc('\n',stderr);
2682 -void set_mnt_logging(struct autofs_point *ap)
2684 - unsigned int opt_verbose = ap->logopt & LOGOPT_VERBOSE;
2685 - unsigned int opt_debug = ap->logopt & LOGOPT_DEBUG;
2688 - if (logging_to_syslog)
2689 - log_debug = syslog_debug;
2691 - log_debug = to_stderr;
2694 - if (opt_verbose || opt_debug) {
2695 - if (logging_to_syslog) {
2696 - log_info = syslog_info;
2697 - log_notice = syslog_notice;
2698 - log_warn = syslog_warn;
2700 - log_info = to_stderr;
2701 - log_notice = to_stderr;
2702 - log_warn = to_stderr;
2704 + if (logging_to_syslog)
2705 + vsyslog(LOG_CRIT, msg, ap);
2707 + vfprintf(stderr, msg, ap);
2708 + fputc('\n', stderr);
2714 void log_to_syslog(void)
2715 @@ -175,31 +205,13 @@ void log_to_syslog(void)
2716 openlog("automount", LOG_PID, LOG_DAEMON);
2720 - log_debug = syslog_debug;
2724 - if (do_verbose || do_debug) {
2725 - log_info = syslog_info;
2726 - log_notice = syslog_notice;
2727 - log_warn = syslog_warn;
2730 - log_notice = null;
2734 - log_error = syslog_err;
2735 - log_crit = syslog_crit;
2737 logging_to_syslog = 1;
2739 /* Redirect all our file descriptors to /dev/null */
2740 nullfd = open("/dev/null", O_RDWR);
2742 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
2743 - syslog_crit(LOGOPT_ANY, "cannot open /dev/null: %s", estr);
2744 + fprintf(stderr, "cannot open /dev/null: %s", estr);
2748 @@ -207,13 +219,15 @@ void log_to_syslog(void)
2749 dup2(nullfd, STDOUT_FILENO) < 0 ||
2750 dup2(nullfd, STDERR_FILENO) < 0) {
2751 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
2752 - syslog_crit(LOGOPT_ANY,
2753 - "redirecting file descriptors failed: %s", estr);
2755 + "redirecting file descriptors failed: %s", estr);
2765 void log_to_stderr(void)
2766 @@ -223,23 +237,7 @@ void log_to_stderr(void)
2771 - log_debug = to_stderr;
2775 - if (do_verbose || do_debug) {
2776 - log_info = to_stderr;
2777 - log_notice = to_stderr;
2778 - log_warn = to_stderr;
2781 - log_notice = null;
2785 - log_error = to_stderr;
2786 - log_crit = to_stderr;
2788 logging_to_syslog = 0;
2792 diff --git a/lib/macros.c b/lib/macros.c
2793 index 936ae06..fa6db8e 100644
2796 @@ -50,8 +50,7 @@ void dump_table(struct substvar *table)
2800 - debug(LOGOPT_NONE,
2801 - "lv->def %s lv->val %s lv->next %p",
2802 + logmsg("lv->def %s lv->val %s lv->next %p",
2803 lv->def, lv->val, lv->next);
2806 diff --git a/lib/master.c b/lib/master.c
2807 index abc3bc2..2e24ad0 100644
2810 @@ -524,8 +524,7 @@ void master_source_writelock(struct master_mapent *entry)
2812 status = pthread_rwlock_wrlock(&entry->source_lock);
2815 - "master_mapent source write lock failed");
2816 + logmsg("master_mapent source write lock failed");
2820 @@ -537,8 +536,7 @@ void master_source_readlock(struct master_mapent *entry)
2822 status = pthread_rwlock_rdlock(&entry->source_lock);
2825 - "master_mapent source read lock failed");
2826 + logmsg("master_mapent source read lock failed");
2830 @@ -550,8 +548,7 @@ void master_source_unlock(struct master_mapent *entry)
2832 status = pthread_rwlock_unlock(&entry->source_lock);
2835 - "master_mapent source unlock failed");
2836 + logmsg("master_mapent source unlock failed");
2840 @@ -572,7 +569,7 @@ void master_source_current_wait(struct master_mapent *entry)
2842 status = pthread_mutex_lock(&entry->current_mutex);
2844 - error(LOGOPT_ANY, "entry current source lock failed");
2845 + logmsg("entry current source lock failed");
2849 @@ -580,8 +577,7 @@ void master_source_current_wait(struct master_mapent *entry)
2850 status = pthread_cond_wait(
2851 &entry->current_cond, &entry->current_mutex);
2854 - "entry current source condition wait failed");
2855 + logmsg("entry current source condition wait failed");
2859 @@ -595,14 +591,13 @@ void master_source_current_signal(struct master_mapent *entry)
2861 status = pthread_cond_signal(&entry->current_cond);
2864 - "entry current source condition signal failed");
2865 + logmsg("entry current source condition signal failed");
2869 status = pthread_mutex_unlock(&entry->current_mutex);
2871 - error(LOGOPT_ANY, "entry current source unlock failed");
2872 + logmsg("entry current source unlock failed");
2876 @@ -770,6 +765,7 @@ struct master *master_new(const char *name, unsigned int timeout, unsigned int g
2877 master->default_ghost = ghost;
2878 master->default_timeout = timeout;
2879 master->default_logging = defaults_get_logging();
2880 + master->logopt = master->default_logging;
2882 INIT_LIST_HEAD(&master->mounts);
2884 @@ -778,11 +774,12 @@ struct master *master_new(const char *name, unsigned int timeout, unsigned int g
2886 int master_read_master(struct master *master, time_t age, int readall)
2888 + unsigned int logopt = master->logopt;
2889 struct mapent_cache *nc;
2891 nc = cache_init_null_cache(master);
2895 "failed to init null map cache for %s", master->name);
2898 @@ -791,7 +788,7 @@ int master_read_master(struct master *master, time_t age, int readall)
2901 if (!lookup_nss_read_master(master, age)) {
2904 "can't read master map %s", master->name);
2907 @@ -802,7 +799,7 @@ int master_read_master(struct master *master, time_t age, int readall)
2909 if (list_empty(&master->mounts)) {
2910 master_mutex_unlock();
2911 - warn(LOGOPT_ANY, "no mounts in table");
2912 + warn(logopt, "no mounts in table");
2916 @@ -934,6 +931,7 @@ void master_notify_state_change(struct master *master, int sig)
2917 struct autofs_point *ap;
2918 struct list_head *p;
2919 int state_pipe, cur_state;
2920 + unsigned int logopt;
2922 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
2923 master_mutex_lock();
2924 @@ -944,6 +942,7 @@ void master_notify_state_change(struct master *master, int sig)
2925 entry = list_entry(p, struct master_mapent, list);
2928 + logopt = ap->logopt;
2930 state_mutex_lock(ap);
2932 @@ -978,7 +977,7 @@ void master_notify_state_change(struct master *master, int sig)
2935 if (next != ST_INVAL)
2938 "sig %d switching %s from %d to %d",
2939 sig, ap->path, ap->state, next);
2941 @@ -1230,6 +1229,11 @@ int master_list_empty(struct master *master)
2945 +inline unsigned int master_get_logopt(void)
2947 + return master_list ? master_list->logopt : LOGOPT_NONE;
2950 int master_kill(struct master *master)
2952 if (!list_empty(&master->mounts))
2953 @@ -1251,6 +1255,6 @@ void dump_master(struct master *master)
2954 head = &master->mounts;
2955 list_for_each(p, head) {
2956 struct master_mapent *this = list_entry(p, struct master_mapent, list);
2957 - debug(LOGOPT_ANY, "path %s", this->path);
2958 + logmsg("path %s", this->path);
2961 diff --git a/lib/master_parse.y b/lib/master_parse.y
2962 index 70b48be..a767f9e 100644
2963 --- a/lib/master_parse.y
2964 +++ b/lib/master_parse.y
2965 @@ -585,13 +585,13 @@ static char *master_strdup(char *str)
2967 static int master_error(const char *s)
2969 - error(LOGOPT_ANY, "%s while parsing map.", s);
2970 + logmsg("%s while parsing map.", s);
2974 static int master_notify(const char *s)
2976 - warn(LOGOPT_ANY, "syntax error in map near [ %s ]", s);
2977 + logmsg("syntax error in map near [ %s ]", s);
2981 @@ -704,6 +704,7 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
2982 struct master_mapent *entry, *new;
2983 struct map_source *source;
2984 unsigned int logopt = logging;
2985 + unsigned int m_logopt = master->logopt;
2989 @@ -758,8 +759,8 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
2991 if (entry->age && entry->age == age) {
2992 if (strcmp(path, "/-")) {
2993 - warn(LOGOPT_VERBOSE,
2994 - "ignoring duplicate indirect mount %s",
2996 + "ignoring duplicate indirect mount %s",
3000 @@ -770,13 +771,12 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
3002 ret = master_add_autofs_point(entry, timeout, logopt, ghost, 0);
3004 - error(LOGOPT_ANY, "failed to add autofs_point");
3005 + error(m_logopt, "failed to add autofs_point");
3007 master_free_mapent(new);
3011 - set_mnt_logging(entry->ap);
3013 struct autofs_point *ap = entry->ap;
3014 time_t tout = timeout;
3015 @@ -786,14 +786,11 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
3016 * use the ghost, log and timeout of the first
3018 if (entry->age < age) {
3019 - ap->ghost = ghost;
3020 - ap->logopt = logopt;
3021 ap->exp_timeout = timeout;
3022 ap->exp_runfreq = (ap->exp_timeout + CHECK_RATIO - 1) / CHECK_RATIO;
3023 if (ap->ioctlfd != -1 && ap->type == LKP_INDIRECT)
3024 ioctl(ap->ioctlfd, AUTOFS_IOC_SETTIMEOUT, &tout);
3026 - set_mnt_logging(ap);
3028 entry->ap->random_selection = random_selection;
3030 @@ -809,7 +806,7 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
3031 source = master_add_map_source(entry, type, format, age,
3032 local_argc, (const char **) local_argv);
3034 - error(LOGOPT_ANY, "failed to add source");
3035 + error(m_logopt, "failed to add source");
3037 master_free_mapent(new);
3039 @@ -817,9 +814,9 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
3043 - source->mc = cache_init(source);
3044 + source->mc = cache_init(entry->ap, source);
3046 - error(LOGOPT_ANY, "failed to init source cache");
3047 + error(m_logopt, "failed to init source cache");
3049 master_free_mapent(new);
3051 diff --git a/lib/master_tok.l b/lib/master_tok.l
3052 index 2735223..00cd223 100644
3053 --- a/lib/master_tok.l
3054 +++ b/lib/master_tok.l
3055 @@ -368,7 +368,7 @@ int master_wrap(void)
3057 static void master_echo(void)
3059 - debug(LOGOPT_NONE, "%s", master_text);
3060 + logmsg("%s", master_text);
3064 diff --git a/lib/mounts.c b/lib/mounts.c
3065 index 0e428e8..425a65a 100644
3068 @@ -126,7 +126,7 @@ char *make_options_string(char *path, int pipefd, char *extra)
3070 options = malloc(MAX_OPTIONS_LEN + 1);
3072 - crit(LOGOPT_ANY, "can't malloc options string");
3073 + logerr("can't malloc options string");
3077 @@ -141,13 +141,12 @@ char *make_options_string(char *path, int pipefd, char *extra)
3078 AUTOFS_MAX_PROTO_VERSION);
3080 if (len >= MAX_OPTIONS_LEN) {
3081 - crit(LOGOPT_ANY, "buffer to small for options - truncated");
3082 + logerr("buffer to small for options - truncated");
3083 len = MAX_OPTIONS_LEN - 1;
3088 - "failed to malloc autofs mount options for %s", path);
3089 + logerr("failed to malloc autofs mount options for %s", path);
3093 @@ -163,7 +162,7 @@ char *make_mnt_name_string(char *path)
3095 mnt_name = malloc(MAX_MNT_NAME_LEN + 1);
3097 - crit(LOGOPT_ANY, "can't malloc mnt_name string");
3098 + logerr("can't malloc mnt_name string");
3102 @@ -171,13 +170,12 @@ char *make_mnt_name_string(char *path)
3103 mnt_name_template, (unsigned) getpid());
3105 if (len >= MAX_MNT_NAME_LEN) {
3106 - crit(LOGOPT_ANY, "buffer to small for mnt_name - truncated");
3107 + logerr("buffer to small for mnt_name - truncated");
3108 len = MAX_MNT_NAME_LEN - 1;
3113 - "failed setting up mnt_name for autofs path %s", path);
3114 + logerr("failed setting up mnt_name for autofs path %s", path);
3118 @@ -207,7 +205,7 @@ struct mnt_list *get_mnt_list(const char *table, const char *path, int include)
3119 tab = setmntent(table, "r");
3121 char *estr = strerror_r(errno, buf, PATH_MAX - 1);
3122 - error(LOGOPT_ANY, "setmntent: %s", estr);
3123 + logerr("setmntent: %s", estr);
3127 @@ -398,7 +396,7 @@ int is_mounted(const char *table, const char *path, unsigned int type)
3128 tab = setmntent(table, "r");
3130 char *estr = strerror_r(errno, buf, PATH_MAX - 1);
3131 - error(LOGOPT_ANY, "setmntent: %s", estr);
3132 + logerr("setmntent: %s", estr);
3136 @@ -443,7 +441,7 @@ int has_fstab_option(const char *opt)
3137 tab = setmntent(_PATH_MNTTAB, "r");
3139 char *estr = strerror_r(errno, buf, PATH_MAX - 1);
3140 - error(LOGOPT_ANY, "setmntent: %s", estr);
3141 + logerr("setmntent: %s", estr);
3145 @@ -471,7 +469,7 @@ char *find_mnt_ino(const char *table, dev_t dev, ino_t ino)
3146 tab = setmntent(table, "r");
3148 char *estr = strerror_r(errno, buf, (size_t) PATH_MAX - 1);
3149 - error(LOGOPT_ANY, "setmntent: %s", estr);
3150 + logerr("setmntent: %s", estr);
3154 @@ -667,7 +665,7 @@ struct mnt_list *tree_make_mnt_tree(const char *table, const char *path)
3155 tab = setmntent(table, "r");
3157 char *estr = strerror_r(errno, buf, PATH_MAX - 1);
3158 - error(LOGOPT_ANY, "setmntent: %s", estr);
3159 + logerr("setmntent: %s", estr);
3163 diff --git a/lib/nss_parse.y b/lib/nss_parse.y
3164 index e559696..90b7d25 100644
3165 --- a/lib/nss_parse.y
3166 +++ b/lib/nss_parse.y
3167 @@ -127,13 +127,13 @@ status_exp: STATUS EQUAL ACTION
3169 static int nss_ignore(const char *s)
3171 - msg("ignored invalid nsswitch config near [ %s ]", s);
3172 + logmsg("ignored invalid nsswitch config near [ %s ]", s);
3176 static int nss_error(const char *s)
3178 - msg("syntax error in nsswitch config near [ %s ]\n", s);
3179 + logmsg("syntax error in nsswitch config near [ %s ]\n", s);
3183 @@ -167,7 +167,7 @@ int nsswitch_parse(struct list_head *list)
3185 nsswitch = fopen(NSSWITCH_FILE, "r");
3187 - error(LOGOPT_ANY, "couldn't open %s\n", NSSWITCH_FILE);
3188 + logerr("couldn't open %s\n", NSSWITCH_FILE);
3192 diff --git a/lib/nss_tok.l b/lib/nss_tok.l
3193 index f96b47f..c435b63 100644
3196 @@ -135,6 +135,6 @@ int nss_wrap(void)
3198 static void nss_echo(void)
3200 - msg("%s", nss_text);
3201 + logmsg("%s", nss_text);
3204 diff --git a/lib/parse_subs.c b/lib/parse_subs.c
3205 index 3627f44..5422fef 100644
3206 --- a/lib/parse_subs.c
3207 +++ b/lib/parse_subs.c
3208 @@ -337,9 +337,9 @@ int umount_ent(struct autofs_point *ap, const char *path)
3209 * and EBADSLT relates to CD changer not responding.
3211 if (!status && (S_ISDIR(st.st_mode) && st.st_dev != ap->dev)) {
3212 - rv = spawn_umount(log_debug, path, NULL);
3213 + rv = spawn_umount(ap->logopt, path, NULL);
3214 } else if (is_smbfs && (sav_errno == EIO || sav_errno == EBADSLT)) {
3215 - rv = spawn_umount(log_debug, path, NULL);
3216 + rv = spawn_umount(ap->logopt, path, NULL);
3219 /* We are doing a forced shutcwdown down so unlink busy mounts */
3220 @@ -356,8 +356,8 @@ int umount_ent(struct autofs_point *ap, const char *path)
3223 if (ap->state == ST_SHUTDOWN_FORCE) {
3224 - msg("forcing umount of %s", path);
3225 - rv = spawn_umount(log_debug, "-l", path, NULL);
3226 + info(ap->logopt, "forcing umount of %s", path);
3227 + rv = spawn_umount(ap->logopt, "-l", path, NULL);
3231 @@ -503,7 +503,7 @@ int umount_multi_triggers(struct autofs_point *ap, char *root, struct mapent *me
3232 * the offset triggers back.
3234 if (is_mounted(_PATH_MOUNTED, root, MNTS_REAL)) {
3235 - msg("unmounting dir = %s", root);
3236 + info(ap->logopt, "unmounting dir = %s", root);
3237 if (umount_ent(ap, root)) {
3238 if (!mount_multi_triggers(ap, root, me, "/"))
3240 diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c
3241 index d79a94f..5797639 100644
3242 --- a/lib/rpc_subs.c
3243 +++ b/lib/rpc_subs.c
3244 @@ -96,7 +96,7 @@ static CLIENT *create_udp_client(struct conn_info *info)
3245 if (ret || !result) {
3246 int err = ghn_errno == -1 ? errno : ghn_errno;
3247 char *estr = strerror_r(err, buf, HOST_ENT_BUF_SIZE);
3248 - error(LOGOPT_ANY, "hostname lookup failed: %s", estr);
3249 + logerr("hostname lookup failed: %s", estr);
3252 memcpy(&raddr.sin_addr.s_addr, php->h_addr, php->h_length);
3253 @@ -305,7 +305,7 @@ static CLIENT *create_tcp_client(struct conn_info *info)
3254 if (ret || !result) {
3255 int err = ghn_errno == -1 ? errno : ghn_errno;
3256 char *estr = strerror_r(err, buf, HOST_ENT_BUF_SIZE);
3257 - error(LOGOPT_ANY, "hostname lookup failed: %s", estr);
3258 + logerr("hostname lookup failed: %s", estr);
3261 memcpy(&addr.sin_addr.s_addr, php->h_addr, php->h_length);
3262 diff --git a/man/automount.8 b/man/automount.8
3263 index e203a3e..5cd63c7 100644
3264 --- a/man/automount.8
3265 +++ b/man/automount.8
3266 @@ -62,6 +62,22 @@ setting.
3268 .I "\-V, \-\-version"
3269 Display the version number, then exit.
3271 +.I "\-l, \-\-set-log-priority priority path [path,...]"
3272 +Set the daemon log priority to the specified value. Valid values include
3273 +the numbers 0-7, or the strings emerg, alert, crit, err, warning, notice,
3274 +info, or debug. Log level debug will log everything, log levels info, warn
3275 +(or warning), or notice with enable the daemon verbose logging. Any other
3276 +level will set basic logging. Note that enabling debug or verbose
3277 +logging in the autofs global configuration will override dynamic log level
3278 +changes. For example, if verbose logging is set in the configuration then
3279 +attempting to set logging to basic logging, by using alert, crit, err
3280 +or emerg won't stop the verbose logging. However, setting logging to debug
3281 +will lead to everything (debug logging) being logged witch can then also
3282 +be disabled, returning the daemon to verbose logging.
3284 +The \fIpath\fP argument corresponds to the automounted
3285 +path name as specified in the master map.
3287 \fBautomount\fP takes one optional argument, the name of the master map to
3289 diff --git a/modules/cyrus-sasl.c b/modules/cyrus-sasl.c
3290 index 68e5dd7..18733f3 100644
3291 --- a/modules/cyrus-sasl.c
3292 +++ b/modules/cyrus-sasl.c
3293 @@ -96,18 +96,18 @@ sasl_log_func(void *context, int level, const char *message)
3297 - error(LOGOPT_ANY, "%s", message);
3298 + logerr("%s", message);
3301 - warn(LOGOPT_ANY, "%s", message);
3302 + logmsg("%s", message);
3305 - info(LOGOPT_ANY, "%s", message);
3306 + logmsg("%s", message);
3308 case SASL_LOG_DEBUG:
3309 case SASL_LOG_TRACE:
3311 - debug(LOGOPT_NONE, "%s", message);
3312 + debug(LOGOPT_DEBUG, "%s", message);
3316 @@ -129,7 +129,7 @@ getuser_func(void *context, int id, const char **result, unsigned *len)
3317 *len = strlen(sasl_auth_id);
3320 - error(LOGOPT_ANY, "unknown id in request: %d", id);
3321 + error(LOGOPT_VERBOSE, "unknown id in request: %d", id);
3325 @@ -166,7 +166,7 @@ getpass_func(sasl_conn_t *conn, void *context, int id, sasl_secret_t **psecret)
3326 * the returned data.
3329 -get_server_SASL_mechanisms(LDAP *ld)
3330 +get_server_SASL_mechanisms(unsigned logopt, LDAP *ld)
3333 const char *saslattrlist[] = {"supportedSASLmechanisms", NULL};
3334 @@ -178,7 +178,7 @@ get_server_SASL_mechanisms(LDAP *ld)
3336 NULL, LDAP_NO_LIMIT, &results);
3337 if (ret != LDAP_SUCCESS) {
3338 - error(LOGOPT_ANY, "%s", ldap_err2string(ret));
3339 + error(logopt, "%s", ldap_err2string(ret));
3343 @@ -186,7 +186,7 @@ get_server_SASL_mechanisms(LDAP *ld)
3344 if (entry == NULL) {
3345 /* No root DSE. (!) */
3346 ldap_msgfree(results);
3347 - debug(LOGOPT_NONE,
3349 "a lookup of \"supportedSASLmechanisms\" returned "
3352 @@ -196,7 +196,7 @@ get_server_SASL_mechanisms(LDAP *ld)
3353 ldap_msgfree(results);
3354 if (mechanisms == NULL) {
3355 /* Well, that was a waste of time. */
3356 - msg("No SASL authentication mechanisms are supported"
3357 + info(logopt, "No SASL authentication mechanisms are supported"
3358 " by the LDAP server.");
3361 @@ -208,7 +208,7 @@ get_server_SASL_mechanisms(LDAP *ld)
3362 * Returns 0 upon successful connect, -1 on failure.
3365 -do_sasl_bind(LDAP *ld, sasl_conn_t *conn, const char **clientout,
3366 +do_sasl_bind(unsigned logopt, LDAP *ld, sasl_conn_t *conn, const char **clientout,
3367 unsigned int *clientoutlen, const char *auth_mech, int sasl_result)
3369 int ret, msgid, bind_result;
3370 @@ -226,7 +226,7 @@ do_sasl_bind(LDAP *ld, sasl_conn_t *conn, const char **clientout,
3371 &client_cred : NULL,
3372 NULL, NULL, &msgid);
3373 if (ret != LDAP_SUCCESS) {
3376 "Error sending sasl_bind request to "
3377 "the server: %s", ldap_err2string(ret));
3379 @@ -236,7 +236,7 @@ do_sasl_bind(LDAP *ld, sasl_conn_t *conn, const char **clientout,
3381 ret = ldap_result(ld, msgid, LDAP_MSG_ALL, NULL, &results);
3382 if (ret != LDAP_RES_BIND) {
3385 "Error while waiting for response to "
3386 "sasl_bind request: %s", ldap_err2string(ret));
3388 @@ -264,7 +264,7 @@ do_sasl_bind(LDAP *ld, sasl_conn_t *conn, const char **clientout,
3389 ret = ldap_get_option(ld, LDAP_OPT_RESULT_CODE,
3391 if (ret != LDAP_SUCCESS) {
3394 "Error retrieving response to sasl_bind "
3395 "request: %s", ldap_err2string(ret));
3397 @@ -277,7 +277,7 @@ do_sasl_bind(LDAP *ld, sasl_conn_t *conn, const char **clientout,
3403 "Error parsing response to sasl_bind "
3404 "request: %s.", ldap_err2string(ret));
3406 @@ -299,7 +299,7 @@ do_sasl_bind(LDAP *ld, sasl_conn_t *conn, const char **clientout,
3407 expected_data = sasl_result == SASL_CONTINUE;
3409 if (have_data && !expected_data) {
3412 "The LDAP server sent data in response to our "
3413 "bind request, but indicated that the bind was "
3414 "complete. LDAP SASL bind with mechansim %s "
3415 @@ -308,7 +308,7 @@ do_sasl_bind(LDAP *ld, sasl_conn_t *conn, const char **clientout,
3418 if (expected_data && !have_data) {
3421 "The LDAP server indicated that the LDAP SASL "
3422 "bind was incomplete, but did not provide the "
3423 "required data to proceed. LDAP SASL bind with "
3424 @@ -340,7 +340,7 @@ do_sasl_bind(LDAP *ld, sasl_conn_t *conn, const char **clientout,
3426 if ((*clientoutlen > 0) &&
3427 (bind_result != LDAP_SASL_BIND_IN_PROGRESS)) {
3430 "We have data for the server, "
3431 "but it thinks we are done!");
3432 /* XXX should print out debug data here */
3433 @@ -372,7 +372,7 @@ do_sasl_bind(LDAP *ld, sasl_conn_t *conn, const char **clientout,
3434 * Upon failure, -1 is returned.
3437 -sasl_do_kinit(struct lookup_context *ctxt)
3438 +sasl_do_kinit(unsigned logopt, struct lookup_context *ctxt)
3440 krb5_error_code ret;
3441 krb5_principal tgs_princ, krb5_client_princ = ctxt->krb5_client_princ;
3442 @@ -384,33 +384,33 @@ sasl_do_kinit(struct lookup_context *ctxt)
3444 ctxt->kinit_done = 1;
3446 - debug(LOGOPT_NONE,
3448 "initializing kerberos ticket: client principal %s ",
3449 ctxt->client_princ ? "" : "autofsclient");
3451 ret = krb5_init_context(&ctxt->krb5ctxt);
3453 - error(LOGOPT_ANY, "krb5_init_context failed with %d", ret);
3454 + error(logopt, "krb5_init_context failed with %d", ret);
3458 ret = krb5_cc_resolve(ctxt->krb5ctxt, krb5ccval, &ctxt->krb5_ccache);
3460 - error(LOGOPT_ANY, "krb5_cc_resolve failed with error %d",
3461 + error(logopt, "krb5_cc_resolve failed with error %d",
3463 krb5_free_context(ctxt->krb5ctxt);
3467 if (ctxt->client_princ) {
3468 - debug(LOGOPT_NONE,
3470 "calling krb5_parse_name on client principal %s",
3471 ctxt->client_princ);
3473 ret = krb5_parse_name(ctxt->krb5ctxt, ctxt->client_princ,
3474 &krb5_client_princ);
3478 "krb5_parse_name failed for "
3479 "specified client principal %s",
3480 ctxt->client_princ);
3481 @@ -419,14 +419,14 @@ sasl_do_kinit(struct lookup_context *ctxt)
3483 char *tmp_name = NULL;
3485 - debug(LOGOPT_NONE,
3487 "calling krb5_sname_to_principal using defaults");
3489 ret = krb5_sname_to_principal(ctxt->krb5ctxt, NULL,
3490 "autofsclient", KRB5_NT_SRV_HST,
3491 &krb5_client_princ);
3495 "krb5_sname_to_principal failed for "
3497 ctxt->client_princ ? "" : "autofsclient", ret);
3498 @@ -437,13 +437,13 @@ sasl_do_kinit(struct lookup_context *ctxt)
3499 ret = krb5_unparse_name(ctxt->krb5ctxt,
3500 krb5_client_princ, &tmp_name);
3502 - debug(LOGOPT_NONE,
3504 "krb5_unparse_name failed with error %d",
3506 goto out_cleanup_cc;
3509 - debug(LOGOPT_NONE,
3511 "principal used for authentication: \"%s\"", tmp_name);
3513 krb5_free_unparsed_name(ctxt->krb5ctxt, tmp_name);
3514 @@ -458,19 +458,19 @@ sasl_do_kinit(struct lookup_context *ctxt)
3515 krb5_princ_realm(ctxt->krb5ctxt, krb5_client_princ)->data,
3520 "krb5_build_principal failed with error %d", ret);
3521 goto out_cleanup_cc;
3524 ret = krb5_unparse_name(ctxt->krb5ctxt, tgs_princ, &tgs_name);
3526 - error(LOGOPT_ANY, "krb5_unparse_name failed with error %d",
3527 + error(logopt, "krb5_unparse_name failed with error %d",
3529 goto out_cleanup_cc;
3532 - debug(LOGOPT_NONE, "Using tgs name %s", tgs_name);
3533 + debug(logopt, "Using tgs name %s", tgs_name);
3535 memset(&my_creds, 0, sizeof(my_creds));
3536 ret = krb5_get_init_creds_keytab(ctxt->krb5ctxt, &my_creds,
3537 @@ -479,7 +479,7 @@ sasl_do_kinit(struct lookup_context *ctxt)
3538 0 /* relative start time */,
3543 "krb5_get_init_creds_keytab failed with error %d",
3545 goto out_cleanup_unparse;
3546 @@ -500,7 +500,7 @@ sasl_do_kinit(struct lookup_context *ctxt)
3552 "krb5_cc_initialize failed with error %d", ret);
3553 goto out_cleanup_unparse;
3555 @@ -508,7 +508,7 @@ sasl_do_kinit(struct lookup_context *ctxt)
3556 /* and store credentials for that principal */
3557 ret = krb5_cc_store_cred(ctxt->krb5ctxt, ctxt->krb5_ccache, &my_creds);
3561 "krb5_cc_store_cred failed with error %d", ret);
3562 goto out_cleanup_unparse;
3564 @@ -516,12 +516,12 @@ sasl_do_kinit(struct lookup_context *ctxt)
3565 /* finally, set the environment variable to point to our
3566 * credentials cache */
3567 if (setenv(krb5ccenv, krb5ccval, 1) != 0) {
3568 - error(LOGOPT_ANY, "setenv failed with %d", errno);
3569 + error(logopt, "setenv failed with %d", errno);
3570 goto out_cleanup_unparse;
3572 ctxt->kinit_successful = 1;
3574 - debug(LOGOPT_NONE, "Kerberos authentication was successful!");
3575 + debug(logopt, "Kerberos authentication was successful!");
3577 krb5_free_unparsed_name(ctxt->krb5ctxt, tgs_name);
3579 @@ -540,7 +540,7 @@ out_cleanup_cc:
3581 ret = krb5_cc_destroy(ctxt->krb5ctxt, ctxt->krb5_ccache);
3585 "krb5_cc_destroy failed with non-fatal error %d", ret);
3587 status = pthread_mutex_unlock(&krb5cc_mutex);
3588 @@ -559,7 +559,7 @@ out_cleanup_cc:
3589 * Returns a valid sasl_conn_t pointer upon success, NULL on failure.
3592 -sasl_bind_mech(LDAP *ldap, struct lookup_context *ctxt, const char *mech)
3593 +sasl_bind_mech(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt, const char *mech)
3596 char *tmp, *host = NULL;
3597 @@ -569,15 +569,15 @@ sasl_bind_mech(LDAP *ldap, struct lookup_context *ctxt, const char *mech)
3600 if (!strncmp(mech, "GSSAPI", 6)) {
3601 - if (sasl_do_kinit(ctxt) != 0)
3602 + if (sasl_do_kinit(logopt, ctxt) != 0)
3606 - debug(LOGOPT_NONE, "Attempting sasl bind with mechanism %s", mech);
3607 + debug(logopt, "Attempting sasl bind with mechanism %s", mech);
3609 result = ldap_get_option(ldap, LDAP_OPT_HOST_NAME, &host);
3610 if (result != LDAP_SUCCESS || !host) {
3611 - debug(LOGOPT_NONE, "failed to get hostname for connection");
3612 + debug(logopt, "failed to get hostname for connection");
3616 @@ -587,7 +587,7 @@ sasl_bind_mech(LDAP *ldap, struct lookup_context *ctxt, const char *mech)
3617 /* Create a new authentication context for the service. */
3618 result = sasl_client_new("ldap", host, NULL, NULL, NULL, 0, &conn);
3619 if (result != SASL_OK) {
3620 - error(LOGOPT_ANY, "sasl_client_new failed with error %d",
3621 + error(logopt, "sasl_client_new failed with error %d",
3625 @@ -599,23 +599,23 @@ sasl_bind_mech(LDAP *ldap, struct lookup_context *ctxt, const char *mech)
3627 /* OK and CONTINUE are the only non-fatal return codes here. */
3628 if ((result != SASL_OK) && (result != SASL_CONTINUE)) {
3629 - error(LOGOPT_ANY, "sasl_client start failed with error: %s",
3630 + error(logopt, "sasl_client start failed with error: %s",
3631 sasl_errdetail(conn));
3633 sasl_dispose(&conn);
3637 - result = do_sasl_bind(ldap, conn,
3638 + result = do_sasl_bind(logopt, ldap, conn,
3639 &clientout, &clientoutlen, chosen_mech, result);
3642 - debug(LOGOPT_NONE, "sasl bind with mechanism %s succeeded",
3643 + debug(logopt, "sasl bind with mechanism %s succeeded",
3648 - info(LOGOPT_ANY, "sasl bind with mechanism %s failed", mech);
3649 + info(logopt, "sasl bind with mechanism %s failed", mech);
3651 /* sasl bind failed */
3653 @@ -629,14 +629,14 @@ sasl_bind_mech(LDAP *ldap, struct lookup_context *ctxt, const char *mech)
3654 * -1 on error or if no mechanism is supported by both client and server.
3657 -sasl_choose_mech(LDAP *ldap, struct lookup_context *ctxt)
3658 +sasl_choose_mech(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
3665 - mechanisms = get_server_SASL_mechanisms(ldap);
3666 + mechanisms = get_server_SASL_mechanisms(logopt, ldap);
3670 @@ -652,12 +652,11 @@ sasl_choose_mech(LDAP *ldap, struct lookup_context *ctxt)
3671 if (authtype_requires_creds(mechanisms[i]))
3674 - conn = sasl_bind_mech(ldap, ctxt, mechanisms[i]);
3675 + conn = sasl_bind_mech(logopt, ldap, ctxt, mechanisms[i]);
3677 ctxt->sasl_mech = strdup(mechanisms[i]);
3678 if (!ctxt->sasl_mech) {
3680 - "Successfully authenticated with "
3681 + crit(logopt, "Successfully authenticated with "
3682 "mechanism %s, but failed to allocate "
3683 "memory to hold the mechanism type.",
3685 @@ -668,11 +667,11 @@ sasl_choose_mech(LDAP *ldap, struct lookup_context *ctxt)
3689 - debug(LOGOPT_NONE, "Failed to authenticate with mech %s",
3690 + debug(logopt, "Failed to authenticate with mech %s",
3694 - debug(LOGOPT_NONE, "authenticated: %d, sasl_mech: %s",
3695 + debug(logopt, "authenticated: %d, sasl_mech: %s",
3696 authenticated, ctxt->sasl_mech);
3698 ldap_value_free(mechanisms);
3699 @@ -680,14 +679,14 @@ sasl_choose_mech(LDAP *ldap, struct lookup_context *ctxt)
3703 -autofs_sasl_bind(LDAP *ldap, struct lookup_context *ctxt)
3704 +autofs_sasl_bind(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
3708 if (!ctxt->sasl_mech)
3711 - conn = sasl_bind_mech(ldap, ctxt, ctxt->sasl_mech);
3712 + conn = sasl_bind_mech(logopt, ldap, ctxt, ctxt->sasl_mech);
3716 @@ -717,13 +716,13 @@ autofs_sasl_unbind(struct lookup_context *ctxt)
3720 -autofs_sasl_init(LDAP *ldap, struct lookup_context *ctxt)
3721 +autofs_sasl_init(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
3725 /* Start up Cyrus SASL--only needs to be done once. */
3726 if (sasl_client_init(callbacks) != SASL_OK) {
3727 - error(LOGOPT_ANY, "sasl_client_init failed");
3728 + error(logopt, "sasl_client_init failed");
3732 @@ -736,9 +735,9 @@ autofs_sasl_init(LDAP *ldap, struct lookup_context *ctxt)
3735 if (ctxt->sasl_mech)
3736 - conn = sasl_bind_mech(ldap, ctxt, ctxt->sasl_mech);
3737 + conn = sasl_bind_mech(logopt, ldap, ctxt, ctxt->sasl_mech);
3739 - conn = sasl_choose_mech(ldap, ctxt);
3740 + conn = sasl_choose_mech(logopt, ldap, ctxt);
3743 sasl_dispose(&conn);
3744 @@ -772,8 +771,7 @@ autofs_sasl_done(struct lookup_context *ctxt)
3746 ret = krb5_cc_destroy(ctxt->krb5ctxt, ctxt->krb5_ccache);
3749 - "krb5_cc_destroy failed with non-fatal error %d",
3750 + logmsg("krb5_cc_destroy failed with non-fatal error %d",
3753 status = pthread_mutex_unlock(&krb5cc_mutex);
3754 @@ -782,8 +780,7 @@ autofs_sasl_done(struct lookup_context *ctxt)
3756 krb5_free_context(ctxt->krb5ctxt);
3757 if (unsetenv(krb5ccenv) != 0)
3759 - "unsetenv failed with error %d", errno);
3760 + logerr("unsetenv failed with error %d", errno);
3762 ctxt->krb5ctxt = NULL;
3763 ctxt->krb5_ccache = NULL;
3764 diff --git a/modules/lookup_file.c b/modules/lookup_file.c
3765 index 31ee0fb..921b32b 100644
3766 --- a/modules/lookup_file.c
3767 +++ b/modules/lookup_file.c
3768 @@ -63,13 +63,13 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
3769 ctxt = malloc(sizeof(struct lookup_context));
3771 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
3772 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
3773 + logerr(MODPREFIX "malloc: %s", estr);
3779 - crit(LOGOPT_ANY, MODPREFIX "No map name");
3780 + logerr(MODPREFIX "No map name");
3784 @@ -77,21 +77,21 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
3786 if (ctxt->mapname[0] != '/') {
3788 - msg(MODPREFIX "file map %s is not an absolute pathname",
3791 + "file map %s is not an absolute pathname", argv[0]);
3795 if (access(ctxt->mapname, R_OK)) {
3797 - msg(MODPREFIX "file map %s missing or not readable",
3799 + warn(LOGOPT_NONE, MODPREFIX
3800 + "file map %s missing or not readable", argv[0]);
3804 if (stat(ctxt->mapname, &st)) {
3806 - crit(LOGOPT_ANY, MODPREFIX "file map %s, could not stat",
3807 + logmsg(MODPREFIX "file map %s, could not stat",
3811 @@ -104,7 +104,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
3812 ctxt->parse = open_parse(mapfmt, MODPREFIX, argc - 1, argv + 1);
3815 - crit(LOGOPT_ANY, MODPREFIX "failed to open parse context");
3816 + logmsg(MODPREFIX "failed to open parse context");
3820 @@ -112,7 +112,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
3824 -static int read_one(FILE *f, char *key, unsigned int *k_len, char *mapent, unsigned int *m_len)
3825 +static int read_one(unsigned logopt, FILE *f, char *key, unsigned int *k_len, char *mapent, unsigned int *m_len)
3828 int mapent_len, key_len;
3829 @@ -193,7 +193,7 @@ static int read_one(FILE *f, char *key, unsigned int *k_len, char *mapent, unsig
3830 if (gotten == got_plus)
3832 else if (escape == esc_all) {
3833 - warn(LOGOPT_ANY, MODPREFIX
3834 + warn(logopt, MODPREFIX
3835 "unmatched \" in map key %s", key);
3837 } else if (escape != esc_val)
3838 @@ -208,7 +208,7 @@ static int read_one(FILE *f, char *key, unsigned int *k_len, char *mapent, unsig
3839 if (key_len == KEY_MAX_LEN) {
3841 gotten = got_nothing;
3844 MODPREFIX "map key \"%s...\" "
3845 "is too long. The maximum key "
3846 "length is %d", key,
3847 @@ -245,7 +245,7 @@ static int read_one(FILE *f, char *key, unsigned int *k_len, char *mapent, unsig
3849 if (gotten == got_real || gotten == getting)
3851 - warn(LOGOPT_ANY, MODPREFIX
3852 + warn(logopt, MODPREFIX
3853 "bad map entry \"%s...\" for key "
3854 "\"%s\"", mapent, key);
3856 @@ -286,7 +286,7 @@ static int read_one(FILE *f, char *key, unsigned int *k_len, char *mapent, unsig
3858 if (escape == esc_all) {
3860 - warn(LOGOPT_ANY, MODPREFIX
3861 + warn(logopt, MODPREFIX
3862 "unmatched \" in %s for key %s",
3865 @@ -310,7 +310,7 @@ static int read_one(FILE *f, char *key, unsigned int *k_len, char *mapent, unsig
3871 MODPREFIX "map entry \"%s...\" for key "
3872 "\"%s\" is too long. The maximum entry"
3873 " size is %d", mapent, key,
3874 @@ -388,6 +388,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
3875 struct lookup_context *ctxt = (struct lookup_context *) context;
3876 unsigned int timeout = master->default_timeout;
3877 unsigned int logging = master->default_logging;
3878 + unsigned int logopt = master->logopt;
3882 @@ -402,29 +403,28 @@ int lookup_read_master(struct master *master, time_t age, void *context)
3883 return NSS_STATUS_UNAVAIL;
3885 if (master->depth > MAX_INCLUDE_DEPTH) {
3888 + error(logopt, MODPREFIX
3889 "maximum include depth exceeded %s", master->name);
3890 return NSS_STATUS_UNAVAIL;
3893 path = alloca(KEY_MAX_LEN + 1);
3897 MODPREFIX "could not malloc storage for path");
3898 return NSS_STATUS_UNAVAIL;
3901 ent = alloca(MAPENT_MAX_LEN + 1);
3905 MODPREFIX "could not malloc storage for mapent");
3906 return NSS_STATUS_UNAVAIL;
3909 f = fopen(ctxt->mapname, "r");
3913 MODPREFIX "could not open master map file %s",
3915 return NSS_STATUS_UNAVAIL;
3916 @@ -438,19 +438,19 @@ int lookup_read_master(struct master *master, time_t age, void *context)
3920 - entry = read_one(f, path, &path_len, ent, &ent_len);
3921 + entry = read_one(logopt, f, path, &path_len, ent, &ent_len);
3926 - warn(LOGOPT_ANY, MODPREFIX
3927 + warn(logopt, MODPREFIX
3928 "error reading map %s", ctxt->mapname);
3934 - debug(LOGOPT_NONE, MODPREFIX "read entry %s", path);
3935 + debug(logopt, MODPREFIX "read entry %s", path);
3938 * If key starts with '+' it has to be an
3939 @@ -470,7 +470,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
3941 status = lookup_nss_read_master(master, age);
3946 "failed to read included master map %s",
3948 @@ -482,7 +482,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
3949 blen = path_len + 1 + ent_len + 1;
3950 buffer = malloc(blen);
3954 MODPREFIX "could not malloc parse buffer");
3955 return NSS_STATUS_UNAVAIL;
3957 @@ -503,7 +503,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
3960 if (fstat(fd, &st)) {
3961 - crit(LOGOPT_ANY, MODPREFIX "file map %s, could not stat",
3962 + crit(logopt, MODPREFIX "file map %s, could not stat",
3964 return NSS_STATUS_UNAVAIL;
3966 @@ -684,12 +684,12 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
3970 - entry = read_one(f, key, &k_len, mapent, &m_len);
3971 + entry = read_one(ap->logopt, f, key, &k_len, mapent, &m_len);
3976 - warn(LOGOPT_ANY, MODPREFIX
3977 + warn(ap->logopt, MODPREFIX
3978 "error reading map %s", ctxt->mapname);
3981 @@ -791,7 +791,7 @@ static int lookup_one(struct autofs_point *ap,
3985 - entry = read_one(f, mkey, &k_len, mapent, &m_len);
3986 + entry = read_one(ap->logopt, f, mkey, &k_len, mapent, &m_len);
3989 * If key starts with '+' it has to be an
3990 @@ -860,7 +860,7 @@ static int lookup_one(struct autofs_point *ap,
3994 - warn(LOGOPT_ANY, MODPREFIX
3995 + warn(ap->logopt, MODPREFIX
3996 "error reading map %s", ctxt->mapname);
3999 @@ -904,7 +904,7 @@ static int lookup_wild(struct autofs_point *ap, struct lookup_context *ctxt)
4003 - entry = read_one(f, mkey, &k_len, mapent, &m_len);
4004 + entry = read_one(ap->logopt, f, mkey, &k_len, mapent, &m_len);
4008 @@ -925,7 +925,7 @@ static int lookup_wild(struct autofs_point *ap, struct lookup_context *ctxt)
4012 - warn(LOGOPT_ANY, MODPREFIX
4013 + warn(ap->logopt, MODPREFIX
4014 "error reading map %s", ctxt->mapname);
4017 diff --git a/modules/lookup_hesiod.c b/modules/lookup_hesiod.c
4018 index f30e9b2..649e24c 100644
4019 --- a/modules/lookup_hesiod.c
4020 +++ b/modules/lookup_hesiod.c
4021 @@ -48,7 +48,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
4022 ctxt = malloc(sizeof(struct lookup_context));
4024 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
4025 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
4026 + logerr(MODPREFIX "malloc: %s", estr);
4030 @@ -58,7 +58,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
4031 /* Initialize the hesiod context. */
4032 if (hesiod_init(&(ctxt->hesiod_context)) != 0) {
4033 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
4034 - crit(LOGOPT_ANY, MODPREFIX "hesiod_init(): %s", estr);
4035 + logerr(MODPREFIX "hesiod_init(): %s", estr);
4039 @@ -70,7 +70,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
4040 /* Open the parser, if we can. */
4041 ctxt->parser = open_parse(mapfmt, MODPREFIX, argc - 1, argv + 1);
4042 if (!ctxt->parser) {
4043 - crit(LOGOPT_ANY, MODPREFIX "failed to open parse context");
4044 + logerr(MODPREFIX "failed to open parse context");
4048 diff --git a/modules/lookup_hosts.c b/modules/lookup_hosts.c
4049 index d711611..d746e42 100644
4050 --- a/modules/lookup_hosts.c
4051 +++ b/modules/lookup_hosts.c
4052 @@ -57,7 +57,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
4053 ctxt = malloc(sizeof(struct lookup_context));
4055 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
4056 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
4057 + logerr(MODPREFIX "malloc: %s", estr);
4061 @@ -65,7 +65,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
4063 ctxt->parse = open_parse(mapfmt, MODPREFIX, argc, argv);
4065 - crit(LOGOPT_ANY, MODPREFIX "failed to open parse context");
4066 + logerr(MODPREFIX "failed to open parse context");
4070 @@ -94,7 +94,7 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
4072 status = pthread_mutex_lock(&hostent_mutex);
4074 - error(LOGOPT_ANY, MODPREFIX "failed to lock hostent mutex");
4075 + error(ap->logopt, MODPREFIX "failed to lock hostent mutex");
4076 return NSS_STATUS_UNAVAIL;
4079 @@ -110,7 +110,7 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
4081 status = pthread_mutex_unlock(&hostent_mutex);
4083 - error(LOGOPT_ANY, MODPREFIX "failed to unlock hostent mutex");
4084 + error(ap->logopt, MODPREFIX "failed to unlock hostent mutex");
4088 @@ -157,10 +157,10 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
4093 + info(ap->logopt, MODPREFIX
4094 "can't find path in hosts map %s", name);
4097 + info(ap->logopt, MODPREFIX
4098 "can't find path in hosts map %s/%s",
4101 @@ -216,7 +216,7 @@ done:
4104 estr = strerror_r(errno, buf, MAX_ERR_BUF);
4105 - crit(ap->logopt, MODPREFIX "malloc: %s", estr);
4106 + logerr(MODPREFIX "malloc: %s", estr);
4107 rpc_exports_free(exp);
4108 return NSS_STATUS_UNAVAIL;
4110 @@ -230,7 +230,7 @@ done:
4113 estr = strerror_r(errno, buf, MAX_ERR_BUF);
4114 - crit(ap->logopt, MODPREFIX "malloc: %s", estr);
4115 + logerr(MODPREFIX "malloc: %s", estr);
4116 rpc_exports_free(exp);
4117 return NSS_STATUS_UNAVAIL;
4119 diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
4120 index c0f228b..00215af 100644
4121 --- a/modules/lookup_ldap.c
4122 +++ b/modules/lookup_ldap.c
4123 @@ -49,9 +49,9 @@ static struct ldap_schema common_schema[] = {
4125 static unsigned int common_schema_count = sizeof(common_schema)/sizeof(struct ldap_schema);
4127 -static LDAP *auth_init(const char *, struct lookup_context *);
4128 +static LDAP *auth_init(unsigned logopt, const char *, struct lookup_context *);
4130 -int bind_ldap_anonymous(LDAP *ldap, struct lookup_context *ctxt)
4131 +int bind_ldap_anonymous(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
4135 @@ -62,15 +62,14 @@ int bind_ldap_anonymous(LDAP *ldap, struct lookup_context *ctxt)
4137 if (rv != LDAP_SUCCESS) {
4140 - MODPREFIX "Unable to bind to the LDAP server: "
4141 + crit(logopt, MODPREFIX
4142 + "Unable to bind to the LDAP server: "
4143 "%s, error %s", ctxt->server ? "" : "(default)",
4144 ldap_err2string(rv));
4146 struct ldap_uri *uri;
4147 uri = list_entry(ctxt->uri->next, struct ldap_uri, list);
4149 - MODPREFIX "Unable to bind to the LDAP server: "
4150 + info(logopt, MODPREFIX "Unable to bind to the LDAP server: "
4151 "%s, error %s", uri->uri, ldap_err2string(rv));
4154 @@ -79,12 +78,11 @@ int bind_ldap_anonymous(LDAP *ldap, struct lookup_context *ctxt)
4158 -int unbind_ldap_connection(LDAP *ldap, struct lookup_context *ctxt)
4159 +int unbind_ldap_connection(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
4164 - debug(LOGOPT_NONE, "use_tls: %d", ctxt->use_tls);
4166 * The OpenSSL library can't handle having its message and error
4167 * string database loaded multiple times and segfaults if the
4168 @@ -102,13 +100,12 @@ int unbind_ldap_connection(LDAP *ldap, struct lookup_context *ctxt)
4170 rv = ldap_unbind_ext(ldap, NULL, NULL);
4171 if (rv != LDAP_SUCCESS)
4173 - "unbind failed: %s", ldap_err2string(rv));
4174 + error(logopt, "unbind failed: %s", ldap_err2string(rv));
4179 -LDAP *init_ldap_connection(const char *uri, struct lookup_context *ctxt)
4180 +LDAP *init_ldap_connection(unsigned logopt, const char *uri, struct lookup_context *ctxt)
4183 struct timeval timeout = { ctxt->timeout, 0 };
4184 @@ -120,9 +117,9 @@ LDAP *init_ldap_connection(const char *uri, struct lookup_context *ctxt)
4185 /* Initialize the LDAP context. */
4186 rv = ldap_initialize(&ldap, uri);
4187 if (rv != LDAP_OPT_SUCCESS) {
4189 - MODPREFIX "couldn't initialize LDAP connection to %s",
4190 - uri ? uri : "default server");
4191 + info(logopt, MODPREFIX
4192 + "couldn't initialize LDAP connection to %s",
4193 + uri ? uri : "default");
4197 @@ -133,7 +130,7 @@ LDAP *init_ldap_connection(const char *uri, struct lookup_context *ctxt)
4198 ldap_unbind_ext(ldap, NULL, NULL);
4199 rv = ldap_initialize(&ldap, uri);
4200 if (rv != LDAP_OPT_SUCCESS) {
4201 - crit(LOGOPT_ANY, MODPREFIX "couldn't initialize LDAP");
4202 + crit(logopt, MODPREFIX "couldn't initialize LDAP");
4206 @@ -144,7 +141,7 @@ LDAP *init_ldap_connection(const char *uri, struct lookup_context *ctxt)
4207 /* Set synchronous call timeout */
4208 rv = ldap_set_option(ldap, LDAP_OPT_TIMEOUT, &timeout);
4209 if (rv != LDAP_OPT_SUCCESS)
4210 - info(LOGOPT_ANY, MODPREFIX
4211 + info(logopt, MODPREFIX
4212 "failed to set synchronous call timeout to %d",
4215 @@ -152,16 +149,14 @@ LDAP *init_ldap_connection(const char *uri, struct lookup_context *ctxt)
4216 /* Sane network timeout */
4217 rv = ldap_set_option(ldap, LDAP_OPT_NETWORK_TIMEOUT, &net_timeout);
4218 if (rv != LDAP_OPT_SUCCESS)
4220 - MODPREFIX "failed to set connection timeout to %d",
4221 + info(logopt, MODPREFIX "failed to set connection timeout to %d",
4222 net_timeout.tv_sec);
4225 if (ctxt->use_tls) {
4226 if (ctxt->version == 2) {
4227 if (ctxt->tls_required) {
4230 + error(logopt, MODPREFIX
4231 "TLS required but connection is version 2");
4232 ldap_unbind_ext(ldap, NULL, NULL);
4234 @@ -171,16 +166,15 @@ LDAP *init_ldap_connection(const char *uri, struct lookup_context *ctxt)
4236 rv = ldap_start_tls_s(ldap, NULL, NULL);
4237 if (rv != LDAP_SUCCESS) {
4238 - unbind_ldap_connection(ldap, ctxt);
4239 + unbind_ldap_connection(logopt, ldap, ctxt);
4240 if (ctxt->tls_required) {
4243 + error(logopt, MODPREFIX
4244 "TLS required but START_TLS failed: %s",
4245 ldap_err2string(rv));
4248 ctxt->use_tls = LDAP_TLS_DONT_USE;
4249 - ldap = init_ldap_connection(uri, ctxt);
4250 + ldap = init_ldap_connection(logopt, uri, ctxt);
4252 ctxt->use_tls = LDAP_TLS_INIT;
4254 @@ -192,7 +186,7 @@ LDAP *init_ldap_connection(const char *uri, struct lookup_context *ctxt)
4258 -static int get_query_dn(LDAP *ldap, struct lookup_context *ctxt, const char *class, const char *key)
4259 +static int get_query_dn(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt, const char *class, const char *key)
4261 char buf[PARSE_MAX_BUF];
4262 char *query, *dn, *qdn;
4263 @@ -206,7 +200,7 @@ static int get_query_dn(LDAP *ldap, struct lookup_context *ctxt, const char *cla
4266 if (!ctxt->mapname && !ctxt->base) {
4267 - error(LOGOPT_ANY, MODPREFIX "no master map to lookup");
4268 + error(logopt, MODPREFIX "no master map to lookup");
4272 @@ -218,7 +212,7 @@ static int get_query_dn(LDAP *ldap, struct lookup_context *ctxt, const char *cla
4274 if (query == NULL) {
4275 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
4276 - crit(LOGOPT_ANY, MODPREFIX "alloca: %s", estr);
4277 + crit(logopt, MODPREFIX "alloca: %s", estr);
4278 return NSS_STATUS_UNAVAIL;
4281 @@ -229,14 +223,14 @@ static int get_query_dn(LDAP *ldap, struct lookup_context *ctxt, const char *cla
4282 if (ctxt->mapname) {
4283 if (sprintf(query, "(&(objectclass=%s)(%s=%.*s))", class,
4284 key, (int) strlen(ctxt->mapname), ctxt->mapname) >= l) {
4285 - debug(LOGOPT_NONE,
4287 MODPREFIX "error forming query string");
4290 scope = LDAP_SCOPE_SUBTREE;
4292 if (sprintf(query, "(objectclass=%s)", class) >= l) {
4293 - debug(LOGOPT_NONE,
4295 MODPREFIX "error forming query string");
4298 @@ -259,15 +253,14 @@ static int get_query_dn(LDAP *ldap, struct lookup_context *ctxt, const char *cla
4300 struct ldap_searchdn *this = ctxt->sdns;
4302 - debug(LOGOPT_NONE, MODPREFIX
4303 - "check search base list");
4304 + debug(logopt, MODPREFIX "check search base list");
4307 rv = ldap_search_s(ldap, this->basedn,
4308 scope, query, attrs, 0, &result);
4310 if ((rv == LDAP_SUCCESS) && result) {
4311 - debug(LOGOPT_NONE, MODPREFIX
4312 + debug(logopt, MODPREFIX
4313 "found search base under %s",
4316 @@ -283,7 +276,7 @@ static int get_query_dn(LDAP *ldap, struct lookup_context *ctxt, const char *cla
4319 if ((rv != LDAP_SUCCESS) || !result) {
4320 - error(LOGOPT_NONE,
4322 MODPREFIX "query failed for %s: %s",
4323 query, ldap_err2string(rv));
4325 @@ -292,9 +285,9 @@ static int get_query_dn(LDAP *ldap, struct lookup_context *ctxt, const char *cla
4326 e = ldap_first_entry(ldap, result);
4328 dn = ldap_get_dn(ldap, e);
4329 - debug(LOGOPT_NONE, MODPREFIX "found query dn %s", dn);
4330 + debug(logopt, MODPREFIX "found query dn %s", dn);
4332 - debug(LOGOPT_NONE,
4334 MODPREFIX "query succeeded, no matches for %s",
4336 ldap_msgfree(result);
4337 @@ -373,7 +366,7 @@ static struct ldap_schema *alloc_common_schema(struct ldap_schema *s)
4341 -static int find_query_dn(LDAP *ldap, struct lookup_context *ctxt)
4342 +static int find_query_dn(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
4344 struct ldap_schema *schema;
4346 @@ -384,11 +377,10 @@ static int find_query_dn(LDAP *ldap, struct lookup_context *ctxt)
4347 for (i = 0; i < common_schema_count; i++) {
4348 const char *class = common_schema[i].map_class;
4349 const char *key = common_schema[i].map_attr;
4350 - if (get_query_dn(ldap, ctxt, class, key)) {
4351 + if (get_query_dn(logopt, ldap, ctxt, class, key)) {
4352 schema = alloc_common_schema(&common_schema[i]);
4355 - MODPREFIX "failed to allocate schema");
4356 + error(logopt, MODPREFIX "failed to allocate schema");
4359 ctxt->schema = schema;
4360 @@ -399,28 +391,26 @@ static int find_query_dn(LDAP *ldap, struct lookup_context *ctxt)
4364 -static int do_bind(LDAP *ldap, struct lookup_context *ctxt)
4365 +static int do_bind(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
4367 char *host = NULL, *nhost;
4368 int rv, need_base = 1;
4371 - debug(LOGOPT_NONE, "auth_required: %d, sasl_mech %s",
4372 + debug(logopt, MODPREFIX "auth_required: %d, sasl_mech %s",
4373 ctxt->auth_required, ctxt->sasl_mech);
4375 if (ctxt->sasl_mech ||
4376 (ctxt->auth_required & (LDAP_AUTH_REQUIRED|LDAP_AUTH_AUTODETECT))) {
4377 - rv = autofs_sasl_bind(ldap, ctxt);
4378 - debug(LOGOPT_NONE, MODPREFIX
4379 - "autofs_sasl_bind returned %d", rv);
4380 + rv = autofs_sasl_bind(logopt, ldap, ctxt);
4381 + debug(logopt, MODPREFIX "autofs_sasl_bind returned %d", rv);
4383 - rv = bind_ldap_anonymous(ldap, ctxt);
4384 - debug(LOGOPT_NONE,
4385 - MODPREFIX "ldap anonymous bind returned %d", rv);
4386 + rv = bind_ldap_anonymous(logopt, ldap, ctxt);
4387 + debug(logopt, MODPREFIX "ldap anonymous bind returned %d", rv);
4390 - rv = bind_ldap_anonymous(ldap, ctxt);
4391 - debug(LOGOPT_NONE, MODPREFIX "ldap anonymous bind returned %d", rv);
4392 + rv = bind_ldap_anonymous(logopt, ldap, ctxt);
4393 + debug(logopt, MODPREFIX "ldap anonymous bind returned %d", rv);
4397 @@ -428,13 +418,13 @@ static int do_bind(LDAP *ldap, struct lookup_context *ctxt)
4399 rv = ldap_get_option(ldap, LDAP_OPT_HOST_NAME, &host);
4400 if (rv != LDAP_SUCCESS || !host) {
4401 - debug(LOGOPT_ANY, "failed to get hostname for connection");
4402 + debug(logopt, "failed to get hostname for connection");
4406 nhost = strdup(host);
4408 - debug(LOGOPT_ANY, "failed to alloc context for hostname");
4409 + debug(logopt, "failed to alloc context for hostname");
4413 @@ -463,16 +453,16 @@ static int do_bind(LDAP *ldap, struct lookup_context *ctxt)
4414 * base dn for searches.
4416 if (!ctxt->schema) {
4417 - if (!find_query_dn(ldap, ctxt)) {
4419 - MODPREFIX "failed to find valid query dn");
4420 + if (!find_query_dn(logopt, ldap, ctxt)) {
4422 + MODPREFIX "failed to find valid query dn");
4426 const char *class = ctxt->schema->map_class;
4427 const char *key = ctxt->schema->map_attr;
4428 - if (!get_query_dn(ldap, ctxt, class, key)) {
4429 - error(LOGOPT_ANY, MODPREFIX "failed to get query dn");
4430 + if (!get_query_dn(logopt, ldap, ctxt, class, key)) {
4431 + error(logopt, MODPREFIX "failed to get query dn");
4435 @@ -480,23 +470,23 @@ static int do_bind(LDAP *ldap, struct lookup_context *ctxt)
4439 -static LDAP *do_connect(const char *uri, struct lookup_context *ctxt)
4440 +static LDAP *do_connect(unsigned logopt, const char *uri, struct lookup_context *ctxt)
4444 - ldap = init_ldap_connection(uri, ctxt);
4445 + ldap = init_ldap_connection(logopt, uri, ctxt);
4449 - if (!do_bind(ldap, ctxt)) {
4450 - unbind_ldap_connection(ldap, ctxt);
4451 + if (!do_bind(logopt, ldap, ctxt)) {
4452 + unbind_ldap_connection(logopt, ldap, ctxt);
4459 -static LDAP *connect_to_server(const char *uri, struct lookup_context *ctxt)
4460 +static LDAP *connect_to_server(unsigned logopt, const char *uri, struct lookup_context *ctxt)
4464 @@ -506,19 +496,19 @@ static LDAP *connect_to_server(const char *uri, struct lookup_context *ctxt)
4467 if (ctxt->auth_required & LDAP_AUTH_REQUIRED) {
4468 - ldap = auth_init(uri, ctxt);
4469 + ldap = auth_init(logopt, uri, ctxt);
4470 if (!ldap && ctxt->auth_required & LDAP_AUTH_AUTODETECT)
4473 "no authentication mechanisms auto detected.");
4475 - error(LOGOPT_ANY, MODPREFIX
4476 + error(logopt, MODPREFIX
4477 "cannot initialize authentication setup");
4481 - if (!do_bind(ldap, ctxt)) {
4482 - unbind_ldap_connection(ldap, ctxt);
4483 - error(LOGOPT_ANY, MODPREFIX "cannot bind to server");
4484 + if (!do_bind(logopt, ldap, ctxt)) {
4485 + unbind_ldap_connection(logopt, ldap, ctxt);
4486 + error(logopt, MODPREFIX "cannot bind to server");
4490 @@ -526,16 +516,18 @@ static LDAP *connect_to_server(const char *uri, struct lookup_context *ctxt)
4494 - ldap = do_connect(uri, ctxt);
4495 + ldap = do_connect(logopt, uri, ctxt);
4497 - error(LOGOPT_ANY, MODPREFIX "cannot connect to server");
4499 + MODPREFIX "couldn't connect to server %s",
4500 + uri ? uri : "default");
4507 -static LDAP *find_server(struct lookup_context *ctxt)
4508 +static LDAP *find_server(unsigned logopt, struct lookup_context *ctxt)
4511 struct ldap_uri *this;
4512 @@ -547,10 +539,9 @@ static LDAP *find_server(struct lookup_context *ctxt)
4513 while(p != ctxt->uri) {
4514 this = list_entry(p, struct ldap_uri, list);
4516 - debug(LOGOPT_ANY, "check uri %s", this->uri);
4517 - ldap = connect_to_server(this->uri, ctxt);
4518 + ldap = connect_to_server(logopt, this->uri, ctxt);
4520 - debug(LOGOPT_ANY, "connexted to uri %s", this->uri);
4521 + info(logopt, "connected to uri %s", this->uri);
4524 list_del_init(&this->list);
4525 @@ -568,17 +559,17 @@ static LDAP *find_server(struct lookup_context *ctxt)
4529 -static LDAP *do_reconnect(struct lookup_context *ctxt)
4530 +static LDAP *do_reconnect(unsigned logopt, struct lookup_context *ctxt)
4534 if (ctxt->server || !ctxt->uri) {
4535 - ldap = do_connect(ctxt->server, ctxt);
4536 + ldap = do_connect(logopt, ctxt->server, ctxt);
4539 struct ldap_uri *this;
4540 this = list_entry(ctxt->uri->next, struct ldap_uri, list);
4541 - ldap = do_connect(this->uri, ctxt);
4542 + ldap = do_connect(logopt, this->uri, ctxt);
4545 /* Failed to connect, put at end of list */
4546 @@ -589,15 +580,15 @@ static LDAP *do_reconnect(struct lookup_context *ctxt)
4547 autofs_sasl_done(ctxt);
4549 /* Current server failed connect, try the rest */
4550 - ldap = find_server(ctxt);
4551 + ldap = find_server(logopt, ctxt);
4553 - error(LOGOPT_ANY, MODPREFIX "failed to find available server");
4554 + error(logopt, MODPREFIX "failed to find available server");
4560 -int get_property(xmlNodePtr node, const char *prop, char **value)
4561 +int get_property(unsigned logopt, xmlNodePtr node, const char *prop, char **value)
4564 xmlChar *property = (xmlChar *) prop;
4565 @@ -608,8 +599,7 @@ int get_property(xmlNodePtr node, const char *prop, char **value)
4568 if (!(*value = strdup((char *) ret))) {
4570 - MODPREFIX "strdup failed with %d", errno);
4571 + logerr(MODPREFIX "strdup failed with %d", errno);
4575 @@ -645,7 +635,7 @@ int authtype_requires_creds(const char *authtype)
4576 * then no further action is necessary. If it is not, the caller is free
4577 * to then use another method to determine how to connect to the server.
4579 -int parse_ldap_config(struct lookup_context *ctxt)
4580 +int parse_ldap_config(unsigned logopt, struct lookup_context *ctxt)
4582 int ret = 0, fallback = 0;
4583 unsigned int auth_required = LDAP_AUTH_NOTREQUIRED;
4584 @@ -662,7 +652,7 @@ int parse_ldap_config(struct lookup_context *ctxt)
4586 auth_conf = (char *) defaults_get_auth_conf_file();
4590 MODPREFIX "failed to get auth config file name.");
4593 @@ -687,7 +677,7 @@ int parse_ldap_config(struct lookup_context *ctxt)
4594 ctxt->client_princ = NULL;
4599 MODPREFIX "stat(2) failed with error %s.",
4602 @@ -696,8 +686,7 @@ int parse_ldap_config(struct lookup_context *ctxt)
4603 if (!S_ISREG(st.st_mode) ||
4604 st.st_uid != 0 || st.st_gid != 0 ||
4605 (st.st_mode & 0x01ff) != 0600) {
4608 + error(logopt, MODPREFIX
4609 "Configuration file %s exists, but is not usable. "
4610 "Please make sure that it is owned by root, group "
4611 "is root, and the mode is 0600.",
4612 @@ -708,30 +697,29 @@ int parse_ldap_config(struct lookup_context *ctxt)
4614 doc = xmlParseFile(auth_conf);
4617 - MODPREFIX "xmlParseFile failed for %s.", auth_conf);
4618 + error(logopt, MODPREFIX
4619 + "xmlParseFile failed for %s.", auth_conf);
4623 root = xmlDocGetRootElement(doc);
4626 - MODPREFIX "empty xml document (%s).", auth_conf);
4627 + debug(logopt, MODPREFIX
4628 + "empty xml document (%s).", auth_conf);
4633 if (xmlStrcmp(root->name, (const xmlChar *)"autofs_ldap_sasl_conf")) {
4636 + error(logopt, MODPREFIX
4637 "The root node of the XML document %s is not "
4638 "autofs_ldap_sasl_conf.", auth_conf);
4642 - ret = get_property(root, "usetls", &usetls);
4643 + ret = get_property(logopt, root, "usetls", &usetls);
4648 "Failed read the usetls property from "
4649 "the configuration file %s.", auth_conf);
4650 @@ -746,7 +734,7 @@ int parse_ldap_config(struct lookup_context *ctxt)
4651 else if (!strcasecmp(usetls, "no"))
4652 use_tls = LDAP_TLS_DONT_USE;
4657 "The usetls property must have value "
4658 "\"yes\" or \"no\".");
4659 @@ -756,9 +744,9 @@ int parse_ldap_config(struct lookup_context *ctxt)
4663 - ret = get_property(root, "tlsrequired", &tlsrequired);
4664 + ret = get_property(logopt, root, "tlsrequired", &tlsrequired);
4669 "Failed read the tlsrequired property from "
4670 "the configuration file %s.", auth_conf);
4671 @@ -773,7 +761,7 @@ int parse_ldap_config(struct lookup_context *ctxt)
4672 else if (!strcasecmp(tlsrequired, "no"))
4673 tls_required = LDAP_TLS_DONT_USE;
4678 "The tlsrequired property must have value "
4679 "\"yes\" or \"no\".");
4680 @@ -783,9 +771,9 @@ int parse_ldap_config(struct lookup_context *ctxt)
4684 - ret = get_property(root, "authrequired", &authrequired);
4685 + ret = get_property(logopt, root, "authrequired", &authrequired);
4690 "Failed read the authrequired property from "
4691 "the configuration file %s.", auth_conf);
4692 @@ -802,7 +790,7 @@ int parse_ldap_config(struct lookup_context *ctxt)
4693 else if (!strcasecmp(authrequired, "autodetect"))
4694 auth_required = LDAP_AUTH_AUTODETECT;
4699 "The authrequired property must have value "
4700 "\"yes\", \"no\" or \"autodetect\".");
4701 @@ -812,9 +800,9 @@ int parse_ldap_config(struct lookup_context *ctxt)
4705 - ret = get_property(root, "authtype", &authtype);
4706 + ret = get_property(logopt, root, "authtype", &authtype);
4711 "Failed read the authtype property from the "
4712 "configuration file %s.", auth_conf);
4713 @@ -822,10 +810,10 @@ int parse_ldap_config(struct lookup_context *ctxt)
4716 if (authtype && authtype_requires_creds(authtype)) {
4717 - ret = get_property(root, "user", &user);
4718 - ret |= get_property(root, "secret", &secret);
4719 + ret = get_property(logopt, root, "user", &user);
4720 + ret |= get_property(logopt, root, "secret", &secret);
4721 if (ret != 0 || (!user || !secret)) {
4725 "%s authentication type requires a username "
4726 "and a secret. Please fix your configuration "
4727 @@ -845,7 +833,7 @@ int parse_ldap_config(struct lookup_context *ctxt)
4728 * We allow the admin to specify the principal to use for the
4729 * client. The default is "autofsclient/hostname@REALM".
4731 - (void)get_property(root, "clientprinc", &client_princ);
4732 + (void)get_property(logopt, root, "clientprinc", &client_princ);
4734 ctxt->auth_conf = auth_conf;
4735 ctxt->use_tls = use_tls;
4736 @@ -856,15 +844,15 @@ int parse_ldap_config(struct lookup_context *ctxt)
4737 ctxt->secret = secret;
4738 ctxt->client_princ = client_princ;
4740 - debug(LOGOPT_NONE,
4741 + debug(logopt, MODPREFIX
4742 "ldap authentication configured with the following options:");
4743 - debug(LOGOPT_NONE,
4744 + debug(logopt, MODPREFIX
4746 "tls_required: %u, "
4747 "auth_required: %u, "
4749 use_tls, tls_required, auth_required, authtype);
4750 - debug(LOGOPT_NONE,
4751 + debug(logopt, MODPREFIX
4754 "client principal: %s",
4755 @@ -889,7 +877,7 @@ out:
4756 * Returns ldap connection on success, with authtype, user and secret
4757 * filled in as appropriate. Returns NULL on failre.
4759 -static LDAP *auth_init(const char *uri, struct lookup_context *ctxt)
4760 +static LDAP *auth_init(unsigned logopt, const char *uri, struct lookup_context *ctxt)
4764 @@ -900,11 +888,11 @@ static LDAP *auth_init(const char *uri, struct lookup_context *ctxt)
4765 * if the permissions on the file were incorrect, or if the
4766 * specified authentication type is not valid.
4768 - ret = parse_ldap_config(ctxt);
4769 + ret = parse_ldap_config(logopt, ctxt);
4773 - ldap = init_ldap_connection(uri, ctxt);
4774 + ldap = init_ldap_connection(logopt, uri, ctxt);
4778 @@ -916,7 +904,7 @@ static LDAP *auth_init(const char *uri, struct lookup_context *ctxt)
4779 * to use. If kerberos is used, it will also take care to initialize
4780 * the credential cache and the client and service principals.
4782 - ret = autofs_sasl_init(ldap, ctxt);
4783 + ret = autofs_sasl_init(logopt, ldap, ctxt);
4785 ctxt->sasl_mech = NULL;
4787 @@ -930,7 +918,7 @@ static LDAP *auth_init(const char *uri, struct lookup_context *ctxt)
4788 * Take an input string as specified in the master map, and break it
4789 * down into a server name and basedn.
4791 -static int parse_server_string(const char *url, struct lookup_context *ctxt)
4792 +static int parse_server_string(unsigned logopt, const char *url, struct lookup_context *ctxt)
4794 char buf[MAX_ERR_BUF], *tmp = NULL, proto[9];
4795 const char *ptr, *name;
4796 @@ -939,8 +927,7 @@ static int parse_server_string(const char *url, struct lookup_context *ctxt)
4797 memset(proto, 0, 9);
4800 - debug(LOGOPT_NONE,
4802 + debug(logopt, MODPREFIX
4803 "Attempting to parse LDAP information from string \"%s\".", ptr);
4805 ctxt->port = LDAP_PORT;
4806 @@ -974,7 +961,7 @@ static int parse_server_string(const char *url, struct lookup_context *ctxt)
4809 estr = strerror_r(errno, buf, MAX_ERR_BUF);
4810 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
4811 + logerr(MODPREFIX "malloc: %s", estr);
4815 @@ -987,7 +974,7 @@ static int parse_server_string(const char *url, struct lookup_context *ctxt)
4816 memcpy(ctxt->server, s, l);
4821 MODPREFIX "invalid LDAP map syntax %s", ptr);
4823 /* TODO: why did I put this here, the parser shouldn't let this by
4824 @@ -996,7 +983,7 @@ static int parse_server_string(const char *url, struct lookup_context *ctxt)
4827 estr = strerror_r(errno, buf, MAX_ERR_BUF);
4828 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
4829 + crit(logopt, MODPREFIX "malloc: %s", estr);
4833 @@ -1014,7 +1001,7 @@ static int parse_server_string(const char *url, struct lookup_context *ctxt)
4839 MODPREFIX "invalid LDAP map syntax %s", ptr);
4842 @@ -1031,7 +1018,7 @@ static int parse_server_string(const char *url, struct lookup_context *ctxt)
4845 estr = strerror_r(errno, buf, MAX_ERR_BUF);
4846 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
4847 + logerr(MODPREFIX "malloc: %s", estr);
4851 @@ -1072,7 +1059,7 @@ static int parse_server_string(const char *url, struct lookup_context *ctxt)
4854 estr = strerror_r(errno, buf, MAX_ERR_BUF);
4855 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
4856 + logerr(MODPREFIX "malloc: %s", estr);
4860 @@ -1083,7 +1070,7 @@ static int parse_server_string(const char *url, struct lookup_context *ctxt)
4863 estr = strerror_r(errno, buf, MAX_ERR_BUF);
4864 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
4865 + logerr(MODPREFIX "malloc: %s", estr);
4869 @@ -1097,7 +1084,7 @@ static int parse_server_string(const char *url, struct lookup_context *ctxt)
4872 estr = strerror_r(errno, buf, MAX_ERR_BUF);
4873 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
4874 + logerr(MODPREFIX "malloc: %s", estr);
4878 @@ -1109,16 +1096,16 @@ static int parse_server_string(const char *url, struct lookup_context *ctxt)
4880 if (!ctxt->server && *proto) {
4881 if (!strncmp(proto, "ldaps", 5)) {
4882 - warn(LOGOPT_ANY, MODPREFIX
4883 + info(logopt, MODPREFIX
4884 "server must be given to force ldaps, connection "
4885 "will use LDAP client configured protocol");
4890 - debug(LOGOPT_NONE, MODPREFIX "mapname %s", ctxt->mapname);
4891 + debug(logopt, MODPREFIX "mapname %s", ctxt->mapname);
4893 - debug(LOGOPT_NONE, MODPREFIX "server \"%s\", base dn \"%s\"",
4894 + debug(logopt, MODPREFIX "server \"%s\", base dn \"%s\"",
4895 ctxt->server ? ctxt->server : "(default)",
4898 @@ -1175,8 +1162,6 @@ static void validate_uris(struct list_head *list)
4900 /* At least we get some basic validation */
4901 if (!ldap_is_ldap_url(this->uri)) {
4903 - "removed invalid uri from list, %s", this->uri);
4904 list_del(&this->list);
4907 @@ -1202,7 +1187,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
4908 ctxt = malloc(sizeof(struct lookup_context));
4910 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
4911 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
4912 + logerr(MODPREFIX "malloc: %s", estr);
4915 memset(ctxt, 0, sizeof(struct lookup_context));
4916 @@ -1215,7 +1200,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
4917 * Parse out the server name and base dn, and fill them
4918 * into the proper places in the lookup context structure.
4920 - if (!parse_server_string(argv[0], ctxt)) {
4921 + if (!parse_server_string(LOGOPT_NONE, argv[0], ctxt)) {
4922 error(LOGOPT_ANY, MODPREFIX "cannot parse server string");
4925 @@ -1236,13 +1221,13 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
4928 if (ctxt->server || !ctxt->uri) {
4929 - ldap = connect_to_server(ctxt->server, ctxt);
4930 + ldap = connect_to_server(LOGOPT_NONE, ctxt->server, ctxt);
4936 - ldap = find_server(ctxt);
4937 + ldap = find_server(LOGOPT_NONE, ctxt);
4940 error(LOGOPT_ANY, MODPREFIX
4941 @@ -1250,13 +1235,13 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
4945 - unbind_ldap_connection(ldap, ctxt);
4946 + unbind_ldap_connection(LOGOPT_ANY, ldap, ctxt);
4948 /* Open the parser, if we can. */
4949 ctxt->parse = open_parse(mapfmt, MODPREFIX, argc - 1, argv + 1);
4952 - crit(LOGOPT_ANY, MODPREFIX "failed to open parse context");
4953 + logerr(MODPREFIX "failed to open parse context");
4957 @@ -1269,6 +1254,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
4958 struct lookup_context *ctxt = (struct lookup_context *) context;
4959 unsigned int timeout = master->default_timeout;
4960 unsigned int logging = master->default_logging;
4961 + unsigned int logopt = master->logopt;
4962 int rv, l, count, blen;
4963 char buf[PARSE_MAX_BUF];
4965 @@ -1293,45 +1279,44 @@ int lookup_read_master(struct master *master, time_t age, void *context)
4967 if (query == NULL) {
4968 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
4969 - crit(LOGOPT_ANY, MODPREFIX "alloca: %s", estr);
4970 + logerr(MODPREFIX "alloca: %s", estr);
4971 return NSS_STATUS_UNAVAIL;
4974 if (sprintf(query, "(objectclass=%s)", class) >= l) {
4975 - debug(LOGOPT_NONE, MODPREFIX "error forming query string");
4976 + error(logopt, MODPREFIX "error forming query string");
4977 return NSS_STATUS_UNAVAIL;
4981 /* Initialize the LDAP context. */
4982 - ldap = do_reconnect(ctxt);
4983 + ldap = do_reconnect(logopt, ctxt);
4985 return NSS_STATUS_UNAVAIL;
4988 - debug(LOGOPT_NONE,
4990 MODPREFIX "searching for \"%s\" under \"%s\"", query, ctxt->qdn);
4992 rv = ldap_search_s(ldap, ctxt->qdn, scope, query, attrs, 0, &result);
4994 if ((rv != LDAP_SUCCESS) || !result) {
4995 - error(LOGOPT_NONE,
4996 - MODPREFIX "query failed for %s: %s",
4997 + error(logopt, MODPREFIX "query failed for %s: %s",
4998 query, ldap_err2string(rv));
4999 - unbind_ldap_connection(ldap, ctxt);
5000 + unbind_ldap_connection(logging, ldap, ctxt);
5001 return NSS_STATUS_NOTFOUND;
5004 e = ldap_first_entry(ldap, result);
5006 - debug(LOGOPT_NONE,
5008 MODPREFIX "query succeeded, no matches for %s",
5010 ldap_msgfree(result);
5011 - unbind_ldap_connection(ldap, ctxt);
5012 + unbind_ldap_connection(logging, ldap, ctxt);
5013 return NSS_STATUS_NOTFOUND;
5015 - debug(LOGOPT_NONE, MODPREFIX "examining entries");
5016 + debug(logopt, MODPREFIX "examining entries");
5019 keyValue = ldap_get_values(ldap, e, entry);
5020 @@ -1346,7 +1331,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5023 if (ldap_count_values(keyValue) > 1) {
5027 "key %s has duplicate entries - ignoring",
5029 @@ -1358,7 +1343,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5030 * inclusion is only valid in file maps.
5032 if (**keyValue == '+') {
5036 "ignoreing '+' map entry - not in file map");
5038 @@ -1366,7 +1351,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5040 values = ldap_get_values(ldap, e, info);
5041 if (!values || !*values) {
5042 - debug(LOGOPT_NONE,
5044 MODPREFIX "no %s defined for %s", info, query);
5047 @@ -1376,7 +1361,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5049 count = ldap_count_values(values);
5054 "one value per key allowed in master map");
5055 ldap_value_free(values);
5056 @@ -1385,7 +1370,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5058 blen = strlen(*keyValue) + 1 + strlen(*values) + 1;
5059 if (blen > PARSE_MAX_BUF) {
5060 - error(LOGOPT_ANY, MODPREFIX "map entry too long");
5061 + error(logopt, MODPREFIX "map entry too long");
5062 ldap_value_free(values);
5065 @@ -1403,7 +1388,7 @@ next:
5068 ldap_msgfree(result);
5069 - unbind_ldap_connection(ldap, ctxt);
5070 + unbind_ldap_connection(logopt, ldap, ctxt);
5072 return NSS_STATUS_SUCCESS;
5074 @@ -1445,7 +1430,7 @@ static int read_one_map(struct autofs_point *ap,
5076 if (query == NULL) {
5077 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5078 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
5079 + logerr(MODPREFIX "malloc: %s", estr);
5080 return NSS_STATUS_UNAVAIL;
5083 @@ -1456,7 +1441,7 @@ static int read_one_map(struct autofs_point *ap,
5086 /* Initialize the LDAP context. */
5087 - ldap = do_reconnect(ctxt);
5088 + ldap = do_reconnect(ap->logopt, ctxt);
5090 return NSS_STATUS_UNAVAIL;
5092 @@ -1470,7 +1455,7 @@ static int read_one_map(struct autofs_point *ap,
5094 MODPREFIX "query failed for %s: %s",
5095 query, ldap_err2string(rv));
5096 - unbind_ldap_connection(ldap, ctxt);
5097 + unbind_ldap_connection(ap->logopt, ldap, ctxt);
5099 return NSS_STATUS_NOTFOUND;
5101 @@ -1480,7 +1465,7 @@ static int read_one_map(struct autofs_point *ap,
5103 MODPREFIX "query succeeded, no matches for %s", query);
5104 ldap_msgfree(result);
5105 - unbind_ldap_connection(ldap, ctxt);
5106 + unbind_ldap_connection(ap->logopt, ldap, ctxt);
5107 return NSS_STATUS_NOTFOUND;
5109 debug(ap->logopt, MODPREFIX "examining entries");
5110 @@ -1612,8 +1597,7 @@ static int read_one_map(struct autofs_point *ap,
5113 estr = strerror_r(errno, buf, MAX_ERR_BUF);
5115 - MODPREFIX "malloc: %s", estr);
5116 + logerr(MODPREFIX "malloc: %s", estr);
5117 ldap_value_free_len(bvValues);
5120 @@ -1633,8 +1617,7 @@ static int read_one_map(struct autofs_point *ap,
5123 estr = strerror_r(errno, buf, MAX_ERR_BUF);
5125 - MODPREFIX "realloc: %s", estr);
5126 + logerr(MODPREFIX "realloc: %s", estr);
5130 @@ -1669,7 +1652,7 @@ next:
5133 ldap_msgfree(result);
5134 - unbind_ldap_connection(ldap, ctxt);
5135 + unbind_ldap_connection(ap->logopt, ldap, ctxt);
5139 @@ -1766,7 +1749,7 @@ static int lookup_one(struct autofs_point *ap,
5142 /* Initialize the LDAP context. */
5143 - ldap = do_reconnect(ctxt);
5144 + ldap = do_reconnect(ap->logopt, ctxt);
5148 @@ -1777,7 +1760,7 @@ static int lookup_one(struct autofs_point *ap,
5150 if ((rv != LDAP_SUCCESS) || !result) {
5151 crit(ap->logopt, MODPREFIX "query failed for %s", query);
5152 - unbind_ldap_connection(ldap, ctxt);
5153 + unbind_ldap_connection(ap->logopt, ldap, ctxt);
5157 @@ -1789,7 +1772,7 @@ static int lookup_one(struct autofs_point *ap,
5159 MODPREFIX "got answer, but no entry for %s", query);
5160 ldap_msgfree(result);
5161 - unbind_ldap_connection(ldap, ctxt);
5162 + unbind_ldap_connection(ap->logopt, ldap, ctxt);
5166 @@ -1897,8 +1880,7 @@ static int lookup_one(struct autofs_point *ap,
5169 estr = strerror_r(errno, buf, MAX_ERR_BUF);
5171 - MODPREFIX "malloc: %s", estr);
5172 + logerr(MODPREFIX "malloc: %s", estr);
5173 ldap_value_free_len(bvValues);
5176 @@ -1918,8 +1900,7 @@ static int lookup_one(struct autofs_point *ap,
5179 estr = strerror_r(errno, buf, MAX_ERR_BUF);
5181 - MODPREFIX "realloc: %s", estr);
5182 + logerr(MODPREFIX "realloc: %s", estr);
5186 @@ -1955,7 +1936,7 @@ next:
5189 ldap_msgfree(result);
5190 - unbind_ldap_connection(ldap, ctxt);
5191 + unbind_ldap_connection(ap->logopt, ldap, ctxt);
5193 /* Failed to find wild entry, update cache if needed */
5194 pthread_cleanup_push(cache_lock_cleanup, mc);
5195 diff --git a/modules/lookup_multi.c b/modules/lookup_multi.c
5196 index 8fa94ae..601d48e 100644
5197 --- a/modules/lookup_multi.c
5198 +++ b/modules/lookup_multi.c
5199 @@ -73,7 +73,7 @@ static struct lookup_mod *nss_open_lookup(const char *format, int argc, const ch
5200 if (nsswitch_parse(&nsslist)) {
5201 if (!list_empty(&nsslist))
5202 free_sources(&nsslist);
5203 - error(LOGOPT_ANY, "can't to read name service switch config.");
5204 + logerr("can't to read name service switch config.");
5208 @@ -92,7 +92,7 @@ static struct lookup_mod *nss_open_lookup(const char *format, int argc, const ch
5209 path = malloc(strlen(AUTOFS_MAP_DIR) + strlen(argv[0]) + 2);
5211 estr = strerror_r(errno, buf, MAX_ERR_BUF);
5212 - crit(LOGOPT_ANY, MODPREFIX "error: %s", estr);
5213 + logerr(MODPREFIX "error: %s", estr);
5214 free_sources(&nsslist);
5217 @@ -150,7 +150,7 @@ int lookup_init(const char *my_mapfmt, int argc, const char *const *argv, void *
5218 memset(ctxt, 0, sizeof(struct lookup_context));
5221 - crit(LOGOPT_ANY, MODPREFIX "No map list");
5222 + logerr(MODPREFIX "No map list");
5226 @@ -176,8 +176,7 @@ int lookup_init(const char *my_mapfmt, int argc, const char *const *argv, void *
5227 if (!strcmp(ctxt->argl[an], "--")) {
5228 ctxt->argl[an] = NULL;
5231 - MODPREFIX "error assigning map args");
5232 + logerr(MODPREFIX "error assigning map args");
5235 ctxt->m[i].argv = copy_argv(ctxt->m[i].argc, (const char **) args);
5236 @@ -201,7 +200,7 @@ int lookup_init(const char *my_mapfmt, int argc, const char *const *argv, void *
5237 ctxt->m[i].mod = nss_open_lookup(my_mapfmt,
5238 ctxt->m[i].argc, ctxt->m[i].argv);
5239 if (!ctxt->m[i].mod) {
5240 - error(LOGOPT_ANY, MODPREFIX "error opening module");
5241 + logerr(MODPREFIX "error opening module");
5245 @@ -211,7 +210,7 @@ int lookup_init(const char *my_mapfmt, int argc, const char *const *argv, void *
5248 estr = strerror_r(errno, buf, MAX_ERR_BUF);
5249 - crit(LOGOPT_ANY, MODPREFIX "error: %s", estr);
5250 + logerr(MODPREFIX "error: %s", estr);
5253 for (i = 0; i < ctxt->n; i++) {
5254 diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
5255 index 83e99e0..ff8bd49 100644
5256 --- a/modules/lookup_nisplus.c
5257 +++ b/modules/lookup_nisplus.c
5258 @@ -41,13 +41,13 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
5259 ctxt = malloc(sizeof(struct lookup_context));
5261 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5262 - crit(LOGOPT_ANY, MODPREFIX "%s", estr);
5263 + logerr(MODPREFIX "%s", estr);
5269 - crit(LOGOPT_ANY, MODPREFIX "No map name");
5270 + logmsg(MODPREFIX "No map name");
5273 ctxt->mapname = argv[0];
5274 @@ -59,7 +59,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
5275 ctxt->domainname = nis_local_directory();
5276 if (!ctxt->domainname) {
5278 - crit(LOGOPT_ANY, MODPREFIX "NIS+ domain not set");
5279 + logmsg(MODPREFIX "NIS+ domain not set");
5283 @@ -69,7 +69,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
5284 ctxt->parse = open_parse(mapfmt, MODPREFIX, argc - 1, argv + 1);
5287 - crit(LOGOPT_ANY, MODPREFIX "failed to open parse context");
5288 + logerr(MODPREFIX "failed to open parse context");
5292 @@ -81,7 +81,8 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5294 struct lookup_context *ctxt = (struct lookup_context *) context;
5295 unsigned int timeout = master->default_timeout;
5296 - unsigned int logging = master->default_logging;
5297 + unsigned int logging = master->default_logging;
5298 + unsigned int logopt = master->logopt;
5302 @@ -95,7 +96,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5303 tablename = alloca(strlen(ctxt->mapname) + strlen(ctxt->domainname) + 20);
5305 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5306 - crit(LOGOPT_ANY, MODPREFIX "alloca: %s", estr);
5307 + logerr(MODPREFIX "alloca: %s", estr);
5308 pthread_setcancelstate(cur_state, NULL);
5309 return NSS_STATUS_UNAVAIL;
5311 @@ -105,8 +106,8 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5312 result = nis_lookup(tablename, FOLLOW_PATH | FOLLOW_LINKS);
5313 if (result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) {
5314 nis_freeresult(result);
5316 - MODPREFIX "couldn't locat nis+ table %s", ctxt->mapname);
5318 + MODPREFIX "couldn't locate nis+ table %s", ctxt->mapname);
5319 pthread_setcancelstate(cur_state, NULL);
5320 return NSS_STATUS_NOTFOUND;
5322 @@ -116,7 +117,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5323 result = nis_list(tablename, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
5324 if (result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) {
5325 nis_freeresult(result);
5328 MODPREFIX "couldn't enumrate nis+ map %s", ctxt->mapname);
5329 pthread_setcancelstate(cur_state, NULL);
5330 return NSS_STATUS_UNAVAIL;
5331 @@ -139,8 +140,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5333 buffer = malloc(ENTRY_LEN(this, 0) + 1 + ENTRY_LEN(this, 1) + 1);
5336 - MODPREFIX "could not malloc parse buffer");
5337 + logerr(MODPREFIX "could not malloc parse buffer");
5341 @@ -182,7 +182,7 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
5342 tablename = alloca(strlen(ctxt->mapname) + strlen(ctxt->domainname) + 20);
5344 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5345 - crit(LOGOPT_ANY, MODPREFIX "alloca: %s", estr);
5346 + logerr(MODPREFIX "alloca: %s", estr);
5347 pthread_setcancelstate(cur_state, NULL);
5348 return NSS_STATUS_UNAVAIL;
5350 @@ -193,7 +193,7 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
5351 if (result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) {
5352 nis_freeresult(result);
5354 - MODPREFIX "couldn't locat nis+ table %s", ctxt->mapname);
5355 + MODPREFIX "couldn't locate nis+ table %s", ctxt->mapname);
5356 pthread_setcancelstate(cur_state, NULL);
5357 return NSS_STATUS_NOTFOUND;
5359 @@ -274,7 +274,7 @@ static int lookup_one(struct autofs_point *ap,
5360 strlen(ctxt->mapname) + strlen(ctxt->domainname) + 20);
5362 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5363 - crit(LOGOPT_ANY, MODPREFIX "alloca: %s", estr);
5364 + logerr(MODPREFIX "alloca: %s", estr);
5365 pthread_setcancelstate(cur_state, NULL);
5368 @@ -327,7 +327,7 @@ static int lookup_wild(struct autofs_point *ap, struct lookup_context *ctxt)
5369 tablename = alloca(strlen(ctxt->mapname) + strlen(ctxt->domainname) + 20);
5371 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5372 - crit(LOGOPT_ANY, MODPREFIX "alloca: %s", estr);
5373 + logerr(MODPREFIX "alloca: %s", estr);
5374 pthread_setcancelstate(cur_state, NULL);
5377 diff --git a/modules/lookup_program.c b/modules/lookup_program.c
5378 index 2fd521a..e28168e 100644
5379 --- a/modules/lookup_program.c
5380 +++ b/modules/lookup_program.c
5381 @@ -51,28 +51,26 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
5382 ctxt = malloc(sizeof(struct lookup_context));
5384 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5385 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
5386 + logerr(MODPREFIX "malloc: %s", estr);
5391 - crit(LOGOPT_ANY, MODPREFIX "No map name");
5392 + logmsg(MODPREFIX "No map name");
5396 ctxt->mapname = argv[0];
5398 if (ctxt->mapname[0] != '/') {
5400 - MODPREFIX "program map %s is not an absolute pathname",
5401 + logmsg(MODPREFIX "program map %s is not an absolute pathname",
5407 if (access(ctxt->mapname, X_OK)) {
5409 - MODPREFIX "program map %s missing or not executable",
5410 + logmsg(MODPREFIX "program map %s missing or not executable",
5414 @@ -83,7 +81,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
5416 ctxt->parse = open_parse(mapfmt, MODPREFIX, argc - 1, argv + 1);
5418 - crit(LOGOPT_ANY, MODPREFIX "failed to open parse context");
5419 + logmsg(MODPREFIX "failed to open parse context");
5423 @@ -163,7 +161,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
5424 mapent = (char *) malloc(MAPENT_MAX_LEN + 1);
5426 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5427 - error(ap->logopt, MODPREFIX "malloc: %s", estr);
5428 + logerr(MODPREFIX "malloc: %s", estr);
5429 return NSS_STATUS_UNAVAIL;
5432 @@ -176,7 +174,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
5435 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5436 - error(ap->logopt, MODPREFIX "pipe: %s", estr);
5437 + logerr(MODPREFIX "pipe: %s", estr);
5440 if (pipe(epipefd)) {
5441 @@ -188,7 +186,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
5444 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5445 - error(ap->logopt, MODPREFIX "fork: %s", estr);
5446 + logerr(MODPREFIX "fork: %s", estr);
5450 @@ -271,8 +269,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
5455 - MODPREFIX "realloc: %s",
5456 + logerr(MODPREFIX "realloc: %s",
5460 @@ -308,12 +305,12 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
5461 } else if (ch == '\n') {
5464 - error(ap->logopt, ">> %s", errbuf);
5465 + logmsg(">> %s", errbuf);
5468 if (errp >= &errbuf[1023]) {
5470 - error(ap->logopt, ">> %s", errbuf);
5471 + logmsg(">> %s", errbuf);
5475 @@ -325,7 +322,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
5477 if (errp > errbuf) {
5479 - error(ap->logopt, ">> %s", errbuf);
5480 + logmsg(">> %s", errbuf);
5484 @@ -333,12 +330,12 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
5486 if (waitpid(f, &status, 0) != f) {
5487 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5488 - error(ap->logopt, MODPREFIX "waitpid: %s", estr);
5489 + logerr(MODPREFIX "waitpid: %s", estr);
5493 if (mapp == mapent || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
5494 - msg(MODPREFIX "lookup for %s failed", name);
5495 + info(ap->logopt, MODPREFIX "lookup for %s failed", name);
5499 diff --git a/modules/lookup_userhome.c b/modules/lookup_userhome.c
5500 index efcab0b..680ddaf 100644
5501 --- a/modules/lookup_userhome.c
5502 +++ b/modules/lookup_userhome.c
5503 @@ -73,7 +73,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
5504 /* Create the appropriate symlink */
5505 if (chdir(ap->path)) {
5506 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5507 - error(ap->logopt, MODPREFIX "chdir failed: %s", estr);
5508 + logerr(MODPREFIX "chdir failed: %s", estr);
5509 return NSS_STATUS_UNAVAIL;
5512 @@ -88,7 +88,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
5514 if (symlink(pw->pw_dir, name) && errno != EEXIST) {
5515 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5516 - error(ap->logopt, MODPREFIX "symlink failed: %s", estr);
5517 + logerr(MODPREFIX "symlink failed: %s", estr);
5518 return NSS_STATUS_UNAVAIL;
5521 diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
5522 index da280cc..63fc8e3 100644
5523 --- a/modules/lookup_yp.c
5524 +++ b/modules/lookup_yp.c
5525 @@ -45,12 +45,14 @@ struct lookup_context {
5526 struct callback_master_data {
5533 struct callback_data {
5534 struct autofs_point *ap;
5535 struct map_source *source;
5540 @@ -111,20 +113,18 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
5541 ctxt = malloc(sizeof(struct lookup_context));
5543 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5544 - crit(LOGOPT_ANY, MODPREFIX "%s", estr);
5545 + logerr(MODPREFIX "%s", estr);
5548 memset(ctxt, 0, sizeof(struct lookup_context));
5552 - crit(LOGOPT_ANY, MODPREFIX "no map name");
5553 + logerr(MODPREFIX "no map name");
5556 ctxt->mapname = argv[0];
5558 - debug(LOGOPT_NONE, MODPREFIX "ctxt->mapname=%s", ctxt->mapname);
5560 /* This should, but doesn't, take a const char ** */
5561 err = yp_get_default_domain((char **) &ctxt->domainname);
5563 @@ -133,8 +133,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
5564 memcpy(name, ctxt->mapname, len);
5567 - debug(LOGOPT_NONE, MODPREFIX "map %s: %s", name,
5568 - yperr_string(err));
5569 + logerr(MODPREFIX "map %s: %s", name, yperr_string(err));
5573 @@ -146,7 +145,7 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
5574 ctxt->parse = open_parse(mapfmt, MODPREFIX, argc - 1, argv + 1);
5577 - crit(LOGOPT_ANY, MODPREFIX "failed to open parse context");
5578 + logmsg(MODPREFIX "failed to open parse context");
5582 @@ -161,6 +160,7 @@ int yp_all_master_callback(int status, char *ypkey, int ypkeylen,
5583 (struct callback_master_data *) ypcb_data;
5584 unsigned int timeout = cbdata->timeout;
5585 unsigned int logging = cbdata->logging;
5586 + unsigned int logopt = cbdata->logopt;
5587 time_t age = cbdata->age;
5590 @@ -182,7 +182,7 @@ int yp_all_master_callback(int status, char *ypkey, int ypkeylen,
5592 buffer = alloca(len);
5594 - error(LOGOPT_ANY, MODPREFIX "could not malloc parse buffer");
5595 + error(logopt, MODPREFIX "could not malloc parse buffer");
5598 memset(buffer, 0, len);
5599 @@ -201,6 +201,8 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5600 struct lookup_context *ctxt = (struct lookup_context *) context;
5601 struct ypall_callback ypcb;
5602 struct callback_master_data ypcb_data;
5603 + unsigned int logging = master->default_logging;
5604 + unsigned int logopt = master->logopt;
5608 @@ -211,7 +213,8 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5609 strcpy(mapname, ctxt->mapname);
5611 ypcb_data.timeout = master->default_timeout;
5612 - ypcb_data.logging = master->default_logging;
5613 + ypcb_data.logging = logging;
5614 + ypcb_data.logopt = logopt;
5615 ypcb_data.age = age;
5617 ypcb.foreach = yp_all_master_callback;
5618 @@ -232,7 +235,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
5619 if (err == YPERR_SUCCESS)
5620 return NSS_STATUS_SUCCESS;
5624 MODPREFIX "read of master map %s failed: %s",
5625 mapname, yperr_string(err));
5627 @@ -249,6 +252,7 @@ int yp_all_callback(int status, char *ypkey, int ypkeylen,
5628 struct autofs_point *ap = cbdata->ap;
5629 struct map_source *source = cbdata->source;
5630 struct mapent_cache *mc = source->mc;
5631 + unsigned int logopt = cbdata->logopt;
5632 time_t age = cbdata->age;
5635 @@ -264,8 +268,10 @@ int yp_all_callback(int status, char *ypkey, int ypkeylen,
5638 key = sanitize_path(ypkey, ypkeylen, ap->type, ap->logopt);
5641 + error(logopt, MODPREFIX "invalid path %s", ypkey);
5645 mapent = alloca(vallen + 1);
5646 strncpy(mapent, val, vallen);
5647 @@ -288,6 +294,7 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
5648 struct lookup_context *ctxt = (struct lookup_context *) context;
5649 struct ypall_callback ypcb;
5650 struct callback_data ypcb_data;
5651 + unsigned int logopt = ap->logopt;
5652 struct map_source *source;
5655 @@ -298,6 +305,7 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
5658 ypcb_data.source = source;
5659 + ypcb_data.logopt = logopt;
5660 ypcb_data.age = age;
5662 ypcb.foreach = yp_all_callback;
5663 diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c
5664 index c45b91b..356fb14 100644
5665 --- a/modules/mount_autofs.c
5666 +++ b/modules/mount_autofs.c
5667 @@ -64,7 +64,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
5668 fullpath = alloca(strlen(root) + name_len + 2);
5670 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5671 - error(ap->logopt, MODPREFIX "alloca: %s", estr);
5672 + logerr(MODPREFIX "alloca: %s", estr);
5676 @@ -156,7 +156,6 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
5680 - set_mnt_logging(nap);
5684 @@ -208,7 +207,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
5688 - source->mc = cache_init(source);
5689 + source->mc = cache_init(entry->ap, source);
5691 error(ap->logopt, MODPREFIX "failed to init source cache");
5692 master_free_mapent(entry);
5693 diff --git a/modules/mount_bind.c b/modules/mount_bind.c
5694 index cb17ce4..04284f5 100644
5695 --- a/modules/mount_bind.c
5696 +++ b/modules/mount_bind.c
5697 @@ -52,16 +52,14 @@ int mount_init(void **context)
5698 if (lstat(t1_dir, &st1) == -1)
5701 - err = spawn_mount(log_debug, "-n", "--bind", t1_dir, t2_dir, NULL);
5702 + err = spawn_mount(LOGOPT_NONE, "-n", "--bind", t1_dir, t2_dir, NULL);
5704 lstat(t2_dir, &st2) == 0 &&
5705 st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
5709 - debug(LOGOPT_NONE, MODPREFIX "bind_works = %d", bind_works);
5711 - spawn_umount(log_debug, "-n", t2_dir, NULL);
5712 + spawn_umount(LOGOPT_NONE, "-n", t2_dir, NULL);
5716 @@ -91,7 +89,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5717 fullpath = alloca(rlen + name_len + 2);
5719 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5720 - error(ap->logopt, MODPREFIX "alloca: %s", estr);
5721 + logerr(MODPREFIX "alloca: %s", estr);
5725 @@ -139,7 +137,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5726 "calling mount --bind " SLOPPY " -o %s %s %s",
5727 options, what, fullpath);
5729 - err = spawn_bind_mount(log_debug,
5730 + err = spawn_bind_mount(ap->logopt,
5731 SLOPPYOPT "-o", options, what, fullpath, NULL);
5734 diff --git a/modules/mount_changer.c b/modules/mount_changer.c
5735 index 6e04c7c..08d9147 100644
5736 --- a/modules/mount_changer.c
5737 +++ b/modules/mount_changer.c
5738 @@ -66,7 +66,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5739 fullpath = alloca(rlen + name_len + 2);
5741 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5742 - error(ap->logopt, MODPREFIX "alloca: %s", estr);
5743 + logerr(MODPREFIX "alloca: %s", estr);
5747 @@ -80,7 +80,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5749 debug(ap->logopt, MODPREFIX "calling umount %s", what);
5751 - err = spawn_umount(log_debug, what, NULL);
5752 + err = spawn_umount(ap->logopt, what, NULL);
5756 @@ -115,18 +115,18 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5757 MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
5758 fstype, options, what, fullpath);
5760 - err = spawn_mount(log_debug, "-t", fstype,
5761 + err = spawn_mount(ap->logopt, "-t", fstype,
5762 SLOPPYOPT "-o", options, what, fullpath, NULL);
5765 MODPREFIX "calling mount -t %s %s %s",
5766 fstype, what, fullpath);
5768 - err = spawn_mount(log_debug, "-t", fstype, what, fullpath, NULL);
5769 + err = spawn_mount(ap->logopt, "-t", fstype, what, fullpath, NULL);
5773 - msg(MODPREFIX "failed to mount %s (type %s) on %s",
5774 + info(ap->logopt, MODPREFIX "failed to mount %s (type %s) on %s",
5775 what, fstype, fullpath);
5777 if (ap->type != LKP_INDIRECT)
5778 @@ -137,7 +137,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5782 - msg(MODPREFIX "mounted %s type %s on %s",
5783 + info(ap->logopt, MODPREFIX "mounted %s type %s on %s",
5784 what, fstype, fullpath);
5787 @@ -161,7 +161,7 @@ int swapCD(const char *device, const char *slotName)
5789 fd = open(device, O_RDONLY | O_NONBLOCK);
5791 - error(LOGOPT_ANY, MODPREFIX "Opening device %s failed : %s",
5792 + logerr(MODPREFIX "Opening device %s failed : %s",
5793 device, strerror(errno));
5796 @@ -174,7 +174,7 @@ int swapCD(const char *device, const char *slotName)
5797 /* Check CD player status */
5798 total_slots_available = ioctl(fd, CDROM_CHANGER_NSLOTS);
5799 if (total_slots_available <= 1) {
5800 - error(LOGOPT_ANY, MODPREFIX
5802 "Device %s is not an ATAPI compliant CD changer.",
5805 @@ -183,14 +183,14 @@ int swapCD(const char *device, const char *slotName)
5807 slot = ioctl(fd, CDROM_SELECT_DISC, slot);
5809 - error(LOGOPT_ANY, MODPREFIX "CDROM_SELECT_DISC failed");
5810 + logerr(MODPREFIX "CDROM_SELECT_DISC failed");
5817 - error(LOGOPT_ANY, MODPREFIX "close failed for `%s': %s",
5818 + logerr(MODPREFIX "close failed for `%s': %s",
5819 device, strerror(errno));
5822 diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
5823 index 45f0615..8cf9937 100644
5824 --- a/modules/mount_ext2.c
5825 +++ b/modules/mount_ext2.c
5826 @@ -58,7 +58,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5827 fullpath = alloca(rlen + name_len + 2);
5829 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5830 - error(ap->logopt, MODPREFIX "alloca: %s", estr);
5831 + logerr(MODPREFIX "alloca: %s", estr);
5835 @@ -108,11 +108,11 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5838 MODPREFIX "calling %s -n %s", fsck_prog, what);
5839 - err = spawnl(log_debug, fsck_prog, fsck_prog, "-n", what, NULL);
5840 + err = spawnl(ap->logopt, fsck_prog, fsck_prog, "-n", what, NULL);
5843 MODPREFIX "calling %s -p %s", fsck_prog, what);
5844 - err = spawnl(log_debug, fsck_prog, fsck_prog, "-p", what, NULL);
5845 + err = spawnl(ap->logopt, fsck_prog, fsck_prog, "-p", what, NULL);
5849 @@ -132,17 +132,17 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5851 MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
5852 fstype, options, what, fullpath);
5853 - err = spawn_mount(log_debug, "-t", fstype,
5854 + err = spawn_mount(ap->logopt, "-t", fstype,
5855 SLOPPYOPT "-o", options, what, fullpath, NULL);
5858 MODPREFIX "calling mount -t %s %s %s",
5859 fstype, what, fullpath);
5860 - err = spawn_mount(log_debug, "-t", fstype, what, fullpath, NULL);
5861 + err = spawn_mount(ap->logopt, "-t", fstype, what, fullpath, NULL);
5865 - msg(MODPREFIX "failed to mount %s (type %s) on %s",
5866 + info(ap->logopt, MODPREFIX "failed to mount %s (type %s) on %s",
5867 what, fstype, fullpath);
5869 if (ap->type != LKP_INDIRECT)
5870 @@ -153,7 +153,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5876 MODPREFIX "mounted %s type %s on %s",
5877 what, fstype, fullpath);
5879 diff --git a/modules/mount_generic.c b/modules/mount_generic.c
5880 index 1f43baa..85b4391 100644
5881 --- a/modules/mount_generic.c
5882 +++ b/modules/mount_generic.c
5883 @@ -57,7 +57,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5884 fullpath = alloca(rlen + name_len + 2);
5886 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5887 - error(ap->logopt, MODPREFIX "alloca: %s", estr);
5888 + logerr(MODPREFIX "alloca: %s", estr);
5892 @@ -93,16 +93,16 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5893 MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
5894 fstype, options, what, fullpath);
5896 - err = spawn_mount(log_debug, "-t", fstype,
5897 + err = spawn_mount(ap->logopt, "-t", fstype,
5898 SLOPPYOPT "-o", options, what, fullpath, NULL);
5900 debug(ap->logopt, MODPREFIX "calling mount -t %s %s %s",
5901 fstype, what, fullpath);
5902 - err = spawn_mount(log_debug, "-t", fstype, what, fullpath, NULL);
5903 + err = spawn_mount(ap->logopt, "-t", fstype, what, fullpath, NULL);
5907 - msg(MODPREFIX "failed to mount %s (type %s) on %s",
5908 + info(ap->logopt, MODPREFIX "failed to mount %s (type %s) on %s",
5909 what, fstype, fullpath);
5911 if (ap->type != LKP_INDIRECT)
5912 @@ -113,7 +113,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5916 - msg(MODPREFIX "mounted %s type %s on %s",
5917 + info(ap->logopt, MODPREFIX "mounted %s type %s on %s",
5918 what, fstype, fullpath);
5921 diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
5922 index e4480c5..bad21fc 100644
5923 --- a/modules/mount_nfs.c
5924 +++ b/modules/mount_nfs.c
5925 @@ -133,14 +133,14 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5927 vers = NFS_VERS_MASK | NFS_PROTO_MASK;
5929 - if (!parse_location(&hosts, what)) {
5930 - warn(ap->logopt, MODPREFIX "no hosts available");
5931 + if (!parse_location(ap->logopt, &hosts, what)) {
5932 + info(ap->logopt, MODPREFIX "no hosts available");
5935 - prune_host_list(&hosts, vers, nfsoptions, ap->random_selection);
5936 + prune_host_list(ap->logopt, &hosts, vers, nfsoptions, ap->random_selection);
5939 - warn(ap->logopt, MODPREFIX "no hosts available");
5940 + info(ap->logopt, MODPREFIX "no hosts available");
5944 @@ -159,7 +159,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5945 fullpath = alloca(rlen + name_len + 2);
5947 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5948 - error(ap->logopt, MODPREFIX "alloca: %s", estr);
5949 + logerr(MODPREFIX "alloca: %s", estr);
5950 free_host_list(&hosts);
5953 @@ -252,19 +252,19 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5954 MODPREFIX "calling mount -t %s " SLOPPY
5955 "-o %s %s %s", fstype, nfsoptions, loc, fullpath);
5957 - err = spawn_mount(log_debug,
5958 + err = spawn_mount(ap->logopt,
5959 "-t", fstype, SLOPPYOPT "-o",
5960 nfsoptions, loc, fullpath, NULL);
5963 MODPREFIX "calling mount -t %s %s %s",
5964 fstype, loc, fullpath);
5965 - err = spawn_mount(log_debug,
5966 + err = spawn_mount(ap->logopt,
5967 "-t", fstype, loc, fullpath, NULL);
5971 - msg(MODPREFIX "mounted %s on %s", loc, fullpath);
5972 + info(ap->logopt, MODPREFIX "mounted %s on %s", loc, fullpath);
5974 free_host_list(&hosts);
5975 ap->ghost = save_ghost;
5976 @@ -280,7 +280,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
5978 /* If we get here we've failed to complete the mount */
5980 - msg(MODPREFIX "nfs: mount failure %s on %s", what, fullpath);
5981 + info(ap->logopt, MODPREFIX "nfs: mount failure %s on %s", what, fullpath);
5983 if (ap->type != LKP_INDIRECT)
5985 diff --git a/modules/parse_sun.c b/modules/parse_sun.c
5986 index 079bda6..186e567 100644
5987 --- a/modules/parse_sun.c
5988 +++ b/modules/parse_sun.c
5989 @@ -277,7 +277,7 @@ int parse_init(int argc, const char *const *argv, void **context)
5991 if (!(ctxt = (struct parse_context *) malloc(sizeof(struct parse_context)))) {
5992 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
5993 - crit(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
5994 + logerr(MODPREFIX "malloc: %s", estr);
5998 @@ -302,7 +302,7 @@ int parse_init(int argc, const char *const *argv, void **context)
6001 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6002 - error(LOGOPT_ANY, MODPREFIX "strdup: %s", estr);
6003 + logerr(MODPREFIX "strdup: %s", estr);
6007 @@ -387,7 +387,7 @@ int parse_init(int argc, const char *const *argv, void **context)
6009 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6011 - crit(LOGOPT_ANY, MODPREFIX "%s", estr);
6012 + logerr(MODPREFIX "%s", estr);
6016 @@ -408,7 +408,7 @@ int parse_init(int argc, const char *const *argv, void **context)
6017 char *tmp = concat_options(gbl_options, ctxt->optstr);
6019 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6020 - error(LOGOPT_ANY, MODPREFIX "concat_options: %s", estr);
6021 + logerr(MODPREFIX "concat_options: %s", estr);
6025 @@ -472,7 +472,7 @@ static char *concat_options(char *left, char *right)
6028 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6029 - error(LOGOPT_ANY, MODPREFIX "malloc: %s", estr);
6030 + logerr(MODPREFIX "malloc: %s", estr);
6034 @@ -637,8 +637,7 @@ static int check_is_multi(const char *mapent)
6035 int not_first_chunk = 0;
6039 - MODPREFIX "unexpected NULL map entry pointer");
6040 + logerr(MODPREFIX "unexpected NULL map entry pointer");
6044 @@ -1021,7 +1020,7 @@ int parse_mount(struct autofs_point *ap, const char *name,
6045 pmapent = alloca(mapent_len + 1);
6047 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6048 - error(ap->logopt, MODPREFIX "alloca: %s", estr);
6049 + logerr(MODPREFIX "alloca: %s", estr);
6050 ctxt->subst = removestdenv(ctxt->subst);
6052 pthread_setcancelstate(cur_state, NULL);
6053 @@ -1041,7 +1040,7 @@ int parse_mount(struct autofs_point *ap, const char *name,
6054 options = strdup(ctxt->optstr ? ctxt->optstr : "");
6056 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6057 - error(ap->logopt, MODPREFIX "strdup: %s", estr);
6058 + logerr(MODPREFIX "strdup: %s", estr);
6061 optlen = strlen(options);
6062 @@ -1119,7 +1118,7 @@ int parse_mount(struct autofs_point *ap, const char *name,
6064 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6066 - error(ap->logopt, MODPREFIX "alloca: %s", estr);
6067 + logerr(MODPREFIX "alloca: %s", estr);
6070 strcpy(m_root, name);
6071 @@ -1129,7 +1128,7 @@ int parse_mount(struct autofs_point *ap, const char *name,
6073 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6075 - error(ap->logopt, MODPREFIX "alloca: %s", estr);
6076 + logerr(MODPREFIX "alloca: %s", estr);
6079 strcpy(m_root, ap->path);
6080 diff --git a/modules/replicated.c b/modules/replicated.c
6081 index e15587c..14b20a9 100644
6082 --- a/modules/replicated.c
6083 +++ b/modules/replicated.c
6084 @@ -113,7 +113,7 @@ static unsigned int get_proximity(const char *host_addr, int addr_len)
6085 sock = socket(AF_INET, SOCK_DGRAM, 0);
6087 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6088 - error(LOGOPT_ANY, "socket creation failed: %s", estr);
6089 + logerr("socket creation failed: %s", estr);
6090 return PROXIMITY_ERROR;
6093 @@ -127,7 +127,7 @@ static unsigned int get_proximity(const char *host_addr, int addr_len)
6094 ret = ioctl(sock, SIOCGIFCONF, &ifc);
6096 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6097 - error(LOGOPT_ANY, "ioctl: %s", estr);
6098 + logerr("ioctl: %s", estr);
6100 return PROXIMITY_ERROR;
6102 @@ -176,7 +176,7 @@ static unsigned int get_proximity(const char *host_addr, int addr_len)
6103 ret = ioctl(sock, SIOCGIFNETMASK, &nmptr);
6105 char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6106 - error(LOGOPT_ANY, "ioctl: %s", estr);
6107 + logerr("ioctl: %s", estr);
6109 return PROXIMITY_ERROR;
6111 @@ -387,7 +387,7 @@ static unsigned short get_port_option(const char *options)
6112 return (unsigned short) port;
6115 -static unsigned int get_nfs_info(struct host *host,
6116 +static unsigned int get_nfs_info(unsigned logopt, struct host *host,
6117 struct conn_info *pm_info, struct conn_info *rpc_info,
6118 const char *proto, unsigned int version,
6119 const char *options, unsigned int random_selection)
6120 @@ -533,7 +533,7 @@ done_ver:
6124 -static int get_vers_and_cost(struct host *host,
6125 +static int get_vers_and_cost(unsigned logopt, struct host *host,
6126 unsigned int version, const char *options,
6127 unsigned int random_selection)
6129 @@ -559,7 +559,7 @@ static int get_vers_and_cost(struct host *host,
6132 if (version & UDP_REQUESTED) {
6133 - supported = get_nfs_info(host,
6134 + supported = get_nfs_info(logopt, host,
6135 &pm_info, &rpc_info, "udp", vers,
6136 options, random_selection);
6138 @@ -569,7 +569,7 @@ static int get_vers_and_cost(struct host *host,
6141 if (version & TCP_REQUESTED) {
6142 - supported = get_nfs_info(host,
6143 + supported = get_nfs_info(logopt, host,
6144 &pm_info, &rpc_info, "tcp", vers,
6145 options, random_selection);
6147 @@ -581,7 +581,7 @@ static int get_vers_and_cost(struct host *host,
6151 -static int get_supported_ver_and_cost(struct host *host,
6152 +static int get_supported_ver_and_cost(unsigned logopt, struct host *host,
6153 unsigned int version, const char *options,
6154 unsigned int random_selection)
6156 @@ -636,7 +636,7 @@ static int get_supported_ver_and_cost(struct host *host,
6157 vers = NFS4_VERSION;
6160 - crit(LOGOPT_ANY, "called with invalid version: 0x%x\n", version);
6161 + crit(logopt, "called with invalid version: 0x%x\n", version);
6165 @@ -701,7 +701,7 @@ done:
6169 -int prune_host_list(struct host **list,
6170 +int prune_host_list(unsigned logopt, struct host **list,
6171 unsigned int vers, const char *options,
6172 unsigned int random_selection)
6174 @@ -742,7 +742,7 @@ int prune_host_list(struct host **list,
6178 - status = get_vers_and_cost(this, vers,
6179 + status = get_vers_and_cost(logopt, this, vers,
6180 options, random_selection);
6182 if (this == first) {
6183 @@ -833,7 +833,7 @@ int prune_host_list(struct host **list,
6184 remove_host(list, this);
6185 add_host(&new, this);
6187 - status = get_supported_ver_and_cost(this,
6188 + status = get_supported_ver_and_cost(logopt, this,
6189 selected_version, options,
6192 @@ -886,11 +886,9 @@ static int add_host_addrs(struct host **list, const char *host, unsigned int wei
6193 buf, MAX_IFC_BUF, &result, &ghn_errno);
6194 if (ret || !result) {
6195 if (ghn_errno == -1)
6197 - "host %s: lookup failure %d", host, errno);
6198 + logmsg("host %s: lookup failure %d", host, errno);
6201 - "host %s: lookup failure %d", host, ghn_errno);
6202 + logmsg("host %s: lookup failure %d", host, ghn_errno);
6206 @@ -965,7 +963,7 @@ static int add_local_path(struct host **hosts, const char *path)
6210 -int parse_location(struct host **hosts, const char *list)
6211 +int parse_location(unsigned logopt, struct host **hosts, const char *list)
6213 char *str, *p, *delim;
6214 unsigned int empty = 1;
6215 @@ -1072,8 +1070,7 @@ void dump_host_list(struct host *hosts)
6220 - "name %s path %s version %x proximity %u weight %u cost %u",
6221 + logmsg("name %s path %s version %x proximity %u weight %u cost %u",
6222 this->name, this->path, this->version,
6223 this->proximity, this->weight, this->cost);