Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Make getlastlogx have the pathname to the lastlogx database ...



details:   https://anonhg.NetBSD.org/src/rev/7b754b0e4617
branches:  trunk
changeset: 550963:7b754b0e4617
user:      wiz <wiz%NetBSD.org@localhost>
date:      Tue Aug 26 16:48:32 2003 +0000

description:
Make getlastlogx have the pathname to the lastlogx database as first
argument, to be consistent with updlastlogx.

Approved by christos, reviewed by kleink.

[The lastlogxname function should not be used any longer.]

diffstat:

 crypto/dist/ssh/sshlogin.c |   6 +++---
 include/utmpx.h            |   9 ++++++++-
 lib/libc/gen/utmpx.c       |  35 ++++++++++++++++++++++++-----------
 usr.bin/login/login.c      |   6 +++---
 4 files changed, 38 insertions(+), 18 deletions(-)

diffs (159 lines):

diff -r 4aa1aeb33784 -r 7b754b0e4617 crypto/dist/ssh/sshlogin.c
--- a/crypto/dist/ssh/sshlogin.c        Tue Aug 26 16:40:10 2003 +0000
+++ b/crypto/dist/ssh/sshlogin.c        Tue Aug 26 16:48:32 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sshlogin.c,v 1.11 2003/07/10 01:09:49 lukem Exp $      */
+/*     $NetBSD: sshlogin.c,v 1.12 2003/08/26 16:48:34 wiz Exp $        */
 /*
  * Author: Tatu Ylonen <ylo%cs.hut.fi@localhost>
  * Copyright (c) 1995 Tatu Ylonen <ylo%cs.hut.fi@localhost>, Espoo, Finland
@@ -41,7 +41,7 @@
 
 #include "includes.h"
 RCSID("$OpenBSD: sshlogin.c,v 1.5 2002/08/29 15:57:25 stevesk Exp $");
-__RCSID("$NetBSD: sshlogin.c,v 1.11 2003/07/10 01:09:49 lukem Exp $");
+__RCSID("$NetBSD: sshlogin.c,v 1.12 2003/08/26 16:48:34 wiz Exp $");
 
 #include <util.h>
 #ifdef SUPPORT_UTMP
@@ -72,7 +72,7 @@
 
        buf[0] = '\0';
 #ifdef SUPPORT_UTMPX
-       if ((llxp = getlastlogx(uid, &llx)) != NULL) {
+       if ((llxp = getlastlogx(_PATH_LASTLOGX, uid, &llx)) != NULL) {
                if (bufsize > sizeof(llxp->ll_host) + 1)
                        bufsize = sizeof(llxp->ll_host) + 1;
                strncpy(buf, llxp->ll_host, bufsize - 1);
diff -r 4aa1aeb33784 -r 7b754b0e4617 include/utmpx.h
--- a/include/utmpx.h   Tue Aug 26 16:40:10 2003 +0000
+++ b/include/utmpx.h   Tue Aug 26 16:48:32 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: utmpx.h,v 1.10 2003/04/28 23:16:15 bjh21 Exp $  */
+/*     $NetBSD: utmpx.h,v 1.11 2003/08/26 16:48:32 wiz Exp $    */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -38,6 +38,7 @@
 #ifndef        _UTMPX_H_
 #define        _UTMPX_H_
 
+#include <sys/cdefs.h>
 #include <sys/featuretest.h>
 #include <sys/socket.h>
 #include <sys/time.h>
@@ -122,7 +123,13 @@
 #if defined(_NETBSD_SOURCE)
 int updwtmpx __P((const char *, const struct utmpx *));
 int lastlogxname __P((const char *));
+#ifdef __LIBC12_SOURCE__
 struct lastlogx *getlastlogx __P((uid_t, struct lastlogx *));
+struct lastlogx *__getlastlogx13 __P((const char *, uid_t, struct lastlogx *));
+#else
+struct lastlogx *getlastlogx __P((const char *, uid_t, struct lastlogx *))
+       __RENAME(__getlastlogx13);
+#endif
 int updlastlogx __P((const char *, uid_t, struct lastlogx *));
 struct utmp;
 void getutmp __P((const struct utmpx *, struct utmp *));
diff -r 4aa1aeb33784 -r 7b754b0e4617 lib/libc/gen/utmpx.c
--- a/lib/libc/gen/utmpx.c      Tue Aug 26 16:40:10 2003 +0000
+++ b/lib/libc/gen/utmpx.c      Tue Aug 26 16:48:32 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: utmpx.c,v 1.19 2003/08/25 23:09:37 matt Exp $   */
+/*     $NetBSD: utmpx.c,v 1.20 2003/08/26 16:48:33 wiz Exp $    */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -38,28 +38,33 @@
 #include <sys/cdefs.h>
 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: utmpx.c,v 1.19 2003/08/25 23:09:37 matt Exp $");
+__RCSID("$NetBSD: utmpx.c,v 1.20 2003/08/26 16:48:33 wiz Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
 #include <sys/types.h>
 #include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
 #include <sys/wait.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/stat.h>
 
 #include <assert.h>
+#include <db.h>
+#include <errno.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <vis.h>
+#include <unistd.h>
 #include <utmp.h>
+/* don't define earlier, has side effects in fcntl.h */
+#define __LIBC12_SOURCE__
 #include <utmpx.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <db.h>
+#include <vis.h>
+
+__warn_references(getlastlogx,
+    "warning: reference to compatibility getlastlogx(); include <utmpx.h> for correct reference")
 
 static FILE *fp;
 static int readonly = 0;
@@ -416,12 +421,20 @@
 struct lastlogx *
 getlastlogx(uid_t uid, struct lastlogx *ll)
 {
+
+       return __getlastlogx13(_PATH_LASTLOGX, uid, ll);
+}
+
+struct lastlogx *
+__getlastlogx13(const char *fname, uid_t uid, struct lastlogx *ll)
+{
        DBT key, data;
        DB *db;
 
+       _DIAGASSERT(fname != NULL);
        _DIAGASSERT(ll != NULL);
 
-       db = dbopen(llfile, O_RDONLY|O_SHLOCK, 0, DB_HASH, NULL);
+       db = dbopen(fname, O_RDONLY|O_SHLOCK, 0, DB_HASH, NULL);
 
        if (db == NULL)
                return NULL;
diff -r 4aa1aeb33784 -r 7b754b0e4617 usr.bin/login/login.c
--- a/usr.bin/login/login.c     Tue Aug 26 16:40:10 2003 +0000
+++ b/usr.bin/login/login.c     Tue Aug 26 16:48:32 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: login.c,v 1.73 2003/08/07 11:14:25 agc Exp $       */
+/*     $NetBSD: login.c,v 1.74 2003/08/26 16:48:33 wiz Exp $       */
 
 /*-
  * Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)login.c    8.4 (Berkeley) 4/2/94";
 #endif
-__RCSID("$NetBSD: login.c,v 1.73 2003/08/07 11:14:25 agc Exp $");
+__RCSID("$NetBSD: login.c,v 1.74 2003/08/26 16:48:33 wiz Exp $");
 #endif /* not lint */
 
 /*
@@ -978,7 +978,7 @@
        int quiet;
 {
        struct lastlogx ll;
-       if (getlastlogx(pwd->pw_uid, &ll) != NULL) {
+       if (getlastlogx(_PATH_LASTLOGX, pwd->pw_uid, &ll) != NULL) {
                time_t t = (time_t)ll.ll_tv.tv_sec;
                (void)printf("Last login: %.24s ", ctime(&t));
                if (*ll.ll_host != '\0')



Home | Main Index | Thread Index | Old Index