[BusyBox] syslogd -p
Stuart Hughes
stuarth at freescale.com
Tue Jul 5 10:11:29 MDT 2005
I've attached a patch against busybox-1.00 that implements this.
Regards, Stuart
>> On 7/5/05, Stuart Hughes <stuarth at freescale.com
>> <mailto:stuarth at freescale.com>> wrote:
>>
>> I'd like to run syslogd on a read-only root filesystem, but I can't
>> because /dev is not writable and the /dev/log socket needs to be
>> created
>> by syslogd.
>>
>> On the fullup sysklogd version there is a "-p" option to specify the
>> location of this socket.
>>
>> Are there any plans to add this option to busybox.
>>
>> TIA, Stuart
>>
>>
>> _______________________________________________
>> busybox mailing list
>> busybox at mail.busybox.net <mailto:busybox at mail.busybox.net>
>> http://busybox.net/mailman/listinfo/busybox
>>
>>
>>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> busybox mailing list
> busybox at mail.busybox.net
> http://busybox.net/mailman/listinfo/busybox
-------------- next part --------------
diff --exclude CVS -uNr busybox-1.00/include/usage.h busybox-1.00.modified/include/usage.h
--- busybox-1.00/include/usage.h 2004-09-14 17:23:56.000000000 +0100
+++ busybox-1.00.modified/include/usage.h 2005-07-05 17:07:35.000000000 +0100
@@ -2286,6 +2286,11 @@
"Write all buffered filesystem blocks to disk."
+#ifdef CONFIG_FEATURE_SYSLOG_SOCKET_FILE
+ #define USAGE_SYSLOG_SOCKET_FILE(a) a
+#else
+ #define USAGE_SYSLOG_SOCKET_FILE(a)
+#endif
#ifdef CONFIG_FEATURE_ROTATE_LOGFILE
#define USAGE_ROTATE_LOGFILE(a) a
#else
@@ -2329,6 +2334,8 @@
"Options:\n" \
"\t-m MIN\t\tMinutes between MARK lines (default=20, 0=off)\n" \
"\t-n\t\tRun as a foreground process\n" \
+ USAGE_SYSLOG_SOCKET_FILE( \
+ "\n\t-p FILE\t\tUse and alternate log socket(default=/dev/log)\n") \
"\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n" \
"\t-S\t\tMake logging output smaller." \
USAGE_ROTATE_LOGFILE( \
diff --exclude CVS -uNr busybox-1.00/sysklogd/Config.in busybox-1.00.modified/sysklogd/Config.in
--- busybox-1.00/sysklogd/Config.in 2004-03-15 08:29:16.000000000 +0000
+++ busybox-1.00.modified/sysklogd/Config.in 2005-07-05 16:41:10.000000000 +0100
@@ -85,6 +85,15 @@
from circular buffer, minimizing semaphore
contention at some minor memory expense.
+config CONFIG_FEATURE_SYSLOG_SOCKET_FILE
+ bool " syslog -p option"
+ default n
+ depends on CONFIG_SYSLOGD
+ help
+ by default syslog creates/uses a socket /dev/log. On
+ systems that use read-only filesystem, this cannot be
+ created. The -p option lets you supply an alternate path
+
config CONFIG_KLOGD
bool "klogd"
default n
diff --exclude CVS -uNr busybox-1.00/sysklogd/syslogd.c busybox-1.00.modified/sysklogd/syslogd.c
--- busybox-1.00/sysklogd/syslogd.c 2004-09-14 19:12:13.000000000 +0100
+++ busybox-1.00.modified/sysklogd/syslogd.c 2005-07-05 17:05:44.000000000 +0100
@@ -57,6 +57,7 @@
/* Path to the unix socket */
static char lfile[MAXPATHLEN];
+static const char *logSockPath = _PATH_LOG;
static const char *logFilePath = __LOG_FILE;
@@ -551,7 +552,7 @@
alarm(MarkInterval);
/* Create the syslog file so realpath() can work. */
- if (realpath(_PATH_LOG, lfile) != NULL) {
+ if (realpath(logSockPath, lfile) != NULL) {
unlink(lfile);
}
@@ -559,17 +560,16 @@
sunx.sun_family = AF_UNIX;
strncpy(sunx.sun_path, lfile, sizeof(sunx.sun_path));
if ((sock_fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) {
- bb_perror_msg_and_die("Couldn't get file descriptor for socket "
- _PATH_LOG);
+ bb_perror_msg_and_die("Couldn't get file descriptor for socket %s", logSockPath);
}
addrLength = sizeof(sunx.sun_family) + strlen(sunx.sun_path);
if (bind(sock_fd, (struct sockaddr *) &sunx, addrLength) < 0) {
- bb_perror_msg_and_die("Could not connect to socket " _PATH_LOG);
+ bb_perror_msg_and_die("Could not connect to socket %s", logSockPath);
}
if (chmod(lfile, 0666) < 0) {
- bb_perror_msg_and_die("Could not set permission on " _PATH_LOG);
+ bb_perror_msg_and_die("Could not set permission on %s", logSockPath);
}
#ifdef CONFIG_FEATURE_IPC_SYSLOG
if (circular_logging == TRUE) {
@@ -623,7 +623,7 @@
char *p;
/* do normal option parsing */
- while ((opt = getopt(argc, argv, "m:nO:s:Sb:R:LC::")) > 0) {
+ while ((opt = getopt(argc, argv, "m:nO:s:p:Sb:R:LC::")) > 0) {
switch (opt) {
case 'm':
MarkInterval = atoi(optarg) * 60;
@@ -634,6 +634,11 @@
case 'O':
logFilePath = optarg;
break;
+#ifdef CONFIG_FEATURE_SYSLOG_SOCKET_FILE
+ case 'p':
+ logSockPath = optarg;
+ break;
+#endif
#ifdef CONFIG_FEATURE_ROTATE_LOGFILE
case 's':
logFileSize = atoi(optarg) * 1024;
More information about the busybox
mailing list