2015-04-24 00:27:48

by Bernhard Reutner-Fischer

[permalink] [raw]
Subject: [PATCH v2 0/7] 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

--
2.1.4



2015-04-24 00:27:49

by Bernhard Reutner-Fischer

[permalink] [raw]
Subject: [PATCH v2 1/7] delete src/config.h

Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
---
src/config.h | 110 -----------------------------------------------------------
1 file changed, 110 deletions(-)
delete mode 100644 src/config.h

diff --git a/src/config.h b/src/config.h
deleted file mode 100644
index e42e1f5..0000000
--- a/src/config.h
+++ /dev/null
@@ -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"
--
2.1.4


2015-04-24 00:27:50

by Bernhard Reutner-Fischer

[permalink] [raw]
Subject: [PATCH v2 4/7] configure.ac: Allow for disabling NIS

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

Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
---
configure.ac | 17 +++++++++++++++++
src/Makefile.am | 5 ++++-
src/auth_des.c | 15 +++++++++++++++
src/auth_time.c | 3 ++-
4 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 80dec85..3ebde36 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)

diff --git a/src/Makefile.am b/src/Makefile.am
index 38d0c3d..2ba4444 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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 \
diff --git a/src/auth_des.c b/src/auth_des.c
index f8749b0..f971481 100644
--- a/src/auth_des.c
+++ b/src/auth_des.c
@@ -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);

diff --git a/src/auth_time.c b/src/auth_time.c
index 10e58eb..e47ece8 100644
--- a/src/auth_time.c
+++ b/src/auth_time.c
@@ -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)
--
2.1.4


2015-04-24 00:27:51

by Bernhard Reutner-Fischer

[permalink] [raw]
Subject: [PATCH v2 5/7] configure.ac: Allow for disabling auth DES

DES encryption might not be available.

Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
---
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(-)

diff --git a/Makefile.am b/Makefile.am
index 9b812eb..e588ae0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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

diff --git a/configure.ac b/configure.ac
index 3ebde36..bcc794e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)

-
diff --git a/libtirpc.pc.in b/libtirpc.pc.in
index 38034c5..ebbc66f 100644
--- a/libtirpc.pc.in
+++ b/libtirpc.pc.in
@@ -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@
diff --git a/src/Makefile.am b/src/Makefile.am
index 2ba4444..081c2bd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
diff --git a/src/rpc_soc.c b/src/rpc_soc.c
index 6574323..1e2f4d6 100644
--- a/src/rpc_soc.c
+++ b/src/rpc_soc.c
@@ -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().
diff --git a/tirpc/rpc/auth.h b/tirpc/rpc/auth.h
index 434d35c..1b6c699 100644
--- a/tirpc/rpc/auth.h
+++ b/tirpc/rpc/auth.h
@@ -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
diff --git a/tirpc/rpc/rpc.h b/tirpc/rpc/rpc.h
index fac2fa9..1dbb391 100644
--- a/tirpc/rpc/rpc.h
+++ b/tirpc/rpc/rpc.h
@@ -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 */
--
2.1.4


2015-04-24 00:27:50

by Bernhard Reutner-Fischer

[permalink] [raw]
Subject: [PATCH v2 2/7] getrpcent: Fix compilation on glibc

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

Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
---
src/getrpcent.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/getrpcent.c b/src/getrpcent.c
index 6da006a..fbb2da4 100644
--- a/src/getrpcent.c
+++ b/src/getrpcent.c
@@ -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,
--
2.1.4


2015-04-24 00:27:48

by Bernhard Reutner-Fischer

[permalink] [raw]
Subject: [PATCH v2 3/7] Make sure to include config.h

I really think the -DINET6 is wrong.

Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
---
src/Makefile.am | 4 ++--
src/auth_time.c | 3 +++
src/getrpcent.c | 8 ++++----
3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 26ccbdf..38d0c3d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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

diff --git a/src/auth_time.c b/src/auth_time.c
index 13717ff..10e58eb 100644
--- a/src/auth_time.c
+++ b/src/auth_time.c
@@ -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>
diff --git a/src/getrpcent.c b/src/getrpcent.c
index fbb2da4..c374673 100644
--- a/src/getrpcent.c
+++ b/src/getrpcent.c
@@ -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.
*/
--
2.1.4


2015-04-24 00:27:51

by Bernhard Reutner-Fischer

[permalink] [raw]
Subject: [PATCH v2 6/7] getrpcport: rephrase host lookup

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.

Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
---
src/getrpcport.c | 37 +++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/src/getrpcport.c b/src/getrpcport.c
index b452c99..f36158d 100644
--- a/src/getrpcport.c
+++ b/src/getrpcport.c
@@ -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);
}
--
2.1.4


2015-04-24 00:27:52

by Bernhard Reutner-Fischer

[permalink] [raw]
Subject: [PATCH v2 7/7] headers: if 0 out some unbuilt functions

Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
---
tirpc/rpc/auth.h | 8 +++++++-
tirpc/rpc/auth_des.h | 2 ++
2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/tirpc/rpc/auth.h b/tirpc/rpc/auth.h
index 1b6c699..b7b7943 100644
--- a/tirpc/rpc/auth.h
+++ b/tirpc/rpc/auth.h
@@ -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
diff --git a/tirpc/rpc/auth_des.h b/tirpc/rpc/auth_des.h
index 77e169d..b157806 100644
--- a/tirpc/rpc/auth_des.h
+++ b/tirpc/rpc/auth_des.h
@@ -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
--
2.1.4


2015-04-29 21:18:40

by Steve Dickson

[permalink] [raw]
Subject: Re: [Libtirpc-devel] [PATCH v2 0/7] Rebase, resend.



On 04/23/2015 08:27 PM, Bernhard Reutner-Fischer wrote:
> 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...

> configure.ac: Allow for disabling NIS
Not this one due to due to Thorsten comments...

> configure.ac: Allow for disabling auth DES
Committed this one.

> getrpcport: rephrase host lookup
This didn't apply and I had a comment about it.

> headers: if 0 out some unbuilt functions
I reworked this one in different commit series.

steved.

>
> 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
>

2016-06-02 14:51:24

by Chuck Lever

[permalink] [raw]
Subject: 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:


> On Apr 23, 2015, at 8:27 PM, Bernhard Reutner-Fischer <[email protected]> wrote:
>
> 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?


> Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
> ---
> configure.ac | 17 +++++++++++++++++
> src/Makefile.am | 5 ++++-
> src/auth_des.c | 15 +++++++++++++++
> src/auth_time.c | 3 ++-
> 4 files changed, 38 insertions(+), 2 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 80dec85..3ebde36 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -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])
> +

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?

> AC_CONFIG_FILES([Makefile src/Makefile man/Makefile doc/Makefile])
> AC_OUTPUT(libtirpc.pc)
>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 38d0c3d..2ba4444 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -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 \
> diff --git a/src/auth_des.c b/src/auth_des.c
> index f8749b0..f971481 100644
> --- a/src/auth_des.c
> +++ b/src/auth_des.c
> @@ -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

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


> 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.

> +# 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 ?


> };
>
> 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);
>
> diff --git a/src/auth_time.c b/src/auth_time.c
> index 10e58eb..e47ece8 100644
> --- a/src/auth_time.c
> +++ b/src/auth_time.c
> @@ -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?


> #ifdef TESTING
> #define msg(x) printf("ERROR: %s\n", x)
> --
> 2.1.4

--
Chuck Lever
[email protected]