Gentoo Archives: gentoo-commits

From: Brian Evans <grknight@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-php/pecl-crack/files/, dev-php/pecl-crack/
Date: Thu, 15 Apr 2021 18:51:41
Message-Id: 1618512676.2e1ca55678d2295d2c113536eec2d92b840d1f3f.grknight@gentoo
1 commit: 2e1ca55678d2295d2c113536eec2d92b840d1f3f
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Thu Apr 15 18:51:16 2021 +0000
4 Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 15 18:51:16 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2e1ca556
7
8 dev-php/pecl-crack: Revbump for PHP 8 support
9
10 Signed-off-by: Brian Evans <grknight <AT> gentoo.org>
11
12 dev-php/pecl-crack/files/0.4-php8.patch | 394 ++++++++++++++++++++++++++++
13 dev-php/pecl-crack/pecl-crack-0.4-r8.ebuild | 29 ++
14 2 files changed, 423 insertions(+)
15
16 diff --git a/dev-php/pecl-crack/files/0.4-php8.patch b/dev-php/pecl-crack/files/0.4-php8.patch
17 new file mode 100644
18 index 00000000000..ce5f36f1173
19 --- /dev/null
20 +++ b/dev-php/pecl-crack/files/0.4-php8.patch
21 @@ -0,0 +1,394 @@
22 +diff -aurN a/crack.c b/crack.c
23 +--- a/crack.c 2021-04-15 13:57:12.174874906 -0400
24 ++++ b/crack.c 2021-04-15 14:10:21.203314001 -0400
25 +@@ -68,9 +68,7 @@
26 + /* {{{ crack_module_entry
27 + */
28 + zend_module_entry crack_module_entry = {
29 +-#if ZEND_MODULE_API_NO >= 20010901
30 + STANDARD_MODULE_HEADER,
31 +-#endif
32 + "crack",
33 + crack_functions,
34 + PHP_MINIT(crack),
35 +@@ -78,9 +76,7 @@
36 + PHP_RINIT(crack),
37 + PHP_RSHUTDOWN(crack),
38 + PHP_MINFO(crack),
39 +-#if ZEND_MODULE_API_NO >= 20010901
40 +- "0.3",
41 +-#endif
42 ++ "0.4",
43 + STANDARD_MODULE_PROPERTIES,
44 + };
45 + /* }}} */
46 +@@ -102,57 +98,19 @@
47 + static void php_crack_init_globals(zend_crack_globals *crack_globals)
48 + {
49 + crack_globals->last_message = NULL;
50 +-#if PHP_VERSION_ID >= 70000
51 + crack_globals->default_dict = NULL;
52 +-#else
53 +- crack_globals->default_dict = -1;
54 +-#endif
55 + }
56 + /* }}} */
57 +
58 + /* {{{ php_crack_checkpath
59 + */
60 +-static int php_crack_checkpath(char* path TSRMLS_DC)
61 ++static int php_crack_checkpath(char* path)
62 + {
63 + char *filename;
64 + int filename_len;
65 + int result = SUCCESS;
66 +
67 +-#if PHP_VERSION_ID < 50400
68 +- if (PG(safe_mode)) {
69 +- filename_len = strlen(path) + 10;
70 +- filename = (char *) emalloc(filename_len);
71 +- if (NULL == filename) {
72 +- return FAILURE;
73 +- }
74 +-
75 +- memset(filename, '\0', filename_len);
76 +- strcpy(filename, path);
77 +- strcat(filename, ".pwd");
78 +- if (!php_checkuid(filename, "r", CHECKUID_CHECK_FILE_AND_DIR)) {
79 +- efree(filename);
80 +- return FAILURE;
81 +- }
82 +-
83 +- memset(filename, '\0', filename_len);
84 +- strcpy(filename, path);
85 +- strcat(filename, ".pwi");
86 +- if (!php_checkuid(filename, "r", CHECKUID_CHECK_FILE_AND_DIR)) {
87 +- efree(filename);
88 +- return FAILURE;
89 +- }
90 +-
91 +- memset(filename, '\0', filename_len);
92 +- strcpy(filename, path);
93 +- strcat(filename, ".hwm");
94 +- if (!php_checkuid(filename, "r", CHECKUID_CHECK_FILE_AND_DIR)) {
95 +- efree(filename);
96 +- return FAILURE;
97 +- }
98 +- }
99 +-#endif
100 +-
101 +- if (php_check_open_basedir(path TSRMLS_CC)) {
102 ++ if (php_check_open_basedir(path)) {
103 + return FAILURE;
104 + }
105 +
106 +@@ -162,7 +120,6 @@
107 +
108 + /* {{{ php_crack_set_default_dict
109 + */
110 +-#if PHP_VERSION_ID >= 70000
111 + static void php_crack_set_default_dict(zend_resource *id)
112 + {
113 + if (CRACKG(default_dict) != NULL) {
114 +@@ -172,60 +129,32 @@
115 + CRACKG(default_dict) = id;
116 + id->gc.refcount++;
117 + }
118 +-#else
119 +-static void php_crack_set_default_dict(int id TSRMLS_DC)
120 +-{
121 +- if (CRACKG(default_dict) != -1) {
122 +- zend_list_delete(CRACKG(default_dict));
123 +- }
124 +-
125 +- CRACKG(default_dict) = id;
126 +- zend_list_addref(id);
127 +-}
128 +-#endif
129 + /* }}} */
130 +
131 + /* {{{ php_crack_get_default_dict
132 + */
133 +-#if PHP_VERSION_ID >= 70000
134 + static zend_resource * php_crack_get_default_dict(INTERNAL_FUNCTION_PARAMETERS)
135 +-#else
136 +-static int php_crack_get_default_dict(INTERNAL_FUNCTION_PARAMETERS)
137 +-#endif
138 + {
139 +-#if PHP_VERSION_ID >= 70000
140 + if ((NULL == CRACKG(default_dict)) && (NULL != CRACKG(default_dictionary))) {
141 +-#else
142 +- if ((-1 == CRACKG(default_dict)) && (NULL != CRACKG(default_dictionary))) {
143 +-#endif
144 + CRACKLIB_PWDICT *pwdict;
145 + printf("trying to open: %s\n", CRACKG(default_dictionary));
146 + pwdict = cracklib_pw_open(CRACKG(default_dictionary), "r");
147 + if (NULL != pwdict) {
148 +-#if PHP_VERSION_ID >= 70000
149 + ZVAL_RES(return_value, zend_register_resource(pwdict, le_crack));
150 + php_crack_set_default_dict(Z_RES_P(return_value));
151 +-#else
152 +- ZEND_REGISTER_RESOURCE(return_value, pwdict, le_crack);
153 +- php_crack_set_default_dict(Z_LVAL_P(return_value) TSRMLS_CC);
154 +-#endif
155 + }
156 + }
157 +-
158 ++
159 + return CRACKG(default_dict);
160 + }
161 + /* }}} */
162 +
163 + /* {{{ php_crack_module_dtor
164 + */
165 +-#if PHP_VERSION_ID >= 70000
166 + static void php_crack_module_dtor(zend_resource *rsrc)
167 +-#else
168 +-static void php_crack_module_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
169 +-#endif
170 + {
171 + CRACKLIB_PWDICT *pwdict = (CRACKLIB_PWDICT *) rsrc->ptr;
172 +-
173 ++
174 + if (pwdict != NULL) {
175 + cracklib_pw_close(pwdict);
176 + }
177 +@@ -239,13 +168,10 @@
178 + #ifdef ZTS
179 + ZEND_INIT_MODULE_GLOBALS(crack, php_crack_init_globals, NULL);
180 + #endif
181 +-
182 ++
183 + REGISTER_INI_ENTRIES();
184 + le_crack = zend_register_list_destructors_ex(php_crack_module_dtor, NULL, "crack dictionary", module_number);
185 +-#if PHP_VERSION_ID < 70000
186 +- Z_TYPE(crack_module_entry) = type;
187 +-#endif
188 +-
189 ++
190 + return SUCCESS;
191 + }
192 +
193 +@@ -263,12 +189,8 @@
194 + PHP_RINIT_FUNCTION(crack)
195 + {
196 + CRACKG(last_message) = NULL;
197 +-#if PHP_VERSION_ID >= 70000
198 + CRACKG(default_dict) = NULL;
199 +-#else
200 +- CRACKG(default_dict) = -1;
201 +-#endif
202 +-
203 ++
204 + return SUCCESS;
205 + }
206 + /* }}} */
207 +@@ -280,7 +202,7 @@
208 + if (NULL != CRACKG(last_message)) {
209 + efree(CRACKG(last_message));
210 + }
211 +-
212 ++
213 + return SUCCESS;
214 + }
215 + /* }}} */
216 +@@ -292,7 +214,7 @@
217 + php_info_print_table_start();
218 + php_info_print_table_header(2, "crack support", "enabled");
219 + php_info_print_table_end();
220 +-
221 ++
222 + DISPLAY_INI_ENTRIES();
223 + }
224 + /* }}} */
225 +@@ -304,32 +226,23 @@
226 + char *path;
227 + size_t path_len;
228 + CRACKLIB_PWDICT *pwdict;
229 +-
230 +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &path_len) == FAILURE) {
231 ++
232 ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &path, &path_len) == FAILURE) {
233 + RETURN_FALSE;
234 + }
235 +-
236 +- if (php_crack_checkpath(path TSRMLS_CC) == FAILURE) {
237 ++
238 ++ if (php_crack_checkpath(path) == FAILURE) {
239 + RETURN_FALSE;
240 + }
241 +-
242 ++
243 + pwdict = cracklib_pw_open(path, "r");
244 + if (NULL == pwdict) {
245 +-#if ZEND_MODULE_API_NO >= 20021010
246 +- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not open crack dictionary: %s", path);
247 +-#else
248 +- php_error(E_WARNING, "Could not open crack dictionary: %s", path);
249 +-#endif
250 ++ php_error_docref(NULL, E_WARNING, "Could not open crack dictionary: %s", path);
251 + RETURN_FALSE;
252 + }
253 +
254 +-#if PHP_VERSION_ID >= 70000
255 + RETURN_RES(zend_register_resource(pwdict, le_crack));
256 + php_crack_set_default_dict(Z_RES_P(return_value));
257 +-#else
258 +- ZEND_REGISTER_RESOURCE(return_value, pwdict, le_crack);
259 +- php_crack_set_default_dict(Z_LVAL_P(return_value) TSRMLS_CC);
260 +-#endif
261 + }
262 + /* }}} */
263 +
264 +@@ -338,33 +251,20 @@
265 + PHP_FUNCTION(crack_closedict)
266 + {
267 + zval *dictionary = NULL;
268 +-#if PHP_VERSION_ID >= 70000
269 + zend_resource *id;
270 +-#else
271 +- int id = -1;
272 +-#endif
273 + CRACKLIB_PWDICT *pwdict;
274 +-
275 +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &dictionary)) {
276 ++
277 ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|r", &dictionary)) {
278 + RETURN_FALSE;
279 + }
280 +-
281 ++
282 + if (NULL == dictionary) {
283 + id = php_crack_get_default_dict(INTERNAL_FUNCTION_PARAM_PASSTHRU);
284 +-#if PHP_VERSION_ID >= 70000
285 + if (id == NULL) {
286 +-#else
287 +- if (id == -1) {
288 +-#endif
289 +-#if ZEND_MODULE_API_NO >= 20021010
290 +- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not open default crack dicionary");
291 +-#else
292 +- php_error(E_WARNING, "Could not open default crack dicionary");
293 +-#endif
294 ++ php_error_docref(NULL, E_WARNING, "Could not open default crack dicionary");
295 + RETURN_FALSE;
296 + }
297 + }
298 +-#if PHP_VERSION_ID >= 70000
299 + if((pwdict = (CRACKLIB_PWDICT *)zend_fetch_resource(Z_RES_P(dictionary), "crack dictionary", le_crack)) == NULL)
300 + {
301 + RETURN_FALSE;
302 +@@ -376,17 +276,6 @@
303 + else {
304 + zend_list_close(Z_RES_P(dictionary));
305 + }
306 +-#else
307 +- ZEND_FETCH_RESOURCE(pwdict, CRACKLIB_PWDICT *, &dictionary, id, "crack dictionary", le_crack);
308 +-
309 +- if (NULL == dictionary) {
310 +- zend_list_delete(CRACKG(default_dict));
311 +- CRACKG(default_dict) = -1;
312 +- }
313 +- else {
314 +- zend_list_delete(Z_RESVAL_P(dictionary));
315 +- }
316 +-#endif
317 + RETURN_TRUE;
318 + }
319 + /* }}} */
320 +@@ -404,25 +293,20 @@
321 + size_t gecos_len;
322 + char *message;
323 + CRACKLIB_PWDICT *pwdict;
324 +-#if PHP_VERSION_ID >= 70000
325 + zend_resource *crack_res;
326 +-#else
327 +- int id = -1;
328 +-#endif
329 +-
330 ++
331 + if (NULL != CRACKG(last_message)) {
332 + efree(CRACKG(last_message));
333 + CRACKG(last_message) = NULL;
334 + }
335 +-
336 +- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dictionary, &password, &password_len) == FAILURE) {
337 +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ssr", &password, &password_len, &username, &username_len, &gecos, &gecos_len, &dictionary) == FAILURE) {
338 ++
339 ++ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "rs", &dictionary, &password, &password_len) == FAILURE) {
340 ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|ssr", &password, &password_len, &username, &username_len, &gecos, &gecos_len, &dictionary) == FAILURE) {
341 + RETURN_FALSE;
342 + }
343 + }
344 +-
345 ++
346 + if (NULL == dictionary) {
347 +-#if PHP_VERSION_ID >= 70000
348 + crack_res = php_crack_get_default_dict(INTERNAL_FUNCTION_PARAM_PASSTHRU);
349 + if (crack_res == NULL || crack_res->ptr == NULL) {
350 + php_error(E_WARNING, "Could not open default crack dicionary");
351 +@@ -436,22 +320,9 @@
352 + RETURN_FALSE;
353 + }
354 + }
355 +-#else
356 +- id = php_crack_get_default_dict(INTERNAL_FUNCTION_PARAM_PASSTHRU);
357 +- if (id == -1) {
358 +-#if ZEND_MODULE_API_NO >= 20021010
359 +- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not open default crack dicionary");
360 +-#else
361 +- php_error(E_WARNING, "Could not open default crack dicionary");
362 +-#endif
363 +- RETURN_FALSE;
364 +- }
365 +- }
366 +- ZEND_FETCH_RESOURCE(pwdict, CRACKLIB_PWDICT *, &dictionary, id, "crack dictionary", le_crack);
367 +-#endif
368 +-
369 ++
370 + message = cracklib_fascist_look_ex(pwdict, password, username, gecos);
371 +-
372 ++
373 + if (NULL == message) {
374 + CRACKG(last_message) = estrdup("strong password");
375 + RETURN_TRUE;
376 +@@ -470,21 +341,13 @@
377 + if (ZEND_NUM_ARGS() != 0) {
378 + WRONG_PARAM_COUNT;
379 + }
380 +-
381 ++
382 + if (NULL == CRACKG(last_message)) {
383 +-#if ZEND_MODULE_API_NO >= 20021010
384 +- php_error_docref(NULL TSRMLS_CC, E_WARNING, "No obscure checks in this session");
385 +-#else
386 +- php_error(E_WARNING, "No obscure checks in this session");
387 +-#endif
388 ++ php_error_docref(NULL, E_WARNING, "No obscure checks in this session");
389 + RETURN_FALSE;
390 + }
391 +-
392 +-#if PHP_VERSION_ID >= 70000
393 ++
394 + RETURN_STRING(CRACKG(last_message));
395 +-#else
396 +- RETURN_STRING(CRACKG(last_message), 1);
397 +-#endif
398 + }
399 + /* }}} */
400 +
401 +diff -aurN a/php_crack.h b/php_crack.h
402 +--- a/php_crack.h 2021-04-15 13:57:12.174874906 -0400
403 ++++ b/php_crack.h 2021-04-15 14:10:28.853298881 -0400
404 +@@ -52,11 +52,7 @@
405 + ZEND_BEGIN_MODULE_GLOBALS(crack)
406 + char *default_dictionary;
407 + char *last_message;
408 +-#if PHP_VERSION_ID >= 70000
409 + zend_resource *default_dict;
410 +-#else
411 +- int default_dict;
412 +-#endif
413 + ZEND_END_MODULE_GLOBALS(crack)
414 +
415 + #ifdef ZTS
416
417 diff --git a/dev-php/pecl-crack/pecl-crack-0.4-r8.ebuild b/dev-php/pecl-crack/pecl-crack-0.4-r8.ebuild
418 new file mode 100644
419 index 00000000000..def1519d101
420 --- /dev/null
421 +++ b/dev-php/pecl-crack/pecl-crack-0.4-r8.ebuild
422 @@ -0,0 +1,29 @@
423 +# Copyright 1999-2021 Gentoo Authors
424 +# Distributed under the terms of the GNU General Public License v2
425 +
426 +EAPI="7"
427 +
428 +PHP_EXT_NAME="crack"
429 +PHP_EXT_INI="yes"
430 +PHP_EXT_ZENDEXT="no"
431 +PHP_EXT_EXTRA_ECONF=""
432 +DOCS=( EXPERIMENTAL )
433 +
434 +USE_PHP="php7-3 php7-4 php8-0"
435 +
436 +inherit php-ext-pecl-r3
437 +
438 +KEYWORDS="~amd64 ~ppc ~ppc64 ~x86"
439 +
440 +DESCRIPTION="PHP interface to the cracklib libraries"
441 +LICENSE="PHP-3 CRACKLIB"
442 +SLOT="0"
443 +IUSE=""
444 +
445 +# Patch for http://pecl.php.net/bugs/bug.php?id=5765
446 +PATCHES=(
447 + "${FILESDIR}/fix-php-5-4-support.patch"
448 + "${FILESDIR}/fix-pecl-bug-5765.patch"
449 + "${FILESDIR}/${PV}-php7.patch"
450 + "${FILESDIR}/0.4-php8.patch"
451 +)