On Monday 02 March 2009 07:03:53 am Hamish Moffatt wrote:
> I'd like /var/log/messages to be readable by non-root users. syslogd.c
> uses device_open to open the file though and it has the permissions
> hardcoded to 0600.
> 
> I can't really see why it uses device_open... nor a good solution.

I propose this patch.
--
vda
diff -d -urpN busybox.1/sysklogd/syslogd.c busybox.2/sysklogd/syslogd.c
--- busybox.1/sysklogd/syslogd.c	2009-03-01 03:26:17.000000000 +0100
+++ busybox.2/sysklogd/syslogd.c	2009-03-02 14:56:50.000000000 +0100
@@ -306,17 +306,23 @@ static void log_locally(time_t now, char
 	}
 #endif
 	if (G.logFD >= 0) {
+		/* Reopen log file every second. This allows admin
+		 * to delete the file and not worry about restarting us.
+		 * This costs almost nothing since it happens
+		 * _at most_ once a second.
+		 */
 		if (!now)
 			now = time(NULL);
 		if (G.last_log_time != now) {
-			G.last_log_time = now; /* reopen log file every second */
+			G.last_log_time = now;
 			close(G.logFD);
 			goto reopen;
 		}
 	} else {
  reopen:
-		G.logFD = device_open(G.logFilePath, O_WRONLY | O_CREAT
-					| O_NOCTTY | O_APPEND | O_NONBLOCK);
+		G.logFD = open(G.logFilePath, O_WRONLY | O_CREAT
+					| O_NOCTTY | O_APPEND | O_NONBLOCK,
+					0666);
 		if (G.logFD < 0) {
 			/* cannot open logfile? - print to /dev/console then */
 			int fd = device_open(DEV_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK);
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to