1 |
commit: 949eefbfce316c692cf4c367a533e34e163d4de6 |
2 |
Author: Sam James <sam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Sep 7 04:44:38 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Sep 7 04:44:51 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=949eefbf |
7 |
|
8 |
dev-libs/libpwquality: fix fgetpwent_r usage on musl |
9 |
|
10 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
11 |
|
12 |
.../libpwquality-1.4.4-musl-fgetpwent_r.patch | 42 ++++++++++ |
13 |
.../libpwquality-1.4.4-pam_pwquality-include.patch | 35 +++++++++ |
14 |
dev-libs/libpwquality/libpwquality-1.4.4-r2.ebuild | 91 ++++++++++++++++++++++ |
15 |
3 files changed, 168 insertions(+) |
16 |
|
17 |
diff --git a/dev-libs/libpwquality/files/libpwquality-1.4.4-musl-fgetpwent_r.patch b/dev-libs/libpwquality/files/libpwquality-1.4.4-musl-fgetpwent_r.patch |
18 |
new file mode 100644 |
19 |
index 000000000000..6cfb538103ae |
20 |
--- /dev/null |
21 |
+++ b/dev-libs/libpwquality/files/libpwquality-1.4.4-musl-fgetpwent_r.patch |
22 |
@@ -0,0 +1,42 @@ |
23 |
+https://github.com/libpwquality/libpwquality/commit/9084c1b032161cdb53d5f66132a91bdc207faecf |
24 |
+ |
25 |
+From: Noel Kuntze <noel.kuntze@××××××.consulting> |
26 |
+Date: Mon, 24 May 2021 14:15:34 +0200 |
27 |
+Subject: [PATCH] pam_pwquality.c: Use pam_modutil_check_user_in_passwd instead |
28 |
+ of fgetpwent_r (not available on musl) |
29 |
+ |
30 |
+--- a/configure.ac |
31 |
++++ b/configure.ac |
32 |
+@@ -97,6 +97,11 @@ if test "$enable_pam" != "no"; then |
33 |
+ test $fail = 1 && |
34 |
+ AC_MSG_ERROR([You must install the PAM development package in order to compile libpwquality]) |
35 |
+ fi |
36 |
++ AC_CHECK_FUNC( |
37 |
++ [pam_modutil_check_user_in_passwd], |
38 |
++ [AC_DEFINE([HAVE_PAM_CHECK_USER_IN_PASSWD], [], [have pam_modutil_check_user_in_passwd])], |
39 |
++ [] |
40 |
++ ) |
41 |
+ fi |
42 |
+ |
43 |
+ if test "$enable_pam" = "yes"; then |
44 |
+--- a/src/pam_pwquality.c |
45 |
++++ b/src/pam_pwquality.c |
46 |
+@@ -98,6 +98,9 @@ static int |
47 |
+ check_local_user (pam_handle_t *pamh, |
48 |
+ const char *user) |
49 |
+ { |
50 |
++#ifdef HAVE_PAM_CHECK_USER_IN_PASSWD |
51 |
++ return pam_modutil_check_user_in_passwd(pamh, user, NULL) == PAM_SUCCESS; |
52 |
++#else |
53 |
+ struct passwd pw, *pwp; |
54 |
+ char buf[4096]; |
55 |
+ int found = 0; |
56 |
+@@ -136,6 +139,7 @@ check_local_user (pam_handle_t *pamh, |
57 |
+ } else { |
58 |
+ return found; |
59 |
+ } |
60 |
++#endif |
61 |
+ } |
62 |
+ |
63 |
+ PAM_EXTERN int |
64 |
+ |
65 |
|
66 |
diff --git a/dev-libs/libpwquality/files/libpwquality-1.4.4-pam_pwquality-include.patch b/dev-libs/libpwquality/files/libpwquality-1.4.4-pam_pwquality-include.patch |
67 |
new file mode 100644 |
68 |
index 000000000000..2ed638c1e34a |
69 |
--- /dev/null |
70 |
+++ b/dev-libs/libpwquality/files/libpwquality-1.4.4-pam_pwquality-include.patch |
71 |
@@ -0,0 +1,35 @@ |
72 |
+https://github.com/libpwquality/libpwquality/pull/62 |
73 |
+ |
74 |
+From 27057c6cbf528108c35df934280c7dd83e8d5ce9 Mon Sep 17 00:00:00 2001 |
75 |
+From: Sam James <sam@g.o> |
76 |
+Date: Wed, 7 Sep 2022 05:42:17 +0100 |
77 |
+Subject: [PATCH] pam_pwquality: add include for |
78 |
+ pam_modutil_check_user_in_passwd |
79 |
+ |
80 |
+After 9084c1b032161cdb53d5f66132a91bdc207faecf, one gets: |
81 |
+``` |
82 |
+pam_pwquality.c: In function 'check_local_user': |
83 |
+pam_pwquality.c:102:16: error: implicit declaration of function 'pam_modutil_check_user_in_passwd' [-Werror=implicit-function-declaration] |
84 |
+ 102 | return pam_modutil_check_user_in_passwd(pamh, user, NULL) == PAM_SUCCESS; |
85 |
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
86 |
+cc1: some warnings being treated as errors |
87 |
+make[2]: *** [Makefile:634: pam_pwquality.lo] Error 1 |
88 |
+make[2]: *** Waiting for unfinished jobs.... |
89 |
+``` |
90 |
+ |
91 |
+We need to include security/pam_modutil.h when appropriate. |
92 |
+ |
93 |
+Signed-off-by: Sam James <sam@g.o> |
94 |
+--- a/src/pam_pwquality.c |
95 |
++++ b/src/pam_pwquality.c |
96 |
+@@ -34,6 +34,10 @@ |
97 |
+ #include <security/_pam_macros.h> |
98 |
+ #include <security/pam_ext.h> |
99 |
+ |
100 |
++#ifdef HAVE_PAM_CHECK_USER_IN_PASSWD |
101 |
++#include <security/pam_modutil.h> |
102 |
++#endif |
103 |
++ |
104 |
+ /* argument parsing */ |
105 |
+ #define PAM_DEBUG_ARG 0x0001 |
106 |
+ |
107 |
|
108 |
diff --git a/dev-libs/libpwquality/libpwquality-1.4.4-r2.ebuild b/dev-libs/libpwquality/libpwquality-1.4.4-r2.ebuild |
109 |
new file mode 100644 |
110 |
index 000000000000..460d78a4c2b0 |
111 |
--- /dev/null |
112 |
+++ b/dev-libs/libpwquality/libpwquality-1.4.4-r2.ebuild |
113 |
@@ -0,0 +1,91 @@ |
114 |
+# Copyright 1999-2022 Gentoo Authors |
115 |
+# Distributed under the terms of the GNU General Public License v2 |
116 |
+ |
117 |
+EAPI=8 |
118 |
+ |
119 |
+PYTHON_COMPAT=( python3_{8..10} ) |
120 |
+inherit autotools pam python-r1 usr-ldscript |
121 |
+ |
122 |
+DESCRIPTION="Library for password quality checking and generating random passwords" |
123 |
+HOMEPAGE="https://github.com/libpwquality/libpwquality" |
124 |
+SRC_URI="https://github.com/${PN}/${PN}/releases/download/${P}/${P}.tar.bz2" |
125 |
+ |
126 |
+LICENSE="|| ( BSD GPL-2 )" |
127 |
+SLOT="0" |
128 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" |
129 |
+IUSE="pam python static-libs" |
130 |
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" |
131 |
+ |
132 |
+BDEPEND=" |
133 |
+ >=sys-devel/gettext-0.18.2 |
134 |
+ virtual/pkgconfig |
135 |
+" |
136 |
+RDEPEND=" |
137 |
+ >=sys-libs/cracklib-2.8:=[static-libs(+)?] |
138 |
+ pam? ( sys-libs/pam ) |
139 |
+ python? ( ${PYTHON_DEPS} ) |
140 |
+" |
141 |
+DEPEND="${RDEPEND}" |
142 |
+ |
143 |
+PATCHES=( |
144 |
+ "${FILESDIR}"/${P}-musl-fgetpwent_r.patch |
145 |
+ "${FILESDIR}"/${PN}-1.4.4-pam_pwquality-include.patch |
146 |
+) |
147 |
+ |
148 |
+src_prepare() { |
149 |
+ default |
150 |
+ # ensure pkgconfig files go in /usr |
151 |
+ sed -e "s:\(pkgconfigdir *=\).*:\1 ${EPREFIX}/usr/$(get_libdir)/pkgconfig:" \ |
152 |
+ -i src/Makefile.{am,in} || die "sed failed" |
153 |
+ |
154 |
+ # Needed for musl patch, drop on next release |
155 |
+ eautoreconf |
156 |
+ |
157 |
+ if use python ; then |
158 |
+ # bug #830397 |
159 |
+ export SETUPTOOLS_USE_DISTUTILS=stdlib |
160 |
+ python_copy_sources |
161 |
+ fi |
162 |
+} |
163 |
+ |
164 |
+src_configure() { |
165 |
+ # Install library in /lib for pam |
166 |
+ configuring() { |
167 |
+ local sitedir |
168 |
+ econf \ |
169 |
+ --libdir="${EPREFIX}/$(get_libdir)" \ |
170 |
+ $(use_enable pam) \ |
171 |
+ --with-securedir="${EPREFIX}/$(getpam_mod_dir)" \ |
172 |
+ $(use_enable python python-bindings) \ |
173 |
+ $(usex python "--with-pythonsitedir=$(use python && python_get_sitedir)" "") \ |
174 |
+ $(use_enable static-libs static) |
175 |
+ } |
176 |
+ if_use_python_python_foreach_impl configuring |
177 |
+} |
178 |
+ |
179 |
+src_compile() { |
180 |
+ if_use_python_python_foreach_impl default |
181 |
+} |
182 |
+ |
183 |
+src_test() { |
184 |
+ if_use_python_python_foreach_impl default |
185 |
+} |
186 |
+ |
187 |
+src_install() { |
188 |
+ if_use_python_python_foreach_impl default |
189 |
+ if use static-libs; then |
190 |
+ # Do not install static libs in /lib |
191 |
+ mkdir -p "${ED}/usr/$(get_libdir)" |
192 |
+ mv "${ED}/$(get_libdir)/libpwquality.a" "${ED}/usr/$(get_libdir)/" || die |
193 |
+ gen_usr_ldscript libpwquality.so |
194 |
+ fi |
195 |
+ find "${ED}" -name '*.la' -delete || die |
196 |
+} |
197 |
+ |
198 |
+if_use_python_python_foreach_impl() { |
199 |
+ if use python; then |
200 |
+ python_foreach_impl run_in_build_dir "$@" |
201 |
+ else |
202 |
+ "$@" |
203 |
+ fi |
204 |
+} |