Line 0
Link Here
|
|
|
1 |
--- pam.c.orig 2018-01-02 11:11:25 UTC |
2 |
+++ pam.c |
3 |
@@ -227,8 +227,13 @@ int chpass_pam_talker(int num_msg, |
4 |
PHP_FUNCTION(pam_auth) |
5 |
{ |
6 |
char *username, *password; |
7 |
+#if PHP_MAJOR_VERSION >= 7 |
8 |
+ size_t username_len, password_len; |
9 |
+ zval *status = NULL, *server, *remote_addr; |
10 |
+#else |
11 |
int username_len, password_len; |
12 |
zval *status = NULL, **server, **remote_addr; |
13 |
+#endif |
14 |
zend_bool checkacctmgmt = 1; |
15 |
|
16 |
pam_auth_t userinfo = {NULL, NULL}; |
17 |
@@ -248,22 +253,37 @@ PHP_FUNCTION(pam_auth) |
18 |
if (status) { |
19 |
spprintf(&error_msg, 0, "%s (in %s)", (char *) pam_strerror(pamh, result), "pam_start"); |
20 |
zval_dtor(status); |
21 |
+#if PHP_MAJOR_VERSION >= 7 |
22 |
+ ZVAL_STRING(status, error_msg); |
23 |
+ efree(error_msg); |
24 |
+#else |
25 |
ZVAL_STRING(status, error_msg, 0); |
26 |
+#endif |
27 |
} |
28 |
RETURN_FALSE; |
29 |
} |
30 |
|
31 |
+#if PHP_MAJOR_VERSION >= 7 |
32 |
+ if ((remote_addr = zend_hash_str_find(Z_ARR(PG(http_globals)[TRACK_VARS_SERVER]), "REMOTE_ADDR", sizeof("REMOTE_ADDR")-1)) != NULL && Z_TYPE_P(remote_addr) == IS_STRING) { |
33 |
+ pam_set_item(pamh, PAM_RHOST, Z_STRVAL_P(remote_addr)); |
34 |
+#else |
35 |
if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **)&server) == SUCCESS && Z_TYPE_PP(server) == IS_ARRAY) { |
36 |
if (zend_hash_find(Z_ARRVAL_PP(server), "REMOTE_ADDR", sizeof("REMOTE_ADDR"), (void **)&remote_addr) == SUCCESS && Z_TYPE_PP(remote_addr) == IS_STRING) { |
37 |
pam_set_item(pamh, PAM_RHOST, Z_STRVAL_PP(remote_addr)); |
38 |
} |
39 |
+#endif |
40 |
} |
41 |
|
42 |
if ((result = pam_authenticate(pamh, PAM_DISALLOW_NULL_AUTHTOK)) != PAM_SUCCESS) { |
43 |
if (status) { |
44 |
spprintf(&error_msg, 0, "%s (in %s)", (char *) pam_strerror(pamh, result), "pam_authenticate"); |
45 |
zval_dtor(status); |
46 |
+#if PHP_MAJOR_VERSION >= 7 |
47 |
+ ZVAL_STRING(status, error_msg); |
48 |
+ efree(error_msg); |
49 |
+#else |
50 |
ZVAL_STRING(status, error_msg, 0); |
51 |
+#endif |
52 |
} |
53 |
pam_end(pamh, PAM_SUCCESS); |
54 |
RETURN_FALSE; |
55 |
@@ -274,7 +294,12 @@ PHP_FUNCTION(pam_auth) |
56 |
if (status) { |
57 |
spprintf(&error_msg, 0, "%s (in %s)", (char *) pam_strerror(pamh, result), "pam_acct_mgmt"); |
58 |
zval_dtor(status); |
59 |
+#if PHP_MAJOR_VERSION >= 7 |
60 |
+ ZVAL_STRING(status, error_msg); |
61 |
+ efree(error_msg); |
62 |
+#else |
63 |
ZVAL_STRING(status, error_msg, 0); |
64 |
+#endif |
65 |
} |
66 |
pam_end(pamh, PAM_SUCCESS); |
67 |
RETURN_FALSE; |
68 |
@@ -291,7 +316,11 @@ PHP_FUNCTION(pam_auth) |
69 |
PHP_FUNCTION(pam_chpass) |
70 |
{ |
71 |
char *username, *oldpass, *newpass; |
72 |
+#if PHP_MAJOR_VERSION >= 7 |
73 |
+ size_t username_len, oldpass_len, newpass_len; |
74 |
+#else |
75 |
int username_len, oldpass_len, newpass_len; |
76 |
+#endif |
77 |
zval *status = NULL; |
78 |
|
79 |
pam_chpass_t userinfo = {NULL, NULL, NULL, 0}; |
80 |
@@ -312,7 +341,12 @@ PHP_FUNCTION(pam_chpass) |
81 |
if (status) { |
82 |
spprintf(&error_msg, 0, "%s (in %s)", (char *) pam_strerror(pamh, result), "pam_start"); |
83 |
zval_dtor(status); |
84 |
+#if PHP_MAJOR_VERSION >= 7 |
85 |
+ ZVAL_STRING(status, error_msg); |
86 |
+ efree(error_msg); |
87 |
+#else |
88 |
ZVAL_STRING(status, error_msg, 0); |
89 |
+#endif |
90 |
} |
91 |
RETURN_FALSE; |
92 |
} |
93 |
@@ -321,7 +355,12 @@ PHP_FUNCTION(pam_chpass) |
94 |
if (status) { |
95 |
spprintf(&error_msg, 0, "%s (in %s)", (char *) pam_strerror(pamh, result), "pam_authenticate"); |
96 |
zval_dtor(status); |
97 |
+#if PHP_MAJOR_VERSION >= 7 |
98 |
+ ZVAL_STRING(status, error_msg); |
99 |
+ efree(error_msg); |
100 |
+#else |
101 |
ZVAL_STRING(status, error_msg, 0); |
102 |
+#endif |
103 |
} |
104 |
pam_end(pamh, PAM_SUCCESS); |
105 |
RETURN_FALSE; |
106 |
@@ -331,7 +370,12 @@ PHP_FUNCTION(pam_chpass) |
107 |
if (status) { |
108 |
spprintf(&error_msg, 0, "%s (in %s)", (char *) pam_strerror(pamh, result), "pam_chauthtok"); |
109 |
zval_dtor(status); |
110 |
+#if PHP_MAJOR_VERSION >= 7 |
111 |
+ ZVAL_STRING(status, error_msg); |
112 |
+ efree(error_msg); |
113 |
+#else |
114 |
ZVAL_STRING(status, error_msg, 0); |
115 |
+#endif |
116 |
} |
117 |
pam_end(pamh, PAM_SUCCESS); |
118 |
RETURN_FALSE; |