Commit e40bcce5 authored by Ryan Bloom's avatar Ryan Bloom
Browse files

Get all of the auth modules to the point that they will install and

be loadable into the server.  Our new build/install mechanism expects
that all modules will have a common name format.  The auth modules
didn't use that format, so we didn't install them properly.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87422 13f79535-47bb-0310-9956-ffa450edef68
parent 7add0ba5
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
Changes with Apache 2.0b1

  *) Get all of the auth modules to the point that they will install and
     be loadable into the server.  Our new build/install mechanism expects
     that all modules will have a common name format.  The auth modules 
     didn't use that format, so we didn't install them properly.
     [Ryan Bloom]

  *) API routines ap_pgethostbyname() and ap_pduphostent() are no longer
     available.  Use apr_getaddrinfo() instead.  [Jeff Trawick]

+38 −38
Original line number Diff line number Diff line
@@ -102,19 +102,19 @@
#include "http_request.h"
#include "apr_strings.h"

typedef struct auth_anon {
typedef struct anon_auth {
    char *password;
    struct auth_anon *next;
} auth_anon;
    struct anon_auth *next;
} anon_auth;

typedef struct {

    auth_anon *auth_anon_passwords;
    int auth_anon_nouserid;
    int auth_anon_logemail;
    int auth_anon_verifyemail;
    int auth_anon_mustemail;
    int auth_anon_authoritative;
    anon_auth *anon_auth_passwords;
    int anon_auth_nouserid;
    int anon_auth_logemail;
    int anon_auth_verifyemail;
    int anon_auth_mustemail;
    int anon_auth_authoritative;

} anon_auth_config_rec;

@@ -127,13 +127,13 @@ static void *create_anon_auth_dir_config(apr_pool_t *p, char *d)
	return NULL;		/* no memory... */

    /* just to illustrate the defaults really. */
    sec->auth_anon_passwords = NULL;
    sec->anon_auth_passwords = NULL;

    sec->auth_anon_nouserid = 0;
    sec->auth_anon_logemail = 1;
    sec->auth_anon_verifyemail = 0;
    sec->auth_anon_mustemail = 1;
    sec->auth_anon_authoritative = 0;
    sec->anon_auth_nouserid = 0;
    sec->anon_auth_logemail = 1;
    sec->anon_auth_verifyemail = 0;
    sec->anon_auth_mustemail = 1;
    sec->anon_auth_authoritative = 0;
    return sec;
}

@@ -141,7 +141,7 @@ static const char *anon_set_passwd_flag(cmd_parms *cmd,
				 void *dummy, int arg)
{
    anon_auth_config_rec *sec = dummy;
    sec->auth_anon_mustemail = arg;
    sec->anon_auth_mustemail = arg;
    return NULL;
}

@@ -149,7 +149,7 @@ static const char *anon_set_userid_flag(cmd_parms *cmd,
				 void *dummy, int arg)
{
    anon_auth_config_rec *sec = dummy;
    sec->auth_anon_nouserid = arg;
    sec->anon_auth_nouserid = arg;
    return NULL;
}

@@ -157,7 +157,7 @@ static const char *anon_set_logemail_flag(cmd_parms *cmd,
				   void *dummy, int arg)
{
    anon_auth_config_rec *sec = dummy;
    sec->auth_anon_logemail = arg;
    sec->anon_auth_logemail = arg;
    return NULL;
}

@@ -165,14 +165,14 @@ static const char *anon_set_verifyemail_flag(cmd_parms *cmd,
				      void *dummy, int arg)
{
    anon_auth_config_rec *sec = dummy;
    sec->auth_anon_verifyemail = arg;
    sec->anon_auth_verifyemail = arg;
    return NULL;
}
static const char *anon_set_authoritative_flag(cmd_parms *cmd,
					void *dummy, int arg)
{
    anon_auth_config_rec *sec = dummy;
    sec->auth_anon_authoritative = arg;
    sec->anon_auth_authoritative = arg;
    return NULL;
}

@@ -180,20 +180,20 @@ static const char *anon_set_string_slots(cmd_parms *cmd,
				  void *dummy, const char *arg)
{
    anon_auth_config_rec *sec = dummy;
    auth_anon *first;
    anon_auth *first;

    if (!(*arg))
	return "Anonymous string cannot be empty, use Anonymous_NoUserId instead";

    /* squeeze in a record */
    first = sec->auth_anon_passwords;
    first = sec->anon_auth_passwords;

    if (!(sec->auth_anon_passwords = apr_palloc(cmd->pool, sizeof(auth_anon))) ||
       !(sec->auth_anon_passwords->password = apr_pstrdup(cmd->pool, arg)))
    if (!(sec->anon_auth_passwords = apr_palloc(cmd->pool, sizeof(anon_auth))) ||
       !(sec->anon_auth_passwords->password = apr_pstrdup(cmd->pool, arg)))
	     return "Failed to claim memory for an anonymous password...";

    /* and repair the next */
    sec->auth_anon_passwords->next = first;
    sec->anon_auth_passwords->next = first;

    return NULL;
}
@@ -215,13 +215,13 @@ static const command_rec anon_auth_cmds[] =
    {NULL}
};

module AP_MODULE_DECLARE_DATA auth_anon_module;
module AP_MODULE_DECLARE_DATA anon_auth_module;

static int anon_authenticate_basic_user(request_rec *r)
{
    anon_auth_config_rec *sec =
    (anon_auth_config_rec *) ap_get_module_config(r->per_dir_config,
					       &auth_anon_module);
					       &anon_auth_module);
    const char *sent_pw;
    int res = DECLINED;

@@ -229,17 +229,17 @@ static int anon_authenticate_basic_user(request_rec *r)
	return res;

    /* Ignore if we are not configured */
    if (!sec->auth_anon_passwords)
    if (!sec->anon_auth_passwords)
	return DECLINED;

    /* Do we allow an empty userID and/or is it the magic one
     */

    if ((!(r->user[0])) && (sec->auth_anon_nouserid)) {
    if ((!(r->user[0])) && (sec->anon_auth_nouserid)) {
	res = OK;
    }
    else {
	auth_anon *p = sec->auth_anon_passwords;
	anon_auth *p = sec->anon_auth_passwords;
	res = DECLINED;
	while ((res == DECLINED) && (p != NULL)) {
	    if (!(strcasecmp(r->user, p->password)))
@@ -251,12 +251,12 @@ static int anon_authenticate_basic_user(request_rec *r)
    /* username is OK */
	   (res == OK)
    /* password been filled out ? */
	   && ((!sec->auth_anon_mustemail) || strlen(sent_pw))
	   && ((!sec->anon_auth_mustemail) || strlen(sent_pw))
    /* does the password look like an email address ? */
	   && ((!sec->auth_anon_verifyemail)
	   && ((!sec->anon_auth_verifyemail)
	       || ((strpbrk("@", sent_pw) != NULL)
		   && (strpbrk(".", sent_pw) != NULL)))) {
	if (sec->auth_anon_logemail && ap_is_initial_req(r)) {
	if (sec->anon_auth_logemail && ap_is_initial_req(r)) {
	    ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, APR_SUCCESS, r,
			"Anonymous: Passwd <%s> Accepted",
			sent_pw ? sent_pw : "\'none\'");
@@ -264,7 +264,7 @@ static int anon_authenticate_basic_user(request_rec *r)
	return OK;
    }
    else {
	if (sec->auth_anon_authoritative) {
	if (sec->anon_auth_authoritative) {
	    ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, APR_SUCCESS, r,
			"Anonymous: Authoritative, Passwd <%s> not accepted",
			sent_pw ? sent_pw : "\'none\'");
@@ -282,12 +282,12 @@ static int check_anon_access(request_rec *r)
    conn_rec *c = r->connection;
    anon_auth_config_rec *sec =
    (anon_auth_config_rec *) ap_get_module_config(r->per_dir_config,
					       &auth_anon_module);
					       &anon_auth_module);

    if (!sec->auth_anon)
    if (!sec->anon_auth)
	return DECLINED;

    if (strcasecmp(r->connection->user, sec->auth_anon))
    if (strcasecmp(r->connection->user, sec->anon_auth))
	return DECLINED;

    return OK;
@@ -300,7 +300,7 @@ static void register_hooks(void)
    ap_hook_auth_checker(check_anon_access,NULL,NULL,AP_HOOK_MIDDLE);
}

module AP_MODULE_DECLARE_DATA auth_anon_module =
module AP_MODULE_DECLARE_DATA anon_auth_module =
{
    STANDARD20_MODULE_STUFF,
    create_anon_auth_dir_config,/* dir config creater */
+5 −5
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@
 *           instead of   AuthDBMUserFile    AuthDBMGroupFile
 *
 * Also, in the configuration file you need to specify
 *  auth_db_module rather than auth_dbm_module
 *  db_auth_module rather than auth_dbm_module
 *
 * On some BSD systems (e.g. FreeBSD and NetBSD) dbm is automatically
 * mapped to Berkeley DB. You can use either mod_auth_dbm or
@@ -158,7 +158,7 @@ static const command_rec db_auth_cmds[] =
    {NULL}
};

module auth_db_module;
module db_auth_module;

static char *get_db_pw(request_rec *r, char *user, const char *auth_dbpwfile)
{
@@ -288,7 +288,7 @@ static int db_authenticate_basic_user(request_rec *r)
{
    db_auth_config_rec *sec =
    (db_auth_config_rec *) ap_get_module_config(r->per_dir_config,
						&auth_db_module);
						&db_auth_module);
    const char *sent_pw;
    char *real_pw, *colon_pw;
    apr_status_t invalid_pw;
@@ -336,7 +336,7 @@ static int db_check_auth(request_rec *r)
{
    db_auth_config_rec *sec =
    (db_auth_config_rec *) ap_get_module_config(r->per_dir_config,
						&auth_db_module);
						&db_auth_module);
    char *user = r->user;
    int m = r->method_number;

@@ -399,7 +399,7 @@ static void register_hooks(void)
    ap_hook_auth_checker(db_check_auth,NULL,NULL,AP_HOOK_MIDDLE);
}

module auth_db_module =
module db_auth_module =
{
    STANDARD20_MODULE_STUFF,
    create_db_auth_dir_config,	/* dir config creater */
+5 −5
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@
 *
 * XXX: this needs updating for apache-2.0 configuration method
 * MODULE-DEFINITION-START
 * Name: auth_dbm_module
 * Name: dbm_auth_module
 * ConfigStart
    . ./helpers/find-dbm-lib
 * ConfigEnd
@@ -153,7 +153,7 @@ static const command_rec dbm_auth_cmds[] =
    {NULL}
};

module AP_MODULE_DECLARE_DATA auth_dbm_module;
module AP_MODULE_DECLARE_DATA dbm_auth_module;

static char *get_dbm_pw(request_rec *r, char *user, char *auth_dbmpwfile)
{
@@ -234,7 +234,7 @@ static int dbm_authenticate_basic_user(request_rec *r)
{
    dbm_auth_config_rec *sec =
    (dbm_auth_config_rec *) ap_get_module_config(r->per_dir_config,
					      &auth_dbm_module);
					      &dbm_auth_module);
    const char *sent_pw;
    char *real_pw, *colon_pw;
    apr_status_t invalid_pw;
@@ -277,7 +277,7 @@ static int dbm_check_auth(request_rec *r)
{
    dbm_auth_config_rec *sec =
    (dbm_auth_config_rec *) ap_get_module_config(r->per_dir_config,
					      &auth_dbm_module);
					      &dbm_auth_module);
    char *user = r->user;
    int m = r->method_number;

@@ -341,7 +341,7 @@ static void register_hooks(void)
    ap_hook_auth_checker(dbm_check_auth, NULL, NULL, AP_HOOK_MIDDLE);
}

module AP_MODULE_DECLARE_DATA auth_dbm_module =
module AP_MODULE_DECLARE_DATA dbm_auth_module =
{
    STANDARD20_MODULE_STUFF,
    create_dbm_auth_dir_config,	/* dir config creater */
+9 −9
Original line number Diff line number Diff line
@@ -262,7 +262,7 @@ static long shmem_size = DEF_SHMEM_SIZE;
static long num_buckets = DEF_NUM_BUCKETS;


module AP_MODULE_DECLARE_DATA auth_digest_module;
module AP_MODULE_DECLARE_DATA digest_auth_module;

/*
 * initialization code
@@ -963,7 +963,7 @@ static int parse_hdr_and_update_nc(request_rec *r)
    resp->raw_request_uri = r->unparsed_uri;
    resp->psd_request_uri = &r->parsed_uri;
    resp->needed_auth = 0;
    ap_set_module_config(r->request_config, &auth_digest_module, resp);
    ap_set_module_config(r->request_config, &digest_auth_module, resp);

    res = get_digest_rec(r, resp);
    resp->client = get_client(resp->opaque_num, r);
@@ -1574,14 +1574,14 @@ static int authenticate_digest_user(request_rec *r)
    while (mainreq->main != NULL)  mainreq = mainreq->main;
    while (mainreq->prev != NULL)  mainreq = mainreq->prev;
    resp = (digest_header_rec *) ap_get_module_config(mainreq->request_config,
						      &auth_digest_module);
						      &digest_auth_module);
    resp->needed_auth = 1;


    /* get our conf */

    conf = (digest_config_rec *) ap_get_module_config(r->per_dir_config,
						      &auth_digest_module);
						      &digest_auth_module);


    /* check for existence and syntax of Auth header */
@@ -1810,7 +1810,7 @@ static int digest_check_auth(request_rec *r)
{
    const digest_config_rec *conf =
		(digest_config_rec *) ap_get_module_config(r->per_dir_config,
							   &auth_digest_module);
							   &digest_auth_module);
    const char *user = r->user;
    int m = r->method_number;
    int method_restricted = 0;
@@ -1880,7 +1880,7 @@ static int digest_check_auth(request_rec *r)

    note_digest_auth_failure(r, conf,
	(digest_header_rec *) ap_get_module_config(r->request_config,
						   &auth_digest_module),
						   &digest_auth_module),
	0);
    return HTTP_UNAUTHORIZED;
}
@@ -1905,10 +1905,10 @@ static int add_auth_info(request_rec *r)
{
    const digest_config_rec *conf =
		(digest_config_rec *) ap_get_module_config(r->per_dir_config,
							   &auth_digest_module);
							   &digest_auth_module);
    digest_header_rec *resp =
		(digest_header_rec *) ap_get_module_config(r->request_config,
							   &auth_digest_module);
							   &digest_auth_module);
    const char *ai = NULL, *digest = NULL, *nextnonce = "";

    if (resp == NULL || !resp->needed_auth || conf == NULL)
@@ -2062,7 +2062,7 @@ static void register_hooks(void)
    ap_hook_fixups(add_auth_info, NULL, NULL, AP_HOOK_MIDDLE);
}

module AP_MODULE_DECLARE_DATA auth_digest_module =
module AP_MODULE_DECLARE_DATA digest_auth_module =
{
    STANDARD20_MODULE_STUFF,
    create_digest_dir_config,	/* dir config creater */