summaryrefslogtreecommitdiff
path: root/networking/inetd.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-01-14 01:29:06 +0000
committerDenis Vlasenko2007-01-14 01:29:06 +0000
commit7a431b3715299854fb423ec00d5fafc0e2c7f07b (patch)
tree4e90c9d364485ef13c2e429ab22b9b925d50ea04 /networking/inetd.c
parent150f402b36197d822f8a7dd835231cd67b77e959 (diff)
downloadbusybox-7a431b3715299854fb423ec00d5fafc0e2c7f07b.zip
busybox-7a431b3715299854fb423ec00d5fafc0e2c7f07b.tar.gz
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 93c16bf..f9f3b51 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1289,31 +1289,28 @@ inetd_main(int argc, char *argv[])
if (CONFIG == NULL)
bb_error_msg_and_die("non-root must specify a config file");
- if (!(opt & 2)) {
#ifdef BB_NOMMU
+ if (!(opt & 2)) {
/* reexec for vfork() do continue parent */
vfork_daemon_rexec(0, 0, argc, argv, "-f");
+ }
+ bb_sanitize_stdio(0);
#else
- xdaemon(0, 0);
+ bb_sanitize_stdio(!(opt & 2));
#endif
- } else {
- setsid();
- }
logmode = LOGMODE_SYSLOG;
if (uid == 0) {
- gid_t gid = getgid();
-
/* If run by hand, ensure groups vector gets trashed */
+ gid_t gid = getgid();
setgroups(1, &gid);
}
{
FILE *fp = fopen(_PATH_INETDPID, "w");
-
if (fp != NULL) {
fprintf(fp, "%u\n", getpid());
- (void) fclose(fp);
+ fclose(fp);
}
}