--- a/inetd.8
+++ b/inetd.8
@@ -39,6 +39,7 @@
.Nm inetd
.Op Fl d
.Op Fl E
+.Op Fl i
.Op Fl l
.Op Fl R Ar rate
.Op Ar configuration file
@@ -71,6 +72,8 @@ from laundering the environment. Withou
potentially harmful environent variables, including
.Pa PATH ,
will be removed and not inherited by services.
+.It Fl d
+Makes the program not daemonize itself.
.It Fl l
Turns on libwrap connection logging and access control.
Internal services cannot be wrapped. When enabled,
--- a/inetd.c
+++ b/inetd.c
@@ -343,6 +343,7 @@ main(int argc, char *argv[], char *envp[
fd_set *fdsrp = NULL;
int readablen = 0, ch;
int keepenv = 0;
+ int nodaemon = 0;
struct servtab *sep;
extern char *optarg;
extern int optind;
@@ -352,7 +353,7 @@ main(int argc, char *argv[], char *envp[
initsetproctitle(argc, argv, envp);
- while ((ch = getopt(argc, argv, "dElR:")) != -1)
+ while ((ch = getopt(argc, argv, "dEilR:")) != -1)
switch (ch) {
case 'd':
debug = 1;
@@ -360,6 +361,9 @@ main(int argc, char *argv[], char *envp[
case 'E':
keepenv = 1;
break;
+ case 'i':
+ nodaemon = 1;
+ break;
case 'l':
#ifdef LIBWRAP
lflag = 1;
@@ -386,7 +390,7 @@ main(int argc, char *argv[], char *envp[
case '?':
default:
fprintf(stderr,
- "usage: %s [-dEl] [-R rate] [configuration file]\n",
+ "usage: %s [-dEil] [-R rate] [configuration file]\n",
progname);
exit(1);
}
@@ -415,7 +419,11 @@ main(int argc, char *argv[], char *envp[
umask(022);
if (debug == 0) {
- daemon(0, 0);
+ if (nodaemon == 0)
+ if (daemon(0, 0) < 0) {
+ syslog(LOG_ERR, "daemon(0, 0): %m");
+ exit(1);
+ }
#ifdef HAVE_SETLOGIN
if (uid == 0)
(void) setlogin("");