2013-09-26 17:14:40 +02:00

103 lines
2.9 KiB
Plaintext

$NetBSD: patch-ah,v 1.7 2008/05/09 18:43:07 agc Exp $
--- src/utmp.c.orig 2006-05-11 04:33:40.000000000 +0100
+++ src/utmp.c 2006-11-25 13:01:25.000000000 +0000
@@ -44,11 +44,20 @@
static int utmp_pos; /* BSD position of utmp-stamp */
# endif
+
# ifdef USE_SYSV_UTMP
# ifdef HAVE_UTMPX_H
+# include <utmp.h>
# undef WTMP_FILENAME
-# define WTMP_FILENAME WTMPX_FILE
+# ifndef _PATH_WTMPX
+# define _PATH_WTMPX "/var/log/wtmp"
+# endif
+# if defined(WTMPX_FILE)
+# define WTMP_FILENAME WTMPX_FILE
+# else
+# define WTMP_FILENAME _PATH_WTMPX
+# endif
# define update_wtmp updwtmpx
# else /* HAVE_UTMPX_H */
@@ -128,22 +137,26 @@
privileges(INVOKE);
# ifdef HAVE_UTMPX_H
getutmp(&utmp, &utmp2);
- getutid(&utmp2); /* position to entry in utmp file */
+ getutxid(&utmp); /* position to entry in utmp file */
# else
- getutid(&utmp); /* position to entry in utmp file */
+ getutxid(&utmp); /* position to entry in utmp file */
# endif
/* set up the new entry */
strncpy(utmp.ut_id, ut_id, sizeof(utmp.ut_id));
strncpy(utmp.ut_line, pty, sizeof(utmp.ut_line));
+# ifndef __APPLE__
strncpy(utmp.ut_name, pwent->pw_name, sizeof(utmp.ut_name));
+# endif
strncpy(utmp.ut_user, pwent->pw_name, sizeof(utmp.ut_user));
strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
utmp.ut_type = USER_PROCESS;
utmp.ut_pid = getpid();
# ifdef HAVE_UTMPX_H
+# ifndef __APPLE__
utmp.ut_session = getsid(0);
utmp.ut_xtime = time(NULL);
+# endif /* __APPLE__ */
utmp.ut_tv.tv_usec = 0;
# else
utmp.ut_time = time(NULL);
@@ -152,16 +165,15 @@
/*
* write a utmp entry to the utmp file
*/
- utmpname(UTMP_FILENAME);
+ utmpxname(UTMP_FILENAME);
# ifdef HAVE_UTMPX_H
getutmp(&utmp, &utmp2);
- pututline(&utmp2);
pututxline(&utmp);
# else
pututline(&utmp);
# endif
update_wtmp(WTMP_FILENAME, &utmp);
- endutent(); /* close the file */
+ endutxent(); /* close the file */
privileges(REVERT);
return;
fd = 0;
@@ -177,19 +189,19 @@
if (!ut_id[0])
return; /* entry not made */
- utmpname(UTMP_FILENAME);
- setutent();
- strncpy(utmp.ut_id, ut_id, sizeof(utmp.ut_id));
- utmp.ut_type = USER_PROCESS;
- if (getutid(&utmp) == NULL) {
+ utmpxname(UTMP_FILENAME);
+ setutxent();
+ strncpy(utmpx.ut_id, ut_id, sizeof(utmpx.ut_id));
+ utmpx.ut_type = USER_PROCESS;
+ if (getutxid(&utmp) == NULL) {
return;
}
- utmp.ut_type = DEAD_PROCESS;
+ utmpx.ut_type = DEAD_PROCESS;
utmp.ut_time = time(NULL);
- pututline(&utmp);
+ pututxline(&utmpx);
getutmpx(&utmp, &utmpx);
update_wtmp(WTMP_FILENAME, &utmpx);
- endutent();
+ endutxent();
# else /* HAVE_UTMPX_H */
struct utmp *putmp;