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

Function dbmgroup_check_authorization

modules/aaa/mod_authz_dbm.c:158–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158static authz_status dbmgroup_check_authorization(request_rec *r,
159 const char *require_args,
160 const void *parsed_require_args)
161{
162 authz_dbm_config_rec *conf = ap_get_module_config(r->per_dir_config,
163 &authz_dbm_module);
164 char *user = r->user;
165
166 const char *err = NULL;
167 const ap_expr_info_t *expr = parsed_require_args;
168 const char *require;
169
170 const char *t;
171 char *w;
172 const char *orig_groups = NULL;
173 const char *realm = ap_auth_name(r);
174 const char *groups;
175 char *v;
176
177 if (!user) {
178 return AUTHZ_DENIED_NO_USER;
179 }
180
181 if (!conf->grpfile) {
182 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01798)
183 "No group file was specified in the configuration");
184 return AUTHZ_DENIED;
185 }
186
187 /* fetch group data from dbm file only once. */
188 if (!orig_groups) {
189 apr_status_t status;
190
191 status = get_dbm_grp(r, apr_pstrcat(r->pool, user, ":", realm, NULL),
192 user, conf->grpfile, conf->dbmtype, &groups);
193
194 if (status != APR_SUCCESS) {
195 return AUTHZ_GENERAL_ERROR;
196 }
197
198 if (groups == NULL) {
199 /* no groups available, so exit immediately */
200 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01800)
201 "Authorization of user %s to access %s failed, reason: "
202 "user doesn't appear in DBM group file (%s).",
203 r->user, r->uri, conf->grpfile);
204 return AUTHZ_DENIED;
205 }
206
207 orig_groups = groups;
208 }
209
210 require = ap_expr_str_exec(r, expr, &err);
211 if (err) {
212 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02591)
213 "authz_dbm authorize: require dbm-group: Can't "
214 "evaluate require expression: %s", err);
215 return AUTHZ_DENIED;

Callers

nothing calls this directly

Calls 6

ap_get_module_configFunction · 0.85
ap_auth_nameFunction · 0.85
get_dbm_grpFunction · 0.85
ap_expr_str_execFunction · 0.85
ap_getword_whiteFunction · 0.85
ap_getwordFunction · 0.85

Tested by

no test coverage detected