Lines 1-45
Link Here
|
1 |
From 9a3d9a05b2c8790c771c166b42f8b80e76b4b336 Mon Sep 17 00:00:00 2001 |
|
|
2 |
From: Lukas Slebodnik <lukas.slebodnik@intrak.sk> |
3 |
Date: Wed, 6 Nov 2013 22:01:20 +0100 |
4 |
Subject: [PATCH 11/25] patch-src__providers__ldap__sdap_access.c |
5 |
|
6 |
--- |
7 |
src/providers/ldap/sdap_access.c | 46 +++++++++++++++++++--------------------- |
8 |
1 file changed, 22 insertions(+), 24 deletions(-) |
9 |
|
10 |
diff --git src/providers/ldap/sdap_access.c src/providers/ldap/sdap_access.c |
1 |
diff --git src/providers/ldap/sdap_access.c src/providers/ldap/sdap_access.c |
11 |
index b198e04..1eaedf7 100644 |
2 |
index 880735e..d349dcf 100644 |
12 |
--- src/providers/ldap/sdap_access.c |
3 |
--- src/providers/ldap/sdap_access.c |
13 |
+++ src/providers/ldap/sdap_access.c |
4 |
+++ src/providers/ldap/sdap_access.c |
14 |
@@ -22,9 +22,7 @@ |
5 |
@@ -499,6 +499,7 @@ static bool nds_check_expired(const char *exp_time_str) |
15 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
16 |
*/ |
17 |
|
18 |
-#define _XOPEN_SOURCE 500 /* for strptime() */ |
19 |
#include <time.h> |
20 |
-#undef _XOPEN_SOURCE |
21 |
#include <sys/param.h> |
22 |
#include <security/pam_modules.h> |
23 |
#include <talloc.h> |
24 |
@@ -109,7 +107,7 @@ void sdap_pam_access_handler(struct be_req *breq) |
25 |
pd); |
26 |
if (req == NULL) { |
27 |
DEBUG(1, ("Unable to start sdap_access request\n")); |
28 |
- sdap_access_reply(breq, PAM_SYSTEM_ERR); |
29 |
+ sdap_access_reply(breq, PAM_SERVICE_ERR); |
30 |
return; |
31 |
} |
32 |
|
33 |
@@ -149,7 +147,7 @@ sdap_access_send(TALLOC_CTX *mem_ctx, |
34 |
|
35 |
state->be_req = be_req; |
36 |
state->pd = pd; |
37 |
- state->pam_status = PAM_SYSTEM_ERR; |
38 |
+ state->pam_status = PAM_SERVICE_ERR; |
39 |
state->ev = ev; |
40 |
state->access_ctx = access_ctx; |
41 |
state->current_rule = 0; |
42 |
@@ -502,18 +500,17 @@ static bool nds_check_expired(const char *exp_time_str) |
43 |
return true; |
6 |
return true; |
44 |
} |
7 |
} |
45 |
|
8 |
|
Lines 46-52
Link Here
|
46 |
+ tzset(); |
9 |
+ tzset(); |
47 |
expire_time = mktime(&tm); |
10 |
expire_time = mktime(&tm); |
48 |
if (expire_time == -1) { |
11 |
if (expire_time == -1) { |
49 |
DEBUG(1, ("mktime failed to convert [%s].\n", exp_time_str)); |
12 |
DEBUG(SSSDBG_CRIT_FAILURE, |
|
|
13 |
@@ -506,13 +507,11 @@ static bool nds_check_expired(const char *exp_time_str) |
50 |
return true; |
14 |
return true; |
51 |
} |
15 |
} |
52 |
|
16 |
|
Lines 53-205
Link Here
|
53 |
- tzset(); |
17 |
- tzset(); |
54 |
- expire_time -= timezone; |
18 |
- expire_time -= timezone; |
55 |
now = time(NULL); |
19 |
now = time(NULL); |
56 |
- DEBUG(9, ("Time info: tzname[0] [%s] tzname[1] [%s] timezone [%d] " |
20 |
DEBUG(SSSDBG_TRACE_ALL, |
57 |
- "daylight [%d] now [%d] expire_time [%d].\n", tzname[0], |
21 |
- "Time info: tzname[0] [%s] tzname[1] [%s] timezone [%ld] " |
58 |
- tzname[1], timezone, daylight, now, expire_time)); |
22 |
- "daylight [%d] now [%ld] expire_time [%ld].\n", tzname[0], |
59 |
+ DEBUG(9, ("Time info: tzname[0] [%s] tzname[1] [%s] " |
23 |
- tzname[1], timezone, daylight, now, expire_time); |
60 |
+ "now [%d] expire_time [%d].\n", tzname[0], |
24 |
+ "Time info: tzname[0] [%s] tzname[1] [%s] " |
61 |
+ tzname[1], now, expire_time)); |
25 |
+ "now [%ld] expire_time [%ld].\n", tzname[0], |
|
|
26 |
+ tzname[1], now, expire_time); |
62 |
|
27 |
|
63 |
if (difftime(now, expire_time) > 0.0) { |
28 |
if (difftime(now, expire_time) > 0.0) { |
64 |
DEBUG(4, ("NDS account expired.\n")); |
29 |
DEBUG(SSSDBG_CONF_SETTINGS, "NDS account expired.\n"); |
65 |
@@ -662,7 +659,7 @@ static struct tevent_req *sdap_account_expired_send(TALLOC_CTX *mem_ctx, |
|
|
66 |
return NULL; |
67 |
} |
68 |
|
69 |
- state->pam_status = PAM_SYSTEM_ERR; |
70 |
+ state->pam_status = PAM_SERVICE_ERR; |
71 |
|
72 |
expire = dp_opt_get_cstring(access_ctx->id_ctx->opts->basic, |
73 |
SDAP_ACCOUNT_EXPIRE_POLICY); |
74 |
@@ -746,7 +743,7 @@ static void sdap_account_expired_done(struct tevent_req *subreq) |
75 |
talloc_zfree(subreq); |
76 |
if (ret != EOK) { |
77 |
DEBUG(1, ("Error retrieving access check result.\n")); |
78 |
- state->pam_status = PAM_SYSTEM_ERR; |
79 |
+ state->pam_status = PAM_SERVICE_ERR; |
80 |
tevent_req_error(req, ret); |
81 |
return; |
82 |
} |
83 |
@@ -806,7 +803,7 @@ static struct tevent_req *sdap_access_filter_send(TALLOC_CTX *mem_ctx, |
84 |
state->filter = NULL; |
85 |
state->be_req = be_req; |
86 |
state->username = username; |
87 |
- state->pam_status = PAM_SYSTEM_ERR; |
88 |
+ state->pam_status = PAM_SERVICE_ERR; |
89 |
state->sdap_ctx = access_ctx->id_ctx; |
90 |
state->ev = ev; |
91 |
state->access_ctx = access_ctx; |
92 |
@@ -953,7 +950,7 @@ static void sdap_access_filter_connect_done(struct tevent_req *subreq) |
93 |
false); |
94 |
if (subreq == NULL) { |
95 |
DEBUG(1, ("Could not start LDAP communication\n")); |
96 |
- state->pam_status = PAM_SYSTEM_ERR; |
97 |
+ state->pam_status = PAM_SERVICE_ERR; |
98 |
tevent_req_error(req, EIO); |
99 |
return; |
100 |
} |
101 |
@@ -984,13 +981,13 @@ static void sdap_access_filter_get_access_done(struct tevent_req *subreq) |
102 |
if (ret == EOK) { |
103 |
return; |
104 |
} |
105 |
- state->pam_status = PAM_SYSTEM_ERR; |
106 |
+ state->pam_status = PAM_SERVICE_ERR; |
107 |
} else if (dp_error == DP_ERR_OFFLINE) { |
108 |
sdap_access_filter_decide_offline(req); |
109 |
} else { |
110 |
DEBUG(1, ("sdap_get_generic_send() returned error [%d][%s]\n", |
111 |
ret, strerror(ret))); |
112 |
- state->pam_status = PAM_SYSTEM_ERR; |
113 |
+ state->pam_status = PAM_SERVICE_ERR; |
114 |
} |
115 |
|
116 |
goto done; |
117 |
@@ -1009,7 +1006,7 @@ static void sdap_access_filter_get_access_done(struct tevent_req *subreq) |
118 |
else if (results == NULL) { |
119 |
DEBUG(1, ("num_results > 0, but results is NULL\n")); |
120 |
ret = EIO; |
121 |
- state->pam_status = PAM_SYSTEM_ERR; |
122 |
+ state->pam_status = PAM_SERVICE_ERR; |
123 |
goto done; |
124 |
} |
125 |
else if (num_results > 1) { |
126 |
@@ -1018,7 +1015,7 @@ static void sdap_access_filter_get_access_done(struct tevent_req *subreq) |
127 |
*/ |
128 |
DEBUG(1, ("Received multiple replies\n")); |
129 |
ret = EIO; |
130 |
- state->pam_status = PAM_SYSTEM_ERR; |
131 |
+ state->pam_status = PAM_SERVICE_ERR; |
132 |
goto done; |
133 |
} |
134 |
else { /* Ok, we got a single reply */ |
135 |
@@ -1104,7 +1101,7 @@ static void sdap_access_filter_done(struct tevent_req *subreq) |
136 |
talloc_zfree(subreq); |
137 |
if (ret != EOK) { |
138 |
DEBUG(1, ("Error retrieving access check result.\n")); |
139 |
- state->pam_status = PAM_SYSTEM_ERR; |
140 |
+ state->pam_status = PAM_SERVICE_ERR; |
141 |
tevent_req_error(req, ret); |
142 |
return; |
143 |
} |
144 |
@@ -1244,7 +1241,7 @@ static void sdap_access_service_done(struct tevent_req *subreq) |
145 |
talloc_zfree(subreq); |
146 |
if (ret != EOK) { |
147 |
DEBUG(1, ("Error retrieving access check result.\n")); |
148 |
- state->pam_status = PAM_SYSTEM_ERR; |
149 |
+ state->pam_status = PAM_SERVICE_ERR; |
150 |
tevent_req_error(req, ret); |
151 |
return; |
152 |
} |
153 |
@@ -1269,7 +1266,7 @@ static struct tevent_req *sdap_access_host_send( |
154 |
struct ldb_message_element *el; |
155 |
unsigned int i; |
156 |
char *host; |
157 |
- char hostname[HOST_NAME_MAX+1]; |
158 |
+ char hostname[_POSIX_HOST_NAME_MAX + 1]; |
159 |
|
160 |
req = tevent_req_create(mem_ctx, &state, struct sdap_access_host_ctx); |
161 |
if (!req) { |
162 |
@@ -1285,11 +1282,12 @@ static struct tevent_req *sdap_access_host_send( |
163 |
goto done; |
164 |
} |
165 |
|
166 |
- if (gethostname(hostname, sizeof(hostname)) == -1) { |
167 |
+ if (gethostname(hostname, _POSIX_HOST_NAME_MAX) == -1) { |
168 |
DEBUG(1, ("Unable to get system hostname. Access denied\n")); |
169 |
ret = EOK; |
170 |
goto done; |
171 |
} |
172 |
+ hostname[_POSIX_HOST_NAME_MAX] = '\0'; |
173 |
|
174 |
/* FIXME: PADL's pam_ldap also calls gethostbyname() on the hostname |
175 |
* in some attempt to get aliases and/or FQDN for the machine. |
176 |
@@ -1365,7 +1363,7 @@ static void sdap_access_host_done(struct tevent_req *subreq) |
177 |
talloc_zfree(subreq); |
178 |
if (ret != EOK) { |
179 |
DEBUG(1, ("Error retrieving access check result.\n")); |
180 |
- state->pam_status = PAM_SYSTEM_ERR; |
181 |
+ state->pam_status = PAM_SERVICE_ERR; |
182 |
tevent_req_error(req, ret); |
183 |
return; |
184 |
} |
185 |
@@ -1391,7 +1389,7 @@ sdap_access_recv(struct tevent_req *req, int *pam_status) |
186 |
static void sdap_access_done(struct tevent_req *req) |
187 |
{ |
188 |
errno_t ret; |
189 |
- int pam_status = PAM_SYSTEM_ERR; |
190 |
+ int pam_status = PAM_SERVICE_ERR; |
191 |
struct be_req *breq = |
192 |
tevent_req_callback_data(req, struct be_req); |
193 |
|
194 |
@@ -1399,7 +1397,7 @@ static void sdap_access_done(struct tevent_req *req) |
195 |
talloc_zfree(req); |
196 |
if (ret != EOK) { |
197 |
DEBUG(1, ("Error retrieving access check result.\n")); |
198 |
- pam_status = PAM_SYSTEM_ERR; |
199 |
+ pam_status = PAM_SERVICE_ERR; |
200 |
} |
201 |
|
202 |
sdap_access_reply(breq, pam_status); |
203 |
-- |
204 |
1.8.0 |
205 |
|