]> andersk Git - openssh.git/blobdiff - bsd-login.c
- NetBSD login.c compile fix from David Rankin
[openssh.git] / bsd-login.c
index 93f230266490f2496ca7b0417d79c60cf383b42e..eccb29ee4a860cd9067a93eb6db1966ece494277 100644 (file)
@@ -45,20 +45,44 @@ static char *rcsid = "$OpenBSD: login.c,v 1.5 1998/07/13 02:11:12 millert Exp $"
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
-#include <utmp.h>
+#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
+# include <utmpx.h>
+#endif
+#ifdef HAVE_UTMP_H
+# include <utmp.h>
+#endif
 #include <stdio.h>
+#include <string.h>
 
+#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
+void
+login(utp,utx)
+       struct utmp *utp;
+       struct utmpx *utx;
+#else /* defined(HAVE_UTMPX_H) && defined(USE_UTMPX) */
 void
 login(utp)
        struct utmp *utp;
+#endif /* defined(HAVE_UTMPX_H) && defined(USE_UTMPX) */
 {
+#if defined(HAVE_HOST_IN_UTMP)
        struct utmp old_ut;
+#endif
+#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
+       struct utmpx *old_utx;
+#endif /* defined(HAVE_UTMPX_H) && defined(USE_UTMPX) */
        register int fd;
        int tty;
 
        tty = ttyslot();
        if (tty > 0 && (fd = open(_PATH_UTMP, O_RDWR|O_CREAT, 0644)) >= 0) {
-#ifdef HAVE_HOST_IN_UTMP
+
+#if defined(HAVE_HOST_IN_UTMP)
+# ifndef UT_LINESIZE
+#  define UT_LINESIZE (sizeof(old_ut.ut_line))
+#  define UT_NAMESIZE (sizeof(old_ut.ut_name))
+#  define UT_HOSTSIZE (sizeof(old_ut.ut_host))
+# endif
                (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
                /*
                 * Prevent luser from zero'ing out ut_host.
@@ -71,7 +95,7 @@ login(utp)
                    strncmp(old_ut.ut_line, utp->ut_line, UT_LINESIZE) == 0 &&
                    strncmp(old_ut.ut_name, utp->ut_name, UT_NAMESIZE) == 0)
                        (void)memcpy(utp->ut_host, old_ut.ut_host, UT_HOSTSIZE);
-#endif /* HAVE_HOST_IN_UTMP */
+#endif /* defined(HAVE_HOST_IN_UTMP) */
                (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
                (void)write(fd, utp, sizeof(struct utmp));
                (void)close(fd);
@@ -80,6 +104,13 @@ login(utp)
                (void)write(fd, utp, sizeof(struct utmp));
                (void)close(fd);
        }
+#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
+       old_utx = pututxline(utx);
+# ifdef HAVE_UPDWTMPX
+       updwtmpx(_PATH_WTMPX, utx);
+# endif /* HAVE_UPDWTMPX */
+       endutxent();
+#endif /* defined(HAVE_UTMPX_H) && defined(USE_UTMPX) */
 }
 
 #endif /* HAVE_LOGIN */
This page took 0.488818 seconds and 4 git commands to generate.