Use realhostname() rather than various combinations of
gethostbyaddr() & gethostbyname(). Remove brokeness in ftpd for hosts of MAXHOSTNAMELEN length.
This commit is contained in:
parent
595f220e04
commit
32af26a501
@ -42,10 +42,10 @@ static const char copyright[] =
|
|||||||
static char sccsid[] = "@(#)fingerd.c 8.1 (Berkeley) 6/4/93";
|
static char sccsid[] = "@(#)fingerd.c 8.1 (Berkeley) 6/4/93";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: fingerd.c,v 1.10 1997/11/20 07:26:04 charnier Exp $";
|
"$Id: fingerd.c,v 1.11 1998/05/15 03:23:28 jb Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/param.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
@ -70,11 +70,11 @@ main(argc, argv)
|
|||||||
register FILE *fp;
|
register FILE *fp;
|
||||||
register int ch;
|
register int ch;
|
||||||
register char *lp;
|
register char *lp;
|
||||||
struct hostent *hp;
|
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
int p[2], logging, secure, sval;
|
int p[2], logging, secure, sval;
|
||||||
#define ENTRIES 50
|
#define ENTRIES 50
|
||||||
char **ap, *av[ENTRIES + 1], **comp, line[1024], *prog;
|
char **ap, *av[ENTRIES + 1], **comp, line[1024], *prog;
|
||||||
|
char rhost[MAXHOSTNAMELEN + 1];
|
||||||
|
|
||||||
prog = _PATH_FINGER;
|
prog = _PATH_FINGER;
|
||||||
logging = secure = 0;
|
logging = secure = 0;
|
||||||
@ -130,12 +130,8 @@ main(argc, argv)
|
|||||||
sval = sizeof(sin);
|
sval = sizeof(sin);
|
||||||
if (getpeername(0, (struct sockaddr *)&sin, &sval) < 0)
|
if (getpeername(0, (struct sockaddr *)&sin, &sval) < 0)
|
||||||
logerr("getpeername: %s", strerror(errno));
|
logerr("getpeername: %s", strerror(errno));
|
||||||
if (hp = gethostbyaddr((char *)&sin.sin_addr.s_addr,
|
realhostname(rhost, sizeof rhost - 1, &sin.sin_addr);
|
||||||
sizeof(sin.sin_addr.s_addr), AF_INET))
|
syslog(LOG_NOTICE, "query from %s: `%s'", rhost, t);
|
||||||
lp = hp->h_name;
|
|
||||||
else
|
|
||||||
lp = inet_ntoa(sin.sin_addr);
|
|
||||||
syslog(LOG_NOTICE, "query from %s: `%s'", lp, t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
comp = &av[1];
|
comp = &av[1];
|
||||||
|
@ -44,7 +44,7 @@ static char copyright[] =
|
|||||||
static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94";
|
static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: ftpd.c,v 1.51 1998/06/03 11:33:44 jb Exp $";
|
"$Id: ftpd.c,v 1.52 1998/10/13 20:42:01 des Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -166,7 +166,7 @@ static struct ftphost {
|
|||||||
} *thishost, *firsthost;
|
} *thishost, *firsthost;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
char remotehost[MAXHOSTNAMELEN];
|
char remotehost[MAXHOSTNAMELEN + 1];
|
||||||
char *ident = NULL;
|
char *ident = NULL;
|
||||||
|
|
||||||
static char ttyline[20];
|
static char ttyline[20];
|
||||||
@ -1896,14 +1896,8 @@ static void
|
|||||||
dolog(sin)
|
dolog(sin)
|
||||||
struct sockaddr_in *sin;
|
struct sockaddr_in *sin;
|
||||||
{
|
{
|
||||||
struct hostent *hp = gethostbyaddr((char *)&sin->sin_addr,
|
realhostname(remotehost, sizeof remotehost - 1, &sin->sin_addr);
|
||||||
sizeof(struct in_addr), AF_INET);
|
|
||||||
|
|
||||||
if (hp)
|
|
||||||
(void) strncpy(remotehost, hp->h_name, sizeof(remotehost));
|
|
||||||
else
|
|
||||||
(void) strncpy(remotehost, inet_ntoa(sin->sin_addr),
|
|
||||||
sizeof(remotehost));
|
|
||||||
#ifdef SETPROCTITLE
|
#ifdef SETPROCTITLE
|
||||||
#ifdef VIRTUAL_HOSTING
|
#ifdef VIRTUAL_HOSTING
|
||||||
if (thishost != firsthost)
|
if (thishost != firsthost)
|
||||||
|
@ -42,7 +42,7 @@ static const char copyright[] =
|
|||||||
static char sccsid[] = "@(#)rexecd.c 8.1 (Berkeley) 6/4/93";
|
static char sccsid[] = "@(#)rexecd.c 8.1 (Berkeley) 6/4/93";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id$";
|
"$Id: rexecd.c,v 1.15 1997/11/26 07:29:04 charnier Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -55,6 +55,7 @@ static const char rcsid[] =
|
|||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
#include <libutil.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@ -72,7 +73,7 @@ char path[sizeof(_PATH_DEFPATH) + sizeof("PATH=")] = "PATH=";
|
|||||||
char *envinit[] =
|
char *envinit[] =
|
||||||
{homedir, shell, path, username, 0};
|
{homedir, shell, path, username, 0};
|
||||||
char **environ;
|
char **environ;
|
||||||
char *remote;
|
char remote[MAXHOSTNAMELEN + 1];
|
||||||
|
|
||||||
struct sockaddr_in asin = { AF_INET };
|
struct sockaddr_in asin = { AF_INET };
|
||||||
|
|
||||||
@ -103,10 +104,7 @@ main(argc, argv)
|
|||||||
if (getpeername(0, (struct sockaddr *)&from, &fromlen) < 0)
|
if (getpeername(0, (struct sockaddr *)&from, &fromlen) < 0)
|
||||||
err(1, "getpeername");
|
err(1, "getpeername");
|
||||||
|
|
||||||
hp = gethostbyaddr((char *) &from.sin_addr, sizeof(from.sin_addr),
|
realhostname(remote, sizeof remote - 1, &from.sin_addr);
|
||||||
from.sin_family);
|
|
||||||
remote = inet_ntoa(from.sin_addr);
|
|
||||||
remote = (hp != NULL) ? hp->h_name : inet_ntoa(from.sin_addr);
|
|
||||||
|
|
||||||
doit(0, &from);
|
doit(0, &from);
|
||||||
return(0);
|
return(0);
|
||||||
|
@ -42,7 +42,7 @@ static const char copyright[] =
|
|||||||
static const char sccsid[] = "@(#)rlogind.c 8.1 (Berkeley) 6/4/93";
|
static const char sccsid[] = "@(#)rlogind.c 8.1 (Berkeley) 6/4/93";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: rlogind.c,v 1.19 1997/11/25 07:17:15 charnier Exp $";
|
"$Id: rlogind.c,v 1.20 1998/12/16 07:20:44 peter Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -211,7 +211,6 @@ doit(f, fromp)
|
|||||||
{
|
{
|
||||||
int master, pid, on = 1;
|
int master, pid, on = 1;
|
||||||
int authenticated = 0;
|
int authenticated = 0;
|
||||||
register struct hostent *hp;
|
|
||||||
char hostname[2 * MAXHOSTNAMELEN + 1];
|
char hostname[2 * MAXHOSTNAMELEN + 1];
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
@ -227,31 +226,7 @@ doit(f, fromp)
|
|||||||
|
|
||||||
alarm(0);
|
alarm(0);
|
||||||
fromp->sin_port = ntohs((u_short)fromp->sin_port);
|
fromp->sin_port = ntohs((u_short)fromp->sin_port);
|
||||||
hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof(struct in_addr),
|
realhostname(hostname, sizeof hostname - 1, &fromp->sin_addr);
|
||||||
fromp->sin_family);
|
|
||||||
if (hp) {
|
|
||||||
strncpy(hostname, hp->h_name, sizeof(hostname) - 1);
|
|
||||||
hostname[sizeof(hostname) - 1] = '\0';
|
|
||||||
hp = gethostbyname(hostname);
|
|
||||||
if (hp == NULL) {
|
|
||||||
strncpy(hostname, inet_ntoa(fromp->sin_addr),
|
|
||||||
sizeof(hostname) - 1);
|
|
||||||
} else for (; ; hp->h_addr_list++) {
|
|
||||||
if (hp->h_addr_list[0] == NULL) {
|
|
||||||
/* End of list - ditch it */
|
|
||||||
strncpy(hostname, inet_ntoa(fromp->sin_addr),
|
|
||||||
sizeof(hostname) - 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!bcmp(hp->h_addr_list[0],
|
|
||||||
(caddr_t)&fromp->sin_addr,
|
|
||||||
sizeof(fromp->sin_addr)))
|
|
||||||
break; /* OK! */
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
strncpy(hostname, inet_ntoa(fromp->sin_addr),
|
|
||||||
sizeof(hostname) - 1);
|
|
||||||
}
|
|
||||||
hostname[sizeof(hostname) - 1] = '\0';
|
hostname[sizeof(hostname) - 1] = '\0';
|
||||||
|
|
||||||
#ifdef KERBEROS
|
#ifdef KERBEROS
|
||||||
|
@ -42,7 +42,7 @@ static const char copyright[] =
|
|||||||
static const char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94";
|
static const char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: rshd.c,v 1.22 1998/12/01 23:27:24 dg Exp $";
|
"$Id: rshd.c,v 1.23 1998/12/16 07:20:45 peter Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -67,6 +67,7 @@ static const char rcsid[] =
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <libutil.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@ -207,13 +208,12 @@ doit(fromp)
|
|||||||
struct sockaddr_in *fromp;
|
struct sockaddr_in *fromp;
|
||||||
{
|
{
|
||||||
extern char *__rcmd_errstr; /* syslog hook from libc/net/rcmd.c. */
|
extern char *__rcmd_errstr; /* syslog hook from libc/net/rcmd.c. */
|
||||||
struct hostent *hp;
|
|
||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
u_short port;
|
u_short port;
|
||||||
fd_set ready, readfrom;
|
fd_set ready, readfrom;
|
||||||
int cc, nfd, pv[2], pid, s;
|
int cc, nfd, pv[2], pid, s;
|
||||||
int one = 1;
|
int one = 1;
|
||||||
char *hostname, *errorstr;
|
char *errorstr;
|
||||||
char *cp, sig, buf[BUFSIZ];
|
char *cp, sig, buf[BUFSIZ];
|
||||||
char cmdbuf[NCARGS+1], locuser[16], remuser[16];
|
char cmdbuf[NCARGS+1], locuser[16], remuser[16];
|
||||||
char fromhost[2 * MAXHOSTNAMELEN + 1];
|
char fromhost[2 * MAXHOSTNAMELEN + 1];
|
||||||
@ -350,36 +350,8 @@ doit(fromp)
|
|||||||
errorstr = NULL;
|
errorstr = NULL;
|
||||||
strncpy(fromhost, inet_ntoa(fromp->sin_addr),
|
strncpy(fromhost, inet_ntoa(fromp->sin_addr),
|
||||||
sizeof(fromhost) - 1);
|
sizeof(fromhost) - 1);
|
||||||
hostname = fromhost;
|
realhostname(fromhost, sizeof fromhost - 1, &fromp->sin_addr);
|
||||||
hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof (struct in_addr),
|
fromhost[sizeof(fromhost) - 1] = '\0';
|
||||||
fromp->sin_family);
|
|
||||||
if (hp) {
|
|
||||||
/*
|
|
||||||
* OK, it looks like a DNS name is attached.. Lets see if
|
|
||||||
* it looks like we can use it. If it doesn't check out,
|
|
||||||
* ditch it and use the IP address for logging instead.
|
|
||||||
* Note that iruserok() does it's own hostname checking!!
|
|
||||||
*/
|
|
||||||
strncpy(fromhost, hp->h_name, sizeof(fromhost) - 1);
|
|
||||||
fromhost[sizeof(fromhost) - 1] = 0;
|
|
||||||
hp = gethostbyname(fromhost);
|
|
||||||
if (hp == NULL) {
|
|
||||||
strncpy(fromhost, inet_ntoa(fromp->sin_addr),
|
|
||||||
sizeof(fromhost) - 1);
|
|
||||||
} else for (; ; hp->h_addr_list++) {
|
|
||||||
if (hp->h_addr_list[0] == NULL) {
|
|
||||||
/* End of list - ditch it */
|
|
||||||
strncpy(fromhost, inet_ntoa(fromp->sin_addr),
|
|
||||||
sizeof(fromhost) - 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!bcmp(hp->h_addr_list[0],
|
|
||||||
(caddr_t)&fromp->sin_addr,
|
|
||||||
sizeof(fromp->sin_addr)))
|
|
||||||
break; /* OK! */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fromhost[sizeof(fromhost) - 1] = 0;
|
|
||||||
|
|
||||||
#ifdef KERBEROS
|
#ifdef KERBEROS
|
||||||
if (use_kerberos) {
|
if (use_kerberos) {
|
||||||
@ -426,7 +398,7 @@ doit(fromp)
|
|||||||
if (pwd == NULL) {
|
if (pwd == NULL) {
|
||||||
syslog(LOG_INFO|LOG_AUTH,
|
syslog(LOG_INFO|LOG_AUTH,
|
||||||
"%s@%s as %s: unknown login. cmd='%.80s'",
|
"%s@%s as %s: unknown login. cmd='%.80s'",
|
||||||
remuser, hostname, locuser, cmdbuf);
|
remuser, fromhost, locuser, cmdbuf);
|
||||||
if (errorstr == NULL)
|
if (errorstr == NULL)
|
||||||
errorstr = "Login incorrect.\n";
|
errorstr = "Login incorrect.\n";
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -440,7 +412,7 @@ doit(fromp)
|
|||||||
login_getcapbool(lc, "requirehome", !!pwd->pw_uid)) {
|
login_getcapbool(lc, "requirehome", !!pwd->pw_uid)) {
|
||||||
syslog(LOG_INFO|LOG_AUTH,
|
syslog(LOG_INFO|LOG_AUTH,
|
||||||
"%s@%s as %s: no home directory. cmd='%.80s'",
|
"%s@%s as %s: no home directory. cmd='%.80s'",
|
||||||
remuser, hostname, locuser, cmdbuf);
|
remuser, fromhost, locuser, cmdbuf);
|
||||||
error("No remote home directory.\n");
|
error("No remote home directory.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -449,7 +421,7 @@ doit(fromp)
|
|||||||
#ifdef notdef
|
#ifdef notdef
|
||||||
syslog(LOG_INFO|LOG_AUTH,
|
syslog(LOG_INFO|LOG_AUTH,
|
||||||
"%s@%s as %s: no home directory. cmd='%.80s'",
|
"%s@%s as %s: no home directory. cmd='%.80s'",
|
||||||
remuser, hostname, locuser, cmdbuf);
|
remuser, fromhost, locuser, cmdbuf);
|
||||||
error("No remote directory.\n");
|
error("No remote directory.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
#endif
|
#endif
|
||||||
@ -479,16 +451,16 @@ doit(fromp)
|
|||||||
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, fromhost, 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, fromhost, locuser, cmdbuf);
|
||||||
fail:
|
fail:
|
||||||
if (errorstr == NULL)
|
if (errorstr == NULL)
|
||||||
errorstr = "Login incorrect.\n";
|
errorstr = "Login incorrect.\n";
|
||||||
error(errorstr, hostname);
|
error(errorstr, fromhost);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,7 +478,7 @@ fail:
|
|||||||
if (!auth_hostok(lc, fromhost, remote_ip)) {
|
if (!auth_hostok(lc, fromhost, remote_ip)) {
|
||||||
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, fromhost, locuser, __rcmd_errstr,
|
||||||
cmdbuf);
|
cmdbuf);
|
||||||
error("Login incorrect.\n");
|
error("Login incorrect.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -729,11 +701,11 @@ fail:
|
|||||||
syslog(LOG_INFO|LOG_AUTH,
|
syslog(LOG_INFO|LOG_AUTH,
|
||||||
"Kerberos shell from %s.%s@%s on %s as %s, cmd='%.80s'",
|
"Kerberos shell from %s.%s@%s on %s as %s, cmd='%.80s'",
|
||||||
kdata->pname, kdata->pinst, kdata->prealm,
|
kdata->pname, kdata->pinst, kdata->prealm,
|
||||||
hostname, locuser, cmdbuf);
|
fromhost, locuser, cmdbuf);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
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, fromhost, 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);
|
||||||
|
@ -42,7 +42,7 @@ static const char copyright[] =
|
|||||||
static char sccsid[] = "@(#)telnetd.c 8.2 (Berkeley) 12/15/93";
|
static char sccsid[] = "@(#)telnetd.c 8.2 (Berkeley) 12/15/93";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: telnetd.c,v 1.15 1998/12/16 06:04:29 peter Exp $";
|
"$Id: telnetd.c,v 1.16 1999/04/06 00:29:41 brian Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "telnetd.h"
|
#include "telnetd.h"
|
||||||
@ -61,6 +61,8 @@ static const char rcsid[] =
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <libutil.h>
|
||||||
|
#include <utmp.h>
|
||||||
|
|
||||||
#if defined(_SC_CRAY_SECURE_SYS)
|
#if defined(_SC_CRAY_SECURE_SYS)
|
||||||
#include <sys/sysv.h>
|
#include <sys/sysv.h>
|
||||||
@ -756,7 +758,7 @@ terminaltypeok(s)
|
|||||||
|
|
||||||
char *hostname;
|
char *hostname;
|
||||||
char host_name[MAXHOSTNAMELEN];
|
char host_name[MAXHOSTNAMELEN];
|
||||||
char remote_host_name[MAXHOSTNAMELEN];
|
char remote_hostname[UT_HOSTSIZE + 1];
|
||||||
|
|
||||||
extern void telnet P((int, int, char *));
|
extern void telnet P((int, int, char *));
|
||||||
|
|
||||||
@ -769,8 +771,6 @@ char user_name[256];
|
|||||||
doit(who)
|
doit(who)
|
||||||
struct sockaddr_in *who;
|
struct sockaddr_in *who;
|
||||||
{
|
{
|
||||||
char *host = NULL;
|
|
||||||
struct hostent *hp;
|
|
||||||
int ptynum;
|
int ptynum;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -813,47 +813,16 @@ doit(who)
|
|||||||
#endif /* _SC_CRAY_SECURE_SYS */
|
#endif /* _SC_CRAY_SECURE_SYS */
|
||||||
|
|
||||||
/* get name of connected client */
|
/* get name of connected client */
|
||||||
hp = gethostbyaddr((char *)&who->sin_addr, sizeof (struct in_addr),
|
if (realhostname(remote_hostname, sizeof remote_hostname - 1,
|
||||||
who->sin_family);
|
&who->sin_addr) == HOSTNAME_INVALIDADDR && registerd_host_only)
|
||||||
|
|
||||||
if (hp == NULL && registerd_host_only) {
|
|
||||||
fatal(net, "Couldn't resolve your address into a host name.\r\n\
|
fatal(net, "Couldn't resolve your address into a host name.\r\n\
|
||||||
Please contact your net administrator");
|
Please contact your net administrator");
|
||||||
} else if (hp &&
|
|
||||||
(strlen(hp->h_name) <= ((utmp_len < 0) ? -utmp_len : utmp_len))) {
|
|
||||||
strncpy(remote_host_name, hp->h_name,
|
|
||||||
sizeof(remote_host_name)-1);
|
|
||||||
hp = gethostbyname(remote_host_name);
|
|
||||||
if (hp == NULL)
|
|
||||||
host = inet_ntoa(who->sin_addr);
|
|
||||||
else for (; ; hp->h_addr_list++) {
|
|
||||||
if (hp->h_addr_list[0] == NULL) {
|
|
||||||
/* End of list - ditch it */
|
|
||||||
host = inet_ntoa(who->sin_addr);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!bcmp(hp->h_addr_list[0], (caddr_t)&who->sin_addr,
|
|
||||||
sizeof(who->sin_addr))) {
|
|
||||||
host = hp->h_name;
|
|
||||||
break; /* OK! */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
host = inet_ntoa(who->sin_addr);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* We must make a copy because Kerberos is probably going
|
|
||||||
* to also do a gethost* and overwrite the static data...
|
|
||||||
*/
|
|
||||||
strncpy(remote_host_name, host, sizeof(remote_host_name)-1);
|
|
||||||
remote_host_name[sizeof(remote_host_name)-1] = 0;
|
|
||||||
host = remote_host_name;
|
|
||||||
|
|
||||||
(void) gethostname(host_name, sizeof (host_name));
|
(void) gethostname(host_name, sizeof (host_name));
|
||||||
hostname = host_name;
|
hostname = host_name;
|
||||||
|
|
||||||
#if defined(AUTHENTICATION)
|
#if defined(AUTHENTICATION)
|
||||||
auth_encrypt_init(hostname, host, "TELNETD", 1);
|
auth_encrypt_init(hostname, remote_hostname, "TELNETD", 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
init_env();
|
init_env();
|
||||||
@ -873,7 +842,7 @@ doit(who)
|
|||||||
}
|
}
|
||||||
#endif /* _SC_CRAY_SECURE_SYS */
|
#endif /* _SC_CRAY_SECURE_SYS */
|
||||||
|
|
||||||
telnet(net, pty, host); /* begin server process */
|
telnet(net, pty, remote_hostname); /* begin server process */
|
||||||
|
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
} /* end of doit */
|
} /* end of doit */
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
# @(#)Makefile 8.1 (Berkeley) 6/4/93
|
# @(#)Makefile 8.1 (Berkeley) 6/4/93
|
||||||
# $Id$
|
# $Id: Makefile,v 1.5 1997/02/22 14:22:35 peter Exp $
|
||||||
|
|
||||||
PROG= tftpd
|
PROG= tftpd
|
||||||
SRCS= tftpd.c tftpsubs.c
|
SRCS= tftpd.c tftpsubs.c
|
||||||
|
DPADD= ${LIBUTIL}
|
||||||
|
LDADD= -lutil
|
||||||
MAN8= tftpd.8
|
MAN8= tftpd.8
|
||||||
CFLAGS+=-I${.CURDIR}/../../usr.bin/tftp
|
CFLAGS+=-I${.CURDIR}/../../usr.bin/tftp
|
||||||
.PATH: ${.CURDIR}/../../usr.bin/tftp
|
.PATH: ${.CURDIR}/../../usr.bin/tftp
|
||||||
|
@ -42,7 +42,7 @@ static const char copyright[] =
|
|||||||
static char sccsid[] = "@(#)tftpd.c 8.1 (Berkeley) 6/4/93";
|
static char sccsid[] = "@(#)tftpd.c 8.1 (Berkeley) 6/4/93";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: tftpd.c,v 1.11 1998/04/12 11:15:54 phk Exp $";
|
"$Id: tftpd.c,v 1.12 1998/10/30 16:17:39 dg Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -65,6 +65,7 @@ static const char rcsid[] =
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <libutil.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
@ -108,7 +109,6 @@ static int logging;
|
|||||||
|
|
||||||
static char *errtomsg __P((int));
|
static char *errtomsg __P((int));
|
||||||
static void nak __P((int));
|
static void nak __P((int));
|
||||||
static char *verifyhost __P((struct sockaddr_in *));
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
@ -325,8 +325,11 @@ again:
|
|||||||
}
|
}
|
||||||
ecode = (*pf->f_validate)(&filename, tp->th_opcode);
|
ecode = (*pf->f_validate)(&filename, tp->th_opcode);
|
||||||
if (logging) {
|
if (logging) {
|
||||||
syslog(LOG_INFO, "%s: %s request for %s: %s",
|
char host[MAXHOSTNAMELEN + 1];
|
||||||
verifyhost(&from),
|
|
||||||
|
realhostname(host, sizeof host - 1, &from.sin_addr);
|
||||||
|
host[sizeof host - 1] = '\0';
|
||||||
|
syslog(LOG_INFO, "%s: %s request for %s: %s", host,
|
||||||
tp->th_opcode == WRQ ? "write" : "read",
|
tp->th_opcode == WRQ ? "write" : "read",
|
||||||
filename, errtomsg(ecode));
|
filename, errtomsg(ecode));
|
||||||
}
|
}
|
||||||
@ -670,17 +673,3 @@ nak(error)
|
|||||||
if (send(peer, buf, length, 0) != length)
|
if (send(peer, buf, length, 0) != length)
|
||||||
syslog(LOG_ERR, "nak: %m");
|
syslog(LOG_ERR, "nak: %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
|
||||||
verifyhost(fromp)
|
|
||||||
struct sockaddr_in *fromp;
|
|
||||||
{
|
|
||||||
struct hostent *hp;
|
|
||||||
|
|
||||||
hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof (fromp->sin_addr),
|
|
||||||
fromp->sin_family);
|
|
||||||
if (hp)
|
|
||||||
return hp->h_name;
|
|
||||||
else
|
|
||||||
return inet_ntoa(fromp->sin_addr);
|
|
||||||
}
|
|
||||||
|
@ -45,7 +45,7 @@ static const char copyright[] =
|
|||||||
static char sccsid[] = "@(#)uucpd.c 8.1 (Berkeley) 6/4/93";
|
static char sccsid[] = "@(#)uucpd.c 8.1 (Berkeley) 6/4/93";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: uucpd.c,v 1.15 1998/06/30 15:19:51 bde Exp $";
|
"$Id: uucpd.c,v 1.16 1999/03/30 10:23:35 joerg Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -121,16 +121,8 @@ void main(int argc, char **argv)
|
|||||||
void badlogin(char *name, struct sockaddr_in *sin)
|
void badlogin(char *name, struct sockaddr_in *sin)
|
||||||
{
|
{
|
||||||
char remotehost[MAXHOSTNAMELEN];
|
char remotehost[MAXHOSTNAMELEN];
|
||||||
struct hostent *hp = gethostbyaddr((char *)&sin->sin_addr,
|
|
||||||
sizeof (struct in_addr), AF_INET);
|
|
||||||
|
|
||||||
if (hp) {
|
|
||||||
strncpy(remotehost, hp->h_name, sizeof (remotehost));
|
|
||||||
endhostent();
|
|
||||||
} else
|
|
||||||
strncpy(remotehost, inet_ntoa(sin->sin_addr),
|
|
||||||
sizeof (remotehost));
|
|
||||||
|
|
||||||
|
realhostname(remotehost, sizeof remotehost - 1, &sin->sin_addr);
|
||||||
remotehost[sizeof remotehost - 1] = '\0';
|
remotehost[sizeof remotehost - 1] = '\0';
|
||||||
|
|
||||||
syslog(LOG_NOTICE, "LOGIN FAILURE FROM %s", remotehost);
|
syslog(LOG_NOTICE, "LOGIN FAILURE FROM %s", remotehost);
|
||||||
@ -251,19 +243,13 @@ void dologout(void)
|
|||||||
void dologin(struct passwd *pw, struct sockaddr_in *sin)
|
void dologin(struct passwd *pw, struct sockaddr_in *sin)
|
||||||
{
|
{
|
||||||
char line[32];
|
char line[32];
|
||||||
char remotehost[MAXHOSTNAMELEN];
|
char remotehost[UT_HOSTSIZE + 1];
|
||||||
int f;
|
int f;
|
||||||
time_t cur_time;
|
time_t cur_time;
|
||||||
struct hostent *hp = gethostbyaddr((char *)&sin->sin_addr,
|
|
||||||
sizeof (struct in_addr), AF_INET);
|
|
||||||
|
|
||||||
if (hp) {
|
realhostname(remotehost, sizeof remotehost - 1, &sin->sin_addr);
|
||||||
strncpy(remotehost, hp->h_name, sizeof (remotehost));
|
|
||||||
endhostent();
|
|
||||||
} else
|
|
||||||
strncpy(remotehost, inet_ntoa(sin->sin_addr),
|
|
||||||
sizeof (remotehost));
|
|
||||||
remotehost[sizeof remotehost - 1] = '\0';
|
remotehost[sizeof remotehost - 1] = '\0';
|
||||||
|
|
||||||
/* hack, but must be unique and no tty line */
|
/* hack, but must be unique and no tty line */
|
||||||
sprintf(line, "uucp%ld", (long)getpid());
|
sprintf(line, "uucp%ld", (long)getpid());
|
||||||
time(&cur_time);
|
time(&cur_time);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user