Browse Source

Added Linux-PAM and updated description.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Nikos Mavrogiannopoulos 10 years ago
parent
commit
7257e863d7

+ 71
- 0
libs/libpam/Makefile View File

@@ -0,0 +1,71 @@
1
+#
2
+# Copyright (C) 2006-2014 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=libpam
11
+PKG_VERSION:=1.1.8
12
+PKG_RELEASE:=3
13
+
14
+PKG_SOURCE:=Linux-PAM-$(PKG_VERSION).tar.bz2
15
+PKG_SOURCE_URL:=http://www.linux-pam.org/library/
16
+PKG_MD5SUM:=35b6091af95981b1b2cd60d813b5e4ee
17
+PKG_INSTALL:=1
18
+PKG_FIXUP:=autoreconf
19
+PKG_MAINTAINER:=Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
20
+
21
+PKG_BUILD_DIR:=$(BUILD_DIR)/Linux-PAM-$(PKG_VERSION)
22
+
23
+include $(INCLUDE_DIR)/package.mk
24
+
25
+define Package/libpam
26
+  SECTION:=libs
27
+  CATEGORY:=Libraries
28
+  TITLE:=the Linux-PAM libraries and modules.
29
+  URL:=http://www.kernel.org/pub/linux/libs/pam
30
+endef
31
+
32
+define Package/libpam/description
33
+	The Linux-PAM Pluggable Authentication Modules.
34
+endef
35
+
36
+TARGET_CFLAGS += $(FPIC)
37
+
38
+define Build/Configure
39
+	$(call Build/Configure/Default, \
40
+		--enable-shared \
41
+		--enable-static \
42
+		--enable-pamlocking \
43
+		--disable-prelude \
44
+		--disable-lckpwdf \
45
+		--disable-selinux \
46
+		--disable-nls \
47
+		--disable-rpath \
48
+		--enable-db=no \
49
+	)
50
+endef
51
+
52
+define Build/InstallDev
53
+	$(INSTALL_DIR) $(1)/lib
54
+	$(INSTALL_DIR) $(1)/usr/include
55
+	$(CP) $(PKG_INSTALL_DIR)/lib/* $(1)/lib/
56
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include
57
+endef
58
+
59
+define Package/libpam/install
60
+	$(INSTALL_DIR) $(1)/lib $(1)/lib/security $(1)/lib/security/pam_filter
61
+	$(INSTALL_DIR) $(1)/etc $(1)/etc/pam.d
62
+	$(INSTALL_DIR) $(1)/usr/sbin
63
+	$(CP) $(PKG_INSTALL_DIR)/lib/*.so* $(1)/lib/
64
+	$(CP) $(PKG_INSTALL_DIR)/lib/security/*.so* $(1)/lib/security/
65
+	$(CP) $(PKG_INSTALL_DIR)/lib/security/pam_filter/* $(1)/lib/security/pam_filter/
66
+	$(CP) $(PKG_INSTALL_DIR)/etc/* $(1)/etc/
67
+	$(CP) ./files/* $(1)/etc/
68
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/* $(1)/usr/sbin/
69
+endef
70
+
71
+$(eval $(call BuildPackage,libpam))

+ 15
- 0
libs/libpam/files/pam.conf View File

@@ -0,0 +1,15 @@
1
+# ---------------------------------------------------------------------------#
2
+# /etc/pam.conf								     #
3
+# ---------------------------------------------------------------------------#
4
+#
5
+# NOTE
6
+# ----
7
+#
8
+# NOTE: Most program use a file under the /etc/pam.d/ directory to setup their
9
+# PAM service modules. This file is used only if that directory does not exist.
10
+# ---------------------------------------------------------------------------#
11
+
12
+# Format:
13
+# serv.	module	   ctrl	      module [path]	...[args..]		     #
14
+# name	type	   flag							     #
15
+

+ 20
- 0
libs/libpam/files/pam.d/common-account View File

@@ -0,0 +1,20 @@
1
+#
2
+# /etc/pam.d/common-account - authorization settings common to all services
3
+#
4
+# This file is included from other service-specific PAM config files,
5
+# and should contain a list of the authorization modules that define
6
+# the central access policy for use on the system.  The default is to
7
+# only deny service to users whose accounts are expired in /etc/shadow.
8
+#
9
+
10
+# here are the per-package modules (the "Primary" block)
11
+account	[success=1 new_authtok_reqd=done default=ignore]	pam_unix.so 
12
+# here's the fallback if no module succeeds
13
+account	requisite			pam_deny.so
14
+# prime the stack with a positive return value if there isn't one already;
15
+# this avoids us returning an error just because nothing sets a success code
16
+# since the modules above will each just jump around
17
+account	required			pam_permit.so
18
+# and here are more per-package modules (the "Additional" block)
19
+
20
+# end of pam-auth-update config

+ 21
- 0
libs/libpam/files/pam.d/common-auth View File

@@ -0,0 +1,21 @@
1
+#
2
+# /etc/pam.d/common-auth - authentication settings common to all services
3
+#
4
+# This file is included from other service-specific PAM config files,
5
+# and should contain a list of the authentication modules that define
6
+# the central authentication scheme for use on the system
7
+# (e.g., /etc/shadow, LDAP, Kerberos, etc.).  The default is to use the
8
+# traditional Unix authentication mechanisms.
9
+#
10
+
11
+# here are the per-package modules (the "Primary" block)
12
+auth	[success=1 default=ignore]	pam_unix.so nullok_secure
13
+# here's the fallback if no module succeeds
14
+auth	requisite			pam_deny.so
15
+# prime the stack with a positive return value if there isn't one already;
16
+# this avoids us returning an error just because nothing sets a success code
17
+# since the modules above will each just jump around
18
+auth	required			pam_permit.so
19
+# and here are more per-package modules (the "Additional" block)
20
+
21
+# end of pam-auth-update config

+ 28
- 0
libs/libpam/files/pam.d/common-password View File

@@ -0,0 +1,28 @@
1
+#
2
+# /etc/pam.d/common-password - password-related modules common to all services
3
+#
4
+# This file is included from other service-specific PAM config files,
5
+# and should contain a list of modules that define the services to be
6
+# used to change user passwords.  The default is pam_unix.
7
+
8
+# Explanation of pam_unix options:
9
+#
10
+# The "sha512" option enables salted SHA512 passwords.  Without this option,
11
+# the default is Unix crypt.  Prior releases used the option "md5".
12
+#
13
+# The "obscure" option replaces the old `OBSCURE_CHECKS_ENAB' option in
14
+# login.defs.
15
+#
16
+# See the pam_unix manpage for other options.
17
+
18
+# here are the per-package modules (the "Primary" block)
19
+password	[success=1 default=ignore]	pam_unix.so obscure sha512
20
+# here's the fallback if no module succeeds
21
+password	requisite			pam_deny.so
22
+# prime the stack with a positive return value if there isn't one already;
23
+# this avoids us returning an error just because nothing sets a success code
24
+# since the modules above will each just jump around
25
+password	required			pam_permit.so
26
+# and here are more per-package modules (the "Additional" block)
27
+
28
+# end of pam-auth-update config

+ 25
- 0
libs/libpam/files/pam.d/common-session View File

@@ -0,0 +1,25 @@
1
+#
2
+# /etc/pam.d/common-session - session-related modules common to all services
3
+#
4
+# This file is included from other service-specific PAM config files,
5
+# and should contain a list of modules that define tasks to be performed
6
+# at the start and end of sessions of *any* kind (both interactive and
7
+# non-interactive).
8
+#
9
+
10
+# here are the per-package modules (the "Primary" block)
11
+session	[default=1]			pam_permit.so
12
+# here's the fallback if no module succeeds
13
+session	requisite			pam_deny.so
14
+# prime the stack with a positive return value if there isn't one already;
15
+# this avoids us returning an error just because nothing sets a success code
16
+# since the modules above will each just jump around
17
+session	required			pam_permit.so
18
+# The pam_umask module will set the umask according to the system default in
19
+# /etc/login.defs and user settings, solving the problem of different
20
+# umask settings with different shells, display managers, remote sessions etc.
21
+# See "man pam_umask".
22
+session optional			pam_umask.so
23
+# and here are more per-package modules (the "Additional" block)
24
+session	required			pam_unix.so 
25
+# end of pam-auth-update config

+ 25
- 0
libs/libpam/files/pam.d/common-session-noninteractive View File

@@ -0,0 +1,25 @@
1
+#
2
+# /etc/pam.d/common-session-noninteractive - session-related modules
3
+# common to all non-interactive services
4
+#
5
+# This file is included from other service-specific PAM config files,
6
+# and should contain a list of modules that define tasks to be performed
7
+# at the start and end of all non-interactive sessions.
8
+#
9
+
10
+# here are the per-package modules (the "Primary" block)
11
+session	[default=1]			pam_permit.so
12
+# here's the fallback if no module succeeds
13
+session	requisite			pam_deny.so
14
+# prime the stack with a positive return value if there isn't one already;
15
+# this avoids us returning an error just because nothing sets a success code
16
+# since the modules above will each just jump around
17
+session	required			pam_permit.so
18
+# The pam_umask module will set the umask according to the system default in
19
+# /etc/login.defs and user settings, solving the problem of different
20
+# umask settings with different shells, display managers, remote sessions etc.
21
+# See "man pam_umask".
22
+session optional			pam_umask.so
23
+# and here are more per-package modules (the "Additional" block)
24
+session	required			pam_unix.so 
25
+# end of pam-auth-update config

+ 16
- 0
libs/libpam/files/pam.d/other View File

@@ -0,0 +1,16 @@
1
+#
2
+# /etc/pam.d/other - specify the PAM fallback behaviour
3
+#
4
+# Note that this file is used for any unspecified service; for example
5
+#if /etc/pam.d/cron  specifies no session modules but cron calls
6
+#pam_open_session, the session module out of /etc/pam.d/other is
7
+#used.  If you really want nothing to happen then use pam_permit.so or
8
+#pam_deny.so as appropriate.
9
+
10
+# We fall back to the system default in /etc/pam.d/common-*
11
+# 
12
+
13
+auth       include      common-auth
14
+account    include      common-account
15
+password   include      common-password
16
+session    include      common-session

+ 35
- 0
libs/libpam/patches/000-OE-libpam-xtests.patch View File

@@ -0,0 +1,35 @@
1
+This patch is used to create a new sub package libpam-xtests to do more checks.
2
+
3
+Upstream-Status: Pending
4
+
5
+Signed-off-by: Kang Kai <kai.kang@windriver.com>
6
+--- a/xtests/Makefile.am
7
++++ b/xtests/Makefile.am
8
+@@ -7,7 +7,7 @@ AM_CFLAGS = -DLIBPAM_COMPILE -I$(top_src
9
+ LDADD = $(top_builddir)/libpam/libpam.la \
10
+ 	$(top_builddir)/libpam_misc/libpam_misc.la
11
+ 
12
+-CLEANFILES = *~ $(XTESTS)
13
++CLEANFILES = *~
14
+ 
15
+ EXTRA_DIST = run-xtests.sh tst-pam_dispatch1.pamd tst-pam_dispatch2.pamd \
16
+ 	tst-pam_dispatch3.pamd tst-pam_dispatch4.pamd \
17
+@@ -51,3 +51,18 @@ EXTRA_PROGRAMS = $(XTESTS)
18
+ 
19
+ xtests: $(XTESTS) run-xtests.sh
20
+ 	"$(srcdir)"/run-xtests.sh "$(srcdir)" ${XTESTS} ${NOSRCTESTS}
21
++
22
++all: $(XTESTS)
23
++
24
++install: install_xtests
25
++
26
++install_xtests:
27
++	$(INSTALL) -d $(DESTDIR)$(pkgdatadir)/xtests
28
++	for file in $(EXTRA_DIST) ; do \
29
++		$(INSTALL) $$file $(DESTDIR)$(pkgdatadir)/xtests ; \
30
++	done
31
++	for file in $(XTESTS); do \
32
++		$(INSTALL) .libs/$$file $(DESTDIR)$(pkgdatadir)/xtests ; \
33
++	done
34
++
35
++.PHONY: all install_xtests

+ 85
- 0
libs/libpam/patches/000-OE-pam-no-innetgr.patch View File

@@ -0,0 +1,85 @@
1
+innetgr may not be there so make sure that when innetgr is not present
2
+then we inform about it and not use it.
3
+
4
+-Khem
5
+--- a/modules/pam_group/pam_group.c
6
++++ b/modules/pam_group/pam_group.c
7
+@@ -656,7 +656,11 @@ static int check_account(pam_handle_t *p
8
+ 	}
9
+ 	/* If buffer starts with @, we are using netgroups */
10
+ 	if (buffer[0] == '@')
11
++#ifdef HAVE_INNETGR
12
+ 	  good &= innetgr (&buffer[1], NULL, user, NULL);
13
++#else
14
++	pam_syslog (pamh, LOG_ERR, "pam_group does not have netgroup support");
15
++#endif
16
+ 	/* otherwise, if the buffer starts with %, it's a UNIX group */
17
+ 	else if (buffer[0] == '%')
18
+           good &= pam_modutil_user_in_group_nam_nam(pamh, user, &buffer[1]);
19
+--- a/modules/pam_time/pam_time.c
20
++++ b/modules/pam_time/pam_time.c
21
+@@ -555,9 +555,13 @@ check_account(pam_handle_t *pamh, const
22
+ 	  }
23
+ 	  /* If buffer starts with @, we are using netgroups */
24
+ 	  if (buffer[0] == '@')
25
+-	    good &= innetgr (&buffer[1], NULL, user, NULL);
26
++#ifdef HAVE_INNETGR
27
++	       good &= innetgr (&buffer[1], NULL, user, NULL);
28
++#else
29
++	       pam_syslog (pamh, LOG_ERR, "pam_time does not have netgroup support");
30
++#endif
31
+ 	  else
32
+-	    good &= logic_field(pamh, user, buffer, count, is_same);
33
++	       good &= logic_field(pamh, user, buffer, count, is_same);
34
+ 	  D(("with user: %s", good ? "passes":"fails" ));
35
+ 
36
+ 	  /* here we get the time field */
37
+--- a/modules/pam_succeed_if/pam_succeed_if.c
38
++++ b/modules/pam_succeed_if/pam_succeed_if.c
39
+@@ -231,18 +231,27 @@ evaluate_notingroup(pam_handle_t *pamh,
40
+ }
41
+ /* Return PAM_SUCCESS if the (host,user) is in the netgroup. */
42
+ static int
43
+-evaluate_innetgr(const char *host, const char *user, const char *group)
44
++evaluate_innetgr(const pam_handle_t* pamh, const char *host, const char *user, const char *group)
45
+ {
46
++#ifdef HAVE_INNETGR
47
+ 	if (innetgr(group, host, user, NULL) == 1)
48
+ 		return PAM_SUCCESS;
49
++#else
50
++        pam_syslog (pamh, LOG_ERR, "pam_succeed_if does not have netgroup support");
51
++#endif
52
++
53
+ 	return PAM_AUTH_ERR;
54
+ }
55
+ /* Return PAM_SUCCESS if the (host,user) is NOT in the netgroup. */
56
+ static int
57
+-evaluate_notinnetgr(const char *host, const char *user, const char *group)
58
++evaluate_notinnetgr(const pam_handle_t* pamh, const char *host, const char *user, const char *group)
59
+ {
60
++#ifdef HAVE_INNETGR
61
+ 	if (innetgr(group, host, user, NULL) == 0)
62
+ 		return PAM_SUCCESS;
63
++#else
64
++	pam_syslog (pamh, LOG_ERR, "pam_succeed_if does not have netgroup support");
65
++#endif
66
+ 	return PAM_AUTH_ERR;
67
+ }
68
+ 
69
+@@ -387,14 +396,14 @@ evaluate(pam_handle_t *pamh, int debug,
70
+ 		const void *rhost;
71
+ 		if (pam_get_item(pamh, PAM_RHOST, &rhost) != PAM_SUCCESS)
72
+ 			rhost = NULL;
73
+-		return evaluate_innetgr(rhost, user, right);
74
++		return evaluate_innetgr(pamh, rhost, user, right);
75
+ 	}
76
+ 	/* (Rhost, user) is not in this group. */
77
+ 	if (strcasecmp(qual, "notinnetgr") == 0) {
78
+ 		const void *rhost;
79
+ 		if (pam_get_item(pamh, PAM_RHOST, &rhost) != PAM_SUCCESS)
80
+ 			rhost = NULL;
81
+-		return evaluate_notinnetgr(rhost, user, right);
82
++		return evaluate_notinnetgr(pamh, rhost, user, right);
83
+ 	}
84
+ 	/* Fail closed. */
85
+ 	return PAM_SERVICE_ERR;

+ 68
- 0
libs/libpam/patches/001-no_nis.patch View File

@@ -0,0 +1,68 @@
1
+--- a/modules/pam_access/pam_access.c
2
++++ b/modules/pam_access/pam_access.c
3
+@@ -44,7 +44,7 @@
4
+ #include <arpa/inet.h>
5
+ #include <netdb.h>
6
+ #include <sys/socket.h>
7
+-#ifdef HAVE_RPCSVC_YPCLNT_H
8
++#ifdef HAVE_RPCSVC_YPCLNT_H && USE_NIS
9
+ #include <rpcsvc/ypclnt.h>
10
+ #endif
11
+ #ifdef HAVE_LIBAUDIT
12
+--- a/modules/pam_unix/pam_unix_passwd.c
13
++++ b/modules/pam_unix/pam_unix_passwd.c
14
+@@ -79,18 +79,18 @@
15
+ #include "passverify.h"
16
+ #include "bigcrypt.h"
17
+ 
18
+-#if (HAVE_YP_GET_DEFAULT_DOMAIN || HAVE_GETDOMAINNAME) && HAVE_YP_MASTER
19
++#if (HAVE_YP_GET_DEFAULT_DOMAIN || HAVE_GETDOMAINNAME) && HAVE_YP_MASTER && USE_NIS
20
+ # define HAVE_NIS
21
+ #endif
22
+ 
23
+ #ifdef HAVE_NIS
24
+ # include <rpc/rpc.h>
25
+ 
26
+-# if HAVE_RPCSVC_YP_PROT_H
27
++# if HAVE_RPCSVC_YP_PROT_H && USE_NIS
28
+ #  include <rpcsvc/yp_prot.h>
29
+ # endif
30
+ 
31
+-# if HAVE_RPCSVC_YPCLNT_H
32
++# if HAVE_RPCSVC_YPCLNT_H && USE_NIS
33
+ #  include <rpcsvc/ypclnt.h>
34
+ # endif
35
+ 
36
+--- a/modules/pam_unix/support.c
37
++++ b/modules/pam_unix/support.c
38
+@@ -19,7 +19,7 @@
39
+ #include <ctype.h>
40
+ #include <syslog.h>
41
+ #include <sys/resource.h>
42
+-#ifdef HAVE_RPCSVC_YPCLNT_H
43
++#ifdef HAVE_RPCSVC_YPCLNT_H && USE_NIS
44
+ #include <rpcsvc/ypclnt.h>
45
+ #endif
46
+ 
47
+@@ -402,7 +402,7 @@ int _unix_getpwnam(pam_handle_t *pamh, c
48
+ 		}
49
+ 	}
50
+ 
51
+-#if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined (HAVE_YP_BIND) && defined (HAVE_YP_MATCH) && defined (HAVE_YP_UNBIND)
52
++#if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined (HAVE_YP_BIND) && defined (HAVE_YP_MATCH) && defined (HAVE_YP_UNBIND) && (USE_NIS)
53
+ 	if (!matched && nis) {
54
+ 		char *userinfo = NULL, *domain = NULL;
55
+ 		int len = 0, i;
56
+--- a/modules/pam_unix/yppasswd_xdr.c
57
++++ b/modules/pam_unix/yppasswd_xdr.c
58
+@@ -15,6 +15,10 @@
59
+ #ifdef HAVE_RPC_RPC_H
60
+ 
61
+ #include <rpc/rpc.h>
62
++#ifdef USE_NIS
63
++#include <rpcsvc/yp_prot.h>
64
++#include <rpcsvc/ypclnt.h>
65
++#endif
66
+ #include "yppasswd.h"
67
+ 
68
+ bool_t

+ 26
- 0
libs/libpam/patches/002-no_yywrap.patch View File

@@ -0,0 +1,26 @@
1
+--- a/conf/pam_conv1/pam_conv_l.c
2
++++ b/conf/pam_conv1/pam_conv_l.c
3
+@@ -534,7 +534,9 @@ void yyset_lineno (int line_number  );
4
+ #ifdef __cplusplus
5
+ extern "C" int yywrap (void );
6
+ #else
7
+-extern int yywrap (void );
8
++int yywrap (void ) {
9
++	return 1;
10
++}
11
+ #endif
12
+ #endif
13
+ 
14
+--- a/doc/specs/parse_l.c
15
++++ b/doc/specs/parse_l.c
16
+@@ -520,7 +520,9 @@ void yyset_lineno (int line_number  );
17
+ #ifdef __cplusplus
18
+ extern "C" int yywrap (void );
19
+ #else
20
+-extern int yywrap (void );
21
++int yywrap (void ) {
22
++	return 1;
23
++}
24
+ #endif
25
+ #endif
26
+ 

+ 22
- 0
libs/libpam/patches/003-no_doc.patch View File

@@ -0,0 +1,22 @@
1
+--- a/Makefile.am
2
++++ b/Makefile.am
3
+@@ -4,7 +4,7 @@
4
+ 
5
+ AUTOMAKE_OPTIONS = 1.9 gnu dist-bzip2 check-news
6
+ 
7
+-SUBDIRS = libpam tests libpamc libpam_misc modules po conf doc examples xtests
8
++SUBDIRS = libpam tests libpamc libpam_misc modules po conf examples xtests
9
+ 
10
+ CLEANFILES = *~
11
+ 
12
+--- a/Makefile.in
13
++++ b/Makefile.in
14
+@@ -288,7 +288,7 @@ top_build_prefix = @top_build_prefix@
15
+ top_builddir = @top_builddir@
16
+ top_srcdir = @top_srcdir@
17
+ AUTOMAKE_OPTIONS = 1.9 gnu dist-bzip2 check-news
18
+-SUBDIRS = libpam tests libpamc libpam_misc modules po conf doc examples xtests
19
++SUBDIRS = libpam tests libpamc libpam_misc modules po conf examples xtests
20
+ CLEANFILES = *~
21
+ EXTRA_DIST = pgp.keys.asc CHANGELOG ChangeLog-CVS Copyright Make.xml.rules
22
+ ACLOCAL_AMFLAGS = -I m4

+ 16
- 0
libs/libpam/patches/004-fix_lib64.patch View File

@@ -0,0 +1,16 @@
1
+--- a/configure.in
2
++++ b/configure.in
3
+@@ -28,12 +28,7 @@ dnl If we use /usr as prefix, use /etc f
4
+         fi
5
+ 	if test ${libdir} = '${exec_prefix}/lib'
6
+ 	then
7
+-		case "`uname -m`" in
8
+-		    x86_64|ppc64|s390x|sparc64)
9
+-			libdir="/lib64" ;;
10
+-		    *)
11
+-			libdir="/lib" ;;
12
+-		esac
13
++		libdir="/lib"
14
+ 	fi
15
+ 	if test ${sbindir} = '${exec_prefix}/sbin'
16
+         then

+ 364
- 0
libs/libpam/patches/005-fix_ruserok.patch View File

@@ -0,0 +1,364 @@
1
+--- a/modules/pam_rhosts/pam_rhosts.c
2
++++ b/modules/pam_rhosts/pam_rhosts.c
3
+@@ -43,6 +43,361 @@
4
+ #include <security/pam_modutil.h>
5
+ #include <security/pam_ext.h>
6
+ 
7
++#ifdef __UCLIBC__
8
++
9
++#include <stdio.h>
10
++#include <sys/stat.h>
11
++
12
++
13
++int  __check_rhosts_file = 1;
14
++
15
++/* Extremely paranoid file open function. */
16
++static FILE *
17
++iruserfopen (const char *file, uid_t okuser)
18
++{
19
++  struct stat st;
20
++  char *cp = NULL;
21
++  FILE *res = NULL;
22
++
23
++  /* If not a regular file, if owned by someone other than user or
24
++     root, if writeable by anyone but the owner, or if hardlinked
25
++     anywhere, quit.  */
26
++  if (lstat (file, &st))
27
++    cp = "lstat failed";
28
++  else if (!S_ISREG (st.st_mode))
29
++    cp = "not regular file";
30
++  else
31
++    {
32
++      res = fopen (file, "r");
33
++      if (!res)
34
++	cp = "cannot open";
35
++      else if (fstat (fileno (res), &st) < 0)
36
++	cp = "fstat failed";
37
++      else if (st.st_uid && st.st_uid != okuser)
38
++	cp = "bad owner";
39
++      else if (st.st_mode & (S_IWGRP|S_IWOTH))
40
++	cp = "writeable by other than owner";
41
++      else if (st.st_nlink > 1)
42
++	cp = "hard linked somewhere";
43
++    }
44
++
45
++  /* If there were any problems, quit.  */
46
++  if (cp != NULL)
47
++    {
48
++      if (res)
49
++	fclose (res);
50
++      return NULL;
51
++    }
52
++
53
++  return res;
54
++}
55
++
56
++/*
57
++ * Returns 1 for blank lines (or only comment lines) and 0 otherwise
58
++ */
59
++static int
60
++__isempty(char *p)
61
++{
62
++    while (*p && isspace (*p)) {
63
++	++p;
64
++    }
65
++
66
++    return (*p == '\0' || *p == '#') ? 1 : 0 ;
67
++}
68
++
69
++/* Returns 1 on positive match, 0 on no match, -1 on negative match.  */
70
++static int
71
++__icheckhost (u_int32_t raddr, char *lhost, const char *rhost)
72
++{
73
++	struct hostent *hp;
74
++	u_int32_t laddr;
75
++	int negate=1;    /* Multiply return with this to get -1 instead of 1 */
76
++	char **pp;
77
++
78
++#ifdef __UCLIBC_HAS_REENTRANT_RPC__
79
++	int save_errno;
80
++	size_t buflen;
81
++	char *buffer;
82
++	struct hostent hostbuf;
83
++	int herr;
84
++#endif
85
++
86
++#ifdef HAVE_NETGROUP
87
++	/* Check nis netgroup.  */
88
++	if (strncmp ("+@", lhost, 2) == 0)
89
++		return innetgr (&lhost[2], rhost, NULL, NULL);
90
++
91
++	if (strncmp ("-@", lhost, 2) == 0)
92
++		return -innetgr (&lhost[2], rhost, NULL, NULL);
93
++#endif /* HAVE_NETGROUP */
94
++
95
++	/* -host */
96
++	if (strncmp ("-", lhost,1) == 0) {
97
++		negate = -1;
98
++		lhost++;
99
++	} else if (strcmp ("+",lhost) == 0) {
100
++		return 1;                    /* asking for trouble, but ok.. */
101
++	}
102
++
103
++	/* Try for raw ip address first. */
104
++	if (isdigit (*lhost) && (laddr = inet_addr (lhost)) != INADDR_NONE)
105
++		return negate * (! (raddr ^ laddr));
106
++
107
++	/* Better be a hostname. */
108
++#ifdef __UCLIBC_HAS_REENTRANT_RPC__
109
++	buflen = 1024;
110
++	buffer = malloc(buflen);
111
++	save_errno = errno;
112
++
113
++	while (gethostbyname_r (lhost, &hostbuf, buffer, buflen, &hp, &herr)
114
++	       != 0) {
115
++	    free(buffer);
116
++	    return (0);
117
++	}
118
++	free(buffer);
119
++	__set_errno (save_errno);
120
++#else
121
++	hp = gethostbyname(lhost);
122
++#endif /* __UCLIBC_HAS_REENTRANT_RPC__ */
123
++
124
++	if (hp == NULL)
125
++		return 0;
126
++
127
++	/* Spin through ip addresses. */
128
++	for (pp = hp->h_addr_list; *pp; ++pp)
129
++		if (!memcmp (&raddr, *pp, sizeof (u_int32_t)))
130
++			return negate;
131
++
132
++	/* No match. */
133
++	return (0);
134
++}
135
++
136
++/* Returns 1 on positive match, 0 on no match, -1 on negative match.  */
137
++static int
138
++__icheckuser (const char *luser, const char *ruser)
139
++{
140
++
141
++    /*
142
++      luser is user entry from .rhosts/hosts.equiv file
143
++      ruser is user id on remote host
144
++      */
145
++
146
++#ifdef HAVE_NETGROUP
147
++    /* [-+]@netgroup */
148
++    if (strncmp ("+@", luser, 2) == 0)
149
++	return innetgr (&luser[2], NULL, ruser, NULL);
150
++
151
++    if (strncmp ("-@", luser,2) == 0)
152
++	return -innetgr (&luser[2], NULL, ruser, NULL);
153
++#endif /* HAVE_NETGROUP */
154
++
155
++    /* -user */
156
++    if (strncmp ("-", luser, 1) == 0)
157
++	return -(strcmp (&luser[1], ruser) == 0);
158
++
159
++    /* + */
160
++    if (strcmp ("+", luser) == 0)
161
++	return 1;
162
++
163
++    /* simple string match */
164
++    return strcmp (ruser, luser) == 0;
165
++}
166
++
167
++/*
168
++ * Returns 0 if positive match, -1 if _not_ ok.
169
++ */
170
++static int
171
++__ivaliduser2(FILE *hostf, u_int32_t raddr,	const char *luser,
172
++			  const char *ruser, const char *rhost)
173
++{
174
++    register const char *user;
175
++    register char *p;
176
++    int hcheck, ucheck;
177
++    char *buf = NULL;
178
++    size_t bufsize = 0;
179
++    int retval = -1;
180
++
181
++    while (getline (&buf, &bufsize, hostf) > 0) {
182
++	buf[bufsize - 1] = '\0'; /* Make sure it's terminated.  */
183
++        p = buf;
184
++
185
++	/* Skip empty or comment lines */
186
++	if (__isempty (p)) {
187
++	    continue;
188
++	}
189
++
190
++	/* Skip lines that are too long. */
191
++	if (strchr (p, '\n') == NULL) {
192
++	    int ch = getc_unlocked (hostf);
193
++
194
++	    while (ch != '\n' && ch != EOF)
195
++	      ch = getc_unlocked (hostf);
196
++	    continue;
197
++	}
198
++
199
++	for (;*p && !isspace(*p); ++p) {
200
++	    *p = tolower (*p);
201
++	}
202
++
203
++	/* Next we want to find the permitted name for the remote user.  */
204
++	if (*p == ' ' || *p == '\t') {
205
++	    /* <nul> terminate hostname and skip spaces */
206
++	    for (*p++='\0'; *p && isspace (*p); ++p);
207
++
208
++	    user = p;                   /* this is the user's name */
209
++	    while (*p && !isspace (*p))
210
++		++p;                    /* find end of user's name */
211
++	} else
212
++	    user = p;
213
++
214
++	*p = '\0';              /* <nul> terminate username (+host?) */
215
++
216
++	/* buf -> host(?) ; user -> username(?) */
217
++
218
++	/* First check host part */
219
++	hcheck = __icheckhost (raddr, buf, rhost);
220
++
221
++	if (hcheck < 0)
222
++	    break;
223
++
224
++	if (hcheck) {
225
++	    /* Then check user part */
226
++	    if (! (*user))
227
++		user = luser;
228
++
229
++	    ucheck = __icheckuser (user, ruser);
230
++
231
++	    /* Positive 'host user' match? */
232
++	    if (ucheck > 0) {
233
++		retval = 0;
234
++		break;
235
++	    }
236
++
237
++	    /* Negative 'host -user' match? */
238
++	    if (ucheck < 0)
239
++		break;
240
++
241
++	    /* Neither, go on looking for match */
242
++	}
243
++    }
244
++
245
++    free (buf);
246
++
247
++    return retval;
248
++}
249
++
250
++static int
251
++iruserok2 (u_int32_t raddr, int superuser, const char *ruser, const char *luser,
252
++		   const char *rhost)
253
++{
254
++	FILE *hostf = NULL;
255
++	int isbad = -1;
256
++
257
++	if (!superuser)
258
++		hostf = iruserfopen (_PATH_HEQUIV, 0);
259
++
260
++	if (hostf) {
261
++		isbad = __ivaliduser2 (hostf, raddr, luser, ruser, rhost);
262
++		fclose (hostf);
263
++
264
++		if (!isbad)
265
++			return 0;
266
++	}
267
++
268
++	if (__check_rhosts_file || superuser) {
269
++		char *pbuf;
270
++		struct passwd *pwd;
271
++		size_t dirlen;
272
++		uid_t uid;
273
++
274
++#ifdef __UCLIBC_HAS_REENTRANT_RPC__
275
++		size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
276
++		struct passwd pwdbuf;
277
++		char *buffer = stack_heap_alloc(buflen);
278
++
279
++		if (getpwnam_r (luser, &pwdbuf, buffer,
280
++			    buflen, &pwd) != 0 || pwd == NULL)
281
++		{
282
++			stack_heap_free(buffer);
283
++			return -1;
284
++		}
285
++		stack_heap_free(buffer);
286
++#else
287
++		if ((pwd = getpwnam(luser)) == NULL)
288
++			return -1;
289
++#endif
290
++
291
++		dirlen = strlen (pwd->pw_dir);
292
++		pbuf = malloc (dirlen + sizeof "/.rhosts");
293
++		strcpy (pbuf, pwd->pw_dir);
294
++		strcat (pbuf, "/.rhosts");
295
++
296
++		/* Change effective uid while reading .rhosts.  If root and
297
++		   reading an NFS mounted file system, can't read files that
298
++		   are protected read/write owner only.  */
299
++		uid = geteuid ();
300
++		seteuid (pwd->pw_uid);
301
++		hostf = iruserfopen (pbuf, pwd->pw_uid);
302
++		free(pbuf);
303
++
304
++		if (hostf != NULL) {
305
++			isbad = __ivaliduser2 (hostf, raddr, luser, ruser, rhost);
306
++			fclose (hostf);
307
++		}
308
++
309
++		seteuid (uid);
310
++		return isbad;
311
++	}
312
++	return -1;
313
++}
314
++
315
++int ruserok(const char *rhost, int superuser, const char *ruser,
316
++			const char *luser)
317
++{
318
++        struct hostent *hp;
319
++	u_int32_t addr;
320
++	char **ap;
321
++#ifdef __UCLIBC_HAS_REENTRANT_RPC__
322
++	size_t buflen;
323
++	char *buffer;
324
++	int herr;
325
++	struct hostent hostbuf;
326
++#endif
327
++
328
++#ifdef __UCLIBC_HAS_REENTRANT_RPC__
329
++	buflen = 1024;
330
++	buffer = stack_heap_alloc(buflen);
331
++
332
++	while (gethostbyname_r (rhost, &hostbuf, buffer,
333
++		    buflen, &hp, &herr) != 0 || hp == NULL)
334
++	{
335
++	    if (herr != NETDB_INTERNAL || errno != ERANGE) {
336
++		stack_heap_free(buffer);
337
++		return -1;
338
++	    } else
339
++	    {
340
++		/* Enlarge the buffer.  */
341
++		buflen *= 2;
342
++		stack_heap_free(buffer);
343
++		buffer = stack_heap_alloc(buflen);
344
++	    }
345
++	}
346
++	stack_heap_free(buffer);
347
++#else
348
++	if ((hp = gethostbyname(rhost)) == NULL) {
349
++		return -1;
350
++	}
351
++#endif
352
++	for (ap = hp->h_addr_list; *ap; ++ap) {
353
++		memmove(&addr, *ap, sizeof(addr));
354
++		if (iruserok2(addr, superuser, ruser, luser, rhost) == 0)
355
++			return 0;
356
++	}
357
++	return -1;
358
++}
359
++
360
++#endif /* __UCLIBC__ */
361
++
362
+ PAM_EXTERN
363
+ int pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc,
364
+ 			 const char **argv)

+ 271
- 0
libs/libpam/patches/006-fix_xdr.patch View File

@@ -0,0 +1,271 @@
1
+--- a/modules/pam_unix/yppasswd_xdr.c
2
++++ b/modules/pam_unix/yppasswd_xdr.c
3
+@@ -21,6 +21,268 @@
4
+ #endif
5
+ #include "yppasswd.h"
6
+ 
7
++#ifdef __UCLIBC__
8
++
9
++static const char xdr_zero[BYTES_PER_XDR_UNIT] = {0, 0, 0, 0};
10
++
11
++/*
12
++ * XDR integers
13
++ */
14
++bool_t
15
++xdr_int (XDR *xdrs, int *ip)
16
++{
17
++
18
++#if INT_MAX < LONG_MAX
19
++  long l;
20
++
21
++  switch (xdrs->x_op)
22
++    {
23
++    case XDR_ENCODE:
24
++      l = (long) *ip;
25
++      return XDR_PUTLONG (xdrs, &l);
26
++
27
++    case XDR_DECODE:
28
++      if (!XDR_GETLONG (xdrs, &l))
29
++	{
30
++	  return FALSE;
31
++	}
32
++      *ip = (int) l;
33
++    case XDR_FREE:
34
++      return TRUE;
35
++    }
36
++  return FALSE;
37
++#elif INT_MAX == LONG_MAX
38
++  return xdr_long (xdrs, (long *) ip);
39
++#elif INT_MAX == SHRT_MAX
40
++  return xdr_short (xdrs, (short *) ip);
41
++#else
42
++#error unexpected integer sizes in xdr_int()
43
++#endif
44
++}
45
++
46
++/*
47
++ * XDR null terminated ASCII strings
48
++ * xdr_string deals with "C strings" - arrays of bytes that are
49
++ * terminated by a NULL character.  The parameter cpp references a
50
++ * pointer to storage; If the pointer is null, then the necessary
51
++ * storage is allocated.  The last parameter is the max allowed length
52
++ * of the string as specified by a protocol.
53
++ */
54
++bool_t
55
++xdr_string (XDR *xdrs, char **cpp, u_int maxsize)
56
++{
57
++  char *sp = *cpp;	/* sp is the actual string pointer */
58
++  u_int size;
59
++  u_int nodesize;
60
++
61
++  /*
62
++   * first deal with the length since xdr strings are counted-strings
63
++   */
64
++  switch (xdrs->x_op)
65
++    {
66
++    case XDR_FREE:
67
++      if (sp == NULL)
68
++	{
69
++	  return TRUE;		/* already free */
70
++	}
71
++      /* fall through... */
72
++    case XDR_ENCODE:
73
++      if (sp == NULL)
74
++	return FALSE;
75
++      size = strlen (sp);
76
++      break;
77
++    case XDR_DECODE:
78
++      break;
79
++    }
80
++  if (!xdr_u_int (xdrs, &size))
81
++    {
82
++      return FALSE;
83
++    }
84
++  if (size > maxsize)
85
++    {
86
++      return FALSE;
87
++    }
88
++  nodesize = size + 1;
89
++
90
++  /*
91
++   * now deal with the actual bytes
92
++   */
93
++  switch (xdrs->x_op)
94
++    {
95
++    case XDR_DECODE:
96
++      if (nodesize == 0)
97
++	{
98
++	  return TRUE;
99
++	}
100
++      if (sp == NULL)
101
++	*cpp = sp = (char *) mem_alloc (nodesize);
102
++      if (sp == NULL)
103
++	{
104
++#ifdef USE_IN_LIBIO
105
++	  if (_IO_fwide (stderr, 0) > 0)
106
++	    (void) fwprintf (stderr, L"%s",
107
++			       _("xdr_string: out of memory\n"));
108
++	  else
109
++#endif
110
++	    (void) fputs (_("xdr_string: out of memory\n"), stderr);
111
++	  return FALSE;
112
++	}
113
++      sp[size] = 0;
114
++      /* fall into ... */
115
++
116
++    case XDR_ENCODE:
117
++      return xdr_opaque (xdrs, sp, size);
118
++
119
++    case XDR_FREE:
120
++      mem_free (sp, nodesize);
121
++      *cpp = NULL;
122
++      return TRUE;
123
++    }
124
++  return FALSE;
125
++}
126
++
127
++/*
128
++ * XDR long integers
129
++ * The definition of xdr_long() is kept for backward
130
++ * compatibility. Instead xdr_int() should be used.
131
++ */
132
++bool_t
133
++xdr_long (XDR *xdrs, long *lp)
134
++{
135
++  if (xdrs->x_op == XDR_ENCODE
136
++      && (sizeof (int32_t) == sizeof (long)
137
++	  || (int32_t) *lp == *lp))
138
++    return XDR_PUTLONG (xdrs, lp);
139
++
140
++  if (xdrs->x_op == XDR_DECODE)
141
++    return XDR_GETLONG (xdrs, lp);
142
++
143
++  if (xdrs->x_op == XDR_FREE)
144
++    return TRUE;
145
++
146
++  return FALSE;
147
++}
148
++
149
++/*
150
++ * XDR unsigned integers
151
++ */
152
++bool_t
153
++xdr_u_int (XDR *xdrs, u_int *up)
154
++{
155
++#if UINT_MAX < ULONG_MAX
156
++  u_long l;
157
++
158
++  switch (xdrs->x_op)
159
++    {
160
++    case XDR_ENCODE:
161
++      l = (u_long) * up;
162
++      return XDR_PUTLONG (xdrs, (long *) &l);
163
++
164
++    case XDR_DECODE:
165
++      if (!XDR_GETLONG (xdrs, (long *) &l))
166
++	{
167
++	  return FALSE;
168
++	}
169
++      *up = (u_int) l;
170
++    case XDR_FREE:
171
++      return TRUE;
172
++    }
173
++  return FALSE;
174
++#elif UINT_MAX == ULONG_MAX
175
++  return xdr_u_long (xdrs, (u_long *) up);
176
++#elif UINT_MAX == USHRT_MAX
177
++  return xdr_short (xdrs, (short *) up);
178
++#else
179
++#error unexpected integer sizes in xdr_u_int()
180
++#endif
181
++}
182
++
183
++/*
184
++ * XDR opaque data
185
++ * Allows the specification of a fixed size sequence of opaque bytes.
186
++ * cp points to the opaque object and cnt gives the byte length.
187
++ */
188
++bool_t
189
++xdr_opaque (XDR *xdrs, caddr_t cp, u_int cnt)
190
++{
191
++  u_int rndup;
192
++  static char crud[BYTES_PER_XDR_UNIT];
193
++
194
++  /*
195
++   * if no data we are done
196
++   */
197
++  if (cnt == 0)
198
++    return TRUE;
199
++
200
++  /*
201
++   * round byte count to full xdr units
202
++   */
203
++  rndup = cnt % BYTES_PER_XDR_UNIT;
204
++  if (rndup > 0)
205
++    rndup = BYTES_PER_XDR_UNIT - rndup;
206
++
207
++  switch (xdrs->x_op)
208
++    {
209
++    case XDR_DECODE:
210
++      if (!XDR_GETBYTES (xdrs, cp, cnt))
211
++	{
212
++	  return FALSE;
213
++	}
214
++      if (rndup == 0)
215
++	return TRUE;
216
++      return XDR_GETBYTES (xdrs, (caddr_t)crud, rndup);
217
++
218
++    case XDR_ENCODE:
219
++      if (!XDR_PUTBYTES (xdrs, cp, cnt))
220
++	{
221
++	  return FALSE;
222
++	}
223
++      if (rndup == 0)
224
++	return TRUE;
225
++      return XDR_PUTBYTES (xdrs, xdr_zero, rndup);
226
++
227
++    case XDR_FREE:
228
++      return TRUE;
229
++    }
230
++  return FALSE;
231
++}
232
++
233
++/*
234
++ * XDR unsigned long integers
235
++ * The definition of xdr_u_long() is kept for backward
236
++ * compatibility. Instead xdr_u_int() should be used.
237
++ */
238
++bool_t
239
++xdr_u_long (XDR *xdrs, u_long *ulp)
240
++{
241
++  switch (xdrs->x_op)
242
++    {
243
++    case XDR_DECODE:
244
++      {
245
++	long int tmp;
246
++
247
++	if (XDR_GETLONG (xdrs, &tmp) == FALSE)
248
++	  return FALSE;
249
++
250
++	*ulp = (uint32_t) tmp;
251
++	return TRUE;
252
++      }
253
++
254
++    case XDR_ENCODE:
255
++      if (sizeof (uint32_t) != sizeof (u_long)
256
++	  && (uint32_t) *ulp != *ulp)
257
++	return FALSE;
258
++
259
++      return XDR_PUTLONG (xdrs, (long *) ulp);
260
++
261
++    case XDR_FREE:
262
++      return TRUE;
263
++    }
264
++  return FALSE;
265
++}
266
++
267
++#endif /* UCLIBC */
268
++
269
+ bool_t
270
+ xdr_xpasswd(XDR * xdrs, xpasswd * objp)
271
+ {