Skip to contentSkip to conversation

Rebase, resend.

PATCH In review Bernhard Reutner-Fischer 3 participants 10 messages Apr 24, 2015 – Jun 2, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Rebase, resend.

Seems i forgot the config.h stuff last time, sorry for that..

Bernhard Reutner-Fischer (7):
delete src/config.h
getrpcent: Fix compilation on glibc
Make sure to include config.h
configure.ac: Allow for disabling NIS
configure.ac: Allow for disabling auth DES
getrpcport: rephrase host lookup
headers: if 0 out some unbuilt functions

 Makefile.am          |  12 ++++--
 configure.ac         |  24 ++++++++++-
 libtirpc.pc.in       |   2 +-
 src/Makefile.am      |  10 +++--
 src/auth_des.c       |  15 +++++++
 src/auth_time.c      |   6 ++-
 src/config.h         | 110 ---------------------------------------------------
 src/getrpcent.c      |  16 ++++----
 src/getrpcport.c     |  37 +++++++++++------
 src/rpc_soc.c        |   2 +-
 tirpc/rpc/auth.h     |  18 ++++++++-
 tirpc/rpc/auth_des.h |   2 +
 tirpc/rpc/rpc.h      |   2 +
 13 files changed, 113 insertions(+), 143 deletions(-)
 delete mode 100644 src/config.h
Signature · 1 line
2.1.4
#1 lore raw

PATCH v2 1/7 delete src/config.h

---
 src/config.h | 110 -----------------------------------------------------------
 1 file changed, 110 deletions(-)
 delete mode 100644 src/config.h
src/config.h deleted +0 -110
deleted file mode 100644
index e42e1f5..0000000
@@ -1,110 +0,0 @@
-/* config.h.  Generated by configure.  */
-/* config.h.in.  Generated from configure.in by autoheader.  */
-
-/* Define to 1 if you have the <arpa/inet.h> header file. */
-#define HAVE_ARPA_INET_H 1
-
-/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
-   */
-#define HAVE_DIRENT_H 1
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the <libintl.h> header file. */
-#define HAVE_LIBINTL_H 1
-
-/* Define to 1 if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define to 1 if you have the <locale.h> header file. */
-#define HAVE_LOCALE_H 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
-/* #undef HAVE_NDIR_H */
-
-/* Define to 1 if you have the <netdb.h> header file. */
-#define HAVE_NETDB_H 1
-
-/* Define to 1 if you have the <netinet/in.h> header file. */
-#define HAVE_NETINET_IN_H 1
-
-/* Define to 1 if you have the <stddef.h> header file. */
-#define HAVE_STDDEF_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the <syslog.h> header file. */
-#define HAVE_SYSLOG_H 1
-
-/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
-   */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define to 1 if you have the <sys/ioctl.h> header file. */
-#define HAVE_SYS_IOCTL_H 1
-
-/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
-   */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define to 1 if you have the <sys/param.h> header file. */
-#define HAVE_SYS_PARAM_H 1
-
-/* Define to 1 if you have the <sys/socket.h> header file. */
-#define HAVE_SYS_SOCKET_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Name of package */
-#define PACKAGE "libtirpc"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT ""
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME ""
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING ""
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION ""
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "0.1.1"
Signature · 1 line
2.1.4
#2 lore raw

PATCH v2 2/7 getrpcent: Fix compilation on glibc

In reply to Bernhard Reutner-Fischer

implicit declaration of function '_yp_check' [-Wimplicit-function-declaration]

---
 src/getrpcent.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
src/getrpcent.c +4 -4
index 6da006a..fbb2da4 100644
@@ -108,7 +108,7 @@ getrpcbynumber(number)
 	if (d == 0)
 		return (0);
 #ifdef	YP
-        if (!__yp_nomap && _yp_check(&d->domain)) {
+        if (!__yp_nomap && __yp_check(&d->domain)) {
                 sprintf(adrstr, "%d", number);
                 reason = yp_match(d->domain, "rpc.bynumber", adrstr, strlen(adrstr),
                                   &d->current, &d->currentlen);
@@ -175,7 +175,7 @@ setrpcent(f)
 	if (d == 0)
 		return;
 #ifdef	YP
-        if (!__yp_nomap && _yp_check(NULL)) {
+        if (!__yp_nomap && __yp_check(NULL)) {
                 if (d->current)
                         free(d->current);
                 d->current = NULL;
@@ -199,7 +199,7 @@ endrpcent()
 	if (d == 0)
 		return;
 #ifdef	YP
-        if (!__yp_nomap && _yp_check(NULL)) {
+        if (!__yp_nomap && __yp_check(NULL)) {
         	if (d->current && !d->stayopen)
                         free(d->current);
                 d->current = NULL;
@@ -228,7 +228,7 @@ getrpcent()
 	if (d == 0)
 		return(NULL);
 #ifdef	YP
-        if (!__yp_nomap && _yp_check(&d->domain)) {
+        if (!__yp_nomap && __yp_check(&d->domain)) {
                 if (d->current == NULL && d->currentlen == 0) {
                         reason = yp_first(d->domain, "rpc.bynumber",
                                           &d->current, &d->currentlen,
Signature · 1 line
2.1.4
#3 lore raw

PATCH v2 3/7 Make sure to include config.h

In reply to Bernhard Reutner-Fischer

I really think the -DINET6 is wrong.

---
 src/Makefile.am | 4 ++--
 src/auth_time.c | 3 +++
 src/getrpcent.c | 8 ++++----
 3 files changed, 9 insertions(+), 6 deletions(-)
src/Makefile.am +2 -2
index 26ccbdf..38d0c3d 100644
@@ -7,8 +7,8 @@
 
 noinst_HEADERS = rpc_com.h debug.h
 
-AM_CPPFLAGS = -I$(top_srcdir)/tirpc -DPORTMAP -DINET6 \
-		-D_GNU_SOURCE -Wall -pipe  
+AM_CPPFLAGS = -I$(top_srcdir)/tirpc -include config.h -DPORTMAP -DINET6 \
+		-D_GNU_SOURCE -Wall -pipe
 
 lib_LTLIBRARIES = libtirpc.la
 
src/auth_time.c +3 -0
index 13717ff..10e58eb 100644
@@ -25,6 +25,9 @@
  *	needed to deal with TCP connections.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #include <stdio.h>
 #include <syslog.h>
 #include <string.h>
src/getrpcent.c +4 -4
index fbb2da4..c374673 100644
@@ -30,6 +30,10 @@
  * Copyright (c) 1984 by Sun Microsystems, Inc.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <sys/types.h>
 
 #include <netinet/in.h>
@@ -50,10 +54,6 @@
 #include <libc_private.h>
 #endif
 
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
 /*
  * Internet version.
  */
Signature · 1 line
2.1.4
#4 lore raw

PATCH v2 4/7 configure.ac: Allow for disabling NIS

In reply to Bernhard Reutner-Fischer

Yellow Pages might not be available, provide a config knob to disable it.

---
 configure.ac    | 17 +++++++++++++++++
 src/Makefile.am |  5 ++++-
 src/auth_des.c  | 15 +++++++++++++++
 src/auth_time.c |  3 ++-
 4 files changed, 38 insertions(+), 2 deletions(-)
configure.ac +17 -0
index 80dec85..3ebde36 100644
@@ -39,6 +39,23 @@ AC_CHECK_LIB([pthread], [pthread_create])
 AC_CHECK_LIB([nsl], [yp_get_default_domain])
 AC_CHECK_FUNCS([getrpcbyname getrpcbynumber])
 
+AC_ARG_ENABLE([nis],
+	[AC_HELP_STRING([--disable-nis],
+		[Disable Yellow Pages (NIS) support @<:@default=no@:>@])],
+	[],[enable_nis=yes])
+if test "x$enable_nis" != xno; then
+	AC_CHECK_HEADERS([rpcsvc/nis.h])
+	if test "x$ac_cv_header_rpcsvc_nis_h" != xyes; then
+		AC_WARN([NIS enabled but no rpcsvc/nis.h header found])
+		AC_WARN([Turning off NIS / YP support])
+		enable_nis="no"
+	fi
+fi
+if test "x$enable_nis" != xno; then
+	AC_DEFINE([YP], [1], [Define to 1 if NIS is available])
+fi
+AM_CONDITIONAL([YP], [test "x$enable_nis" != xno])
+
 AC_CONFIG_FILES([Makefile src/Makefile man/Makefile doc/Makefile])
 AC_OUTPUT(libtirpc.pc)
 
src/Makefile.am +4 -1
index 38d0c3d..2ba4444 100644
@@ -52,7 +52,7 @@ libtirpc_la_SOURCES = auth_none.c auth_unix.c authunix_prot.c bindresvport.c cln
         rpc_callmsg.c rpc_generic.c rpc_soc.c rpcb_clnt.c rpcb_prot.c \
         rpcb_st_xdr.c svc.c svc_auth.c svc_dg.c svc_auth_unix.c svc_auth_none.c \
         svc_generic.c svc_raw.c svc_run.c svc_simple.c svc_vc.c getpeereid.c \
-        auth_time.c debug.c
+        debug.c
 
 ## XDR
 libtirpc_la_SOURCES += xdr.c xdr_rec.c xdr_array.c xdr_float.c xdr_mem.c xdr_reference.c xdr_stdio.c
@@ -70,6 +70,9 @@ if AUTHDES
     libtirpc_la_CFLAGS += -DHAVE_AUTHDES
 endif
 
+if YP
+    libtirpc_la_SOURCES += auth_time.c
+endif
 
 ## libtirpc_a_SOURCES += key_call.c key_prot_xdr.c getpublickey.c
 ## libtirpc_a_SOURCES += netname.c netnamer.c rpcdname.c \
src/auth_des.c +15 -0
index f8749b0..f971481 100644
@@ -47,7 +47,9 @@
 #include <rpc/xdr.h>
 #include <sys/socket.h>
 #undef NIS
+#ifdef HAVE_RPCSVC_NIS_H
 #include <rpcsvc/nis.h>
+#endif
 
 #if defined(LIBC_SCCS) && !defined(lint)
 #endif
@@ -66,8 +68,13 @@ extern bool_t xdr_authdes_cred( XDR *, struct authdes_cred *);
 extern bool_t xdr_authdes_verf( XDR *, struct authdes_verf *);
 extern int key_encryptsession_pk( char *, netobj *, des_block *);
 
+#ifdef YP
 extern bool_t __rpc_get_time_offset(struct timeval *, nis_server *, char *,
 	char **, char **);
+#else
+# define __rpc_get_time_offset(__a,__b,__c,__d, __e) (1) /* always valid */
+# define nis_server char
+#endif
 
 /* 
  * DES authenticator operations vector
@@ -101,7 +108,9 @@ struct ad_private {
 	u_char ad_pkey[1024];		/* Server's actual public key */
 	char *ad_netid;			/* Timehost netid */
 	char *ad_uaddr;			/* Timehost uaddr */
+#ifdef YP
 	nis_server *ad_nis_srvr;	/* NIS+ server struct */
+#endif
 };
 
 AUTH *authdes_pk_seccreate(const char *, netobj *, u_int, const char *,
@@ -169,7 +178,9 @@ authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window,
 	ad->ad_timehost = NULL;
 	ad->ad_netid = NULL;
 	ad->ad_uaddr = NULL;
+#ifdef YP
 	ad->ad_nis_srvr = NULL;
+#endif
 	ad->ad_timediff.tv_sec = 0;
 	ad->ad_timediff.tv_usec = 0;
 	memcpy(ad->ad_pkey, pkey->n_bytes, pkey->n_len);
@@ -192,9 +203,11 @@ authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window,
 		}
 		memcpy(ad->ad_timehost, timehost, strlen(timehost) + 1);
 		ad->ad_dosync = TRUE;
+#ifdef YP
 	} else if (srvr != NULL) {
 		ad->ad_nis_srvr = srvr;	/* transient */
 		ad->ad_dosync = TRUE;
+#endif
 	} else {
 		ad->ad_dosync = FALSE;
 	}
@@ -222,7 +235,9 @@ authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window,
 	if (!authdes_refresh(auth, NULL)) {
 		goto failed;
 	}
+#ifdef YP
 	ad->ad_nis_srvr = NULL; /* not needed any longer */
+#endif
 	auth_get(auth);		/* Reference for caller */
 	return (auth);
 
src/auth_time.c +2 -1
index 10e58eb..e47ece8 100644
@@ -45,8 +45,9 @@
 //#include <clnt_soc.h>
 #include <sys/select.h>
 #undef NIS
+#ifdef HAVE_RPCSVC_NIS_H
 #include <rpcsvc/nis.h>
-
+#endif
 
 #ifdef TESTING
 #define	msg(x)	printf("ERROR: %s\n", x)
Signature · 1 line
2.1.4
#5 lore raw

Re: [Libtirpc-devel] [PATCH v2 4/7] configure.ac: Allow for disabling NIS

Hi Bernhard-

I'm a little uncomfortable with this. We've tried removing AUTH_DES support before, for similar reasons, and with not much success.

Review comments below:

Quoted 4 lines · Bernhard Reutner-Fischer

Yellow Pages might not be available, provide a config knob to disable it.

The patch description is inadequate: can you provide the details of what "Yellow Pages might not be available" means? What is your build environment and which C library, for example? Or is this a concern about what features may be available on the target install system?

Can you say anything about other solutions you may have tried?

Are there any significant portability consequences for RPC applications when "YP is disabled" ? What happens to AUTH_DES support, for example? Are there ramifications for other, more commonly used, parts of the TI-RPC API?

Quoted 23 lines

---

configure.ac    | 17 +++++++++++++++++
src/Makefile.am |  5 ++++-
src/auth_des.c  | 15 +++++++++++++++
src/auth_time.c |  3 ++-
4 files changed, 38 insertions(+), 2 deletions(-)
configure.ac +7 -0
index 80dec85..3ebde36 100644
@@ -39,6 +39,23 @@ AC_CHECK_LIB([pthread], [pthread_create])
 AC_CHECK_LIB([nsl], [yp_get_default_domain])
 AC_CHECK_FUNCS([getrpcbyname getrpcbynumber])
 
+AC_ARG_ENABLE([nis],
+	[AC_HELP_STRING([--disable-nis],
+		[Disable Yellow Pages (NIS) support @<:@default=no@:>@])],
+	[],[enable_nis=yes])
+if test "x$enable_nis" != xno; then
+	AC_CHECK_HEADERS([rpcsvc/nis.h])
+	if test "x$ac_cv_header_rpcsvc_nis_h" != xyes; then

configure.ac AC_CHECK_LIB([pthread], [pthread_create]) · line 58

Quoted 10 lines
configure.ac +10 -0
+		AC_WARN([NIS enabled but no rpcsvc/nis.h header found])
+		AC_WARN([Turning off NIS / YP support])
+		enable_nis="no"
+	fi
+fi
+if test "x$enable_nis" != xno; then
+	AC_DEFINE([YP], [1], [Define to 1 if NIS is available])
+fi
+AM_CONDITIONAL([YP], [test "x$enable_nis" != xno])
+

Why is a configure command line option needed? Why isn't the AC_CHECK_HEADERS macro sufficient by itself?

Should libtirpc rather provide rpcsvc/nis.h and friends?

Quoted 41 lines
configure.ac +0 -0
 AC_CONFIG_FILES([Makefile src/Makefile man/Makefile doc/Makefile])
 AC_OUTPUT(libtirpc.pc)
 
src/Makefile.am +1 -1
index 38d0c3d..2ba4444 100644
@@ -52,7 +52,7 @@ libtirpc_la_SOURCES = auth_none.c auth_unix.c authunix_prot.c bindresvport.c cln
        rpc_callmsg.c rpc_generic.c rpc_soc.c rpcb_clnt.c rpcb_prot.c \
        rpcb_st_xdr.c svc.c svc_auth.c svc_dg.c svc_auth_unix.c svc_auth_none.c \
        svc_generic.c svc_raw.c svc_run.c svc_simple.c svc_vc.c getpeereid.c \
-        auth_time.c debug.c
+        debug.c
 
 ## XDR

libtirpc_la_SOURCES += xdr.c xdr_rec.c xdr_array.c xdr_float.c xdr_mem.c xdr_reference.c xdr_stdio.c

src/Makefile.am +0 -0
@@ -70,6 +70,9 @@ if AUTHDES
    libtirpc_la_CFLAGS += -DHAVE_AUTHDES

endif

src/Makefile.am +3 -0
+if YP
+    libtirpc_la_SOURCES += auth_time.c
+endif

## libtirpc_a_SOURCES += key_call.c key_prot_xdr.c getpublickey.c ## libtirpc_a_SOURCES += netname.c netnamer.c rpcdname.c \

src/auth_des.c +2 -0
index f8749b0..f971481 100644
@@ -47,7 +47,9 @@
 #include <rpc/xdr.h>
 #include <sys/socket.h>
 #undef NIS
+#ifdef HAVE_RPCSVC_NIS_H
 #include <rpcsvc/nis.h>
+#endif
 
 #if defined(LIBC_SCCS) && !defined(lint)
 #endif

src/auth_des.c extern bool_t xdr_authdes_cred( XDR *, struct authdes_cred *); · line 71

Quoted 4 lines
src/auth_des.c +1 -0
@@ -66,8 +68,13 @@ extern bool_t xdr_authdes_cred( XDR *, struct authdes_cred *);
 extern bool_t xdr_authdes_verf( XDR *, struct authdes_verf *);
 extern int key_encryptsession_pk( char *, netobj *, des_block *);
 
+#ifdef YP

Shouldn't you use YP only in Makefiles and HAVE_RPCSVC_NIS_H only in source files?

src/auth_des.c extern bool_t xdr_authdes_cred( XDR *, struct authdes_cred *); · line 75

Quoted 4 lines
src/auth_des.c +2 -0
 extern bool_t __rpc_get_time_offset(struct timeval *, nis_server *, char *,
 	char **, char **);
+#else
+# define __rpc_get_time_offset(__a,__b,__c,__d, __e) (1) /* always valid */

The usual practice is to provide a static inline function as a stub, rather than a macro.

src/auth_des.c struct ad_private { · line 113

Quoted 12 lines
src/auth_des.c +4 -0
+# define nis_server char
+#endif
 
 /* 
 * DES authenticator operations vector
@@ -101,7 +108,9 @@ struct ad_private {
 	u_char ad_pkey[1024];		/* Server's actual public key */
 	char *ad_netid;			/* Timehost netid */
 	char *ad_uaddr;			/* Timehost uaddr */
+#ifdef YP
 	nis_server *ad_nis_srvr;	/* NIS+ server struct */
+#endif

Why is it necessary to remove this field if
you have #defined nis_server as a char ?

Quoted 40 lines
src/auth_des.c +6 -0
 };
 
 AUTH *authdes_pk_seccreate(const char *, netobj *, u_int, const char *,
@@ -169,7 +178,9 @@ authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window,
 	ad->ad_timehost = NULL;
 	ad->ad_netid = NULL;
 	ad->ad_uaddr = NULL;
+#ifdef YP
 	ad->ad_nis_srvr = NULL;
+#endif
 	ad->ad_timediff.tv_sec = 0;
 	ad->ad_timediff.tv_usec = 0;
 	memcpy(ad->ad_pkey, pkey->n_bytes, pkey->n_len);
@@ -192,9 +203,11 @@ authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window,
 		}
 		memcpy(ad->ad_timehost, timehost, strlen(timehost) + 1);
 		ad->ad_dosync = TRUE;
+#ifdef YP
 	} else if (srvr != NULL) {
 		ad->ad_nis_srvr = srvr;	/* transient */
 		ad->ad_dosync = TRUE;
+#endif
 	} else {
 		ad->ad_dosync = FALSE;
 	}
@@ -222,7 +235,9 @@ authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window,
 	if (!authdes_refresh(auth, NULL)) {
 		goto failed;
 	}
+#ifdef YP
 	ad->ad_nis_srvr = NULL; /* not needed any longer */
+#endif
 	auth_get(auth);		/* Reference for caller */
 	return (auth);
 
src/auth_time.c +0 -0
index 10e58eb..e47ece8 100644

src/auth_time.c line 50

Quoted 7 lines
src/auth_time.c +2 -1
@@ -45,8 +45,9 @@
 //#include <clnt_soc.h>
 #include <sys/select.h>
 #undef NIS
+#ifdef HAVE_RPCSVC_NIS_H
 #include <rpcsvc/nis.h>
-
+#endif

Due to the Makefile change above, auth_time.c isn't even compiled if ndef HAVE_RPCSVC_NIS_H. Do you need this change? It implies that auth_time.c _can_ be built without nis.h, in which case, why not just remove the #include altogether or allow this file to be compiled?

Quoted 4 lines
src/auth_time.c +0 -0
 #ifdef TESTING
 #define	msg(x)	printf("ERROR: %s\n", x)
Signature · 1 line
2.1.4

--
Chuck Lever
[email protected]

#6 lore raw

PATCH v2 5/7 configure.ac: Allow for disabling auth DES

In reply to Bernhard Reutner-Fischer

DES encryption might not be available.

---
 Makefile.am      | 12 ++++++++----
 configure.ac     |  7 ++++++-
 libtirpc.pc.in   |  2 +-
 src/Makefile.am  |  1 -
 src/rpc_soc.c    |  2 +-
 tirpc/rpc/auth.h | 10 ++++++++++
 tirpc/rpc/rpc.h  |  2 ++
 7 files changed, 28 insertions(+), 8 deletions(-)
Makefile.am +8 -4
index 9b812eb..e588ae0 100644
@@ -27,17 +27,21 @@ nobase_include_HEADERS = tirpc/netconfig.h \
 			 tirpc/rpc/pmap_prot.h \
 			 tirpc/rpc/pmap_clnt.h \
 			 tirpc/rpc/nettype.h \
-			 tirpc/rpc/des.h \
-			 tirpc/rpc/des_crypt.h \
 			 tirpc/rpc/clnt_stat.h \
 			 tirpc/rpc/clnt_soc.h \
 			 tirpc/rpc/clnt.h \
 			 tirpc/rpc/auth_unix.h \
 			 tirpc/rpc/auth_kerb.h \
 			 tirpc/rpc/auth.h \
-			 tirpc/rpc/auth_gss.h \
+			 tirpc/rpc/auth_gss.h
+
+if AUTHDES
+nobase_include_HEADERS += \
+			 tirpc/rpc/des.h \
+			 tirpc/rpc/des_crypt.h \
 			 tirpc/rpc/auth_des.h
-    
+endif
+
 pkgconfigdir=$(libdir)/pkgconfig
 pkgconfig_DATA = libtirpc.pc
 
configure.ac +6 -1
index 3ebde36..bcc794e 100644
@@ -20,6 +20,12 @@ AC_ARG_ENABLE(authdes,
 	[AC_HELP_STRING([--disable-authdes], [Disable DES authentication @<:@default=no@:>@])],
       [],[enable_authdes=yes])
 AM_CONDITIONAL(AUTHDES, test x$enable_authdes = xyes)
+if test x$enable_authdes = xyes; then
+	AC_DEFINE([HAVE_AUTHDES], [1],
+		  [Define to 1 if DES authentication is enabled])
+	CFLAG_AUTHDES="-DHAVE_AUTHDES=1"
+	AC_SUBST([CFLAG_AUTHDES])
+fi
 
 AC_ARG_ENABLE(ipv6,
 	[AC_HELP_STRING([--disable-ipv6], [Disable IPv6 support @<:@default=no@:>@])],
@@ -59,4 +65,3 @@ AM_CONDITIONAL([YP], [test "x$enable_nis" != xno])
 AC_CONFIG_FILES([Makefile src/Makefile man/Makefile doc/Makefile])
 AC_OUTPUT(libtirpc.pc)
 
-
libtirpc.pc.in +1 -1
index 38034c5..ebbc66f 100644
@@ -9,4 +9,4 @@ Requires:
 Version: @PACKAGE_VERSION@
 Libs: -L@libdir@ -ltirpc
 Libs.private: -lpthread
-Cflags: -I@includedir@/tirpc
+Cflags: -I@includedir@/tirpc @CFLAG_AUTHDES@
src/Makefile.am +0 -1
index 2ba4444..081c2bd 100644
@@ -67,7 +67,6 @@ endif
 ## DES authentication
 if AUTHDES
     libtirpc_la_SOURCES += auth_des.c authdes_prot.c
-    libtirpc_la_CFLAGS += -DHAVE_AUTHDES
 endif
 
 if YP
src/rpc_soc.c +1 -1
index 6574323..1e2f4d6 100644
@@ -520,7 +520,7 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
 	    (resultproc_t) rpc_wrap_bcast, "udp");
 }
 
-#if HAVE_AUTHDES
+#ifdef HAVE_AUTHDES
 /*
  * Create the client des authentication object. Obsoleted by
  * authdes_seccreate().
tirpc/rpc/auth.h +10 -0
index 434d35c..1b6c699 100644
@@ -163,6 +163,8 @@ union des_block {
 	char c[8];
 };
 typedef union des_block des_block;
+
+#ifdef HAVE_AUTHDES
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -170,6 +172,7 @@ extern bool_t xdr_des_block(XDR *, des_block *);
 #ifdef __cplusplus
 }
 #endif
+#endif /* HAVE_AUTHDES */
 
 /*
  * Authentication info.  Opaque to client.
@@ -316,6 +319,8 @@ extern AUTH *authnone_create(void);		/* takes no parameters */
 #ifdef __cplusplus
 }
 #endif
+
+#ifdef HAVE_AUTHDES
 /*
  * DES style authentication
  * AUTH *authsecdes_create(servername, window, timehost, ckey)
@@ -333,6 +338,7 @@ extern AUTH *authdes_seccreate (const char *, const u_int, const  char *,
 #ifdef __cplusplus
 }
 #endif
+#endif /* HAVE_AUTHDES */
 
 #ifdef __cplusplus
 extern "C" {
@@ -356,7 +362,9 @@ extern int host2netname(char *, const char *, const char *);
 extern int user2netname(char *, const uid_t, const char *);
 extern int netname2user(char *, uid_t *, gid_t *, int *, gid_t *);
 extern int netname2host(char *, char *, const int);
+#ifdef HAVE_AUTHDES
 extern void passwd2des ( char *, char * );
+#endif /* HAVE_AUTHDES */
 #ifdef __cplusplus
 }
 #endif
@@ -371,7 +379,9 @@ extern "C" {
 #endif
 extern int key_decryptsession(const char *, des_block *);
 extern int key_encryptsession(const char *, des_block *);
+#ifdef HAVE_AUTHDES
 extern int key_gendes(des_block *);
+#endif /* HAVE_AUTHDES */
 extern int key_setsecret(const char *);
 extern int key_secretkey_is_set(void);
 #ifdef __cplusplus
tirpc/rpc/rpc.h +2 -0
index fac2fa9..1dbb391 100644
@@ -52,11 +52,13 @@
 #include <rpc/rpc_msg.h>	/* protocol for rpc messages */
 #include <rpc/auth_unix.h>	/* protocol for unix style cred */
 
+#ifdef HAVE_AUTHDES
 /*
  *  Uncomment-out the next line if you are building the rpc library with
  *  DES Authentication (see the README file in the secure_rpc/ directory).
  */
 #include <rpc/auth_des.h>	/* protocol for des style cred */
+#endif /* HAVE_AUTHDES */
 
 #ifdef HAVE_RPCSEC_GSS
 #include <rpc/auth_gss.h>   /* RPCSEC_GSS */
Signature · 1 line
2.1.4
#7 lore raw

PATCH v2 6/7 getrpcport: rephrase host lookup

In reply to Bernhard Reutner-Fischer

Most folks seem to copy this gentoo patch to silence an alleged _FORTIFY_SOURCE=2 warning:
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-libs/libtirpc/files/libtirpc-0.2.1-fortify.patch?diff_format=s&revision=1.2&view=markup

Given that gethostbyname is obsolescent, let's just use getaddrinfo instead (to silence warnings about the OB function).

I am undecided if setting AI_V4MAPPED and AI_ADDRCONFIG is a good idea. Personally i would be inclined to s/if 0/if 1/ but i'll leave that up to you.

---
 src/getrpcport.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)
src/getrpcport.c +25 -12
index b452c99..f36158d 100644
@@ -48,19 +48,32 @@ getrpcport(host, prognum, versnum, proto)
 	int prognum, versnum, proto;
 {
 	struct sockaddr_in addr;
-	struct hostent *hp;
+	struct addrinfo hints, *result, *rp;
+	int ret = 0;
 
 	assert(host != NULL);
-
-	if ((hp = gethostbyname(host)) == NULL)
+	memset(&hints, 0, sizeof(struct addrinfo));
+	hints.ai_family = AF_INET; /* ??? :-( */
+#if 0
+#ifdef AI_V4MAPPED
+	hints.ai_flags |= AI_V4MAPPED;
+#endif
+#ifdef AI_ADDRCONFIG
+	hints.ai_flags |= AI_ADDRCONFIG;
+#endif
+#endif
+	if (getaddrinfo(host, NULL, &hints, &result) != 0)
 		return (0);
-	memset(&addr, 0, sizeof(addr));
-	addr.sin_family = AF_INET;
-	addr.sin_port =  0;
-	if (hp->h_length > sizeof(addr))
-	  hp->h_length = sizeof(addr);
-	memcpy(&addr.sin_addr.s_addr, hp->h_addr, (size_t)hp->h_length);
-	/* Inconsistent interfaces need casts! :-( */
-	return (pmap_getport(&addr, (u_long)prognum, (u_long)versnum, 
-	    (u_int)proto));
+	for (rp = result; rp != NULL; rp = rp->ai_next) {
+		assert (rp->ai_family == AF_INET && rp->ai_addrlen == 16);
+		memcpy(&addr, rp->ai_addr, rp->ai_addrlen);
+		assert (addr.sin_family == AF_INET && addr.sin_port == 0);
+		/* Inconsistent interfaces need casts! :-( */
+		ret = (pmap_getport(&addr, (u_long)prognum, (u_long)versnum,
+		    (u_int)proto));
+		if (ret)
+			break;
+	}
+	freeaddrinfo(result);
+	return (ret);
 }
Signature · 1 line
2.1.4
#8 lore raw

PATCH v2 7/7 headers: if 0 out some unbuilt functions

In reply to Bernhard Reutner-Fischer
---
 tirpc/rpc/auth.h     | 8 +++++++-
 tirpc/rpc/auth_des.h | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)
tirpc/rpc/auth.h +7 -1
index 1b6c699..b7b7943 100644
@@ -377,13 +377,17 @@ extern void passwd2des ( char *, char * );
 #ifdef __cplusplus
 extern "C" {
 #endif
+#if 0
 extern int key_decryptsession(const char *, des_block *);
 extern int key_encryptsession(const char *, des_block *);
+#endif
 #ifdef HAVE_AUTHDES
 extern int key_gendes(des_block *);
 #endif /* HAVE_AUTHDES */
+#if 0
 extern int key_setsecret(const char *);
 extern int key_secretkey_is_set(void);
+#endif
 #ifdef __cplusplus
 }
 #endif
@@ -394,9 +398,11 @@ extern int key_secretkey_is_set(void);
 #ifdef __cplusplus
 extern "C" {
 #endif
+#if 0
 extern int getpublickey (const char *, char *);
 extern int getpublicandprivatekey (char *, char *);
-extern int getsecretkey (char *, char *, char *);
+//extern int getsecretkey (char *, char *, char *);
+#endif
 #ifdef __cplusplus
 }
 #endif
tirpc/rpc/auth_des.h +2 -0
index 77e169d..b157806 100644
@@ -127,8 +127,10 @@ extern "C" {
 #endif
 extern bool_t	xdr_authdes_cred(XDR *, struct authdes_cred *);
 extern bool_t	xdr_authdes_verf(XDR *, struct authdes_verf *);
+#if 0
 extern int	rtime(dev_t, struct netbuf *, int, struct timeval *,
 		    struct timeval *);
+#endif
 extern void	kgetnetname(char *);
 extern enum auth_stat _svcauth_des(struct svc_req *, struct rpc_msg *);
 #ifdef __cplusplus
Signature · 1 line
2.1.4
#9 lore raw
In reply to Bernhard Reutner-Fischer
Quoted 6 lines · Bernhard Reutner-Fischer

Seems i forgot the config.h stuff last time, sorry for that..

Bernhard Reutner-Fischer (7):
delete src/config.h
getrpcent: Fix compilation on glibc
Make sure to include config.h

I committed these three...

Quoted 1 line

configure.ac: Allow for disabling NIS

Not this one due to due to Thorsten comments...

Quoted 1 line

configure.ac: Allow for disabling auth DES

Committed this one.

Quoted 1 line

getrpcport: rephrase host lookup

This didn't apply and I had a comment about it.

Quoted 1 line

headers: if 0 out some unbuilt functions

I reworked this one in different commit series.

steved.

Quoted 17 lines
 Makefile.am          |  12 ++++--
 configure.ac         |  24 ++++++++++-
 libtirpc.pc.in       |   2 +-
 src/Makefile.am      |  10 +++--
 src/auth_des.c       |  15 +++++++
 src/auth_time.c      |   6 ++-
 src/config.h         | 110 ---------------------------------------------------
 src/getrpcent.c      |  16 ++++----
 src/getrpcport.c     |  37 +++++++++++------
 src/rpc_soc.c        |   2 +-
 tirpc/rpc/auth.h     |  18 ++++++++-
 tirpc/rpc/auth_des.h |   2 +
 tirpc/rpc/rpc.h      |   2 +
 13 files changed, 113 insertions(+), 143 deletions(-)
 delete mode 100644 src/config.h