From 30c2d42ddea29be405d84c75d3583e56339be25b Mon Sep 17 00:00:00 2001 From: Mats Erik Andersson Date: Thu, 16 Sep 2010 01:00:35 +0200 Subject: [PATCH 3/3] libinetutils/cleansess,utmp_*: Adaptions for OpenBSD. --- ChangeLog | 14 ++++++++++++++ libinetutils/cleansess.c | 7 ++++++- libinetutils/utmp_init.c | 15 +++++++++++++-- libinetutils/utmp_logout.c | 11 ++++++++++- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c65cb9..df40c4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2010-09-16 Mats Erik Andersson + * libinetutils/cleansess.c: OpenBSD: include if HAVE_UTIL_H. + * libinetutils/utmp_init.c: Likewise. + * libinetutils/utmp_logout.c: Likewise. + * libinetutils/utmp_init.c (utmp_init): Conditional use of + "utx.ut_name" depends on HAVE_STRUCT_UTMPX?_UT_NAME. + * libinetutils/utmp_init.c (utmp_init): New conditional use of + "utx.ut_host" depends on HAVE_STRUCT_UTMPX?_UT_HOST. + * libinetutils/utmp_init.c (utmp_init): The case !HAVE_UTMPX_H is + split into HAVE_DECL_GETUTENT and a third case needed for OpenBSD. + * libinetutils/utmp_logout.c (utmp_logout): The case !HAVE_UTMPX_H + is split into HAVE_DECL_GETUTENT and a third case needed for OpenBSD. + +2010-09-16 Mats Erik Andersson + * src/rexec.c (do_rexec): Casts to "struct sockaddr". 2010-09-16 Mats Erik Andersson diff --git a/libinetutils/cleansess.c b/libinetutils/cleansess.c index 87d3de5..f16a646 100644 --- a/libinetutils/cleansess.c +++ b/libinetutils/cleansess.c @@ -25,9 +25,14 @@ #include #include #include + #ifdef HAVE_UTMP_H # include -#else +# if HAVE_UTIL_H +/* Needed in OpenBSD 4.6 for logout(3), logwtmp(3). */ +# include +# endif +#else /* !HAVE_UTMP_H */ # ifdef HAVE_UTMPX_H # include # define utmp utmpx /* make utmpx look more like utmp */ diff --git a/libinetutils/utmp_init.c b/libinetutils/utmp_init.c index 8e4fcfd..b04df5f 100644 --- a/libinetutils/utmp_init.c +++ b/libinetutils/utmp_init.c @@ -46,6 +46,7 @@ #include #include + #ifdef HAVE_UTMPX_H # ifndef __USE_GNU # define __USE_GNU @@ -53,7 +54,12 @@ # include #else # include +# if HAVE_UTIL_H +/* Needed in OpenBSD 4.6 for login(3). */ +# include +# endif #endif + #include #include @@ -77,9 +83,12 @@ utmp_init (char *line, char *user, char *id) #endif #if defined HAVE_STRUCT_UTMP_UT_USER || defined HAVE_STRUCT_UTMPX_UT_USER strncpy (utx.ut_user, user, sizeof (utx.ut_user)); -#else +#elif defined HAVE_STRUCT_UTMP_UT_NAME || defined HAVE_STRUCT_UTMPX_UT_NAME strncpy (utx.ut_name, user, sizeof (utx.ut_name)); #endif +#if defined HAVE_STRUCT_UTMP_UT_HOST + strncpy (utx.ut_host, user, sizeof (utx.ut_host)); +#endif strncpy (utx.ut_line, line, sizeof (utx.ut_line)); #if defined HAVE_STRUCT_UTMP_UT_PID utx.ut_pid = getpid (); @@ -100,7 +109,7 @@ utmp_init (char *line, char *user, char *id) updwtmpx (PATH_WTMPX, &utx); # endif endutxent (); -#else +#elif HAVE_DECL_GETUTENT /* !HAVE_UTMPX_H */ pututline (&utx); # ifdef HAVE_UPDWTMP updwtmp (PATH_WTMP, &utx); @@ -108,6 +117,8 @@ utmp_init (char *line, char *user, char *id) logwtmp (line, user, id); # endif endutent (); +#else /* !HAVE_UTMPX_H && !HAVE_DECL_GETUTENT */ + login (&utx); #endif } diff --git a/libinetutils/utmp_logout.c b/libinetutils/utmp_logout.c index 9774f3c..d174206 100644 --- a/libinetutils/utmp_logout.c +++ b/libinetutils/utmp_logout.c @@ -45,12 +45,18 @@ #include #include #include + #if defined UTMPX && defined HAVE_UTMPX_H # define __USE_GNU # include #else # include +# if HAVE_UTIL_H +/* Needed in OpenBSD 4.6 for logwtmp(3), logout(3). */ +# include +# endif #endif + #include /* utmp_logout - update utmp and wtmp after logout */ @@ -79,7 +85,7 @@ utmp_logout (char *line) updwtmpx (PATH_WTMPX, ut); } endutxent (); -#else +#elif HAVE_DECL_GETUTENT /* !UTMPX */ struct utmp utx; struct utmp *ut; @@ -116,5 +122,8 @@ utmp_logout (char *line) # endif } endutent (); +#else /* !UTMPX && !HAVE_DECL_GETUTENT */ + if (logout (line)) + logwtmp (line, "", ""); #endif } -- 1.6.3.3