/*
* Copyright (c) 1983 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
*/
#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1983 Regents of the University of California.\n\
All rights reserved.\n";
-#endif not lint
+#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)inetd.c 5.9 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)inetd.c 5.12 (Berkeley) %G%";
+#endif /* not lint */
/*
* Inetd - Internet super-server
}
if (argc > 0)
CONFIG = argv[0];
-#ifndef DEBUG
- if (fork())
- exit(0);
- { int s;
- for (s = 0; s < 10; s++)
- (void) close(s);
- }
- (void) open("/", O_RDONLY);
- (void) dup2(0, 1);
- (void) dup2(0, 2);
- { int tt = open("/dev/tty", O_RDWR);
- if (tt > 0) {
- ioctl(tt, TIOCNOTTY, (char *)0);
- close(tt);
- }
+ if (debug == 0) {
+ if (fork())
+ exit(0);
+ { int s;
+ for (s = 0; s < 10; s++)
+ (void) close(s);
+ }
+ (void) open("/", O_RDONLY);
+ (void) dup2(0, 1);
+ (void) dup2(0, 2);
+ { int tt = open("/dev/tty", O_RDWR);
+ if (tt > 0) {
+ ioctl(tt, TIOCNOTTY, (char *)0);
+ close(tt);
+ }
+ }
+ (void) setpgrp(0, 0);
+ signal(SIGTSTP, SIG_IGN);
+ signal(SIGTTIN, SIG_IGN);
+ signal(SIGTTOU, SIG_IGN);
}
- (void) setpgrp(0, 0);
-#endif
openlog("inetd", LOG_PID | LOG_NOWAIT, LOG_DAEMON);
bzero((char *)&sv, sizeof(sv));
sv.sv_mask = SIGBLOCK;
}
sigsetmask(0L);
if (pid == 0) {
-#ifdef DEBUG
- int tt;
+ if (debug) {
+ int tt;
- if (dofork && (tt = open("/dev/tty", O_RDWR)) > 0) {
+ if (dofork && (tt = open("/dev/tty", O_RDWR)) > 0) {
ioctl(tt, TIOCNOTTY, 0);
close(tt);
+ }
+ (void) setpgrp(0, 0);
+ signal(SIGTSTP, SIG_IGN);
+ signal(SIGTTIN, SIG_IGN);
+ signal(SIGTTOU, SIG_IGN);
}
-#endif
if (dofork)
for (i = getdtablesize(); --i > 2; )
if (i != ctrl)
{
register struct servtab *sep;
long omask;
- char *strdup();
sep = (struct servtab *)malloc(sizeof (*sep));
if (sep == (struct servtab *)0) {
getconfigent()
{
register struct servtab *sep = &serv;
- char *cp, *arg;
int argc;
+ char *cp, *arg, *strdup();
more:
while ((cp = nextline(fconfig)) && *cp == '#')
cp = Argv[0];
size = sizeof(sin);
if (getpeername(s, &sin, &size) == 0)
- sprintf(buf, "-%s [%s]", a, inet_ntoa(sin.sin_addr));
+ (void) sprintf(buf, "-%s [%s]", a, inet_ntoa(sin.sin_addr));
else
- sprintf(buf, "-%s", a);
+ (void) sprintf(buf, "-%s", a);
strncpy(cp, buf, LastArg - cp);
cp += strlen(cp);
while (cp < LastArg)
clock = time((time_t *) 0);
- sprintf(buffer, "%.24s\r\n", ctime(&clock));
+ (void) sprintf(buffer, "%.24s\r\n", ctime(&clock));
(void) write(s, buffer, strlen(buffer));
}
size = sizeof(sa);
if (recvfrom(s, buffer, sizeof(buffer), 0, &sa, &size) < 0)
return;
- sprintf(buffer, "%.24s\r\n", ctime(&clock));
+ (void) sprintf(buffer, "%.24s\r\n", ctime(&clock));
(void) sendto(s, buffer, strlen(buffer), 0, &sa, sizeof(sa));
}