head 1.4; access; symbols pkgsrc-2026Q1:1.4.0.106 pkgsrc-2026Q1-base:1.4 pkgsrc-2025Q4:1.4.0.104 pkgsrc-2025Q4-base:1.4 pkgsrc-2025Q3:1.4.0.102 pkgsrc-2025Q3-base:1.4 pkgsrc-2025Q2:1.4.0.100 pkgsrc-2025Q2-base:1.4 pkgsrc-2025Q1:1.4.0.98 pkgsrc-2025Q1-base:1.4 pkgsrc-2024Q4:1.4.0.96 pkgsrc-2024Q4-base:1.4 pkgsrc-2024Q3:1.4.0.94 pkgsrc-2024Q3-base:1.4 pkgsrc-2024Q2:1.4.0.92 pkgsrc-2024Q2-base:1.4 pkgsrc-2024Q1:1.4.0.90 pkgsrc-2024Q1-base:1.4 pkgsrc-2023Q4:1.4.0.88 pkgsrc-2023Q4-base:1.4 pkgsrc-2023Q3:1.4.0.86 pkgsrc-2023Q3-base:1.4 pkgsrc-2023Q2:1.4.0.84 pkgsrc-2023Q2-base:1.4 pkgsrc-2023Q1:1.4.0.82 pkgsrc-2023Q1-base:1.4 pkgsrc-2022Q4:1.4.0.80 pkgsrc-2022Q4-base:1.4 pkgsrc-2022Q3:1.4.0.78 pkgsrc-2022Q3-base:1.4 pkgsrc-2022Q2:1.4.0.76 pkgsrc-2022Q2-base:1.4 pkgsrc-2022Q1:1.4.0.74 pkgsrc-2022Q1-base:1.4 pkgsrc-2021Q4:1.4.0.72 pkgsrc-2021Q4-base:1.4 pkgsrc-2021Q3:1.4.0.70 pkgsrc-2021Q3-base:1.4 pkgsrc-2021Q2:1.4.0.68 pkgsrc-2021Q2-base:1.4 pkgsrc-2021Q1:1.4.0.66 pkgsrc-2021Q1-base:1.4 pkgsrc-2020Q4:1.4.0.64 pkgsrc-2020Q4-base:1.4 pkgsrc-2020Q3:1.4.0.62 pkgsrc-2020Q3-base:1.4 pkgsrc-2020Q2:1.4.0.58 pkgsrc-2020Q2-base:1.4 pkgsrc-2020Q1:1.4.0.38 pkgsrc-2020Q1-base:1.4 pkgsrc-2019Q4:1.4.0.60 pkgsrc-2019Q4-base:1.4 pkgsrc-2019Q3:1.4.0.56 pkgsrc-2019Q3-base:1.4 pkgsrc-2019Q2:1.4.0.54 pkgsrc-2019Q2-base:1.4 pkgsrc-2019Q1:1.4.0.52 pkgsrc-2019Q1-base:1.4 pkgsrc-2018Q4:1.4.0.50 pkgsrc-2018Q4-base:1.4 pkgsrc-2018Q3:1.4.0.48 pkgsrc-2018Q3-base:1.4 pkgsrc-2018Q2:1.4.0.46 pkgsrc-2018Q2-base:1.4 pkgsrc-2018Q1:1.4.0.44 pkgsrc-2018Q1-base:1.4 pkgsrc-2017Q4:1.4.0.42 pkgsrc-2017Q4-base:1.4 pkgsrc-2017Q3:1.4.0.40 pkgsrc-2017Q3-base:1.4 pkgsrc-2017Q2:1.4.0.36 pkgsrc-2017Q2-base:1.4 pkgsrc-2017Q1:1.4.0.34 pkgsrc-2017Q1-base:1.4 pkgsrc-2016Q4:1.4.0.32 pkgsrc-2016Q4-base:1.4 pkgsrc-2016Q3:1.4.0.30 pkgsrc-2016Q3-base:1.4 pkgsrc-2016Q2:1.4.0.28 pkgsrc-2016Q2-base:1.4 pkgsrc-2016Q1:1.4.0.26 pkgsrc-2016Q1-base:1.4 pkgsrc-2015Q4:1.4.0.24 pkgsrc-2015Q4-base:1.4 pkgsrc-2015Q3:1.4.0.22 pkgsrc-2015Q3-base:1.4 pkgsrc-2015Q2:1.4.0.20 pkgsrc-2015Q2-base:1.4 pkgsrc-2015Q1:1.4.0.18 pkgsrc-2015Q1-base:1.4 pkgsrc-2014Q4:1.4.0.16 pkgsrc-2014Q4-base:1.4 pkgsrc-2014Q3:1.4.0.14 pkgsrc-2014Q3-base:1.4 pkgsrc-2014Q2:1.4.0.12 pkgsrc-2014Q2-base:1.4 pkgsrc-2014Q1:1.4.0.10 pkgsrc-2014Q1-base:1.4 pkgsrc-2013Q4:1.4.0.8 pkgsrc-2013Q4-base:1.4 pkgsrc-2013Q3:1.4.0.6 pkgsrc-2013Q3-base:1.4 pkgsrc-2013Q2:1.4.0.4 pkgsrc-2013Q2-base:1.4 pkgsrc-2013Q1:1.4.0.2 pkgsrc-2013Q1-base:1.4 pkgsrc-2012Q4:1.3.0.78 pkgsrc-2012Q4-base:1.3 pkgsrc-2012Q3:1.3.0.76 pkgsrc-2012Q3-base:1.3 pkgsrc-2012Q2:1.3.0.74 pkgsrc-2012Q2-base:1.3 pkgsrc-2012Q1:1.3.0.72 pkgsrc-2012Q1-base:1.3 pkgsrc-2011Q4:1.3.0.70 pkgsrc-2011Q4-base:1.3 pkgsrc-2011Q3:1.3.0.68 pkgsrc-2011Q3-base:1.3 pkgsrc-2011Q2:1.3.0.66 pkgsrc-2011Q2-base:1.3 pkgsrc-2011Q1:1.3.0.64 pkgsrc-2011Q1-base:1.3 pkgsrc-2010Q4:1.3.0.62 pkgsrc-2010Q4-base:1.3 pkgsrc-2010Q3:1.3.0.60 pkgsrc-2010Q3-base:1.3 pkgsrc-2010Q2:1.3.0.58 pkgsrc-2010Q2-base:1.3 pkgsrc-2010Q1:1.3.0.56 pkgsrc-2010Q1-base:1.3 pkgsrc-2009Q4:1.3.0.54 pkgsrc-2009Q4-base:1.3 pkgsrc-2009Q3:1.3.0.52 pkgsrc-2009Q3-base:1.3 pkgsrc-2009Q2:1.3.0.50 pkgsrc-2009Q2-base:1.3 pkgsrc-2009Q1:1.3.0.48 pkgsrc-2009Q1-base:1.3 pkgsrc-2008Q4:1.3.0.46 pkgsrc-2008Q4-base:1.3 pkgsrc-2008Q3:1.3.0.44 pkgsrc-2008Q3-base:1.3 cube-native-xorg:1.3.0.42 cube-native-xorg-base:1.3 pkgsrc-2008Q2:1.3.0.40 pkgsrc-2008Q2-base:1.3 cwrapper:1.3.0.38 pkgsrc-2008Q1:1.3.0.36 pkgsrc-2008Q1-base:1.3 pkgsrc-2007Q4:1.3.0.34 pkgsrc-2007Q4-base:1.3 pkgsrc-2007Q3:1.3.0.32 pkgsrc-2007Q3-base:1.3 pkgsrc-2007Q2:1.3.0.30 pkgsrc-2007Q2-base:1.3 pkgsrc-2007Q1:1.3.0.28 pkgsrc-2007Q1-base:1.3 pkgsrc-2006Q4:1.3.0.26 pkgsrc-2006Q4-base:1.3 pkgsrc-2006Q3:1.3.0.24 pkgsrc-2006Q3-base:1.3 pkgsrc-2006Q2:1.3.0.22 pkgsrc-2006Q2-base:1.3 pkgsrc-2006Q1:1.3.0.20 pkgsrc-2006Q1-base:1.3 pkgsrc-2005Q4:1.3.0.18 pkgsrc-2005Q4-base:1.3 pkgsrc-2005Q3:1.3.0.16 pkgsrc-2005Q3-base:1.3 pkgsrc-2005Q2:1.3.0.14 pkgsrc-2005Q2-base:1.3 pkgsrc-2005Q1:1.3.0.12 pkgsrc-2005Q1-base:1.3 pkgsrc-2004Q4:1.3.0.10 pkgsrc-2004Q4-base:1.3 pkgsrc-2004Q3:1.3.0.8 pkgsrc-2004Q3-base:1.3 pkgsrc-2004Q2:1.3.0.6 pkgsrc-2004Q2-base:1.3 pkgsrc-2004Q1:1.3.0.4 pkgsrc-2004Q1-base:1.3 pkgsrc-2003Q4:1.3.0.2 pkgsrc-2003Q4-base:1.3; locks; strict; comment @# @; 1.4 date 2013.03.28.21.17.57; author joerg; state Exp; branches; next 1.3; 1.3 date 2003.02.27.21.43.36; author fredb; state Exp; branches; next 1.2; 1.2 date 2003.02.27.14.42.55; author fredb; state Exp; branches; next 1.1; 1.1 date 2003.02.26.21.45.45; author fredb; state Exp; branches; next ; desc @@ 1.4 log @utmpx.h is no longer included by util.h, adjust. Fix inline use. @ text @$NetBSD: patch-al,v 1.3 2003/02/27 21:43:36 fredb Exp $ --- utmp.c.orig 2001-12-17 22:43:25.000000000 +0000 +++ utmp.c @@@@ -7,7 +7,11 @@@@ #include "mgetty.h" -#if defined(sunos4) || defined(BSD) +#ifdef __NetBSD__ +#include +#endif + +#if defined(sunos4) || ( defined(BSD) && !defined(NETBSD_UTMPX) ) #include #include @@@@ -20,10 +24,11 @@@@ #include #include #include -#include - -#ifndef ENOENT -#include +#if !defined(SVR4) && !defined(NETBSD_UTMPX) && !defined(__GLIBC__) || __GLIBC__ < 2 +# include +# ifndef ENOENT +# include +# endif #endif #if defined(_3B1_) || defined(MEIBE) || defined(ISC) @@@@ -42,8 +47,14 @@@@ typedef short pid_t; # endif #endif +#ifndef WTMPX_FILE +# ifdef _PATH_WTMPX +# define WTMPX_FILE _PATH_WTMPX /* NetBSD */ +# endif +#endif + -#if defined(sunos4) || defined(BSD) || defined(ultrix) +#if ( defined(sunos4) || defined(BSD) || defined(ultrix) ) && !defined(NETBSD_UTMPX) /* on SunOS (and other BSD-derived systems), the getty process does * * not have to care for the utmp entries, login and init do all the work * Anyway, we have to _read_ it to get the number of users logged in. @@@@ -109,26 +120,74 @@@@ void make_utmp_wtmp _P4( (line, ut_type, { struct utmp *utmp; pid_t pid; +#ifdef NETBSD_UTMPX +struct utmpx ut; +char *id; +#else +# if !defined(SVR4) && !defined(__GLIBC__) || __GLIBC__ < 2 struct stat st; +# endif +#endif FILE * fp; +#ifdef NETBSD_UTMPX + id = line; + if ( strlen( line ) > sizeof( ut.ut_id ) ) + id += strlen( line ) - sizeof( ut.ut_id ); + + if ( ut_type == UT_INIT ) { + lprintf(L_JUNK, + "creating initial utmp entry... (ID: %s)", + id); + + memset( &ut, 0, sizeof( ut ) ); + strncpy( ut.ut_id, id, sizeof( ut.ut_id ) ); + strncpy( ut.ut_line, line, sizeof( ut.ut_line ) ); + gettimeofday( &ut.ut_tv, NULL ); + ut.ut_type = INIT_PROCESS; + login( &ut ); + + lprintf(L_NOISE, "initial utmp + wtmp entry made"); + return; + } + + if ((pid = checklock( line )) == NO_LOCK) { + pid = getpid(); + } + + lprintf(L_JUNK, + "looking for utmp entry... (ID: %s)", id); +#else pid = getpid(); + lprintf(L_JUNK, "looking for utmp entry... (my PID: %d)", pid); +#endif + setutent(); while ((utmp = getutent()) != (struct utmp *) NULL) { - if (utmp->ut_pid == pid && - (utmp->ut_type == INIT_PROCESS || utmp->ut_type == LOGIN_PROCESS)) +#ifdef NETBSD_UTMPX + if ( strncmp( utmp->ut_id, id, sizeof( utmp->ut_id ) ) == 0 && +#else + if ( utmp->ut_pid == pid && +#endif + (utmp->ut_type == INIT_PROCESS || utmp->ut_type == LOGIN_PROCESS) ) { - strcpy(utmp->ut_line, line ); + strncpy(utmp->ut_line, line, sizeof( utmp->ut_line) ); +#ifdef NETBSD_UTMPX + utmp->ut_pid = pid; + gettimeofday( &utmp->ut_tv, NULL ); +#else utmp->ut_time = time( NULL ); +#endif utmp->ut_type = ut_type; /* {INIT,LOGIN,USER}_PROCESS */ - /* "LOGIN", "uugetty", "dialout" */ + strncpy( utmp->ut_user, ut_user, sizeof( utmp->ut_user ) ); + /* "LOGIN", "uugetty", "dialout" */ -#if defined(SVR4) || defined(linux) +#if defined(SVR4) || defined(linux) || defined(NETBSD_UTMPX) if (ut_host != NULL) { strncpy( utmp->ut_host, ut_host, sizeof( utmp->ut_host ) - 1); @@@@ -138,7 +197,7 @@@@ FILE * fp; } #endif /* SVR4 */ -#if defined(M_UNIX) || defined(__GLIBC__) +#if defined(M_UNIX) || defined(__GLIBC__) || defined(NETBSD_UTMPX) if ( pututline(utmp) == NULL ) { lprintf( L_ERROR, "cannot create utmp entry" ); @@@@ -151,7 +210,7 @@@@ FILE * fp; /* write same record to end of wtmp * if wtmp file exists */ -#ifdef SVR4 +#if defined(SVR4) || defined(NETBSD_UTMPX) updwtmpx(WTMPX_FILE, utmp); #else # if defined(__GLIBC__) && __GLIBC__ >= 2 @ 1.3 log @Use the same ut_id as "login" does, so we can properly close out the wtmpx entry that "login" creates. @ text @d1 1 a1 1 $NetBSD: patch-al,v 1.2 2003/02/27 14:42:55 fredb Exp $ d3 1 a3 1 --- utmp.c.orig 2001-12-17 16:43:25.000000000 -0600 d5 1 a5 1 @@@@ -7,7 +7,7 @@@@ d10 4 d18 1 a18 1 @@@@ -20,10 +20,11 @@@@ d34 1 a34 1 @@@@ -42,8 +43,14 @@@@ d50 1 a50 1 @@@@ -109,26 +116,74 @@@@ d130 1 a130 1 @@@@ -138,7 +193,7 @@@@ d139 1 a139 1 @@@@ -151,7 +206,7 @@@@ @ 1.2 log @Be consistent about testing for __GLIBC__. @ text @d1 1 a1 1 $NetBSD: patch-al,v 1.1 2003/02/26 21:45:45 fredb Exp $ d46 1 a46 1 @@@@ -109,26 +116,68 @@@@ a50 1 +char id[4]; d52 1 d61 4 a64 4 + id[0] = line[0]; + id[1] = line[strlen(line) - 2]; + id[2] = line[strlen(line) - 1]; + id[3] = '\0'; d66 3 a68 1 + lprintf(L_JUNK, "creating initial utmp entry... (id: %s)", id); d70 4 a73 4 + memset(&ut, 0, sizeof( ut )); + memcpy(ut.ut_id, id, 4); + strncpy(ut.ut_line, line, sizeof( ut.ut_line )); + gettimeofday(&ut.ut_tv, NULL ); d80 1 d84 3 a86 1 + lprintf(L_JUNK, "looking for utmp entry... (my ID: %s)", id); d89 1 d96 2 d99 1 a99 1 + if (memcmp(utmp->ut_id, id, 4) == 0 && d101 1 a101 1 if (utmp->ut_pid == pid && d103 1 a103 1 (utmp->ut_type == INIT_PROCESS || utmp->ut_type == LOGIN_PROCESS)) d126 1 a126 1 @@@@ -138,7 +187,7 @@@@ d135 1 a135 1 @@@@ -151,7 +200,7 @@@@ @ 1.1 log @Add support for /var/run/utmpx on NetBSD 1.6B or newer, including building on a suggestion by Gert Doering, filling ut_pid with the pid of the uucp-style lock holder. This should fix PR pkg/12261, although you will need today's "w" to see any results. Bump PKGREVSION. @ text @d1 1 a1 1 $NetBSD$ d22 1 a22 1 +#if !defined(SVR4) && !defined(NETBSD_UTMPX) && __GLIBC__ < 2 d54 1 a54 1 +# if !(defined(SVR4) || (defined(__GLIBC__) && __GLIBC__ >= 2) @