| 134 | } |
| 135 | |
| 136 | static authz_status group_check_authorization(request_rec *r, |
| 137 | const char *require_args, |
| 138 | const void *parsed_require_args) |
| 139 | { |
| 140 | authz_groupfile_config_rec *conf = ap_get_module_config(r->per_dir_config, |
| 141 | &authz_groupfile_module); |
| 142 | char *user = r->user; |
| 143 | |
| 144 | const char *err = NULL; |
| 145 | const ap_expr_info_t *expr = parsed_require_args; |
| 146 | const char *require; |
| 147 | |
| 148 | const char *t, *w; |
| 149 | apr_table_t *grpstatus = NULL; |
| 150 | apr_status_t status; |
| 151 | |
| 152 | if (!user) { |
| 153 | return AUTHZ_DENIED_NO_USER; |
| 154 | } |
| 155 | |
| 156 | /* If there is no group file - then we are not |
| 157 | * configured. So decline. |
| 158 | */ |
| 159 | if (!(conf->groupfile)) { |
| 160 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01664) |
| 161 | "No group file was specified in the configuration"); |
| 162 | return AUTHZ_DENIED; |
| 163 | } |
| 164 | |
| 165 | status = groups_for_user(r->pool, user, conf->groupfile, |
| 166 | &grpstatus); |
| 167 | |
| 168 | if (status != APR_SUCCESS) { |
| 169 | ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(01665) |
| 170 | "Could not open group file: %s", |
| 171 | conf->groupfile); |
| 172 | return AUTHZ_DENIED; |
| 173 | } |
| 174 | |
| 175 | if (apr_is_empty_table(grpstatus)) { |
| 176 | /* no groups available, so exit immediately */ |
| 177 | ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(01666) |
| 178 | "Authorization of user %s to access %s failed, reason: " |
| 179 | "user doesn't appear in group file (%s).", |
| 180 | r->user, r->uri, conf->groupfile); |
| 181 | return AUTHZ_DENIED; |
| 182 | } |
| 183 | |
| 184 | require = ap_expr_str_exec(r, expr, &err); |
| 185 | if (err) { |
| 186 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02592) |
| 187 | "authz_groupfile authorize: require group: Can't " |
| 188 | "evaluate require expression: %s", err); |
| 189 | return AUTHZ_DENIED; |
| 190 | } |
| 191 | |
| 192 | t = require; |
| 193 | while ((w = ap_getword_conf(r->pool, &t)) && w[0]) { |
nothing calls this directly
no test coverage detected