busybox current status

Luciano Miguel Ferreira Rocha strange at nsk.no-ip.org
Thu Nov 30 01:06:11 UTC 2006


On Thu, Nov 30, 2006 at 12:56:02AM +0100, Bernhard Fischer wrote:
> On Wed, Nov 29, 2006 at 11:44:38PM +0000, Luciano Miguel Ferreira Rocha wrote:
> >
> >Is this the state of the public svn?
> 
> yes.
> >                                     I can update my cpio hardlink fix
> >and httpd cgi output to syslog if you want.
> 
> Please do so if you want them to be integrated. I managed to miss these
> patches of your the first time round, so let me ask to resend the
> problem description they were solving.

The cpio is already in (bug 0001095).

The httpd patch adds new options to httpd, for logging the output sent
by CGIs to stderr in syslog.

A new patch is attached, for latest revision at svn.

-- 
lfr
0/0
-------------- next part --------------
Index: networking/httpd.c
===================================================================
--- networking/httpd.c	(revision 16736)
+++ networking/httpd.c	(working copy)
@@ -100,6 +100,8 @@
 static const char httpd_conf[] = "httpd.conf";
 static const char home[] = "./";
 
+SKIP_FEATURE_HTTPD_CGI_SYSLOG_PERPROC(static int logFd);
+
 #define TIMEOUT 60
 
 // Note: busybox xfuncs are not used because we want the server to keep running
@@ -943,6 +945,48 @@
 	else return -1;
 }
 
+#if ENABLE_FEATURE_HTTPD_CGI_SYSLOG
+/****************************************************************************
+ *
+ > $Function: openLogger()
+ *
+ * $Description: Open a connection to a logger
+ *
+ * $Parameters:
+ *
+ * $Return: int  . . . . File descriptor for writting to the logger.
+ *
+ * $Errors: None, but returns STDERR on error
+****************************************************************************/
+static int openLogger(void)
+{
+	char *cmd[] = { "logger", "-thttpd", "-p",
+		CONFIG_FEATURE_HTTPD_CGI_SYSLOG_PRIORITY,
+		NULL
+	};
+	int p[2];
+
+	if (pipe(p)) return 2;
+
+	/* connect stdin to pipe */
+	dup2(p[0], 0);
+	close(p[0]);
+
+	/* other endpoint won't be used by the logger, set close on exec.
+	 * this will allow the use o vfork */
+	fcntl(p[1], F_SETFD, FD_CLOEXEC);
+
+	if (spawn(cmd) < 0) {
+		close(p[1]);
+		return 2;
+	}
+
+	/* clear close on exec (will be used by cgis) */
+	fcntl(p[1], F_SETFD, 0);
+	return p[1];
+}
+#endif          /* FEATURE_HTTPD_CGI_SYSLOG */
+
 #if ENABLE_FEATURE_HTTPD_CGI
 /****************************************************************************
  *
@@ -981,6 +1025,10 @@
 	int status;
 	size_t post_readed_size, post_readed_idx;
 
+#if ENABLE_FEATURE_HTTPD_CGI_SYSLOG_PERPROC
+	int logFd = openLogger();
+#endif
+
 	if (pipe(fromCgi) != 0)
 		return 0;
 	if (pipe(toCgi) != 0)
@@ -1004,8 +1052,13 @@
 
 		dup2(inFd, 0);  // replace stdin with the pipe
 		dup2(outFd, 1);  // replace stdout with the pipe
+#if ENABLE_FEATURE_HTTPD_CGI_SYSLOG
+		dup2(logFd, 2);
+		close(logFd);
+#else
 		if (!DEBUG)
 			dup2(outFd, 2);  // replace stderr with the pipe
+#endif
 
 		close(toCgi[0]);
 		close(toCgi[1]);
@@ -1966,5 +2019,8 @@
 
 	if (!(opt & OPT_FOREGROUND))
 		xdaemon(1, 0);     /* don't change current directory */
+#if ENABLE_FEATURE_HTTPD_CGI_SYSLOG && !ENABLE_FEATURE_HTTPD_CGI_SYSLOG_PERPROC
+	logFd = openLogger();
+#endif
 	return miniHttpd(config->server_socket);
 }
Index: networking/Config.in
===================================================================
--- networking/Config.in	(revision 16736)
+++ networking/Config.in	(working copy)
@@ -119,6 +119,31 @@
 	  This option allows scripts and executables to be invoked
 	  when specific URLs are requested.
 
+config FEATURE_HTTPD_CGI_SYSLOG
+	bool "Log stderr to syslog"
+	default n
+	depends on FEATURE_HTTPD_CGI && LOGGER
+	help
+	  This option causes the output sent to standard error from CGIs to
+	  be sent to syslog, using the program logger.
+
+config FEATURE_HTTPD_CGI_SYSLOG_PRIORITY
+	string "Priority"
+	default "daemon.notice"
+	depends on FEATURE_HTTPD_CGI_SYSLOG
+	help
+	  Define the priority of the messages (facility and level,
+	  see -p option for logger).
+
+config FEATURE_HTTPD_CGI_SYSLOG_PERPROC
+	bool "One logger per process"
+	default n
+	depends on FEATURE_HTTPD_CGI_SYSLOG
+	help
+	  This option starts one logger per CGI executed, instead of reusing
+	  a single, per-httpd, logger. This will prevent output from
+	  different processes to be mixed, but will use more memory.
+
 config FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
 	bool "Enable support for running scripts through an interpreter"
 	default n
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20061130/22f8052c/attachment-0002.pgp 


More information about the busybox mailing list