diff options
| author | christos <christos@NetBSD.org> | 2004-11-11 01:14:10 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2004-11-11 01:14:10 +0000 |
| commit | 3b40bfaefe2be81e2af159144fb6ee094fe93804 (patch) | |
| tree | d86c3616ea34cfda0fd0220ca483426316dcf751 /libexec/ftpd | |
| parent | 4050e4b376af1cd8fb246be7bcb995494ce3f800 (diff) | |
Don't write trash in ut_ss; either initialize it to 0, or put in the proper
information.
Diffstat (limited to 'libexec/ftpd')
| -rw-r--r-- | libexec/ftpd/extern.h | 7 | ||||
| -rw-r--r-- | libexec/ftpd/ftpd.c | 18 | ||||
| -rw-r--r-- | libexec/ftpd/logwtmp.c | 11 |
3 files changed, 23 insertions, 13 deletions
diff --git a/libexec/ftpd/extern.h b/libexec/ftpd/extern.h index 8803c396776..53b349cd66c 100644 --- a/libexec/ftpd/extern.h +++ b/libexec/ftpd/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.50 2004/08/09 12:56:47 lukem Exp $ */ +/* $NetBSD: extern.h,v 1.51 2004/11/11 01:14:10 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -187,9 +187,10 @@ int ftpd_logout(const char *line); #ifdef SUPPORT_UTMPX struct utmpx; - +struct sockinet; void ftpd_loginx(const struct utmpx *); -void ftpd_logwtmpx(const char *, const char *, const char *, int, int); +void ftpd_logwtmpx(const char *, const char *, const char *, + struct sockinet *, int, int); #endif #include <netinet/in.h> diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 08a0f913d83..82a7d699ae0 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $NetBSD: ftpd.c,v 1.159 2004/11/05 21:45:36 dsl Exp $ */ +/* $NetBSD: ftpd.c,v 1.160 2004/11/11 01:14:10 christos Exp $ */ /* * Copyright (c) 1997-2004 The NetBSD Foundation, Inc. @@ -105,7 +105,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: ftpd.c,v 1.159 2004/11/05 21:45:36 dsl Exp $"); +__RCSID("$NetBSD: ftpd.c,v 1.160 2004/11/11 01:14:10 christos Exp $"); #endif #endif /* not lint */ @@ -236,7 +236,8 @@ static int checkpassword(const struct passwd *, const char *); static void end_login(void); static FILE *getdatasock(const char *); static char *gunique(const char *); -static void login_utmp(const char *, const char *, const char *); +static void login_utmp(const char *, const char *, const char *, + struct sockinet *); static void logremotehost(struct sockinet *); static void lostconn(int); static void toolong(int); @@ -1001,7 +1002,8 @@ checkaccess(const char *name) } static void -login_utmp(const char *line, const char *name, const char *host) +login_utmp(const char *line, const char *name, const char *host, + struct sockinet *haddr) { #if defined(SUPPORT_UTMPX) || defined(SUPPORT_UTMP) struct timeval tv; @@ -1020,10 +1022,11 @@ login_utmp(const char *line, const char *name, const char *host) (void)strncpy(utmpx.ut_name, name, sizeof(utmpx.ut_name)); (void)strncpy(utmpx.ut_line, line, sizeof(utmpx.ut_line)); (void)strncpy(utmpx.ut_host, host, sizeof(utmpx.ut_host)); + (void)memcpy(&utmpx.ut_ss, &haddr->si_su, haddr->su_len); ftpd_loginx(&utmpx); } if (dowtmp) - ftpd_logwtmpx(line, name, host, 0, USER_PROCESS); + ftpd_logwtmpx(line, name, host, haddr, 0, USER_PROCESS); #endif #ifdef SUPPORT_UTMP if (doutmp) { @@ -1054,7 +1057,8 @@ logout_utmp(void) } if (okwtmp) { #ifdef SUPPORT_UTMPX - ftpd_logwtmpx(ttyline, "", "", 0, DEAD_PROCESS); + ftpd_logwtmpx(ttyline, "", "", NULL, 0, + DEAD_PROCESS); #endif #ifdef SUPPORT_UTMP ftpd_logwtmp(ttyline, "", ""); @@ -1183,7 +1187,7 @@ pass(const char *passwd) gidcount = getgroups(gidcount, gidlist); /* open utmp/wtmp before chroot */ - login_utmp(ttyline, pw->pw_name, remotehost); + login_utmp(ttyline, pw->pw_name, remotehost, &his_addr); logged_in = 1; diff --git a/libexec/ftpd/logwtmp.c b/libexec/ftpd/logwtmp.c index 5b9818e4c3c..a20c42093b9 100644 --- a/libexec/ftpd/logwtmp.c +++ b/libexec/ftpd/logwtmp.c @@ -1,4 +1,4 @@ -/* $NetBSD: logwtmp.c,v 1.22 2004/08/09 12:56:48 lukem Exp $ */ +/* $NetBSD: logwtmp.c,v 1.23 2004/11/11 01:14:10 christos Exp $ */ /* * Copyright (c) 1988, 1993 @@ -36,7 +36,7 @@ #if 0 static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: logwtmp.c,v 1.22 2004/08/09 12:56:48 lukem Exp $"); +__RCSID("$NetBSD: logwtmp.c,v 1.23 2004/11/11 01:14:10 christos Exp $"); #endif #endif /* not lint */ @@ -95,7 +95,8 @@ ftpd_logwtmp(const char *line, const char *name, const char *host) #ifdef SUPPORT_UTMPX void -ftpd_logwtmpx(const char *line, const char *name, const char *host, int status, int utx_type) +ftpd_logwtmpx(const char *line, const char *name, const char *host, + struct sockinet *haddr, int status, int utx_type) { struct utmpx ut; struct stat buf; @@ -106,6 +107,10 @@ ftpd_logwtmpx(const char *line, const char *name, const char *host, int status, (void)strncpy(ut.ut_line, line, sizeof(ut.ut_line)); (void)strncpy(ut.ut_name, name, sizeof(ut.ut_name)); (void)strncpy(ut.ut_host, host, sizeof(ut.ut_host)); + if (haddr) + (void)memcpy(&ut.ut_ss, &haddr->si_su, haddr->su_len); + else + (void)memset(&ut.ut_ss, 0, sizeof(ut.ut_ss)); ut.ut_type = utx_type; if (WIFEXITED(status)) ut.ut_exit.e_exit = (uint16_t)WEXITSTATUS(status); |
