aboutsummaryrefslogtreecommitdiff
path: root/networking/isrv_identd.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-14 13:12:06 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-14 13:12:06 +0000
commitd97c9244b18dbfc373465a111c9a17a28e84477d (patch)
tree141a5ae1628989a73dcb87419bbe555746e8b333 /networking/isrv_identd.c
parentb8b81a6f8fc8083ebef4a5557fe8e2121d623152 (diff)
downloadbusybox-w32-d97c9244b18dbfc373465a111c9a17a28e84477d.tar.gz
busybox-w32-d97c9244b18dbfc373465a111c9a17a28e84477d.tar.bz2
busybox-w32-d97c9244b18dbfc373465a111c9a17a28e84477d.zip
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.
Diffstat (limited to 'networking/isrv_identd.c')
-rw-r--r--networking/isrv_identd.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/networking/isrv_identd.c b/networking/isrv_identd.c
index 0279fc0bb..e757d7c29 100644
--- a/networking/isrv_identd.c
+++ b/networking/isrv_identd.c
@@ -65,6 +65,7 @@ static int do_rd(int fd, void **paramp)
65 goto ok; 65 goto ok;
66 /* Terminate session. If we are in server mode, then 66 /* Terminate session. If we are in server mode, then
67 * fd is still in nonblocking mode - we never block here */ 67 * fd is still in nonblocking mode - we never block here */
68 if (fd == 0) fd++; /* inetd mode? then write to fd 1 */
68 fdprintf(fd, "%s : USERID : UNIX : %s\r\n", buf->buf, bogouser); 69 fdprintf(fd, "%s : USERID : UNIX : %s\r\n", buf->buf, bogouser);
69 term: 70 term:
70 free(buf); 71 free(buf);
@@ -97,7 +98,7 @@ int fakeidentd_main(int argc, char **argv)
97 OPT_foreground = 0x1, 98 OPT_foreground = 0x1,
98 OPT_inetd = 0x2, 99 OPT_inetd = 0x2,
99 OPT_inetdwait = 0x4, 100 OPT_inetdwait = 0x4,
100 OPT_nodeamon = 0x7, 101 OPT_fiw = 0x7,
101 OPT_bindaddr = 0x8, 102 OPT_bindaddr = 0x8,
102 }; 103 };
103 104
@@ -109,9 +110,14 @@ int fakeidentd_main(int argc, char **argv)
109 if (optind < argc) 110 if (optind < argc)
110 bogouser = argv[optind]; 111 bogouser = argv[optind];
111 112
112 /* Daemonize if no -f or -i or -w */ 113 /* Daemonize if no -f and no -i and no -w */
113 bb_sanitize_stdio(!(opt & OPT_nodeamon)); 114 bb_sanitize_server_stdio(!(opt & OPT_fiw));
114 if (!(opt & OPT_nodeamon)) { 115 /* Where to log in inetd modes? "Classic" inetd
116 * probably has its stderr /dev/null'ed (we need log to syslog?),
117 * but daemontools-like utilities usually expect that children
118 * log to stderr. I like daemontools more. Go their way.
119 * (Or maybe we need yet another option "log to syslog") */
120 if (!(opt & OPT_fiw) /* || (opt & OPT_syslog) */) {
115 openlog(applet_name, 0, LOG_DAEMON); 121 openlog(applet_name, 0, LOG_DAEMON);
116 logmode = LOGMODE_SYSLOG; 122 logmode = LOGMODE_SYSLOG;
117 } 123 }
@@ -124,9 +130,8 @@ int fakeidentd_main(int argc, char **argv)
124 /* Ignore closed connections when writing */ 130 /* Ignore closed connections when writing */
125 signal(SIGPIPE, SIG_IGN); 131 signal(SIGPIPE, SIG_IGN);
126 132
127 if (opt & OPT_inetdwait) { 133 fd = 0;
128 fd = 0; 134 if (!(opt & OPT_inetdwait)) {
129 } else {
130 fd = create_and_bind_stream_or_die(bind_address, 135 fd = create_and_bind_stream_or_die(bind_address,
131 bb_lookup_port("identd", "tcp", 113)); 136 bb_lookup_port("identd", "tcp", 113));
132 xlisten(fd, 5); 137 xlisten(fd, 5);