svn commit: trunk/busybox: include libbb networking

vda at busybox.net vda at busybox.net
Sun Jan 14 13:12:07 UTC 2007


Author: vda
Date: 2007-01-14 05:12:06 -0800 (Sun, 14 Jan 2007)
New Revision: 17302

Log:
Rename bb_sanitize_stdio -> bb_sanitize_server_stdio
(name is still bad - it doesn't hint that function
may do daemonization trick for you if asked to).
Small fixes to fakeidentd.


Modified:
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/xfuncs.c
   trunk/busybox/networking/inetd.c
   trunk/busybox/networking/isrv_identd.c


Changeset:
Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2007-01-14 12:47:27 UTC (rev 17301)
+++ trunk/busybox/include/libbb.h	2007-01-14 13:12:06 UTC (rev 17302)
@@ -279,7 +279,7 @@
 extern void xsetuid(uid_t uid);
 extern void xdaemon(int nochdir, int noclose);
 /* More clever/thorough xdaemon */
-extern void bb_sanitize_stdio(int daemonize);
+extern void bb_sanitize_server_stdio(int daemonize);
 extern void xchdir(const char *path);
 extern void xsetenv(const char *key, const char *value);
 extern int xopen(const char *pathname, int flags);

Modified: trunk/busybox/libbb/xfuncs.c
===================================================================
--- trunk/busybox/libbb/xfuncs.c	2007-01-14 12:47:27 UTC (rev 17301)
+++ trunk/busybox/libbb/xfuncs.c	2007-01-14 13:12:06 UTC (rev 17302)
@@ -509,7 +509,7 @@
 }
 #endif
 
-void bb_sanitize_stdio(int daemonize)
+void bb_sanitize_server_stdio(int daemonize)
 {
 	int fd;
 	/* Mega-paranoid */

Modified: trunk/busybox/networking/inetd.c
===================================================================
--- trunk/busybox/networking/inetd.c	2007-01-14 12:47:27 UTC (rev 17301)
+++ trunk/busybox/networking/inetd.c	2007-01-14 13:12:06 UTC (rev 17302)
@@ -1292,9 +1292,9 @@
 		/* reexec for vfork() do continue parent */
 		vfork_daemon_rexec(0, 0, argc, argv, "-f");
 	}
-	bb_sanitize_stdio(0);
+	bb_sanitize_server_stdio(0);
 #else
-	bb_sanitize_stdio(!(opt & 2));
+	bb_sanitize_server_stdio(!(opt & 2));
 #endif
 	openlog(applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
 	logmode = LOGMODE_SYSLOG;

Modified: trunk/busybox/networking/isrv_identd.c
===================================================================
--- trunk/busybox/networking/isrv_identd.c	2007-01-14 12:47:27 UTC (rev 17301)
+++ trunk/busybox/networking/isrv_identd.c	2007-01-14 13:12:06 UTC (rev 17302)
@@ -65,6 +65,7 @@
 		goto ok;
 	/* Terminate session. If we are in server mode, then
 	 * fd is still in nonblocking mode - we never block here */
+	if (fd == 0) fd++; /* inetd mode? then write to fd 1 */
 	fdprintf(fd, "%s : USERID : UNIX : %s\r\n", buf->buf, bogouser);
  term:
 	free(buf);
@@ -97,7 +98,7 @@
 		OPT_foreground = 0x1,
 		OPT_inetd      = 0x2,
 		OPT_inetdwait  = 0x4,
-		OPT_nodeamon   = 0x7,
+		OPT_fiw        = 0x7,
 		OPT_bindaddr   = 0x8,
 	};
 
@@ -109,9 +110,14 @@
 	if (optind < argc)
 		bogouser = argv[optind];
 
-	/* Daemonize if no -f or -i or -w */
-	bb_sanitize_stdio(!(opt & OPT_nodeamon));
-	if (!(opt & OPT_nodeamon)) {
+	/* Daemonize if no -f and no -i and no -w */
+	bb_sanitize_server_stdio(!(opt & OPT_fiw));
+	/* Where to log in inetd modes? "Classic" inetd
+	 * probably has its stderr /dev/null'ed (we need log to syslog?),
+	 * but daemontools-like utilities usually expect that children
+	 * log to stderr. I like daemontools more. Go their way.
+	 * (Or maybe we need yet another option "log to syslog") */
+	if (!(opt & OPT_fiw) /* || (opt & OPT_syslog) */) {
 		openlog(applet_name, 0, LOG_DAEMON);
 		logmode = LOGMODE_SYSLOG;
 	}
@@ -124,9 +130,8 @@
 	/* Ignore closed connections when writing */
 	signal(SIGPIPE, SIG_IGN);
 
-	if (opt & OPT_inetdwait) {
-		fd = 0;
-	} else {
+	fd = 0;
+	if (!(opt & OPT_inetdwait)) {
 		fd = create_and_bind_stream_or_die(bind_address,
 				bb_lookup_port("identd", "tcp", 113));
 		xlisten(fd, 5);




More information about the busybox-cvs mailing list