MCPcopy Create free account
hub / github.com/apache/httpd / filegroup_check_authorization

Function filegroup_check_authorization

modules/aaa/mod_authz_groupfile.c:209–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207static APR_OPTIONAL_FN_TYPE(authz_owner_get_file_group) *authz_owner_get_file_group;
208
209static authz_status filegroup_check_authorization(request_rec *r,
210 const char *require_args,
211 const void *parsed_require_args)
212{
213 authz_groupfile_config_rec *conf = ap_get_module_config(r->per_dir_config,
214 &authz_groupfile_module);
215 char *user = r->user;
216 apr_table_t *grpstatus = NULL;
217 apr_status_t status;
218 const char *filegroup = NULL;
219
220 if (!user) {
221 return AUTHZ_DENIED_NO_USER;
222 }
223
224 /* If there is no group file - then we are not
225 * configured. So decline.
226 */
227 if (!(conf->groupfile)) {
228 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01668)
229 "No group file was specified in the configuration");
230 return AUTHZ_DENIED;
231 }
232
233 status = groups_for_user(r->pool, user, conf->groupfile,
234 &grpstatus);
235 if (status != APR_SUCCESS) {
236 ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(01669)
237 "Could not open group file: %s",
238 conf->groupfile);
239 return AUTHZ_DENIED;
240 }
241
242 if (apr_is_empty_table(grpstatus)) {
243 /* no groups available, so exit immediately */
244 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01670)
245 "Authorization of user %s to access %s failed, reason: "
246 "user doesn't appear in group file (%s).",
247 r->user, r->uri, conf->groupfile);
248 return AUTHZ_DENIED;
249 }
250
251 filegroup = authz_owner_get_file_group(r);
252
253 if (filegroup) {
254 if (apr_table_get(grpstatus, filegroup)) {
255 return AUTHZ_GRANTED;
256 }
257 }
258 else {
259 /* No need to emit a error log entry because the call
260 to authz_owner_get_file_group already did it
261 for us.
262 */
263 return AUTHZ_DENIED;
264 }
265
266 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01671)

Callers

nothing calls this directly

Calls 3

ap_get_module_configFunction · 0.85
groups_for_userFunction · 0.85

Tested by

no test coverage detected