summaryrefslogtreecommitdiff
blob: fdb8b96d9f0d756ae8fd1d5b6939844a97244b76 (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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
Index: Linux-PAM-1.1.3/configure.in
===================================================================
--- Linux-PAM-1.1.3.orig/configure.in
+++ Linux-PAM-1.1.3/configure.in
@@ -441,12 +441,39 @@ fi
 AC_SUBST(LIBDB)
 AM_CONDITIONAL([HAVE_LIBDB], [test ! -z "$LIBDB"])
 
-AC_CHECK_LIB([nsl],[yp_get_default_domain], LIBNSL="-lnsl", LIBNSL="")
-BACKUP_LIBS=$LIBS
-LIBS="$LIBS $LIBNSL"
-AC_CHECK_FUNCS(yp_get_default_domain getdomainname innetgr yperr_string yp_master yp_bind yp_match yp_unbind)
-LIBS=$BACKUP_LIBS
-AC_SUBST(LIBNSL)
+AC_ARG_ENABLE([nis],
+        AS_HELP_STRING([-disable-nis], [Disable building NIS/YP support in pam_unix and pam_access]))
+
+AS_IF([test "x$enable_nis" != "xno"], [
+  CFLAGS=$old_CFLAGS
+  LIBS=$old_LIBS
+
+  dnl if there's libtirpc available, prefer that over the system
+  dnl implementation.
+  PKG_CHECK_MODULES([libtirpc], [libtirpc], [
+    CFLAGS="$CFLAGS $libtirpc_CFLAGS"
+    LIBS="$LIBS $libtirpc_LIBS"
+  ], [:;])
+
+  AC_SEARCH_LIBS([yp_get_default_domain], [nsl])
+
+  AC_CHECK_FUNCS([yp_get_default_domain yperr_string yp_master yp_bind yp_match yp_unbind])
+  AC_CHECK_HEADERS([rpc/rpc.h rpcsvc/ypclnt.h rpcsvc/yp_prot.h])
+  AC_CHECK_DECLS([getrpcport], , , [
+    #if HAVE_RPC_RPC_H
+    # include <rpc/rpc.h>
+    #endif
+  ])
+
+  NIS_CFLAGS="${CFLAGS%${old_CFLAGS}}"
+  NIS_LIBS="${LIBS%${old_LIBS}}"
+
+  CFLAGS="$old_CFLAGS"
+  LIBS="$old_LIBS"
+])
+
+AC_SUBST([NIS_CFLAGS])
+AC_SUBST([NIS_LIBS])
 
 AC_ARG_ENABLE([selinux],
         AS_HELP_STRING([--disable-selinux],[do not use SELinux]),
@@ -471,7 +498,7 @@ dnl Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/file.h sys/ioctl.h sys/time.h syslog.h net/if.h termio.h unistd.h sys/fsuid.h inittypes.h rpcsvc/ypclnt.h rpcsvc/yp_prot.h)
+AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/file.h sys/ioctl.h sys/time.h syslog.h net/if.h termio.h unistd.h sys/fsuid.h inittypes.h)
 
 dnl For module/pam_lastlog
 AC_CHECK_HEADERS(lastlog.h utmp.h utmpx.h)
@@ -491,11 +518,11 @@ AC_TYPE_GETGROUPS
 AC_PROG_GCC_TRADITIONAL
 AC_FUNC_MEMCMP
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(fseeko gethostname gettimeofday lckpwdf mkdir select)
+AC_CHECK_FUNCS(fseeko getdomainname gethostname gettimeofday lckpwdf mkdir select)
 AC_CHECK_FUNCS(strcspn strdup strspn strstr strtol uname)
 AC_CHECK_FUNCS(getutent_r getpwnam_r getpwuid_r getgrnam_r getgrgid_r getspnam_r)
 AC_CHECK_FUNCS(getgrouplist getline getdelim)
-AC_CHECK_FUNCS(inet_ntop inet_pton ruserok_af)
+AC_CHECK_FUNCS(inet_ntop inet_pton innetgr ruserok_af)
 
 AC_CHECK_FUNCS(unshare, [UNSHARE=yes], [UNSHARE=no])
 AM_CONDITIONAL([HAVE_UNSHARE], [test "$UNSHARE" = yes])
Index: Linux-PAM-1.1.3/modules/pam_unix/pam_unix_passwd.c
===================================================================
--- Linux-PAM-1.1.3.orig/modules/pam_unix/pam_unix_passwd.c
+++ Linux-PAM-1.1.3/modules/pam_unix/pam_unix_passwd.c
@@ -54,13 +54,6 @@
 #include <ctype.h>
 #include <sys/time.h>
 #include <sys/stat.h>
-#include <rpc/rpc.h>
-#ifdef HAVE_RPCSVC_YP_PROT_H
-#include <rpcsvc/yp_prot.h>
-#endif
-#ifdef HAVE_RPCSVC_YPCLNT_H
-#include <rpcsvc/ypclnt.h>
-#endif
 
 #include <signal.h>
 #include <errno.h>
@@ -76,16 +69,33 @@
 #include <security/pam_ext.h>
 #include <security/pam_modutil.h>
 
-#include "yppasswd.h"
 #include "md5.h"
 #include "support.h"
 #include "passverify.h"
 #include "bigcrypt.h"
 
-#if !((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))
+#if (HAVE_YP_GET_DEFAULT_DOMAIN || HAVE_GETDOMAINNAME) && HAVE_YP_MASTER
+# define HAVE_NIS 1
+#endif
+
+#ifdef HAVE_NIS
+# include <rpc/rpc.h>
+
+# if HAVE_RPCSVC_YP_PROT_H
+#  include <rpcsvc/yp_prot.h>
+# endif
+
+# if HAVE_RPCSVC_YPCLNT_H
+#  include <rpcsvc/ypclnt.h>
+# endif
+
+# if !HAVE_DECL_GETRPCPORT
 extern int getrpcport(const char *host, unsigned long prognum,
 		      unsigned long versnum, unsigned int proto);
-#endif				/* GNU libc 2.1 */
+# endif				/* GNU libc 2.1 */
+
+# include "yppasswd.h"
+#endif
 
 /*
    How it works:
@@ -102,9 +112,9 @@ extern int getrpcport(const char *host,
 
 #define MAX_PASSWD_TRIES	3
 
+#if HAVE_NIS
 static char *getNISserver(pam_handle_t *pamh, unsigned int ctrl)
 {
-#if (defined(HAVE_YP_GET_DEFAULT_DOMAIN) || defined(HAVE_GETDOMAINNAME)) && defined(HAVE_YP_MASTER)
 	char *master;
 	char *domainname;
 	int port, err;
@@ -151,14 +161,8 @@ static char *getNISserver(pam_handle_t *
 		     master, port);
 	}
 	return master;
-#else
-	if (on(UNIX_DEBUG, ctrl)) {
-	  pam_syslog(pamh, LOG_DEBUG, "getNISserver: No NIS support available");
-	}
-
-	return NULL;
-#endif
 }
+#endif
 
 #ifdef WITH_SELINUX
 
@@ -326,6 +330,7 @@ static int _do_setpass(pam_handle_t* pam
 	}
 
 	if (on(UNIX_NIS, ctrl) && _unix_comesfromsource(pamh, forwho, 0, 1)) {
+#if HAVE_NIS
 	  if ((master=getNISserver(pamh, ctrl)) != NULL) {
 		struct timeval timeout;
 		struct yppasswd yppwd;
@@ -391,6 +396,13 @@ static int _do_setpass(pam_handle_t* pam
 	    } else {
 		    retval = PAM_TRY_AGAIN;
 	    }
+#else
+          if (on(UNIX_DEBUG, ctrl)) {
+            pam_syslog(pamh, LOG_DEBUG, "No NIS support available");
+          }
+
+          retval = PAM_TRY_AGAIN;
+#endif
 	}
 
 	if (_unix_comesfromsource(pamh, forwho, 1, 0)) {
Index: Linux-PAM-1.1.3/modules/pam_unix/yppasswd_xdr.c
===================================================================
--- Linux-PAM-1.1.3.orig/modules/pam_unix/yppasswd_xdr.c
+++ Linux-PAM-1.1.3/modules/pam_unix/yppasswd_xdr.c
@@ -12,6 +12,8 @@
 
 #include "config.h"
 
+#ifdef HAVE_RPC_RPC_H
+
 #include <rpc/rpc.h>
 #include "yppasswd.h"
 
@@ -34,3 +36,5 @@ xdr_yppasswd(XDR * xdrs, yppasswd * objp
 	return xdr_string(xdrs, &objp->oldpass, ~0)
 	    && xdr_xpasswd(xdrs, &objp->newpw);
 }
+
+#endif
Index: Linux-PAM-1.1.3/libpam/Makefile.am
===================================================================
--- Linux-PAM-1.1.3.orig/libpam/Makefile.am
+++ Linux-PAM-1.1.3/libpam/Makefile.am
@@ -25,7 +25,8 @@ libpam_la_LIBADD = @LIBAUDIT@ $(LIBPRELU
 
 if STATIC_MODULES
   libpam_la_LIBADD += $(shell ls ../modules/pam_*/*.lo) \
-	@LIBDB@ @LIBCRYPT@ @LIBNSL@ @LIBCRACK@ -lutil
+	@LIBDB@ @LIBCRYPT@ $(NIS_LIBS) @LIBCRACK@ -lutil
+  AM_CFLAGS += $(NIS_CFLAGS)
 endif
 if HAVE_VERSIONING
   libpam_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libpam.map
Index: Linux-PAM-1.1.3/modules/pam_access/Makefile.am
===================================================================
--- Linux-PAM-1.1.3.orig/modules/pam_access/Makefile.am
+++ Linux-PAM-1.1.3/modules/pam_access/Makefile.am
@@ -15,14 +15,14 @@ securelibdir = $(SECUREDIR)
 secureconfdir = $(SCONFIGDIR)
 
 AM_CFLAGS = -I$(top_srcdir)/libpam/include -I$(top_srcdir)/libpamc/include \
-	-DPAM_ACCESS_CONFIG=\"$(SCONFIGDIR)/access.conf\"
+	-DPAM_ACCESS_CONFIG=\"$(SCONFIGDIR)/access.conf\" $(NIS_CFLAGS)
 AM_LDFLAGS =  -no-undefined -avoid-version -module
 if HAVE_VERSIONING
   AM_LDFLAGS += -Wl,--version-script=$(srcdir)/../modules.map
 endif
 
 securelib_LTLIBRARIES = pam_access.la
-pam_access_la_LIBADD = -L$(top_builddir)/libpam -lpam @LIBNSL@
+pam_access_la_LIBADD = -L$(top_builddir)/libpam -lpam $(NIS_LIBS)
 
 secureconf_DATA = access.conf
 
Index: Linux-PAM-1.1.3/modules/pam_unix/Makefile.am
===================================================================
--- Linux-PAM-1.1.3.orig/modules/pam_unix/Makefile.am
+++ Linux-PAM-1.1.3/modules/pam_unix/Makefile.am
@@ -18,7 +18,8 @@ secureconfdir = $(SCONFIGDIR)
 
 AM_CFLAGS = -I$(top_srcdir)/libpam/include -I$(top_srcdir)/libpamc/include \
 	-DCHKPWD_HELPER=\"$(sbindir)/unix_chkpwd\" \
-	-DUPDATE_HELPER=\"$(sbindir)/unix_update\"
+	-DUPDATE_HELPER=\"$(sbindir)/unix_update\" \
+	$(NIS_CFLAGS)
 
 if HAVE_LIBSELINUX
   AM_CFLAGS += -D"WITH_SELINUX"
@@ -28,7 +29,7 @@ pam_unix_la_LDFLAGS = -no-undefined -avo
 if HAVE_VERSIONING
   pam_unix_la_LDFLAGS += -Wl,--version-script=$(srcdir)/../modules.map
 endif
-pam_unix_la_LIBADD = @LIBNSL@ -L$(top_builddir)/libpam -lpam \
+pam_unix_la_LIBADD = $(NIS_LIBS) -L$(top_builddir)/libpam -lpam \
 	@LIBCRYPT@ @LIBSELINUX@
 
 securelib_LTLIBRARIES = pam_unix.la