diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-14 13:12:06 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-14 13:12:06 +0000 |
commit | d97c9244b18dbfc373465a111c9a17a28e84477d (patch) | |
tree | 141a5ae1628989a73dcb87419bbe555746e8b333 | |
parent | b8b81a6f8fc8083ebef4a5557fe8e2121d623152 (diff) | |
download | busybox-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.
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | libbb/xfuncs.c | 2 | ||||
-rw-r--r-- | networking/inetd.c | 4 | ||||
-rw-r--r-- | networking/isrv_identd.c | 19 |
4 files changed, 16 insertions, 11 deletions
diff --git a/include/libbb.h b/include/libbb.h index c191dc2a0..1294fb75d 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -279,7 +279,7 @@ extern void xsetgid(gid_t gid); | |||
279 | extern void xsetuid(uid_t uid); | 279 | extern void xsetuid(uid_t uid); |
280 | extern void xdaemon(int nochdir, int noclose); | 280 | extern void xdaemon(int nochdir, int noclose); |
281 | /* More clever/thorough xdaemon */ | 281 | /* More clever/thorough xdaemon */ |
282 | extern void bb_sanitize_stdio(int daemonize); | 282 | extern void bb_sanitize_server_stdio(int daemonize); |
283 | extern void xchdir(const char *path); | 283 | extern void xchdir(const char *path); |
284 | extern void xsetenv(const char *key, const char *value); | 284 | extern void xsetenv(const char *key, const char *value); |
285 | extern int xopen(const char *pathname, int flags); | 285 | extern int xopen(const char *pathname, int flags); |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 6a6bdced3..84d47414a 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -509,7 +509,7 @@ void xdaemon(int nochdir, int noclose) | |||
509 | } | 509 | } |
510 | #endif | 510 | #endif |
511 | 511 | ||
512 | void bb_sanitize_stdio(int daemonize) | 512 | void bb_sanitize_server_stdio(int daemonize) |
513 | { | 513 | { |
514 | int fd; | 514 | int fd; |
515 | /* Mega-paranoid */ | 515 | /* Mega-paranoid */ |
diff --git a/networking/inetd.c b/networking/inetd.c index fd2c88a6b..01f38ad60 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -1292,9 +1292,9 @@ inetd_main(int argc, char *argv[]) | |||
1292 | /* reexec for vfork() do continue parent */ | 1292 | /* reexec for vfork() do continue parent */ |
1293 | vfork_daemon_rexec(0, 0, argc, argv, "-f"); | 1293 | vfork_daemon_rexec(0, 0, argc, argv, "-f"); |
1294 | } | 1294 | } |
1295 | bb_sanitize_stdio(0); | 1295 | bb_sanitize_server_stdio(0); |
1296 | #else | 1296 | #else |
1297 | bb_sanitize_stdio(!(opt & 2)); | 1297 | bb_sanitize_server_stdio(!(opt & 2)); |
1298 | #endif | 1298 | #endif |
1299 | openlog(applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON); | 1299 | openlog(applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON); |
1300 | logmode = LOGMODE_SYSLOG; | 1300 | logmode = LOGMODE_SYSLOG; |
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); |