Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 161196 Details for
Bug 240972
autofs does not log enough data to troubleshoot replicated server selection
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Add a daemon option to set the log priority at run-time.
autofs-4.1.3-on-the-fly-debugging.patch (text/plain), 8.73 KB, created by
Jeff Moyer
on 2007-08-13 18:14:11 UTC
(
hide
)
Description:
Add a daemon option to set the log priority at run-time.
Filename:
MIME Type:
Creator:
Jeff Moyer
Created:
2007-08-13 18:14:11 UTC
Size:
8.73 KB
patch
obsolete
>--- autofs-4.1.3/daemon/automount.c.on-the-fly 2007-08-13 13:52:22.000000000 -0400 >+++ autofs-4.1.3/daemon/automount.c 2007-08-13 14:11:14.000000000 -0400 >@@ -20,6 +20,7 @@ > * > * ----------------------------------------------------------------------- */ > >+#include <ctype.h> > #include <dirent.h> > #include <errno.h> > #include <fcntl.h> >@@ -38,6 +39,8 @@ > #include <sys/stat.h> > #include <sys/time.h> > #include <sys/poll.h> >+#include <sys/socket.h> >+#include <sys/un.h> > #include <linux/auto_fs4.h> > > #include "automount.h" >@@ -1168,18 +1171,188 @@ static int fullread(int fd, void *ptr, s > return len; > } > >+#define autofs_ptype_ipc 2 /* Inter-process communication */ >+#define ipc_ptype_logpri 0 >+ >+struct autofs_ipc_packet { >+ struct autofs_packet_hdr hdr; >+ int ipc_ptype; >+ union { >+ int logpri; >+ } ipc_union; >+}; >+ >+static void bind_event_sock(void) >+{ >+ int sock; >+ struct sockaddr_un saddr; >+ >+ memset(&saddr, 0, sizeof(saddr)); >+ saddr.sun_family = AF_UNIX; >+ strncpy(saddr.sun_path, AUTOFS_CONTROL_SOCKNAME, >+ strlen(AUTOFS_CONTROL_SOCKNAME)); >+ unlink(AUTOFS_CONTROL_SOCKNAME); >+ sock = socket(PF_UNIX, SOCK_STREAM, 0); >+ if (sock < 0) { >+ crit("Unable to create control socket."); >+ exit(1); >+ } >+ if (fchmod(sock, S_IRUSR|S_IWUSR) < 0) { >+ crit("fchmod on PF_UNIX socket failed with errno %d\n", >+ errno); >+ exit(1); >+ } >+ if (bind(sock, (struct sockaddr *)&saddr, SUN_LEN(&saddr)) < 0) { >+ crit("Failed to bind to control socket: %d. " >+ "Is the automounter already running?", errno); >+ exit(1); >+ } >+ if (listen(sock, 1) < 0) { >+ crit("Failed to listen on control socket: %d.\n", errno); >+ exit(1); >+ } >+ ap.event_sock = sock; >+ return; >+} >+ >+static void handle_ipc_packet(int listenfd) >+{ >+ struct autofs_ipc_packet packet; >+ struct autofs_packet_hdr *header = (struct autofs_packet_hdr *)&packet; >+ struct sockaddr_un cliaddr; >+ socklen_t clilen = sizeof(cliaddr); >+ int fd; >+ int len, ret; >+ >+ fd = accept(listenfd, &cliaddr, &clilen); >+ if (fd < 0) { >+ warn("%s: accept failed with %d\n", __FUNCTION__, errno); >+ return; >+ } >+ >+ ret = read(fd, header, sizeof(struct autofs_packet_hdr)); >+ if (ret != sizeof(struct autofs_packet_hdr)) { >+ warn("%s: incomplete packet received on control socket.", >+ __FUNCTION__); >+ warn("%s: expected %d bytes, got %d\n", __FUNCTION__, >+ sizeof(struct autofs_packet_hdr), ret); >+ goto out; >+ } >+ if (header->type != autofs_ptype_ipc) { >+ warn("get_pkt: invalidate packet type (%d) received on " >+ "control socket.", header->type); >+ goto out; >+ } >+ >+ debug("sane packet header received, retrieving payload."); >+ /* read in the remainder of the ipc packet */ >+ len = sizeof(struct autofs_ipc_packet) - >+ sizeof(struct autofs_packet_hdr); >+ ret = read(fd, (char *)&packet + sizeof(struct autofs_packet_hdr),len); >+ if (ret != len) { >+ warn("get_pkt: incomplete packet received on control socket " >+ "(%d of %d bytes)", ret, len); >+ goto out; >+ } >+ >+ if (packet.ipc_ptype != ipc_ptype_logpri) { >+ warn("get_pkt: invalid ipc packet type (%d) received on " >+ "control socket.", packet.ipc_ptype); >+ goto out; >+ } >+ if (packet.ipc_union.logpri > LOG_DEBUG || >+ packet.ipc_union.logpri < LOG_EMERG) { >+ warn("get_pkt: invalid log priority (%d) specified in ipc " >+ "packet.", packet.ipc_union.logpri); >+ goto out; >+ } >+ /* >+ * OK, the packet passed all of the sanity checks. The >+ * automounter actually only supports two log priorities. >+ * Everything at warning or above is only logged when >+ * debugging is enabled. >+ */ >+ if (packet.ipc_union.logpri >= LOG_WARNING) { >+ do_debug = 1; >+ info("Debug logging enabled.\n"); >+ } else { >+ if (do_verbose || do_debug) >+ crit("Debug logging disabled.\n"); >+ do_verbose = do_debug = 0; >+ } >+out: >+ close(fd); >+} >+ >+static int connect_to_event_socket(void) >+{ >+ int sock; >+ struct sockaddr_un saddr; >+ >+ memset(&saddr, 0, sizeof(saddr)); >+ saddr.sun_family = AF_UNIX; >+ strncpy(saddr.sun_path, AUTOFS_CONTROL_SOCKNAME, >+ strlen(AUTOFS_CONTROL_SOCKNAME)); >+ >+ sock = socket(PF_UNIX, SOCK_STREAM, 0); >+ if (sock < 0) { >+ crit("Unable to create control socket."); >+ return -1; >+ } >+ >+ if (connect(sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { >+ fprintf(stderr, "Failed to connect to the automount daemon " >+ "(%d). Is it running?\n", errno); >+ return -1; >+ } >+ >+ return sock; >+} >+ >+static int set_log_priority(int priority) >+{ >+ int fd; >+ struct autofs_ipc_packet pkt; >+ >+ if (priority > LOG_DEBUG || priority < LOG_EMERG) { >+ fprintf(stderr, "Log priority %d is invalid.\n", priority); >+ fprintf(stderr, "Please spcify a number in the range 0-7.\n"); >+ return -1; >+ } >+ >+ pkt.hdr.type = autofs_ptype_ipc; >+ pkt.ipc_ptype = ipc_ptype_logpri; >+ fprintf(stderr, "Setting log priority to %d\n", priority); >+ pkt.ipc_union.logpri = priority; >+ >+ fd = connect_to_event_socket(); >+ if (fd < 0) >+ return -1; >+ >+ if (write(fd, &pkt, sizeof(pkt)) != sizeof(pkt)) { >+ fprintf(stderr, "Failed to change logging priority: %d\n", >+ errno); >+ close(fd); >+ return -1; >+ } >+ close(fd); >+ return 0; >+} >+ > static int get_pkt(int fd, union autofs_packet_union *pkt) > { > sigset_t old; >- struct pollfd fds[2]; >+ struct pollfd fds[3]; > > fds[0].fd = fd; > fds[0].events = POLLIN; > fds[1].fd = ap.state_pipe[0]; > fds[1].events = POLLIN; >+ fds[2].fd = ap.event_sock; >+ fds[2].events = POLLIN; > > for (;;) { >- if (poll(fds, 2, -1) == -1) { >+ if (poll(fds, 3, -1) == -1) { > if (errno == EINTR) > continue; > syslog(LOG_ERR, "get_pkt: poll failed: %m"); >@@ -1246,6 +1419,11 @@ static int get_pkt(int fd, union autofs_ > > if (fds[0].revents & POLLIN) > return fullread(fd, pkt, sizeof(*pkt)); >+ >+ if (fds[2].revents & POLLIN) { >+ debug("connection pending on control socket."); >+ handle_ipc_packet(fds[2].fd); >+ } > } > } > >@@ -2005,11 +2183,47 @@ void init_path_mounted(void) > path_mounted = _PATH_MOUNTED; > } > >+typedef struct _code { >+ char *c_name; >+ int c_val; >+} CODE; >+ >+CODE prioritynames[] = { >+ { "alert", LOG_ALERT }, >+ { "crit", LOG_CRIT }, >+ { "debug", LOG_DEBUG }, >+ { "emerg", LOG_EMERG }, >+ { "err", LOG_ERR }, >+ { "error", LOG_ERR }, /* DEPRECATED */ >+ { "info", LOG_INFO }, >+ { "notice", LOG_NOTICE }, >+ { "panic", LOG_EMERG }, /* DEPRECATED */ >+ { "warn", LOG_WARNING }, /* DEPRECATED */ >+ { "warning", LOG_WARNING }, >+ { NULL, -1 }, >+}; >+ >+static int convert_log_priority(char *priority_name) >+{ >+ CODE *priority_mapping; >+ >+ for (priority_mapping = prioritynames; >+ priority_mapping->c_name != NULL; >+ priority_mapping++) { >+ >+ if (!strcasecmp(priority_name, priority_mapping->c_name)) >+ return priority_mapping->c_val; >+ } >+ >+ return -1; >+} >+ > int main(int argc, char *argv[]) > { > char *path, *map, *mapfmt; > const char **mapargv; > int mapargc, opt; >+ int logpri; > static const struct option long_options[] = { > {"help", 0, 0, 'h'}, > {"pid-file", 1, 0, 'p'}, >@@ -2024,6 +2238,7 @@ int main(int argc, char *argv[]) > {"random-multimount-selection", 0, 0, 'r'}, > {"use-old-ldap-lookup", 0, 0, 'u'}, > {"negative-timeout", 1, 0, 'n'}, >+ {"set-log-priority", 1, 0, 'l'}, > {0, 0, 0, 0} > }; > >@@ -2083,6 +2298,26 @@ int main(int argc, char *argv[]) > case 'n': > ap.negative_timeout = getnumopt(optarg, opt); > break; >+ case 'l': >+ if (isalpha(*optarg)) { >+ logpri = convert_log_priority(optarg); >+ if (logpri < 0) { >+ fprintf(stderr, "Invalid log priority:" >+ " %s\n", optarg); >+ exit(1); >+ } >+ } else if (isdigit(*optarg)) { >+ logpri = getnumopt(optarg, opt); >+ } else { >+ fprintf(stderr, "non-alphanumeric character " >+ "found in log priority. Aborting.\n"); >+ exit(1); >+ } >+ if (set_log_priority(logpri) < 0) >+ exit(1); >+ >+ exit(0); >+ /* NOTREACHED */ > case '?': > case ':': > printf("%s: Ambiguous or unknown options\n", program); >@@ -2104,8 +2339,10 @@ int main(int argc, char *argv[]) > exit(1); > } > >- if (!dumpmap) >+ if (!dumpmap) { > become_daemon(); >+ bind_event_sock(); >+ } > > init_path_mounted(); > >--- autofs-4.1.3/include/automount.h.on-the-fly 2007-08-13 13:52:22.000000000 -0400 >+++ autofs-4.1.3/include/automount.h 2007-08-13 13:52:22.000000000 -0400 >@@ -111,6 +111,7 @@ struct autofs_point { > char *path; /* Mount point name */ > int pipefd; /* File descriptor for pipe */ > int ioctlfd; /* File descriptor for ioctls */ >+ int event_sock; /* UNIX domain socket used for ipc */ > dev_t dev; /* "Device" number assigned by kernel */ > char *maptype; /* Type of map "file", "NIS", etc */ > unsigned int type; /* Type of map direct or indirect */ >@@ -158,6 +159,8 @@ int is_mounted(const char *path); > #define KEY_MAX_LEN NAME_MAX > #define MAPENT_MAX_LEN 4095 > >+#define AUTOFS_CONTROL_SOCKNAME "/tmp/autofs.sock" >+ > #ifdef MODULE_LOOKUP > int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **context); > int lookup_ghost(const char *, int, time_t, void *);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 240972
:
161196
|
161222