Cosmetic changes; fix more indentation (just added/deleted white spaces).

This commit is contained in:
enami 1998-02-28 13:29:03 +00:00
parent 01e1d15a0e
commit 86053c56a1
1 changed files with 38 additions and 39 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rshd.c,v 1.12 1998/01/08 03:30:49 lukem Exp $ */ /* $NetBSD: rshd.c,v 1.13 1998/02/28 13:29:03 enami Exp $ */
/*- /*-
* Copyright (c) 1988, 1989, 1992, 1993, 1994 * Copyright (c) 1988, 1989, 1992, 1993, 1994
@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1992, 1993, 1994\n\
#if 0 #if 0
static char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94"; static char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94";
#else #else
__RCSID("$NetBSD: rshd.c,v 1.12 1998/01/08 03:30:49 lukem Exp $"); __RCSID("$NetBSD: rshd.c,v 1.13 1998/02/28 13:29:03 enami Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -216,26 +216,26 @@ doit(fromp)
} }
#endif #endif
if (fromp->sin_port >= IPPORT_RESERVED || if (fromp->sin_port >= IPPORT_RESERVED ||
fromp->sin_port < IPPORT_RESERVED/2) { fromp->sin_port < IPPORT_RESERVED/2) {
syslog(LOG_NOTICE|LOG_AUTH, syslog(LOG_NOTICE|LOG_AUTH,
"Connection from %s on illegal port %u", "Connection from %s on illegal port %u",
inet_ntoa(fromp->sin_addr), inet_ntoa(fromp->sin_addr), fromp->sin_port);
fromp->sin_port); exit(1);
exit(1); }
}
(void) alarm(60); (void) alarm(60);
port = 0; port = 0;
for (;;) { for (;;) {
char c; char c;
if ((cc = read(STDIN_FILENO, &c, 1)) != 1) { if ((cc = read(STDIN_FILENO, &c, 1)) != 1) {
if (cc < 0) if (cc < 0)
syslog(LOG_NOTICE, "read: %m"); syslog(LOG_NOTICE, "read: %m");
shutdown(0, 1+1); shutdown(0, 1+1);
exit(1); exit(1);
} }
if (c== 0) if (c == 0)
break; break;
port = port * 10 + c - '0'; port = port * 10 + c - '0';
} }
@ -268,7 +268,7 @@ doit(fromp)
#endif #endif
errorstr = NULL; errorstr = NULL;
hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof (struct in_addr), hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof (struct in_addr),
fromp->sin_family); fromp->sin_family);
if (hp) { if (hp) {
/* /*
* If name returned by gethostbyaddr is in our domain, * If name returned by gethostbyaddr is in our domain,
@ -309,11 +309,10 @@ doit(fromp)
} }
} }
hostname = strncpy(hostnamebuf, hostname, hostname = strncpy(hostnamebuf, hostname,
sizeof(hostnamebuf) - 1); sizeof(hostnamebuf) - 1);
} else } else
errorhost = hostname = strncpy(hostnamebuf, errorhost = hostname = strncpy(hostnamebuf,
inet_ntoa(fromp->sin_addr), inet_ntoa(fromp->sin_addr), sizeof(hostnamebuf) - 1);
sizeof(hostnamebuf) - 1);
hostnamebuf[sizeof(hostnamebuf) - 1] = '\0'; hostnamebuf[sizeof(hostnamebuf) - 1] = '\0';
@ -342,25 +341,25 @@ doit(fromp)
} }
if (errorstr || if (errorstr ||
(pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0' && (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0' &&
iruserok(fromp->sin_addr.s_addr, pwd->pw_uid == 0, iruserok(fromp->sin_addr.s_addr, pwd->pw_uid == 0,
remuser, locuser) < 0)) { remuser, locuser) < 0)) {
if (__rcmd_errstr) if (__rcmd_errstr)
syslog(LOG_INFO|LOG_AUTH, syslog(LOG_INFO|LOG_AUTH,
"%s@%s as %s: permission denied (%s). cmd='%.80s'", "%s@%s as %s: permission denied (%s). cmd='%.80s'",
remuser, hostname, locuser, __rcmd_errstr, remuser, hostname, locuser, __rcmd_errstr,
cmdbuf); cmdbuf);
else else
syslog(LOG_INFO|LOG_AUTH, syslog(LOG_INFO|LOG_AUTH,
"%s@%s as %s: permission denied. cmd='%.80s'", "%s@%s as %s: permission denied. cmd='%.80s'",
remuser, hostname, locuser, cmdbuf); remuser, hostname, locuser, cmdbuf);
fail: fail:
if (errorstr == NULL) if (errorstr == NULL)
errorstr = "Permission denied.\n"; errorstr = "Permission denied.\n";
error(errorstr, errorhost); error(errorstr, errorhost);
exit(1); exit(1);
} }
if (pwd->pw_uid && !access(_PATH_NOLOGIN, F_OK)) { if (pwd->pw_uid && !access(_PATH_NOLOGIN, F_OK)) {
error("Logins currently disabled.\n"); error("Logins currently disabled.\n");
@ -395,18 +394,19 @@ fail:
nfd = pv[0]; nfd = pv[0];
else else
nfd = s; nfd = s;
ioctl(pv[0], FIONBIO, (char *)&one); ioctl(pv[0], FIONBIO, (char *)&one);
/* should set s nbio! */ /* should set s nbio! */
nfd++; nfd++;
do { do {
ready = readfrom; ready = readfrom;
if (select(nfd, &ready, (fd_set *)0, if (select(nfd, &ready, (fd_set *)0,
(fd_set *)0, (struct timeval *)0) < 0) (fd_set *)0, (struct timeval *)0) < 0)
break; break;
if (FD_ISSET(s, &ready)) { if (FD_ISSET(s, &ready)) {
int ret; int ret;
ret = read(s, &sig, 1);
ret = read(s, &sig, 1);
if (ret <= 0) if (ret <= 0)
FD_CLR(s, &readfrom); FD_CLR(s, &readfrom);
else else
@ -419,8 +419,7 @@ fail:
shutdown(s, 1+1); shutdown(s, 1+1);
FD_CLR(pv[0], &readfrom); FD_CLR(pv[0], &readfrom);
} else { } else {
(void) (void) write(s, buf, cc);
write(s, buf, cc);
} }
} }
@ -455,8 +454,8 @@ fail:
cp = pwd->pw_shell; cp = pwd->pw_shell;
endpwent(); endpwent();
if (log_success || pwd->pw_uid == 0) { if (log_success || pwd->pw_uid == 0) {
syslog(LOG_INFO|LOG_AUTH, "%s@%s as %s: cmd='%.80s'", syslog(LOG_INFO|LOG_AUTH, "%s@%s as %s: cmd='%.80s'",
remuser, hostname, locuser, cmdbuf); remuser, hostname, locuser, cmdbuf);
} }
execl(pwd->pw_shell, cp, "-c", cmdbuf, 0); execl(pwd->pw_shell, cp, "-c", cmdbuf, 0);
perror(pwd->pw_shell); perror(pwd->pw_shell);