cvs: pecl /pam config.m4 package.xml pam.c /pam/tests 001.phpt 002.phpt 003.phpt 004.phpt
| From: | Mikael Johansson | Date: | Sun, 19 Nov 2006 10:22:36 +0000 |
| Subject: | cvs: pecl /pam config.m4 package.xml pam.c /pam/tests 001.phpt 002.phpt 003.phpt 004.phpt | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-6653@lists.php.net to get a copy of this message | ||
mikl Sun Nov 19 10:22:36 2006 UTC
Modified files:
/pecl/pam config.m4 package.xml pam.c
/pecl/pam/tests 001.phpt 002.phpt 003.phpt 004.phpt
Log:
Detect PAM presence using security/pam_appl.h instead of lib/libpam.so
Error messages specify which pam_* function failed
http://cvs.php.net/viewvc.cgi/pecl/pam/config.m4?r1=1.2&r2=1.3&diff_format=u
Index: pecl/pam/config.m4
diff -u pecl/pam/config.m4:1.2 pecl/pam/config.m4:1.3
--- pecl/pam/config.m4:1.2 Mon Nov 13 12:39:27 2006
+++ pecl/pam/config.m4 Sun Nov 19 10:22:36 2006
@@ -1,4 +1,4 @@
-dnl $Id: config.m4,v 1.2 2006/11/13 12:39:27 mikl Exp $
+dnl $Id: config.m4,v 1.3 2006/11/19 10:22:36 mikl Exp $
dnl config.m4 for extension pam
dnl vim:se ts=2 sw=2 et:
@@ -17,10 +17,8 @@
if test "$PHP_PAM" != "no"; then
AC_DEFINE(HAVE_PAM, 1, [ ])
- AC_CHECK_HEADERS(security/pam_appl.h)
-
for i in $PHP_PAM /usr/local /usr /; do
- if test -f $i/$PHP_LIBDIR/libpam.$SHLIB_SUFFIX_NAME; then
+ if test -r $i/include/security/pam_appl.h; then
PAM_DIR=$i
fi
done
http://cvs.php.net/viewvc.cgi/pecl/pam/package.xml?r1=1.2&r2=1.3&diff_format=u
Index: pecl/pam/package.xml
diff -u pecl/pam/package.xml:1.2 pecl/pam/package.xml:1.3
--- pecl/pam/package.xml:1.2 Mon Nov 13 08:05:35 2006
+++ pecl/pam/package.xml Sun Nov 19 10:22:36 2006
@@ -13,11 +13,14 @@
</maintainer>
</maintainers>
<release>
- <version>1.0.0</version>
- <date>2006-11-13</date>
+ <version>1.0.1</version>
+ <date>2006-xx-xx</date>
<license>PHP</license>
<state>stable</state>
- <notes>Initial PECL release</notes>
+ <notes>
+ Error messages specify which pam_* function failed
+ Fixed build on lib64 type systems
+ </notes>
<deps>
<dep type="php" rel="ge" version="4.3.0"
optional="no"/>
</deps>
@@ -30,5 +33,15 @@
<file role="src" name="pam.c" />
</filelist>
<changelog>
+ <release>
+ <version>1.0.0</version>
+ <date>2006-11-13</date>
+ <license>PHP</license>
+ <state>stable</state>
+ <notes>Initial PECL release</notes>
+ <deps>
+ <dep type="php" rel="ge" version="4.3.0"
optional="no"/>
+ </deps>
+ </release>
</changelog>
</package>
http://cvs.php.net/viewvc.cgi/pecl/pam/pam.c?r1=1.2&r2=1.3&diff_format=u
Index: pecl/pam/pam.c
diff -u pecl/pam/pam.c:1.2 pecl/pam/pam.c:1.3
--- pecl/pam/pam.c:1.2 Mon Nov 13 08:12:39 2006
+++ pecl/pam/pam.c Sun Nov 19 10:22:36 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pam.c,v 1.2 2006/11/13 08:12:39 mikl Exp $ */
+/* $Id: pam.c,v 1.3 2006/11/19 10:22:36 mikl Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -233,6 +233,7 @@
struct pam_conv conv_info = {&auth_pam_talker, (void *) &userinfo};
pam_handle_t *pamh = NULL;
int result;
+ char *error_msg;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|z", &username,
&username_len, &password, &password_len, &status) == FAILURE) {
return;
@@ -241,14 +242,32 @@
userinfo.name = username;
userinfo.pw = password;
- if ((result = pam_start(PAM_G(servicename), userinfo.name, &conv_info, &pamh)) !=
PAM_SUCCESS ||
- (result = pam_authenticate(pamh, PAM_DISALLOW_NULL_AUTHTOK)) != PAM_SUCCESS ||
- (result = pam_acct_mgmt(pamh, PAM_DISALLOW_NULL_AUTHTOK)) != PAM_SUCCESS) {
+ if ((result = pam_start(PAM_G(servicename), userinfo.name, &conv_info, &pamh)) !=
PAM_SUCCESS) {
if (status) {
+ spprintf(&error_msg, 0, "%s (in %s)", (char *) pam_strerror(pamh, result),
"pam_start");
zval_dtor(status);
- ZVAL_STRING(status, (char *) pam_strerror(pamh, result), 1);
+ ZVAL_STRING(status, error_msg, 0);
}
- pam_end(pamh, result);
+ RETURN_FALSE;
+ }
+
+ if ((result = pam_authenticate(pamh, PAM_DISALLOW_NULL_AUTHTOK)) != PAM_SUCCESS) {
+ if (status) {
+ spprintf(&error_msg, 0, "%s (in %s)", (char *) pam_strerror(pamh, result),
"pam_authenticate");
+ zval_dtor(status);
+ ZVAL_STRING(status, error_msg, 0);
+ }
+ pam_end(pamh, PAM_SUCCESS);
+ RETURN_FALSE;
+ }
+
+ if ((result = pam_acct_mgmt(pamh, PAM_DISALLOW_NULL_AUTHTOK)) != PAM_SUCCESS) {
+ if (status) {
+ spprintf(&error_msg, 0, "%s (in %s)", (char *) pam_strerror(pamh, result),
"pam_acct_mgmt");
+ zval_dtor(status);
+ ZVAL_STRING(status, error_msg, 0);
+ }
+ pam_end(pamh, PAM_SUCCESS);
RETURN_FALSE;
}
@@ -269,6 +288,7 @@
struct pam_conv conv_info = {&chpass_pam_talker, (void *) &userinfo};
pam_handle_t *pamh = NULL;
int result;
+ char *error_msg;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|z", &username,
&username_len, &oldpass, &oldpass_len, &newpass, &newpass_len, &status) ==
FAILURE) {
return;
@@ -278,12 +298,30 @@
userinfo.oldpw = oldpass;
userinfo.newpw = newpass;
- if ((result = pam_start(PAM_G(servicename), userinfo.name, &conv_info, &pamh)) !=
PAM_SUCCESS ||
- (result = pam_authenticate(pamh, PAM_DISALLOW_NULL_AUTHTOK)) != PAM_SUCCESS ||
- (result = pam_chauthtok(pamh, PAM_DISALLOW_NULL_AUTHTOK)) != PAM_SUCCESS) {
+ if ((result = pam_start(PAM_G(servicename), userinfo.name, &conv_info, &pamh)) !=
PAM_SUCCESS) {
+ if (status) {
+ spprintf(&error_msg, 0, "%s (in %s)", (char *) pam_strerror(pamh, result),
"pam_start");
+ zval_dtor(status);
+ ZVAL_STRING(status, error_msg, 0);
+ }
+ RETURN_FALSE;
+ }
+
+ if ((result = pam_authenticate(pamh, PAM_DISALLOW_NULL_AUTHTOK)) != PAM_SUCCESS) {
+ if (status) {
+ spprintf(&error_msg, 0, "%s (in %s)", (char *) pam_strerror(pamh, result),
"pam_authenticate");
+ zval_dtor(status);
+ ZVAL_STRING(status, error_msg, 0);
+ }
+ pam_end(pamh, PAM_SUCCESS);
+ RETURN_FALSE;
+ }
+
+ if ((result = pam_chauthtok(pamh, PAM_DISALLOW_NULL_AUTHTOK)) != PAM_SUCCESS) {
if (status) {
+ spprintf(&error_msg, 0, "%s (in %s)", (char *) pam_strerror(pamh, result),
"pam_chauthtok");
zval_dtor(status);
- ZVAL_STRING(status, (char *) pam_strerror(pamh, result), 1);
+ ZVAL_STRING(status, error_msg, 0);
}
pam_end(pamh, PAM_SUCCESS);
RETURN_FALSE;
http://cvs.php.net/viewvc.cgi/pecl/pam/tests/001.phpt?r1=1.1&r2=1.2&diff_format=u
Index: pecl/pam/tests/001.phpt
diff -u pecl/pam/tests/001.phpt:1.1 pecl/pam/tests/001.phpt:1.2
--- pecl/pam/tests/001.phpt:1.1 Mon Nov 13 07:47:40 2006
+++ pecl/pam/tests/001.phpt Sun Nov 19 10:22:36 2006
@@ -20,4 +20,4 @@
--EXPECTF--
bool(false)
bool(false)
-string(%d) "%s"
\ No newline at end of file
+string(%d) "%s (in pam_authenticate)"
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/pecl/pam/tests/002.phpt?r1=1.1&r2=1.2&diff_format=u
Index: pecl/pam/tests/002.phpt
diff -u pecl/pam/tests/002.phpt:1.1 pecl/pam/tests/002.phpt:1.2
--- pecl/pam/tests/002.phpt:1.1 Mon Nov 13 07:47:40 2006
+++ pecl/pam/tests/002.phpt Sun Nov 19 10:22:36 2006
@@ -28,4 +28,4 @@
bool(true)
NULL
bool(false)
-string(%d) "%s"
\ No newline at end of file
+string(%d) "%s (in pam_authenticate)"
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/pecl/pam/tests/003.phpt?r1=1.1&r2=1.2&diff_format=u
Index: pecl/pam/tests/003.phpt
diff -u pecl/pam/tests/003.phpt:1.1 pecl/pam/tests/003.phpt:1.2
--- pecl/pam/tests/003.phpt:1.1 Mon Nov 13 07:47:40 2006
+++ pecl/pam/tests/003.phpt Sun Nov 19 10:22:36 2006
@@ -37,7 +37,7 @@
--EXPECTF--
bool(true)
bool(false)
-string(%d) "%s"
+string(%d) "%s (in pam_authenticate)"
bool(true)
bool(false)
bool(true)
http://cvs.php.net/viewvc.cgi/pecl/pam/tests/004.phpt?r1=1.1&r2=1.2&diff_format=u
Index: pecl/pam/tests/004.phpt
diff -u pecl/pam/tests/004.phpt:1.1 pecl/pam/tests/004.phpt:1.2
--- pecl/pam/tests/004.phpt:1.1 Mon Nov 13 07:47:40 2006
+++ pecl/pam/tests/004.phpt Sun Nov 19 10:22:36 2006
@@ -30,4 +30,4 @@
string(%d) "%s"
bool(false)
bool(false)
-string(%d) "%s"
\ No newline at end of file
+string(%d) "%s (in pam_authenticate)"
\ No newline at end of file