aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/libtirpc/libtirpc/0001-configure.ac-Allow-for-disabling-NIS.patch
blob: 5b2aa3dfc627136d1b827834b82acb6d02cfd837 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
From b562294d35d8a87af2bcdbc32c15cc973e50ed4e Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Sun, 1 Mar 2015 12:18:05 +0100
Subject: [PATCH 1/2] configure.ac: Allow for disabling NIS
To: libtirpc-devel@lists.sourceforge.net
Cc: Steve Dickson <SteveD@redhat.com>

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

Upstream-Status: Submitted

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 configure.ac    | 16 ++++++++++++++++
 src/Makefile.am |  6 +++++-
 src/auth_des.c  | 18 +++++++++++++++++-
 src/auth_time.c |  3 ++-
 4 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 10d17ea..d006ac9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,22 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h locale.h netdb.h netine
 AC_CHECK_LIB([pthread], [pthread_create])
 AC_CHECK_LIB([nsl], [yp_get_default_domain])
 
+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 de57c8f..7861057 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -51,7 +51,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 auth_des.c authdes_prot.c debug.c
+        auth_des.c authdes_prot.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
@@ -63,6 +63,10 @@ if GSS
     libtirpc_la_CFLAGS = -DHAVE_RPCSEC_GSS $(GSSAPI_CFLAGS)
 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 \
 ## libtirpc_a_SOURCES += rtime.c \
diff --git a/src/auth_des.c b/src/auth_des.c
index cff777c..be9d364 100644
--- a/src/auth_des.c
+++ b/src/auth_des.c
@@ -48,7 +48,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
@@ -68,8 +70,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();
 
+#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
@@ -103,7 +110,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 *,
@@ -148,7 +157,8 @@ authdes_seccreate(const char *servername, const u_int win,
  */
 AUTH *
 authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window,
-	const char *timehost, const des_block *ckey, nis_server *srvr)
+	const char *timehost, const des_block *ckey, nis_server *srvr
+	)
 {
 	AUTH *auth;
 	struct ad_private *ad;
@@ -171,7 +181,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);
@@ -194,9 +206,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;
 	}
@@ -224,7 +238,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 7cfbb7e..111de90 100644
--- a/src/auth_time.c
+++ b/src/auth_time.c
@@ -43,8 +43,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