SCCS-vsn: usr.sbin/inetd/inetd.c 5.5
#endif not lint
#ifndef lint
#endif not lint
#ifndef lint
-static char sccsid[] = "@(#)inetd.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)inetd.c 5.5 (Berkeley) %G%";
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <arpa/inet.h>
(void) dup2(0, 2);
{ int tt = open("/dev/tty", O_RDWR);
if (tt > 0) {
(void) dup2(0, 2);
{ int tt = open("/dev/tty", O_RDWR);
if (tt > 0) {
- ioctl(tt, TIOCNOTTY, 0);
+ ioctl(tt, TIOCNOTTY, (char *)0);
while (nsock == 0)
sigpause(0);
readable = allsock;
while (nsock == 0)
sigpause(0);
readable = allsock;
- if ((n = select(maxsock + 1, &readable, 0, 0, 0)) <= 0)
+ if ((n = select(maxsock + 1, &readable, (fd_set *)0,
+ (fd_set *)0, (struct timeval *)0)) <= 0)
continue;
for (s = 0; s <= maxsock; s++)
if (FD_ISSET(s, &readable))
continue;
for (s = 0; s <= maxsock; s++)
if (FD_ISSET(s, &readable))
for (sep = servtab; sep; sep = sep->se_next)
if (s == sep->se_fd)
goto found;
for (sep = servtab; sep; sep = sep->se_next)
if (s == sep->se_fd)
goto found;
found:
if (debug)
fprintf(stderr, "someone wants %s\n", sep->se_service);
if (!sep->se_wait && sep->se_socktype == SOCK_STREAM) {
found:
if (debug)
fprintf(stderr, "someone wants %s\n", sep->se_service);
if (!sep->se_wait && sep->se_socktype == SOCK_STREAM) {
- ctrl = accept(s, 0, 0);
+ ctrl = accept(s, (struct sockaddr *)0, (int *)0);
if (debug)
fprintf(stderr, "accept, ctrl %d\n", ctrl);
if (ctrl < 0) {
if (debug)
fprintf(stderr, "accept, ctrl %d\n", ctrl);
if (ctrl < 0) {
}
} else
ctrl = sep->se_fd;
}
} else
ctrl = sep->se_fd;
- sigblock(sigmask(SIGCHLD)|sigmask(SIGHUP));
+ (void) sigblock(sigmask(SIGCHLD)|sigmask(SIGHUP));
pid = 0;
if (sep->se_bi == 0 || sep->se_bi->bi_fork)
pid = fork();
pid = 0;
if (sep->se_bi == 0 || sep->se_bi->bi_fork)
pid = fork();
_exit(1);
}
if (pwd->pw_uid) {
_exit(1);
}
if (pwd->pw_uid) {
- (void) setgid(pwd->pw_gid);
+ (void) setgid((gid_t)pwd->pw_gid);
initgroups(pwd->pw_name, pwd->pw_gid);
initgroups(pwd->pw_name, pwd->pw_gid);
- (void) setuid(pwd->pw_uid);
+ (void) setuid((uid_t)pwd->pw_uid);
}
if (debug)
fprintf(stderr, "%d execl %s\n",
}
if (debug)
fprintf(stderr, "%d execl %s\n",
register struct servtab *sep;
for (;;) {
register struct servtab *sep;
for (;;) {
- pid = wait3(&status, WNOHANG, 0);
+ pid = wait3(&status, WNOHANG, (struct rusage *)0);
if (pid <= 0)
break;
if (debug)
if (pid <= 0)
break;
if (debug)
omask = sigblock(sigmask(SIGCHLD));
sep->se_wait = cp->se_wait;
#define SWAP(a, b) { char *c = a; a = b; b = c; }
omask = sigblock(sigmask(SIGCHLD));
sep->se_wait = cp->se_wait;
#define SWAP(a, b) { char *c = a; a = b; b = c; }
+ if (cp->se_user)
+ SWAP(sep->se_user, cp->se_user);
if (cp->se_server)
SWAP(sep->se_server, cp->se_server);
for (i = 0; i < MAXARGV; i++)
if (cp->se_server)
SWAP(sep->se_server, cp->se_server);
for (i = 0; i < MAXARGV; i++)
continue;
}
#define turnon(fd, opt) \
continue;
}
#define turnon(fd, opt) \
- setsockopt(fd, SOL_SOCKET, opt, &on, sizeof (on))
+ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on))
if (strcmp(sep->se_proto, "tcp") == 0 && (options & SO_DEBUG) &&
turnon(sep->se_fd, SO_DEBUG) < 0)
syslog(LOG_ERR, "setsockopt (SO_DEBUG): %m");
if (strcmp(sep->se_proto, "tcp") == 0 && (options & SO_DEBUG) &&
turnon(sep->se_fd, SO_DEBUG) < 0)
syslog(LOG_ERR, "setsockopt (SO_DEBUG): %m");
syslog(LOG_ERR, "setsockopt (SO_REUSEADDR): %m");
#undef turnon
if (bind(sep->se_fd, &sep->se_ctrladdr,
syslog(LOG_ERR, "setsockopt (SO_REUSEADDR): %m");
#undef turnon
if (bind(sep->se_fd, &sep->se_ctrladdr,
- sizeof (sep->se_ctrladdr), 0) < 0) {
+ sizeof (sep->se_ctrladdr)) < 0) {
syslog(LOG_ERR, "%s/%s: bind: %m",
sep->se_service, sep->se_proto);
continue;
syslog(LOG_ERR, "%s/%s: bind: %m",
sep->se_service, sep->se_proto);
continue;
- fseek(fconfig, 0, L_SET);
+ fseek(fconfig, 0L, L_SET);
return (1);
}
fconfig = fopen(CONFIG, "r");
return (1);
}
fconfig = fopen(CONFIG, "r");
free(cp->se_service);
if (cp->se_proto)
free(cp->se_proto);
free(cp->se_service);
if (cp->se_proto)
free(cp->se_proto);
+ if (cp->se_user)
+ free(cp->se_user);
if (cp->se_server)
free(cp->se_server);
for (i = 0; i < MAXARGV; i++)
if (cp->se_server)
free(cp->se_server);
for (i = 0; i < MAXARGV; i++)
- if (fgets(line, sizeof (line), fconfig) == NULL)
+ if (fgets(line, sizeof (line), fd) == NULL)
return ((char *)0);
cp = index(line, '\n');
if (cp)
return ((char *)0);
cp = index(line, '\n');
if (cp)
- new = malloc(strlen(cp) + 1);
+ new = malloc((unsigned)(strlen(cp) + 1));
if (new == (char *)0) {
syslog(LOG_ERR, "Out of memory.");
exit(-1);
if (new == (char *)0) {
syslog(LOG_ERR, "Out of memory.");
exit(-1);
* we must add 2208988800 seconds to this figure to make up for
* some seventy years Bell Labs was asleep.
*/
* we must add 2208988800 seconds to this figure to make up for
* some seventy years Bell Labs was asleep.
*/
long
machtime()
{
struct timeval tv;
long
machtime()
{
struct timeval tv;
- if (gettimeofday(&tv, 0) < 0) {
+ if (gettimeofday(&tv, (struct timezone *)0) < 0) {
fprintf(stderr, "Unable to get time of day\n");
fprintf(stderr, "Unable to get time of day\n");
}
return (htonl((long)tv.tv_sec + 2208988800));
}
}
return (htonl((long)tv.tv_sec + 2208988800));
}
int size;
size = sizeof(sa);
int size;
size = sizeof(sa);
- if (recvfrom(s, &result, sizeof(result), 0, &sa, &size) < 0)
+ if (recvfrom(s, (char *)&result, sizeof(result), 0, &sa, &size) < 0)
return;
result = machtime();
(void) sendto(s, (char *) &result, sizeof(result), 0, &sa, sizeof(sa));
return;
result = machtime();
(void) sendto(s, (char *) &result, sizeof(result), 0, &sa, sizeof(sa));
clock = time((time_t *) 0);
sprintf(buffer, "%s\r", ctime(&clock));
clock = time((time_t *) 0);
sprintf(buffer, "%s\r", ctime(&clock));
- write(s, buffer, strlen(buffer));
+ (void) write(s, buffer, strlen(buffer));