mod_authz_groupfile.c revision 0b58c14ec46c0c7247f78d351f1ff3d2ef39b688
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* This module is triggered by an
*
*
* and the presense of a
*
* require group <list-of-groups>
*
*
* If there are no AuthGroupFile directives valid for
* the request; we DECLINED.
*
* If the AuthGroupFile is defined; but somehow not
* accessible: we SERVER_ERROR (was DECLINED).
*
* If there are no 'require ' directives defined for
* this request then we DECLINED (was OK).
*
* If there are no 'require ' directives valid for
* this request method then we DECLINED. (was OK)
*
* If there are any 'require group' blocks and we
* are not in any group - we HTTP_UNAUTHORIZE
*
*/
#include "apr_strings.h"
#include "apr_lib.h" /* apr_isspace */
#include "ap_config.h"
#include "ap_provider.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_protocol.h"
#include "http_request.h"
#include "util_varbuf.h"
#include "mod_auth.h"
#include "mod_authz_owner.h"
typedef struct {
char *groupfile;
static void *create_authz_groupfile_dir_config(apr_pool_t *p, char *d)
{
return conf;
}
static const command_rec authz_groupfile_cmds[] =
{
"text file containing group names and member user IDs"),
{NULL}
};
#define VARBUF_INIT_LEN 512
apr_table_t ** out)
{
ap_configfile_t *f;
apr_pool_t *sp;
const char *group_name, *ll, *w;
return status ;
}
apr_pool_create(&sp, p);
continue;
}
--group_len;
}
while (ll[0]) {
"in");
break;
}
}
}
ap_cfg_closefile(f);
ap_varbuf_free(&vb);
return APR_SUCCESS;
}
const char *require_args,
const void *parsed_require_args)
{
const char *require;
const char *t, *w;
if (!user) {
return AUTHZ_DENIED_NO_USER;
}
/* If there is no group file - then we are not
* configured. So decline.
*/
"No group file was specified in the configuration");
return AUTHZ_DENIED;
}
&grpstatus);
if (status != APR_SUCCESS) {
"Could not open group file: %s",
return AUTHZ_DENIED;
}
if (apr_is_empty_table(grpstatus)) {
/* no groups available, so exit immediately */
"Authorization of user %s to access %s failed, reason: "
"user doesn't appear in group file (%s).",
return AUTHZ_DENIED;
}
if (err) {
"authz_groupfile authorize: require group: Can't "
"evaluate require expression: %s", err);
return AUTHZ_DENIED;
}
t = require;
while ((w = ap_getword_conf(r->pool, &t)) && w[0]) {
if (apr_table_get(grpstatus, w)) {
return AUTHZ_GRANTED;
}
}
"Authorization of user %s to access %s failed, reason: "
"user is not part of the 'require'ed group(s).",
return AUTHZ_DENIED;
}
const char *require_args,
const void *parsed_require_args)
{
if (!user) {
return AUTHZ_DENIED_NO_USER;
}
/* If there is no group file - then we are not
* configured. So decline.
*/
"No group file was specified in the configuration");
return AUTHZ_DENIED;
}
&grpstatus);
if (status != APR_SUCCESS) {
"Could not open group file: %s",
return AUTHZ_DENIED;
}
if (apr_is_empty_table(grpstatus)) {
/* no groups available, so exit immediately */
"Authorization of user %s to access %s failed, reason: "
"user doesn't appear in group file (%s).",
return AUTHZ_DENIED;
}
if (filegroup) {
return AUTHZ_GRANTED;
}
}
else {
/* No need to emit a error log entry because the call
to authz_owner_get_file_group already did it
for us.
*/
return AUTHZ_DENIED;
}
"Authorization of user %s to access %s failed, reason: "
"user is not part of the 'require'ed file group.",
return AUTHZ_DENIED;
}
const void **parsed_require_line)
{
if (expr_err)
"Cannot parse expression in require line: ",
return NULL;
}
static const authz_provider authz_group_provider =
{
};
static const authz_provider authz_filegroup_provider =
{
NULL,
};
static void authz_groupfile_getfns(void)
{
}
static void register_hooks(apr_pool_t *p)
{
}
{
create_authz_groupfile_dir_config,/* dir config creater */
NULL, /* dir merger -- default is to override */
NULL, /* server config */
NULL, /* merge server config */
authz_groupfile_cmds, /* command apr_table_t */
register_hooks /* register hooks */
};