dgaudet 97/09/18 00:59:16
Modified: src INDENT
src/modules/standard mod_auth.c mod_auth_anon.c
mod_auth_db.c mod_auth_dbm.c
Log:
indent
Revision Changes Path
1.28 +8 -8 apachen/src/INDENT
Index: INDENT
===================================================================
RCS file: /export/home/cvs/apachen/src/INDENT,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- INDENT 1997/09/18 07:49:51 1.27
+++ INDENT 1997/09/18 07:59:12 1.28
@@ -61,14 +61,14 @@
mod_actions.c DONE by Dean
mod_alias.c DONE by Dean
mod_asis.c DONE by Dean
- mod_auth.c RESERVED by Dean
- mod_auth_anon.c RESERVED by Dean
- mod_auth_db.c RESERVED by Dean
- mod_auth_dbm.c RESERVED by Dean
- mod_autoindex.c
- mod_cern_meta.c
- mod_cgi.c
- mod_digest.c
+ mod_auth.c DONE by Dean
+ mod_auth_anon.c DONE by Dean
+ mod_auth_db.c DONE by Dean
+ mod_auth_dbm.c DONE by Dean
+ mod_autoindex.c RESERVED by Dean
+ mod_cern_meta.c RESERVED by Dean
+ mod_cgi.c RESERVED by Dean
+ mod_digest.c RESERVED by Dean
mod_dir.c
mod_dld.c
mod_env.c
1.27 +121 -114 apachen/src/modules/standard/mod_auth.c
Index: mod_auth.c
===================================================================
RCS file: /export/home/cvs/apachen/src/modules/standard/mod_auth.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- mod_auth.c 1997/08/31 21:41:13 1.26
+++ mod_auth.c 1997/09/18 07:59:13 1.27
@@ -58,10 +58,10 @@
* Adapted to Apache by rst.
*
* dirkx - Added Authoritative control to allow passing on to lower
- * modules if and only if the user-id is not known to this
- * module. A known user with a faulty or absent password still
- * causes an AuthRequired. The default is 'Authoritative', i.e.
- * no control is passed along.
+ * modules if and only if the user-id is not known to this
+ * module. A known user with a faulty or absent password still
+ * causes an AuthRequired. The default is 'Authoritative', i.e.
+ * no control is passed along.
*/
#include "httpd.h"
@@ -79,36 +79,37 @@
int auth_authoritative;
} auth_config_rec;
-static void *create_auth_dir_config (pool *p, char *d)
+static void *create_auth_dir_config(pool *p, char *d)
{
auth_config_rec *sec =
- (auth_config_rec *) pcalloc (p, sizeof(auth_config_rec));
- sec->auth_pwfile = NULL; /* just to illustrate the default really */
- sec->auth_grpfile = NULL; /* unless you have a broken HP cc */
- sec->auth_authoritative = 1; /* keep the fortress secure by default */
+ (auth_config_rec *) pcalloc(p, sizeof(auth_config_rec));
+ sec->auth_pwfile = NULL; /* just to illustrate the default really */
+ sec->auth_grpfile = NULL; /* unless you have a broken HP cc */
+ sec->auth_authoritative = 1; /* keep the fortress secure by default
*/
return sec;
}
-static const char *set_auth_slot (cmd_parms *cmd, void *offset, char *f,
char *t)
+static const char *set_auth_slot(cmd_parms *cmd, void *offset, char *f, char
*t)
{
if (t && strcmp(t, "standard"))
- return pstrcat(cmd->pool, "Invalid auth file type: ", t, NULL);
+ return pstrcat(cmd->pool, "Invalid auth file type: ", t, NULL);
return set_file_slot(cmd, offset, f);
}
-static command_rec auth_cmds[] = {
-{ "AuthUserFile", set_auth_slot,
- (void*)XtOffsetOf(auth_config_rec,auth_pwfile), OR_AUTHCFG, TAKE12,
- "text file containing user IDs and passwords" },
-{ "AuthGroupFile", set_auth_slot,
- (void*)XtOffsetOf(auth_config_rec,auth_grpfile), OR_AUTHCFG, TAKE12,
- "text file containing group names and member user IDs" },
-{ "AuthAuthoritative", set_flag_slot,
- (void*)XtOffsetOf(auth_config_rec,auth_authoritative),
- OR_AUTHCFG, FLAG,
- "Set to 'no' to allow access control to be passed along to lower modules
if the UserID is not known to this module" },
-{ NULL }
+static command_rec auth_cmds[] =
+{
+ {"AuthUserFile", set_auth_slot,
+ (void *) XtOffsetOf(auth_config_rec, auth_pwfile), OR_AUTHCFG, TAKE12,
+ "text file containing user IDs and passwords"},
+ {"AuthGroupFile", set_auth_slot,
+ (void *) XtOffsetOf(auth_config_rec, auth_grpfile), OR_AUTHCFG, TAKE12,
+ "text file containing group names and member user IDs"},
+ {"AuthAuthoritative", set_flag_slot,
+ (void *) XtOffsetOf(auth_config_rec, auth_authoritative),
+ OR_AUTHCFG, FLAG,
+ "Set to 'no' to allow access control to be passed along to lower
modules if the UserID is not known to this module"},
+ {NULL}
};
module MODULE_VAR_EXPORT auth_module;
@@ -119,54 +120,57 @@
char l[MAX_STRING_LEN];
const char *rpw, *w;
- if(!(f=pfopen(r->pool, auth_pwfile, "r"))) {
- aplog_error(APLOG_MARK, APLOG_ERR, r->server,
+ if (!(f = pfopen(r->pool, auth_pwfile, "r"))) {
+ aplog_error(APLOG_MARK, APLOG_ERR, r->server,
"Could not open password file: %s", auth_pwfile);
return NULL;
}
- while(!(cfg_getline(l,MAX_STRING_LEN,f))) {
- if((l[0] == '#') || (!l[0])) continue;
+ while (!(cfg_getline(l, MAX_STRING_LEN, f))) {
+ if ((l[0] == '#') || (!l[0]))
+ continue;
rpw = l;
- w = getword(r->pool, &rpw, ':');
+ w = getword(r->pool, &rpw, ':');
- if(!strcmp(user,w)) {
+ if (!strcmp(user, w)) {
pfclose(r->pool, f);
- return getword(r->pool, &rpw, ':');
+ return getword(r->pool, &rpw, ':');
}
}
pfclose(r->pool, f);
return NULL;
}
-static table *groups_for_user (pool *p, char *user, char *grpfile) {
+static table *groups_for_user(pool *p, char *user, char *grpfile)
+{
FILE *f;
- table *grps = make_table (p, 15);
+ table *grps = make_table(p, 15);
pool *sp;
char l[MAX_STRING_LEN];
const char *group_name, *ll, *w;
- if(!(f=pfopen(p, grpfile, "r")))
- return NULL;
+ if (!(f = pfopen(p, grpfile, "r")))
+ return NULL;
- sp = make_sub_pool (p);
-
- while(!(cfg_getline(l,MAX_STRING_LEN,f))) {
- if((l[0] == '#') || (!l[0])) continue;
+ sp = make_sub_pool(p);
+
+ while (!(cfg_getline(l, MAX_STRING_LEN, f))) {
+ if ((l[0] == '#') || (!l[0]))
+ continue;
ll = l;
- clear_pool (sp);
-
- group_name = getword(sp, &ll, ':');
-
- while(ll[0]) {
- w = getword_conf (sp, &ll);
- if(!strcmp(w,user)) {
- table_set (grps, group_name, "in");
+ clear_pool(sp);
+
+ group_name = getword(sp, &ll, ':');
+
+ while (ll[0]) {
+ w = getword_conf(sp, &ll);
+ if (!strcmp(w, user)) {
+ table_set(grps, group_name, "in");
break;
}
}
}
pfclose(p, f);
- destroy_pool (sp);
+ destroy_pool(sp);
return grps;
}
@@ -184,122 +188,125 @@
* basic authentication...
*/
-static int authenticate_basic_user (request_rec *r)
+static int authenticate_basic_user(request_rec *r)
{
auth_config_rec *sec =
- (auth_config_rec *)get_module_config (r->per_dir_config, &auth_module);
+ (auth_config_rec *) get_module_config(r->per_dir_config, &auth_module);
conn_rec *c = r->connection;
char *sent_pw, *real_pw;
char errstr[MAX_STRING_LEN];
int res;
-
- if ((res = get_basic_auth_pw (r, &sent_pw))) return res;
-
- if (!sec->auth_pwfile)
- return DECLINED;
-
+
+ if ((res = get_basic_auth_pw(r, &sent_pw)))
+ return res;
+
+ if (!sec->auth_pwfile)
+ return DECLINED;
+
if (!(real_pw = get_pw(r, c->user, sec->auth_pwfile))) {
if (!(sec->auth_authoritative))
return DECLINED;
- ap_snprintf(errstr, sizeof(errstr), "user %s not found", c->user);
+ ap_snprintf(errstr, sizeof(errstr), "user %s not found", c->user);
aplog_error(APLOG_MARK, APLOG_ERR, r->server, "%s: %s", errstr, r->uri);
note_basic_auth_failure(r);
return AUTH_REQUIRED;
}
/* anyone know where the prototype for crypt is? */
- if (strcmp(real_pw, (char *)crypt(sent_pw,real_pw))) {
- ap_snprintf(errstr, sizeof(errstr), "user %s: password
mismatch",c->user);
+ if (strcmp(real_pw, (char *) crypt(sent_pw, real_pw))) {
+ ap_snprintf(errstr, sizeof(errstr), "user %s: password mismatch",
c->user);
aplog_error(APLOG_MARK, APLOG_ERR, r->server, "%s: %s", errstr, r->uri);
note_basic_auth_failure(r);
return AUTH_REQUIRED;
}
return OK;
}
-
+
/* Checking ID */
-
-static int check_user_access (request_rec *r)
+
+static int check_user_access(request_rec *r)
{
auth_config_rec *sec =
- (auth_config_rec *)get_module_config (r->per_dir_config, &auth_module);
+ (auth_config_rec *) get_module_config(r->per_dir_config, &auth_module);
char *user = r->connection->user;
int m = r->method_number;
int method_restricted = 0;
register int x;
const char *t, *w;
table *grpstatus;
- array_header *reqs_arr = requires (r);
+ array_header *reqs_arr = requires(r);
require_line *reqs;
/* BUG FIX: tadc, 11-Nov-1995. If there is no "requires" directive,
* then any user will do.
*/
if (!reqs_arr)
- return (OK);
- reqs = (require_line *)reqs_arr->elts;
+ return (OK);
+ reqs = (require_line *) reqs_arr->elts;
if (sec->auth_grpfile)
- grpstatus = groups_for_user (r->pool, user, sec->auth_grpfile);
+ grpstatus = groups_for_user(r->pool, user, sec->auth_grpfile);
else
- grpstatus = NULL;
+ grpstatus = NULL;
for (x = 0; x < reqs_arr->nelts; x++) {
-
- if (! (reqs[x].method_mask & (1 << m))) continue;
-
+
+ if (!(reqs[x].method_mask & (1 << m)))
+ continue;
+
method_restricted = 1;
- t = reqs[x].requirement;
- w = getword(r->pool, &t, ' ');
- if (!strcmp(w,"valid-user"))
- return OK;
- if (!strcmp(w,"user")) {
- while(t[0]) {
- w = getword_conf(r->pool, &t);
- if (!strcmp(user,w))
- return OK;
- }
- }
- else if (!strcmp(w,"group")) {
- if (!grpstatus)
- return DECLINED; /* DBM group? Something else? */
-
- while (t[0]) {
- w = getword_conf(r->pool, &t);
- if (table_get(grpstatus, w))
+ t = reqs[x].requirement;
+ w = getword(r->pool, &t, ' ');
+ if (!strcmp(w, "valid-user"))
+ return OK;
+ if (!strcmp(w, "user")) {
+ while (t[0]) {
+ w = getword_conf(r->pool, &t);
+ if (!strcmp(user, w))
+ return OK;
+ }
+ }
+ else if (!strcmp(w, "group")) {
+ if (!grpstatus)
+ return DECLINED; /* DBM group? Something else? */
+
+ while (t[0]) {
+ w = getword_conf(r->pool, &t);
+ if (table_get(grpstatus, w))
return OK;
- }
- }
+ }
+ }
}
-
+
if (!method_restricted)
- return OK;
+ return OK;
- if (!(sec -> auth_authoritative))
- return DECLINED;
+ if (!(sec->auth_authoritative))
+ return DECLINED;
note_basic_auth_failure(r);
return AUTH_REQUIRED;
}
-module MODULE_VAR_EXPORT auth_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- create_auth_dir_config, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- auth_cmds, /* command table */
- NULL, /* handlers */
- NULL, /* filename translation */
- authenticate_basic_user, /* check_user_id */
- check_user_access, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+module MODULE_VAR_EXPORT auth_module =
+{
+ STANDARD_MODULE_STUFF,
+ NULL, /* initializer */
+ create_auth_dir_config, /* dir config creater */
+ NULL, /* dir merger --- default is to override */
+ NULL, /* server config */
+ NULL, /* merge server config */
+ auth_cmds, /* command table */
+ NULL, /* handlers */
+ NULL, /* filename translation */
+ authenticate_basic_user, /* check_user_id */
+ check_user_access, /* check auth */
+ NULL, /* check access */
+ NULL, /* type_checker */
+ NULL, /* fixups */
+ NULL, /* logger */
+ NULL, /* header parser */
+ NULL, /* child_init */
+ NULL, /* child_exit */
+ NULL /* post read-request */
};
1.25 +124 -113 apachen/src/modules/standard/mod_auth_anon.c
Index: mod_auth_anon.c
===================================================================
RCS file: /export/home/cvs/apachen/src/modules/standard/mod_auth_anon.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- mod_auth_anon.c 1997/08/31 21:54:00 1.24
+++ mod_auth_anon.c 1997/09/18 07:59:14 1.25
@@ -67,12 +67,12 @@
*
* Just add the following tokes to your <directory> setup:
*
- * Anonymous magic-user-id [magic-user-id]...
+ * Anonymous magic-user-id [magic-user-id]...
*
- * Anonymous_MustGiveEmail [ on | off ] default = off
- * Anonymous_LogEmail [ on | off ] default = on
- * Anonymous_VerifyEmail [ on | off ] default = off
- * Anonymous_NoUserId [ on | off ] default = off
+ * Anonymous_MustGiveEmail [ on | off ] default = off
+ * Anonymous_LogEmail [ on | off ] default = on
+ * Anonymous_VerifyEmail [ on | off ] default = off
+ * Anonymous_NoUserId [ on | off ] default = off
* Anonymous_Authoritative [ on | off ] default = off
*
* The magic user id is something like 'anonymous', it is NOT case
sensitive.
@@ -97,80 +97,88 @@
typedef struct auth_anon {
char *password;
- struct auth_anon * next;
- } auth_anon;
+ struct auth_anon *next;
+} auth_anon;
-typedef struct {
+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;
+ int auth_anon_nouserid;
+ int auth_anon_logemail;
+ int auth_anon_verifyemail;
+ int auth_anon_mustemail;
+ int auth_anon_authoritative;
} anon_auth_config_rec;
-void *create_anon_auth_dir_config (pool *p, char *d)
+void *create_anon_auth_dir_config(pool *p, char *d)
{
- anon_auth_config_rec * sec = (anon_auth_config_rec *)
- pcalloc (p, sizeof(anon_auth_config_rec));
+ anon_auth_config_rec *sec = (anon_auth_config_rec *)
+ pcalloc(p, sizeof(anon_auth_config_rec));
- if (!sec) return NULL; /* no memory... */
+ if (!sec)
+ return NULL; /* no memory... */
/* just to illustrate the defaults really. */
- sec -> auth_anon_passwords =NULL;
+ sec->auth_anon_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->auth_anon_nouserid = 0;
+ sec->auth_anon_logemail = 1;
+ sec->auth_anon_verifyemail = 0;
+ sec->auth_anon_mustemail = 1;
+ sec->auth_anon_authoritative = 0;
return sec;
}
-const char *anon_set_passwd_flag (cmd_parms *cmd,
- anon_auth_config_rec *sec, int arg) {
- sec->auth_anon_mustemail=arg;
+const char *anon_set_passwd_flag(cmd_parms *cmd,
+ anon_auth_config_rec * sec, int arg)
+{
+ sec->auth_anon_mustemail = arg;
return NULL;
}
-const char *anon_set_userid_flag (cmd_parms *cmd,
- anon_auth_config_rec *sec, int arg) {
- sec->auth_anon_nouserid=arg;
+const char *anon_set_userid_flag(cmd_parms *cmd,
+ anon_auth_config_rec * sec, int arg)
+{
+ sec->auth_anon_nouserid = arg;
return NULL;
}
-const char *anon_set_logemail_flag (cmd_parms *cmd,
- anon_auth_config_rec *sec, int arg) {
- sec->auth_anon_logemail=arg;
+const char *anon_set_logemail_flag(cmd_parms *cmd,
+ anon_auth_config_rec * sec, int arg)
+{
+ sec->auth_anon_logemail = arg;
return NULL;
}
-const char *anon_set_verifyemail_flag (cmd_parms *cmd,
- anon_auth_config_rec *sec, int arg) {
- sec->auth_anon_verifyemail=arg;
+const char *anon_set_verifyemail_flag(cmd_parms *cmd,
+ anon_auth_config_rec * sec, int arg)
+{
+ sec->auth_anon_verifyemail = arg;
return NULL;
}
-const char *anon_set_authoritative_flag (cmd_parms *cmd,
- anon_auth_config_rec *sec, int arg) {
- sec->auth_anon_authoritative=arg;
+const char *anon_set_authoritative_flag(cmd_parms *cmd,
+ anon_auth_config_rec * sec, int arg)
+{
+ sec->auth_anon_authoritative = arg;
return NULL;
}
-const char *anon_set_string_slots (cmd_parms *cmd,
- anon_auth_config_rec *sec, char *arg) {
-
- auth_anon * first;
+const char *anon_set_string_slots(cmd_parms *cmd,
+ anon_auth_config_rec * sec, char *arg)
+{
+
+ auth_anon *first;
if (!(*arg))
- return "Anonymous string cannot be empty, use Anonymous_NoUserId
instead";
+ return "Anonymous string cannot be empty, use Anonymous_NoUserId
instead";
/* squeeze in a record */
first = sec->auth_anon_passwords;
-
+
if (
- (!(sec->auth_anon_passwords=(auth_anon *) palloc(cmd -> pool,
sizeof(auth_anon)))) ||
- (!(sec->auth_anon_passwords->password = pstrdup(cmd -> pool, arg)))
- ) return "Failed to claim memory for an anonymous password...";
+ (!(sec->auth_anon_passwords = (auth_anon *) palloc(cmd->pool,
sizeof(auth_anon)))) ||
+ (!(sec->auth_anon_passwords->password = pstrdup(cmd->pool, arg)))
+ )
+ return "Failed to claim memory for an anonymous password...";
/* and repair the next */
sec->auth_anon_passwords->next = first;
@@ -178,75 +186,76 @@
return NULL;
}
-command_rec anon_auth_cmds[] = {
-{ "Anonymous", anon_set_string_slots, NULL,OR_AUTHCFG, ITERATE,
- "a space-separated list of user IDs" },
-{ "Anonymous_MustGiveEmail", anon_set_passwd_flag, NULL, OR_AUTHCFG, FLAG,
- "Limited to 'on' or 'off'" },
-{ "Anonymous_NoUserId", anon_set_userid_flag, NULL, OR_AUTHCFG, FLAG,
- "Limited to 'on' or 'off'" },
-{ "Anonymous_VerifyEmail", anon_set_verifyemail_flag, NULL, OR_AUTHCFG,
FLAG,
- "Limited to 'on' or 'off'" },
-{ "Anonymous_LogEmail", anon_set_logemail_flag, NULL, OR_AUTHCFG, FLAG,
- "Limited to 'on' or 'off'" },
-{ "Anonymous_Authoritative", anon_set_authoritative_flag, NULL, OR_AUTHCFG,
FLAG,
- "Limited to 'on' or 'off'" },
+command_rec anon_auth_cmds[] =
+{
+ {"Anonymous", anon_set_string_slots, NULL, OR_AUTHCFG, ITERATE,
+ "a space-separated list of user IDs"},
+ {"Anonymous_MustGiveEmail", anon_set_passwd_flag, NULL, OR_AUTHCFG, FLAG,
+ "Limited to 'on' or 'off'"},
+ {"Anonymous_NoUserId", anon_set_userid_flag, NULL, OR_AUTHCFG, FLAG,
+ "Limited to 'on' or 'off'"},
+{"Anonymous_VerifyEmail", anon_set_verifyemail_flag, NULL, OR_AUTHCFG, FLAG,
+ "Limited to 'on' or 'off'"},
+ {"Anonymous_LogEmail", anon_set_logemail_flag, NULL, OR_AUTHCFG, FLAG,
+ "Limited to 'on' or 'off'"},
+ {"Anonymous_Authoritative", anon_set_authoritative_flag, NULL,
OR_AUTHCFG, FLAG,
+ "Limited to 'on' or 'off'"},
-{ NULL }
+ {NULL}
};
module MODULE_VAR_EXPORT anon_auth_module;
-int anon_authenticate_basic_user (request_rec *r)
+int anon_authenticate_basic_user(request_rec *r)
{
anon_auth_config_rec *sec =
- (anon_auth_config_rec *)get_module_config(r->per_dir_config,
- &anon_auth_module);
+ (anon_auth_config_rec *) get_module_config(r->per_dir_config,
+ &anon_auth_module);
conn_rec *c = r->connection;
char *send_pw;
char errstr[MAX_STRING_LEN];
int res = DECLINED;
- if ((res=get_basic_auth_pw (r,&send_pw)))
+ if ((res = get_basic_auth_pw(r, &send_pw)))
return res;
/* Ignore if we are not configured */
- if (!sec->auth_anon_passwords) return DECLINED;
+ if (!sec->auth_anon_passwords)
+ return DECLINED;
/* Do we allow an empty userID and/or is it the magic one
*/
-
+
if ((!(c->user[0])) && (sec->auth_anon_nouserid)) {
res = OK;
}
else {
- auth_anon *p=sec->auth_anon_passwords;
+ auth_anon *p = sec->auth_anon_passwords;
res = DECLINED;
- while ((res == DECLINED) && (p !=NULL)) {
- if (!(strcasecmp(c->user,p->password)))
+ while ((res == DECLINED) && (p != NULL)) {
+ if (!(strcasecmp(c->user, p->password)))
res = OK;
p = p->next;
}
}
if (
- /* username is OK */
- (res == OK)
- /* password been filled out ? */
- && ((!sec->auth_anon_mustemail) || strlen(send_pw))
- /* does the password look like an email address ? */
- && ((!sec->auth_anon_verifyemail)
- || ((strpbrk("@",send_pw) != NULL)
- && (strpbrk(".",send_pw) != NULL))))
- {
+ /* username is OK */
+ (res == OK)
+ /* password been filled out ? */
+ && ((!sec->auth_anon_mustemail) || strlen(send_pw))
+ /* does the password look like an email address ? */
+ && ((!sec->auth_anon_verifyemail)
+ || ((strpbrk("@", send_pw) != NULL)
+ && (strpbrk(".", send_pw) != NULL)))) {
if (sec->auth_anon_logemail && is_initial_req(r)) {
- ap_snprintf(errstr, sizeof(errstr), "Anonymous: Passwd <%s>
Accepted",
+ ap_snprintf(errstr, sizeof(errstr), "Anonymous: Passwd <%s>
Accepted",
send_pw ? send_pw : "\'none\'");
aplog_error(APLOG_MARK, APLOG_ERR, r->server, errstr);
}
return OK;
}
else {
- if (sec->auth_anon_authoritative) {
+ if (sec->auth_anon_authoritative) {
ap_snprintf(errstr, sizeof(errstr),
"Anonymous: Authoritative, Passwd <%s> not accepted",
send_pw ? send_pw : "\'none\'");
@@ -255,47 +264,49 @@
}
/* Drop out the bottom to return DECLINED */
}
-
+
return DECLINED;
}
-
-int check_anon_access (request_rec *r)
+
+int check_anon_access(request_rec *r)
{
#ifdef NOTYET
conn_rec *c = r->connection;
anon_auth_config_rec *sec =
- (anon_auth_config_rec *)get_module_config (r->per_dir_config,
- &anon_auth_module);
-
- if (!sec->auth_anon) return DECLINED;
+ (anon_auth_config_rec *) get_module_config(r->per_dir_config,
+ &anon_auth_module);
- if ( strcasecmp(r->connection->user,sec->auth_anon ))
- return DECLINED;
+ if (!sec->auth_anon)
+ return DECLINED;
- return OK;
+ if (strcasecmp(r->connection->user, sec->auth_anon))
+ return DECLINED;
+
+ return OK;
#endif
- return DECLINED;
+ return DECLINED;
}
-
-module MODULE_VAR_EXPORT anon_auth_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- create_anon_auth_dir_config, /* dir config creater */
- NULL, /* dir merger ensure strictness */
- NULL, /* server config */
- NULL, /* merge server config */
- anon_auth_cmds, /* command table */
- NULL, /* handlers */
- NULL, /* filename translation */
- anon_authenticate_basic_user,/* check_user_id */
- check_anon_access, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+
+module MODULE_VAR_EXPORT anon_auth_module =
+{
+ STANDARD_MODULE_STUFF,
+ NULL, /* initializer */
+ create_anon_auth_dir_config, /* dir config creater */
+ NULL, /* dir merger ensure strictness */
+ NULL, /* server config */
+ NULL, /* merge server config */
+ anon_auth_cmds, /* command table */
+ NULL, /* handlers */
+ NULL, /* filename translation */
+ anon_authenticate_basic_user, /* check_user_id */
+ check_anon_access, /* check auth */
+ NULL, /* check access */
+ NULL, /* type_checker */
+ NULL, /* fixups */
+ NULL, /* logger */
+ NULL, /* header parser */
+ NULL, /* child_init */
+ NULL, /* child_exit */
+ NULL /* post read-request */
};
1.23 +143 -133 apachen/src/modules/standard/mod_auth_db.c
Index: mod_auth_db.c
===================================================================
RCS file: /export/home/cvs/apachen/src/modules/standard/mod_auth_db.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- mod_auth_db.c 1997/09/01 03:34:33 1.22
+++ mod_auth_db.c 1997/09/18 07:59:14 1.23
@@ -87,76 +87,77 @@
#include "http_protocol.h"
#include <db.h>
-typedef struct {
+typedef struct {
char *auth_dbpwfile;
char *auth_dbgrpfile;
- int auth_dbauthoritative;
+ int auth_dbauthoritative;
} db_auth_config_rec;
-static void *create_db_auth_dir_config (pool *p, char *d)
+static void *create_db_auth_dir_config(pool *p, char *d)
{
db_auth_config_rec *sec
- = (db_auth_config_rec *)pcalloc (p, sizeof(db_auth_config_rec));
+ = (db_auth_config_rec *) pcalloc(p, sizeof(db_auth_config_rec));
sec->auth_dbpwfile = NULL;
sec->auth_dbgrpfile = NULL;
- sec->auth_dbauthoritative=1; /* fortress is secure by default */
+ sec->auth_dbauthoritative = 1; /* fortress is secure by default */
return sec;
}
-static const char *set_db_slot (cmd_parms *cmd, void *offset, char *f, char
*t)
+static const char *set_db_slot(cmd_parms *cmd, void *offset, char *f, char
*t)
{
if (!t || strcmp(t, "db"))
- return DECLINE_CMD;
+ return DECLINE_CMD;
return set_file_slot(cmd, offset, f);
}
-static command_rec db_auth_cmds[] = {
-{ "AuthDBUserFile", set_file_slot,
- (void*)XtOffsetOf(db_auth_config_rec, auth_dbpwfile),
- OR_AUTHCFG, TAKE1, NULL },
-{ "AuthDBGroupFile", set_file_slot,
- (void*)XtOffsetOf(db_auth_config_rec, auth_dbgrpfile),
- OR_AUTHCFG, TAKE1, NULL },
-{ "AuthUserFile", set_db_slot,
- (void*)XtOffsetOf(db_auth_config_rec, auth_dbpwfile),
- OR_AUTHCFG, TAKE12, NULL },
-{ "AuthGroupFile", set_db_slot,
- (void*)XtOffsetOf(db_auth_config_rec, auth_dbgrpfile),
- OR_AUTHCFG, TAKE12, NULL },
-{ "AuthDBAuthoritative", set_flag_slot,
- (void*)XtOffsetOf(db_auth_config_rec, auth_dbauthoritative),
- OR_AUTHCFG, FLAG,
- "Set to 'no' to allow access control to be passed along to lower modules
if the userID is not known to this module" },
-{ NULL }
+static command_rec db_auth_cmds[] =
+{
+ {"AuthDBUserFile", set_file_slot,
+ (void *) XtOffsetOf(db_auth_config_rec, auth_dbpwfile),
+ OR_AUTHCFG, TAKE1, NULL},
+ {"AuthDBGroupFile", set_file_slot,
+ (void *) XtOffsetOf(db_auth_config_rec, auth_dbgrpfile),
+ OR_AUTHCFG, TAKE1, NULL},
+ {"AuthUserFile", set_db_slot,
+ (void *) XtOffsetOf(db_auth_config_rec, auth_dbpwfile),
+ OR_AUTHCFG, TAKE12, NULL},
+ {"AuthGroupFile", set_db_slot,
+ (void *) XtOffsetOf(db_auth_config_rec, auth_dbgrpfile),
+ OR_AUTHCFG, TAKE12, NULL},
+ {"AuthDBAuthoritative", set_flag_slot,
+ (void *) XtOffsetOf(db_auth_config_rec, auth_dbauthoritative),
+ OR_AUTHCFG, FLAG,
+ "Set to 'no' to allow access control to be passed along to lower
modules if the userID is not known to this module"},
+ {NULL}
};
module db_auth_module;
static char *get_db_pw(request_rec *r, char *user, const char *auth_dbpwfile)
{
- DB *f;
- DBT d, q;
+ DB *f;
+ DBT d, q;
char *pw = NULL;
- q.data = user;
- q.size = strlen(q.data);
-
- if (!(f = dbopen(auth_dbpwfile,O_RDONLY,0664,DB_HASH,NULL))) {
- aplog_error(APLOG_MARK, APLOG_ERR, r->server,
+ q.data = user;
+ q.size = strlen(q.data);
+
+ if (!(f = dbopen(auth_dbpwfile, O_RDONLY, 0664, DB_HASH, NULL))) {
+ aplog_error(APLOG_MARK, APLOG_ERR, r->server,
"could not open db auth file: %s", auth_dbpwfile);
return NULL;
}
- if (!((f->get)(f,&q,&d,0))) {
- pw = palloc(r->pool, d.size + 1);
- strncpy(pw,d.data,d.size);
- pw[d.size] = '\0'; /* Terminate the string */
+ if (!((f->get) (f, &q, &d, 0))) {
+ pw = palloc(r->pool, d.size + 1);
+ strncpy(pw, d.data, d.size);
+ pw[d.size] = '\0'; /* Terminate the string */
}
- (f->close)(f);
- return pw;
+ (f->close) (f);
+ return pw;
}
/* We do something strange with the group file. If the group file
@@ -170,141 +171,150 @@
* [EMAIL PROTECTED], 22Sep95
*/
-static char *get_db_grp(request_rec *r, char *user, const char
*auth_dbgrpfile) {
- char *grp_data = get_db_pw (r, user, auth_dbgrpfile);
- char *grp_colon; char *grp_colon2;
-
- if (grp_data == NULL) return NULL;
-
- if ((grp_colon = strchr(grp_data, ':'))!=NULL) {
- grp_colon2 = strchr(++grp_colon, ':');
- if (grp_colon2) *grp_colon2='\0';
- return grp_colon;
+static char *get_db_grp(request_rec *r, char *user, const char
*auth_dbgrpfile)
+{
+ char *grp_data = get_db_pw(r, user, auth_dbgrpfile);
+ char *grp_colon;
+ char *grp_colon2;
+
+ if (grp_data == NULL)
+ return NULL;
+
+ if ((grp_colon = strchr(grp_data, ':')) != NULL) {
+ grp_colon2 = strchr(++grp_colon, ':');
+ if (grp_colon2)
+ *grp_colon2 = '\0';
+ return grp_colon;
}
return grp_data;
}
-static int db_authenticate_basic_user (request_rec *r)
+static int db_authenticate_basic_user(request_rec *r)
{
db_auth_config_rec *sec =
- (db_auth_config_rec *)get_module_config(r->per_dir_config,
- &db_auth_module);
+ (db_auth_config_rec *) get_module_config(r->per_dir_config,
+ &db_auth_module);
conn_rec *c = r->connection;
char *sent_pw, *real_pw, *colon_pw;
char errstr[MAX_STRING_LEN];
int res;
-
+
if ((res = get_basic_auth_pw(r, &sent_pw)))
- return res;
-
+ return res;
+
if (!sec->auth_dbpwfile)
- return DECLINED;
-
+ return DECLINED;
+
if (!(real_pw = get_db_pw(r, c->user, sec->auth_dbpwfile))) {
- if (!(sec -> auth_dbauthoritative))
- return DECLINED;
- ap_snprintf(errstr, sizeof(errstr), "DB user %s not found", c->user);
+ if (!(sec->auth_dbauthoritative))
+ return DECLINED;
+ ap_snprintf(errstr, sizeof(errstr), "DB user %s not found", c->user);
aplog_error(APLOG_MARK, APLOG_ERR, r->server, "%s: %s", errstr,
r->filename);
note_basic_auth_failure(r);
return AUTH_REQUIRED;
- }
+ }
/* Password is up to first : if exists */
- colon_pw = strchr(real_pw,':');
- if (colon_pw) *colon_pw='\0';
+ colon_pw = strchr(real_pw, ':');
+ if (colon_pw)
+ *colon_pw = '\0';
/* anyone know where the prototype for crypt is? */
- if (strcmp(real_pw,(char *)crypt(sent_pw,real_pw))) {
- ap_snprintf(errstr, sizeof(errstr), "user %s: password
mismatch",c->user);
+ if (strcmp(real_pw, (char *) crypt(sent_pw, real_pw))) {
+ ap_snprintf(errstr, sizeof(errstr), "user %s: password mismatch",
c->user);
aplog_error(APLOG_MARK, APLOG_ERR, r->server, "%s: %s", errstr, r->uri);
note_basic_auth_failure(r);
return AUTH_REQUIRED;
}
return OK;
}
-
+
/* Checking ID */
-
+
static int db_check_auth(request_rec *r)
{
db_auth_config_rec *sec =
- (db_auth_config_rec *)get_module_config(r->per_dir_config,
- &db_auth_module);
+ (db_auth_config_rec *) get_module_config(r->per_dir_config,
+ &db_auth_module);
char *user = r->connection->user;
int m = r->method_number;
char errstr[MAX_STRING_LEN];
-
- array_header *reqs_arr = requires (r);
- require_line *reqs = reqs_arr ? (require_line *)reqs_arr->elts : NULL;
+
+ array_header *reqs_arr = requires(r);
+ require_line *reqs = reqs_arr ? (require_line *) reqs_arr->elts : NULL;
register int x;
const char *t;
char *w;
- if (!sec->auth_dbgrpfile) return DECLINED;
- if (!reqs_arr) return DECLINED;
-
+ if (!sec->auth_dbgrpfile)
+ return DECLINED;
+ if (!reqs_arr)
+ return DECLINED;
+
for (x = 0; x < reqs_arr->nelts; x++) {
-
- if (! (reqs[x].method_mask & (1 << m))) continue;
-
- t = reqs[x].requirement;
- w = getword(r->pool, &t, ' ');
-
- if (!strcmp(w,"group") && sec->auth_dbgrpfile) {
- const char *orig_groups,*groups;
- char *v;
-
- if (!(groups = get_db_grp(r, user, sec->auth_dbgrpfile))) {
- if (!(sec->auth_dbauthoritative))
- return DECLINED;
- ap_snprintf(errstr, sizeof(errstr),
- "user %s not in DB group file %s",
- user, sec->auth_dbgrpfile);
- aplog_error(APLOG_MARK, APLOG_ERR, r->server,
- "%s: %s", errstr, r->filename);
- note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
- orig_groups = groups;
- while (t[0]) {
- w = getword(r->pool, &t, ' ');
- groups = orig_groups;
- while (groups[0]) {
- v = getword(r->pool, &groups,',');
- if (!strcmp(v,w))
- return OK;
- }
- }
- ap_snprintf(errstr, sizeof(errstr),
- "user %s not in right group",user);
- aplog_error(APLOG_MARK, APLOG_ERR, r->server,
- "%s: %s", errstr, r->filename);
- note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
+
+ if (!(reqs[x].method_mask & (1 << m)))
+ continue;
+
+ t = reqs[x].requirement;
+ w = getword(r->pool, &t, ' ');
+
+ if (!strcmp(w, "group") && sec->auth_dbgrpfile) {
+ const char *orig_groups, *groups;
+ char *v;
+
+ if (!(groups = get_db_grp(r, user, sec->auth_dbgrpfile))) {
+ if (!(sec->auth_dbauthoritative))
+ return DECLINED;
+ ap_snprintf(errstr, sizeof(errstr),
+ "user %s not in DB group file %s",
+ user, sec->auth_dbgrpfile);
+ aplog_error(APLOG_MARK, APLOG_ERR, r->server,
+ "%s: %s", errstr, r->filename);
+ note_basic_auth_failure(r);
+ return AUTH_REQUIRED;
+ }
+ orig_groups = groups;
+ while (t[0]) {
+ w = getword(r->pool, &t, ' ');
+ groups = orig_groups;
+ while (groups[0]) {
+ v = getword(r->pool, &groups, ',');
+ if (!strcmp(v, w))
+ return OK;
+ }
+ }
+ ap_snprintf(errstr, sizeof(errstr),
+ "user %s not in right group", user);
+ aplog_error(APLOG_MARK, APLOG_ERR, r->server,
+ "%s: %s", errstr, r->filename);
+ note_basic_auth_failure(r);
+ return AUTH_REQUIRED;
+ }
}
-
+
return DECLINED;
}
-module db_auth_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- create_db_auth_dir_config, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- db_auth_cmds, /* command table */
- NULL, /* handlers */
- NULL, /* filename translation */
- db_authenticate_basic_user, /* check_user_id */
- db_check_auth, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+module db_auth_module =
+{
+ STANDARD_MODULE_STUFF,
+ NULL, /* initializer */
+ create_db_auth_dir_config, /* dir config creater */
+ NULL, /* dir merger --- default is to override */
+ NULL, /* server config */
+ NULL, /* merge server config */
+ db_auth_cmds, /* command table */
+ NULL, /* handlers */
+ NULL, /* filename translation */
+ db_authenticate_basic_user, /* check_user_id */
+ db_check_auth, /* check auth */
+ NULL, /* check access */
+ NULL, /* type_checker */
+ NULL, /* fixups */
+ NULL, /* logger */
+ NULL, /* header parser */
+ NULL, /* child_init */
+ NULL, /* child_exit */
+ NULL /* post read-request */
};
1.29 +157 -147 apachen/src/modules/standard/mod_auth_dbm.c
Index: mod_auth_dbm.c
===================================================================
RCS file: /export/home/cvs/apachen/src/modules/standard/mod_auth_dbm.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- mod_auth_dbm.c 1997/08/31 22:23:20 1.28
+++ mod_auth_dbm.c 1997/09/18 07:59:14 1.29
@@ -80,49 +80,49 @@
* Name: dbm_auth_module
* ConfigStart
if ./helpers/TestCompile func dbm_open; then
- :
+ :
else
- case "$PLAT" in
- *-linux*)
- # many systems don't have -ldbm
- DBM_LIB=""
- if ./helpers/TestCompile lib dbm; then
- DBM_LIB="-ldbm"
- elif ./helpers/TestCompile lib ndbm; then
- DBM_LIB="-lndbm"
- fi
- ;;
- esac
- LIBS="$LIBS $DBM_LIB"
- if [ "X$DBM_LIB" != "X" ]; then
- echo " + using $DBM_LIB for mod_auth_dbm"
- fi
+ case "$PLAT" in
+ *-linux*)
+ # many systems don't have -ldbm
+ DBM_LIB=""
+ if ./helpers/TestCompile lib dbm; then
+ DBM_LIB="-ldbm"
+ elif ./helpers/TestCompile lib ndbm; then
+ DBM_LIB="-lndbm"
+ fi
+ ;;
+ esac
+ LIBS="$LIBS $DBM_LIB"
+ if [ "X$DBM_LIB" != "X" ]; then
+ echo " + using $DBM_LIB for mod_auth_dbm"
+ fi
fi
* ConfigEnd
* MODULE-DEFINITION-END
*/
-typedef struct {
+typedef struct {
char *auth_dbmpwfile;
char *auth_dbmgrpfile;
- int auth_dbmauthoritative;
+ int auth_dbmauthoritative;
} dbm_auth_config_rec;
-static void *create_dbm_auth_dir_config (pool *p, char *d)
+static void *create_dbm_auth_dir_config(pool *p, char *d)
{
dbm_auth_config_rec *sec
- = (dbm_auth_config_rec *)pcalloc (p, sizeof(dbm_auth_config_rec));
+ = (dbm_auth_config_rec *) pcalloc(p, sizeof(dbm_auth_config_rec));
sec->auth_dbmpwfile = NULL;
sec->auth_dbmgrpfile = NULL;
- sec->auth_dbmauthoritative = 1; /* fortress is secure by default */
+ sec->auth_dbmauthoritative = 1; /* fortress is secure by default */
return sec;
}
-static const char *set_dbm_slot (cmd_parms *cmd, void *offset, char *f, char
*t)
+static const char *set_dbm_slot(cmd_parms *cmd, void *offset, char *f, char
*t)
{
if (!t || strcmp(t, "dbm"))
return DECLINE_CMD;
@@ -130,43 +130,44 @@
return set_file_slot(cmd, offset, f);
}
-static command_rec dbm_auth_cmds[] = {
-{ "AuthDBMUserFile", set_file_slot,
- (void*)XtOffsetOf(dbm_auth_config_rec, auth_dbmpwfile),
- OR_AUTHCFG, TAKE1, NULL },
-{ "AuthDBMGroupFile", set_file_slot,
- (void*)XtOffsetOf(dbm_auth_config_rec, auth_dbmgrpfile),
- OR_AUTHCFG, TAKE1, NULL },
-{ "AuthUserFile", set_dbm_slot,
- (void*)XtOffsetOf(dbm_auth_config_rec, auth_dbmpwfile),
- OR_AUTHCFG, TAKE12, NULL },
-{ "AuthGroupFile", set_dbm_slot,
- (void*)XtOffsetOf(dbm_auth_config_rec, auth_dbmgrpfile),
- OR_AUTHCFG, TAKE12, NULL },
-{ "AuthDBMAuthoritative", set_flag_slot,
- (void*)XtOffsetOf(dbm_auth_config_rec, auth_dbmauthoritative),
- OR_AUTHCFG, FLAG, "Set to 'no' to allow access control to be passed
along to lower modules, if the UserID is not known in this module" },
-{ NULL }
+static command_rec dbm_auth_cmds[] =
+{
+ {"AuthDBMUserFile", set_file_slot,
+ (void *) XtOffsetOf(dbm_auth_config_rec, auth_dbmpwfile),
+ OR_AUTHCFG, TAKE1, NULL},
+ {"AuthDBMGroupFile", set_file_slot,
+ (void *) XtOffsetOf(dbm_auth_config_rec, auth_dbmgrpfile),
+ OR_AUTHCFG, TAKE1, NULL},
+ {"AuthUserFile", set_dbm_slot,
+ (void *) XtOffsetOf(dbm_auth_config_rec, auth_dbmpwfile),
+ OR_AUTHCFG, TAKE12, NULL},
+ {"AuthGroupFile", set_dbm_slot,
+ (void *) XtOffsetOf(dbm_auth_config_rec, auth_dbmgrpfile),
+ OR_AUTHCFG, TAKE12, NULL},
+ {"AuthDBMAuthoritative", set_flag_slot,
+ (void *) XtOffsetOf(dbm_auth_config_rec, auth_dbmauthoritative),
+ OR_AUTHCFG, FLAG, "Set to 'no' to allow access control to be passed
along to lower modules, if the UserID is not known in this module"},
+ {NULL}
};
module dbm_auth_module;
-static char *get_dbm_pw (request_rec *r, char *user, char *auth_dbmpwfile)
+static char *get_dbm_pw(request_rec *r, char *user, char *auth_dbmpwfile)
{
- DBM *f;
- datum d, q;
+ DBM *f;
+ datum d, q;
char *pw = NULL;
- q.dptr = user;
+ q.dptr = user;
#ifndef NETSCAPE_DBM_COMPAT
- q.dsize = strlen(q.dptr);
+ q.dsize = strlen(q.dptr);
#else
- q.dsize = strlen(q.dptr) + 1;
+ q.dsize = strlen(q.dptr) + 1;
#endif
-
- if (!(f=dbm_open(auth_dbmpwfile,O_RDONLY,0664))) {
- aplog_error(APLOG_MARK, APLOG_ERR, r->server,
+
+ if (!(f = dbm_open(auth_dbmpwfile, O_RDONLY, 0664))) {
+ aplog_error(APLOG_MARK, APLOG_ERR, r->server,
"could not open dbm auth file: %s", auth_dbmpwfile);
return NULL;
}
@@ -174,13 +175,13 @@
d = dbm_fetch(f, q);
if (d.dptr) {
- pw = palloc(r->pool, d.dsize + 1);
- strncpy(pw,d.dptr,d.dsize);
- pw[d.dsize] = '\0'; /* Terminate the string */
+ pw = palloc(r->pool, d.dsize + 1);
+ strncpy(pw, d.dptr, d.dsize);
+ pw[d.dsize] = '\0'; /* Terminate the string */
}
dbm_close(f);
- return pw;
+ return pw;
}
/* We do something strange with the group file. If the group file
@@ -194,142 +195,151 @@
* [EMAIL PROTECTED], 22Sep95
*/
-static char *get_dbm_grp(request_rec *r, char *user, char *auth_dbmgrpfile)
{
- char *grp_data = get_dbm_pw (r, user, auth_dbmgrpfile);
- char *grp_colon; char *grp_colon2;
-
- if (grp_data == NULL) return NULL;
-
- if ((grp_colon = strchr(grp_data, ':'))!=NULL) {
- grp_colon2 = strchr(++grp_colon, ':');
- if (grp_colon2) *grp_colon2='\0';
- return grp_colon;
+static char *get_dbm_grp(request_rec *r, char *user, char *auth_dbmgrpfile)
+{
+ char *grp_data = get_dbm_pw(r, user, auth_dbmgrpfile);
+ char *grp_colon;
+ char *grp_colon2;
+
+ if (grp_data == NULL)
+ return NULL;
+
+ if ((grp_colon = strchr(grp_data, ':')) != NULL) {
+ grp_colon2 = strchr(++grp_colon, ':');
+ if (grp_colon2)
+ *grp_colon2 = '\0';
+ return grp_colon;
}
return grp_data;
}
-static int dbm_authenticate_basic_user (request_rec *r)
+static int dbm_authenticate_basic_user(request_rec *r)
{
dbm_auth_config_rec *sec =
- (dbm_auth_config_rec *)get_module_config(r->per_dir_config,
- &dbm_auth_module);
+ (dbm_auth_config_rec *) get_module_config(r->per_dir_config,
+ &dbm_auth_module);
conn_rec *c = r->connection;
char *sent_pw, *real_pw, *colon_pw;
char errstr[MAX_STRING_LEN];
int res;
-
+
if ((res = get_basic_auth_pw(r, &sent_pw)))
- return res;
-
+ return res;
+
if (!sec->auth_dbmpwfile)
- return DECLINED;
-
- if(!(real_pw = get_dbm_pw(r, c->user, sec->auth_dbmpwfile))) {
+ return DECLINED;
+
+ if (!(real_pw = get_dbm_pw(r, c->user, sec->auth_dbmpwfile))) {
if (!(sec->auth_dbmauthoritative))
return DECLINED;
- ap_snprintf(errstr, sizeof(errstr), "DBM user %s not found",
c->user);
+ ap_snprintf(errstr, sizeof(errstr), "DBM user %s not found", c->user);
aplog_error(APLOG_MARK, APLOG_ERR, r->server, "%s: %s", errstr,
r->filename);
note_basic_auth_failure(r);
return AUTH_REQUIRED;
- }
+ }
/* Password is up to first : if exists */
- colon_pw = strchr(real_pw,':');
- if (colon_pw) *colon_pw='\0';
+ colon_pw = strchr(real_pw, ':');
+ if (colon_pw)
+ *colon_pw = '\0';
/* anyone know where the prototype for crypt is? */
- if (strcmp(real_pw,(char *)crypt(sent_pw,real_pw))) {
- ap_snprintf(errstr, sizeof(errstr),
- "user %s: password mismatch",c->user);
+ if (strcmp(real_pw, (char *) crypt(sent_pw, real_pw))) {
+ ap_snprintf(errstr, sizeof(errstr),
+ "user %s: password mismatch", c->user);
aplog_error(APLOG_MARK, APLOG_ERR, r->server, "%s: %s", errstr, r->uri);
note_basic_auth_failure(r);
return AUTH_REQUIRED;
}
return OK;
}
-
+
/* Checking ID */
-
-static int dbm_check_auth (request_rec *r)
+
+static int dbm_check_auth(request_rec *r)
{
dbm_auth_config_rec *sec =
- (dbm_auth_config_rec *)get_module_config(r->per_dir_config,
- &dbm_auth_module);
+ (dbm_auth_config_rec *) get_module_config(r->per_dir_config,
+ &dbm_auth_module);
char *user = r->connection->user;
int m = r->method_number;
char errstr[MAX_STRING_LEN];
-
+
array_header *reqs_arr = requires(r);
- require_line *reqs = reqs_arr ? (require_line *)reqs_arr->elts : NULL;
+ require_line *reqs = reqs_arr ? (require_line *) reqs_arr->elts : NULL;
register int x;
const char *t;
char *w;
- if (!sec->auth_dbmgrpfile) return DECLINED;
- if (!reqs_arr) return DECLINED;
-
+ if (!sec->auth_dbmgrpfile)
+ return DECLINED;
+ if (!reqs_arr)
+ return DECLINED;
+
for (x = 0; x < reqs_arr->nelts; x++) {
-
- if (! (reqs[x].method_mask & (1 << m))) continue;
-
- t = reqs[x].requirement;
- w = getword(r->pool, &t, ' ');
-
- if (!strcmp(w,"group") && sec->auth_dbmgrpfile) {
- const char *orig_groups,*groups;
- char *v;
-
- if (!(groups = get_dbm_grp(r, user, sec->auth_dbmgrpfile))) {
- if (!(sec->auth_dbmauthoritative))
- return DECLINED;
- ap_snprintf(errstr, sizeof(errstr),
- "user %s not in DBM group file %s",
- user, sec->auth_dbmgrpfile);
- aplog_error(APLOG_MARK, APLOG_ERR, r->server,
- "%s: %s", errstr, r->filename);
- note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
- orig_groups = groups;
- while (t[0]) {
- w = getword(r->pool, &t, ' ');
- groups = orig_groups;
- while (groups[0]) {
- v = getword(r->pool, &groups,',');
- if (!strcmp(v,w))
- return OK;
- }
- }
- ap_snprintf(errstr, sizeof(errstr),
- "user %s not in right group", user);
- aplog_error(APLOG_MARK, APLOG_ERR, r->server,
- "%s: %s", errstr, r->filename);
- note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
+
+ if (!(reqs[x].method_mask & (1 << m)))
+ continue;
+
+ t = reqs[x].requirement;
+ w = getword(r->pool, &t, ' ');
+
+ if (!strcmp(w, "group") && sec->auth_dbmgrpfile) {
+ const char *orig_groups, *groups;
+ char *v;
+
+ if (!(groups = get_dbm_grp(r, user, sec->auth_dbmgrpfile))) {
+ if (!(sec->auth_dbmauthoritative))
+ return DECLINED;
+ ap_snprintf(errstr, sizeof(errstr),
+ "user %s not in DBM group file %s",
+ user, sec->auth_dbmgrpfile);
+ aplog_error(APLOG_MARK, APLOG_ERR, r->server,
+ "%s: %s", errstr, r->filename);
+ note_basic_auth_failure(r);
+ return AUTH_REQUIRED;
+ }
+ orig_groups = groups;
+ while (t[0]) {
+ w = getword(r->pool, &t, ' ');
+ groups = orig_groups;
+ while (groups[0]) {
+ v = getword(r->pool, &groups, ',');
+ if (!strcmp(v, w))
+ return OK;
+ }
+ }
+ ap_snprintf(errstr, sizeof(errstr),
+ "user %s not in right group", user);
+ aplog_error(APLOG_MARK, APLOG_ERR, r->server,
+ "%s: %s", errstr, r->filename);
+ note_basic_auth_failure(r);
+ return AUTH_REQUIRED;
+ }
}
-
+
return DECLINED;
}
-module dbm_auth_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- create_dbm_auth_dir_config, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- dbm_auth_cmds, /* command table */
- NULL, /* handlers */
- NULL, /* filename translation */
- dbm_authenticate_basic_user, /* check_user_id */
- dbm_check_auth, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+module dbm_auth_module =
+{
+ STANDARD_MODULE_STUFF,
+ NULL, /* initializer */
+ create_dbm_auth_dir_config, /* dir config creater */
+ NULL, /* dir merger --- default is to override */
+ NULL, /* server config */
+ NULL, /* merge server config */
+ dbm_auth_cmds, /* command table */
+ NULL, /* handlers */
+ NULL, /* filename translation */
+ dbm_authenticate_basic_user, /* check_user_id */
+ dbm_check_auth, /* check auth */
+ NULL, /* check access */
+ NULL, /* type_checker */
+ NULL, /* fixups */
+ NULL, /* logger */
+ NULL, /* header parser */
+ NULL, /* child_init */
+ NULL, /* child_exit */
+ NULL /* post read-request */
};