1 diff --git a/Makefile.conf.in b/Makefile.conf.in
2 index ea5fe1d..09c3129 100644
5 @@ -71,6 +71,9 @@ autofsconfdir = @confdir@
6 # Location for autofs maps
7 autofsmapdir = @mapdir@
9 +# Location for autofs fifos
10 +autofsfifodir = @fifodir@
12 # Where to install the automount program
15 diff --git a/aclocal.m4 b/aclocal.m4
16 index ffeb232..118ef0d 100644
19 @@ -120,6 +120,22 @@ AC_DEFUN(AF_MAP_D,
23 +dnl --------------------------------------------------------------------------
26 +dnl Check the location of the autofs fifos directory
27 +dnl --------------------------------------------------------------------------
29 +[if test -z "$fifodir"; then
30 + for fifo_d in /var/run /tmp; do
31 + if test -z "$fifodir"; then
32 + if test -d "$fifo_d"; then
39 dnl ----------------------------------- ## -*- Autoconf -*-
40 dnl Check if --with-dmalloc was given. ##
41 dnl From Franc,ois Pinard ##
42 diff --git a/configure b/configure
43 index 3508224..0360086 100755
46 @@ -654,6 +654,7 @@ target_alias
54 @@ -1293,6 +1294,7 @@ Optional Packages:
55 --with-path=PATH look in PATH for binaries needed by the automounter
56 --with-confdir=DIR use DIR for autofs configuration files
57 --with-mapdir=PATH look in PATH for mount maps used by the automounter
58 + --with-fifodir=PATH use PATH as the directory for fifos used by the automounter
59 --with-dmalloc use dmalloc, as in
60 http://www.dmalloc.com/dmalloc.tar.gz
61 --with-hesiod=DIR enable Hesiod support (libs and includes in DIR)
62 @@ -1844,6 +1846,36 @@ echo "${ECHO_T}$mapdir" >&6; }
66 +# The user can specify --with-fifodir=PATH to specify where autofs fifos go
68 +if test -z "$fifodir"; then
69 + for fifo_d in /var/run /tmp; do
70 + if test -z "$fifodir"; then
71 + if test -d "$fifo_d"; then
78 +# Check whether --with-fifodir was given.
79 +if test "${with_fifodir+set}" = set; then
80 + withval=$with_fifodir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no"
84 + fifodir="${withval}"
89 +{ echo "$as_me:$LINENO: checking for autofs fifos directory" >&5
90 +echo $ECHO_N "checking for autofs fifos directory... $ECHO_C" >&6; }
91 +{ echo "$as_me:$LINENO: result: $fifodir" >&5
92 +echo "${ECHO_T}$fifodir" >&6; }
96 # Optional include dmalloc
98 { echo "$as_me:$LINENO: checking if malloc debugging is wanted" >&5
99 @@ -6074,6 +6106,7 @@ target_alias!$target_alias$ac_delim
100 initdir!$initdir$ac_delim
101 confdir!$confdir$ac_delim
102 mapdir!$mapdir$ac_delim
103 +fifodir!$fifodir$ac_delim
104 DMALLOCLIB!$DMALLOCLIB$ac_delim
105 MOUNT!$MOUNT$ac_delim
106 HAVE_MOUNT!$HAVE_MOUNT$ac_delim
107 @@ -6124,7 +6157,7 @@ LIBOBJS!$LIBOBJS$ac_delim
108 LTLIBOBJS!$LTLIBOBJS$ac_delim
111 - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 88; then
112 + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 89; then
114 elif $ac_last_try; then
115 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
116 diff --git a/configure.in b/configure.in
117 index 8cddf90..a83b3f1 100644
120 @@ -79,6 +79,23 @@ AC_MSG_RESULT([$mapdir])
124 +# The user can specify --with-fifodir=PATH to specify where autofs fifos go
127 +AC_ARG_WITH(fifodir,
128 +[ --with-fifodir=PATH use PATH as the directory for fifos used by the automounter],
129 + if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no"
133 + fifodir="${withval}"
136 +AC_MSG_CHECKING([for autofs fifos directory])
137 +AC_MSG_RESULT([$fifodir])
141 # Optional include dmalloc
144 diff --git a/daemon/Makefile b/daemon/Makefile
145 index 4ee70eb..528a684 100644
146 --- a/daemon/Makefile
147 +++ b/daemon/Makefile
148 @@ -16,6 +16,7 @@ CFLAGS += -rdynamic $(DAEMON_CFLAGS) -D_GNU_SOURCE -I../include
149 CFLAGS += -DAUTOFS_LIB_DIR=\"$(autofslibdir)\"
150 CFLAGS += -DAUTOFS_MAP_DIR=\"$(autofsmapdir)\"
151 CFLAGS += -DAUTOFS_CONF_DIR=\"$(autofsconfdir)\"
152 +CFLAGS += -DAUTOFS_FIFO_DIR=\"$(autofsfifodir)\"
153 CFLAGS += -DVERSION_STRING=\"$(version)\"
156 diff --git a/daemon/automount.c b/daemon/automount.c
157 index 7e7d1e6..a12b6da 100644
158 --- a/daemon/automount.c
159 +++ b/daemon/automount.c
160 @@ -50,6 +50,9 @@ const char *libdir = AUTOFS_LIB_DIR; /* Location of library modules */
161 const char *mapdir = AUTOFS_MAP_DIR; /* Location of mount maps */
162 const char *confdir = AUTOFS_CONF_DIR; /* Location of autofs config file */
164 +/* autofs fifo name prefix */
165 +const char *fifodir = AUTOFS_FIFO_DIR "/autofs.fifo";
167 const char *global_options; /* Global option, from command line */
169 static char *pid_file = NULL; /* File in which to keep pid */
170 @@ -650,14 +653,13 @@ static int fullread(int fd, void *ptr, size_t len)
171 static char *automount_path_to_fifo(unsigned logopt, const char *path)
174 - int name_len = strlen(path) + strlen(AUTOFS_LOGPRI_FIFO) + 1;
175 + int name_len = strlen(path) + strlen(fifodir) + 1;
178 fifo_name = malloc(name_len);
181 - ret = snprintf(fifo_name, name_len, "%s%s",
182 - AUTOFS_LOGPRI_FIFO, path);
183 + ret = snprintf(fifo_name, name_len, "%s%s", fifodir, path);
184 if (ret >= name_len) {
186 "fifo path for \"%s\" truncated to \"%s\". This may "
187 @@ -670,7 +672,7 @@ static char *automount_path_to_fifo(unsigned logopt, const char *path)
188 * create the fifo name, we will just replace instances of '/' with
191 - p = fifo_name + strlen(AUTOFS_LOGPRI_FIFO);
192 + p = fifo_name + strlen(fifodir);
196 @@ -685,8 +687,9 @@ static char *automount_path_to_fifo(unsigned logopt, const char *path)
197 static int create_logpri_fifo(struct autofs_point *ap)
203 + char buf[MAX_ERR_BUF];
205 fifo_name = automount_path_to_fifo(ap->logopt, ap->path);
207 @@ -704,18 +707,27 @@ static int create_logpri_fifo(struct autofs_point *ap)
209 ret = mkfifo(fifo_name, S_IRUSR|S_IWUSR);
211 + char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
213 - "mkfifo for %s returned %d", fifo_name, errno);
214 + "mkfifo for %s failed: %s", fifo_name, estr);
218 fd = open(fifo_name, O_RDWR|O_NONBLOCK);
220 + char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
222 - "Failed to open %s, errno %d", fifo_name, errno);
223 + "Failed to open %s: %s", fifo_name, estr);
229 + if ((cl_flags = fcntl(fd, F_GETFD, 0)) != -1) {
230 + cl_flags |= FD_CLOEXEC;
231 + fcntl(fd, F_SETFD, cl_flags);
234 ap->logpri_fifo = fd;
237 @@ -728,6 +740,10 @@ static int destroy_logpri_fifo(struct autofs_point *ap)
239 int fd = ap->logpri_fifo;
241 + char buf[MAX_ERR_BUF];
246 fifo_name = automount_path_to_fifo(ap->logopt, ap->path);
248 @@ -739,8 +755,9 @@ static int destroy_logpri_fifo(struct autofs_point *ap)
252 + char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
254 - "close for fifo %s returned %d", fifo_name, errno);
255 + "close for fifo %s: %s", fifo_name, estr);
258 ret = unlink(fifo_name);
259 @@ -760,11 +777,13 @@ static void handle_fifo_message(struct autofs_point *ap, int fd)
260 char buffer[PIPE_BUF];
263 + char buf[MAX_ERR_BUF];
265 memset(buffer, 0, sizeof(buffer));
266 ret = read(fd, &buffer, sizeof(buffer));
268 - warn(ap->logopt, "read on fifo returned error %d", errno);
269 + char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
270 + warn(ap->logopt, "read on fifo returned error: %s", estr);
274 @@ -846,16 +865,18 @@ static int set_log_priority(const char *path, int priority)
276 fd = open(fifo_name, O_WRONLY|O_NONBLOCK);
278 - fprintf(stderr, "%s: open of %s failed with %d\n",
279 - __FUNCTION__, fifo_name, errno);
280 + fprintf(stderr, "%s: open of %s failed with %s\n",
281 + __FUNCTION__, fifo_name, strerror(errno));
282 + fprintf(stderr, "%s: perhaps the fifo wasn't setup,"
283 + " please check your log for more information\n", __FUNCTION__);
288 if (write(fd, buf, sizeof(buf)) != sizeof(buf)) {
289 fprintf(stderr, "Failed to change logging priority. ");
290 - fprintf(stderr, "write to fifo failed with errno %d.\n",
292 + fprintf(stderr, "write to fifo failed: %s.\n",
297 @@ -870,6 +891,7 @@ static int set_log_priority(const char *path, int priority)
298 static int get_pkt(struct autofs_point *ap, union autofs_packet_union *pkt)
300 struct pollfd fds[3];
302 char buf[MAX_ERR_BUF];
304 fds[0].fd = ap->pipefd;
305 @@ -878,9 +900,11 @@ static int get_pkt(struct autofs_point *ap, union autofs_packet_union *pkt)
306 fds[1].events = POLLIN;
307 fds[2].fd = ap->logpri_fifo;
308 fds[2].events = POLLIN;
309 + if (fds[2].fd == -1)
313 - if (poll(fds, 3, -1) == -1) {
314 + if (poll(fds, pollfds, -1) == -1) {
318 @@ -930,7 +954,7 @@ static int get_pkt(struct autofs_point *ap, union autofs_packet_union *pkt)
319 if (fds[0].revents & POLLIN)
320 return fullread(ap->pipefd, pkt, kpkt_len);
322 - if (fds[2].revents & POLLIN) {
323 + if (fds[2].fd != -1 && fds[2].revents & POLLIN) {
324 debug(ap->logopt, "message pending on control fifo.");
325 handle_fifo_message(ap, fds[2].fd);
327 @@ -983,7 +1007,6 @@ static int autofs_init_ap(struct autofs_point *ap)
329 "failed to create commumication pipe for autofs path %s",
335 @@ -1006,7 +1029,6 @@ static int autofs_init_ap(struct autofs_point *ap)
336 "failed create state pipe for autofs path %s", ap->path);
338 close(ap->kpipefd); /* Close kernel pipe end */
343 @@ -1021,15 +1043,8 @@ static int autofs_init_ap(struct autofs_point *ap)
346 if (create_logpri_fifo(ap) < 0) {
348 - "failed to create FIFO for path %s\n", ap->path);
349 - destroy_logpri_fifo(ap);
351 - close(ap->kpipefd);
353 - close(ap->state_pipe[0]);
354 - close(ap->state_pipe[1]);
356 + logmsg("could not create FIFO for path %s\n", ap->path);
357 + logmsg("dynamic log level changes not available for %s", ap->path);
361 diff --git a/include/automount.h b/include/automount.h
362 index 37a3c0a..b0d1a9c 100644
363 --- a/include/automount.h
364 +++ b/include/automount.h
365 @@ -223,8 +223,6 @@ int rmdir_path(struct autofs_point *ap, const char *path, dev_t dev);
366 #define MAPENT_MAX_LEN 4095
367 #define PARSE_MAX_BUF KEY_MAX_LEN + MAPENT_MAX_LEN + 2
369 -#define AUTOFS_LOGPRI_FIFO "/tmp/autofs.fifo"
371 int lookup_nss_read_master(struct master *master, time_t age);
372 int lookup_nss_read_map(struct autofs_point *ap, struct map_source *source, time_t age);
373 int lookup_enumerate(struct autofs_point *ap,
374 diff --git a/lib/master.c b/lib/master.c
375 index 2e24ad0..2188bca 100644
378 @@ -56,6 +56,7 @@ int master_add_autofs_point(struct master_mapent *entry,
380 ap->state_pipe[0] = -1;
381 ap->state_pipe[1] = -1;
382 + ap->logpri_fifo = -1;
384 ap->path = strdup(entry->path);