Hello, more corrections and adaptions to OpenBSD. A set of three patches:
0001-ifconfig-... : Augmentation to formatted printing. 0002-src-rexec.c- ... : Missing casts to "struct sockaddr". 0003-libinetutils-cleansess-utmp_*.c : Necessary adaptions to get compilable code from the autodetected properties. This third patch also discloses a serious failure in the detection for GNU/Linux: #define HAVE_STRUCT_UTMP_UT_USER 1 #define HAVE_STRUCT_UTMPX_UT_USER 1 #define HAVE_STRUCT_UTMP_UT_NAME 1 #define HAVE_STRUCT_UTMPX_UT_NAME 1 All these are found in config.log, but the last two are false, as a look into utmp(5) reveals. This error made 0003-libinetutils-... keep its non-stringent conditionals. Could someone take a good look into the detection for GNU/Linux here? For OpenBSD the detection is correct! Best regards, Mats E A
From de9822e1de2e3f46cbd5e21811b08539f6d014f3 Mon Sep 17 00:00:00 2001 From: Mats Erik Andersson <g...@gisladisker.se> Date: Thu, 16 Sep 2010 00:56:03 +0200 Subject: [PATCH 1/3] ifconfig/flags,options,printif: Correct format strings for "unix". --- ChangeLog | 8 ++++++++ ifconfig/flags.c | 3 +++ ifconfig/options.c | 4 ++-- ifconfig/printif.c | 9 ++++++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5cb717b..6a35bfc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-09-16 Mats Erik Andersson <g...@gisladisker.se> + + * ifconfig/flags.c (flag_char_tab): Include IFF_SIMPLEX. + * ifconfig/printif.c (put_int): Correct the position of "#" modifier. + (put_int): Implement modifier "h" for short integers, etcetera. + (put_flags): Declare "unsigned short" to correctly interpret flags. + * ifconfig/options.c (formats/unix): Correct some format strings. + 2010-09-15 Mats Erik Andersson <g...@gisladisker.se> * ifconfig/if_nameindex.c: Protect using HAVE_STRUCT_IF_NAMEINDEX. diff --git a/ifconfig/flags.c b/ifconfig/flags.c index 29b9162..279b295 100644 --- a/ifconfig/flags.c +++ b/ifconfig/flags.c @@ -407,6 +407,9 @@ static struct if_flag_char flag_char_tab[] = { #ifdef IFF_MASTER { IFF_MASTER, 'm' }, #endif +#ifdef IFF_SIMPLEX + { IFF_SIMPLEX, 'S' }, +#endif { IFF_RUNNING, 'R' }, { IFF_UP, 'U' }, { 0 } diff --git a/ifconfig/options.c b/ifconfig/options.c index 7e1c309..dcd38d9 100644 --- a/ifconfig/options.c +++ b/ifconfig/options.c @@ -139,10 +139,10 @@ struct format formats[] = { "Traditional UNIX interface listing. Default for Solaris and HPUX.", "${format}{check-existence}" "${ifdisplay?}{" - "${name}: flags=${flags}{number}<${flags}{string}{,}>" + "${name}: flags=${flags}{number}{%hx}<${flags}{string}{,}>" "${mtu?}{ mtu ${mtu}}${\\n}" "${addr?}{${\\t}inet ${addr}" - " netmask ${netmask}{0}{%02x}${netmask}{1}{%02x}" + " netmask ${netmask}{0}{%#02x}${netmask}{1}{%02x}" "${netmask}{2}{%02x}${netmask}{3}{%02x}" "${brdaddr?}{ broadcast ${brdaddr}}${\\n}}" "${exists?}{hwtype?}{${hwtype?}{${\\t}${hwtype}" diff --git a/ifconfig/printif.c b/ifconfig/printif.c index 03cdf80..9e73a78 100644 --- a/ifconfig/printif.c +++ b/ifconfig/printif.c @@ -153,12 +153,15 @@ put_int (format_data_t form, int argc, char *argv[], int nr) { p++; - while (isdigit (*p)) + if (*p == '#') p++; - if (*p == '#') + while (isdigit (*p)) p++; + if ((*p == 'h' || *p == 'H') && p[1]) + ++p; /* Half length modifier, go to type specifier. */ + switch (*p) { default: @@ -294,7 +297,7 @@ void put_flags (format_data_t form, int argc, char *argv[], short flags) { /* XXX */ - short int f = 1; + unsigned short int f = 1; const char *name; int first = 1; -- 1.6.3.3
From 66c979b0e2ac5782417302cba400654c8319deba Mon Sep 17 00:00:00 2001 From: Mats Erik Andersson <g...@gisladisker.se> Date: Thu, 16 Sep 2010 00:58:43 +0200 Subject: [PATCH 2/3] src/rexec.c: Use casts to "struct sockaddr". --- ChangeLog | 4 ++++ src/rexec.c | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a35bfc..2c65cb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-09-16 Mats Erik Andersson <g...@gisladisker.se> + * src/rexec.c (do_rexec): Casts to "struct sockaddr". + +2010-09-16 Mats Erik Andersson <g...@gisladisker.se> + * ifconfig/flags.c (flag_char_tab): Include IFF_SIMPLEX. * ifconfig/printif.c (put_int): Correct the position of "#" modifier. (put_int): Implement modifier "h" for short integers, etcetera. diff --git a/src/rexec.c b/src/rexec.c index 37b6ef8..6fa098b 100644 --- a/src/rexec.c +++ b/src/rexec.c @@ -205,7 +205,7 @@ do_rexec (struct arguments *arguments) addr.sin_port = htons ((short)arguments->port); - if (connect (sock, &addr, sizeof (addr)) < 0) + if (connect (sock, (struct sockaddr *) &addr, sizeof (addr)) < 0) error (EXIT_FAILURE, errno, "cannot connect to the specified host"); if (!arguments->use_err) @@ -227,11 +227,11 @@ do_rexec (struct arguments *arguments) memset (&serv_addr, 0, sizeof (serv_addr)); serv_addr.sin_port = arguments->err_port; - if (bind (serv_sock, &serv_addr, sizeof (serv_addr)) < 0) + if (bind (serv_sock, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0) error (EXIT_FAILURE, errno, "cannot bind socket"); len = sizeof (serv_addr); - if (getsockname (serv_sock, &serv_addr, &len)) + if (getsockname (serv_sock, (struct sockaddr *) &serv_addr, &len)) error (EXIT_FAILURE, errno, "error reading socket port"); if (listen (serv_sock, 1)) @@ -241,7 +241,7 @@ do_rexec (struct arguments *arguments) sprintf (port_str, "%i", arguments->err_port); safe_write (sock, port_str, strlen (port_str) + 1); - err_sock = accept (serv_sock, &serv_addr, &len); + err_sock = accept (serv_sock, (struct sockaddr *) &serv_addr, &len); if (err_sock < 0) error (EXIT_FAILURE, errno, "error accepting connection"); -- 1.6.3.3
From 30c2d42ddea29be405d84c75d3583e56339be25b Mon Sep 17 00:00:00 2001 From: Mats Erik Andersson <g...@gisladisker.se> 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 <g...@gisladisker.se> + * libinetutils/cleansess.c: OpenBSD: include <util.h> 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 <g...@gisladisker.se> + * src/rexec.c (do_rexec): Casts to "struct sockaddr". 2010-09-16 Mats Erik Andersson <g...@gisladisker.se> 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 <sys/types.h> #include <sys/time.h> #include <time.h> + #ifdef HAVE_UTMP_H # include <utmp.h> -#else +# if HAVE_UTIL_H +/* Needed in OpenBSD 4.6 for logout(3), logwtmp(3). */ +# include <util.h> +# endif +#else /* !HAVE_UTMP_H */ # ifdef HAVE_UTMPX_H # include <utmpx.h> # 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 <sys/time.h> #include <time.h> + #ifdef HAVE_UTMPX_H # ifndef __USE_GNU # define __USE_GNU @@ -53,7 +54,12 @@ # include <utmpx.h> #else # include <utmp.h> +# if HAVE_UTIL_H +/* Needed in OpenBSD 4.6 for login(3). */ +# include <util.h> +# endif #endif + #include <string.h> #include <unistd.h> @@ -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 <sys/types.h> #include <sys/time.h> #include <time.h> + #if defined UTMPX && defined HAVE_UTMPX_H # define __USE_GNU # include <utmpx.h> #else # include <utmp.h> +# if HAVE_UTIL_H +/* Needed in OpenBSD 4.6 for logwtmp(3), logout(3). */ +# include <util.h> +# endif #endif + #include <string.h> /* 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
signature.asc
Description: Digital signature