aboutsummaryrefslogtreecommitdiff
path: root/networking/inetd.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-14 01:29:06 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-14 01:29:06 +0000
commit7a431b3715299854fb423ec00d5fafc0e2c7f07b (patch)
tree4e90c9d364485ef13c2e429ab22b9b925d50ea04 /networking/inetd.c
parent150f402b36197d822f8a7dd835231cd67b77e959 (diff)
downloadbusybox-w32-7a431b3715299854fb423ec00d5fafc0e2c7f07b.tar.gz
busybox-w32-7a431b3715299854fb423ec00d5fafc0e2c7f07b.tar.bz2
busybox-w32-7a431b3715299854fb423ec00d5fafc0e2c7f07b.zip
By popular request reinstate fakeidentd's standalone mode.
Since this is also needed for other applets like telnetd, introduce generic driver for such things. It even supports inetd-wait ('linger') mode, when inetd hands out listen socket to child and waits to it to die, instead of handing out accepted socket and continuing listening itself (nowait mode). Code growth ~200 bytes. NB: our inetd doesn't support wait mode yet (or mabe it is buggy).
Diffstat (limited to 'networking/inetd.c')
-rw-r--r--networking/inetd.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/networking/inetd.c b/networking/inetd.c
index 93c16bf60..f9f3b51b6 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1289,31 +1289,28 @@ inetd_main(int argc, char *argv[])
1289 if (CONFIG == NULL) 1289 if (CONFIG == NULL)
1290 bb_error_msg_and_die("non-root must specify a config file"); 1290 bb_error_msg_and_die("non-root must specify a config file");
1291 1291
1292 if (!(opt & 2)) {
1293#ifdef BB_NOMMU 1292#ifdef BB_NOMMU
1293 if (!(opt & 2)) {
1294 /* reexec for vfork() do continue parent */ 1294 /* reexec for vfork() do continue parent */
1295 vfork_daemon_rexec(0, 0, argc, argv, "-f"); 1295 vfork_daemon_rexec(0, 0, argc, argv, "-f");
1296 }
1297 bb_sanitize_stdio(0);
1296#else 1298#else
1297 xdaemon(0, 0); 1299 bb_sanitize_stdio(!(opt & 2));
1298#endif 1300#endif
1299 } else {
1300 setsid();
1301 }
1302 logmode = LOGMODE_SYSLOG; 1301 logmode = LOGMODE_SYSLOG;
1303 1302
1304 if (uid == 0) { 1303 if (uid == 0) {
1305 gid_t gid = getgid();
1306
1307 /* If run by hand, ensure groups vector gets trashed */ 1304 /* If run by hand, ensure groups vector gets trashed */
1305 gid_t gid = getgid();
1308 setgroups(1, &gid); 1306 setgroups(1, &gid);
1309 } 1307 }
1310 1308
1311 { 1309 {
1312 FILE *fp = fopen(_PATH_INETDPID, "w"); 1310 FILE *fp = fopen(_PATH_INETDPID, "w");
1313
1314 if (fp != NULL) { 1311 if (fp != NULL) {
1315 fprintf(fp, "%u\n", getpid()); 1312 fprintf(fp, "%u\n", getpid());
1316 (void) fclose(fp); 1313 fclose(fp);
1317 } 1314 }
1318 } 1315 }
1319 1316