--- mod_auth.c	Mon Jan 15 17:05:36 2001
+++ mod_auth_plain.c	Mon Apr 23 17:07:41 2001
@@ -58,5 +58,10 @@
 
 /*
- * http_auth: authentication
+ * http_auth_plain: plaintext authentication
+ *
+ * Based on http_auth
+ * Adapted by Piotr Roszatycki <dexter@debian.org>
+ * 
+ * Original code:
  * 
  * Rob McCool
@@ -77,14 +82,14 @@
 #include "http_protocol.h"
 
-typedef struct auth_config_struct {
+typedef struct plain_auth_config_struct {
     char *auth_pwfile;
     char *auth_grpfile;
     int auth_authoritative;
-} auth_config_rec;
+} plain_auth_config_rec;
 
-static void *create_auth_dir_config(pool *p, char *d)
+static void *create_plain_auth_dir_config(pool *p, char *d)
 {
-    auth_config_rec *sec =
-    (auth_config_rec *) ap_pcalloc(p, sizeof(auth_config_rec));
+    plain_auth_config_rec *sec =
+    (plain_auth_config_rec *) ap_pcalloc(p, sizeof(plain_auth_config_rec));
     sec->auth_pwfile = NULL;	/* just to illustrate the default really */
     sec->auth_grpfile = NULL;	/* unless you have a broken HP cc */
@@ -93,22 +98,26 @@
 }
 
-static const char *set_auth_slot(cmd_parms *cmd, void *offset, char *f, char *t)
+static const char *set_plain_slot(cmd_parms *cmd, void *offset, char *f, char *t)
 {
-    if (t && strcmp(t, "standard"))
-	return ap_pstrcat(cmd->pool, "Invalid auth file type: ", t, NULL);
+    if (!t || strcmp(t, "plain"))
+	return DECLINE_CMD;
 
     return ap_set_file_slot(cmd, offset, f);
 }
 
-static const command_rec auth_cmds[] =
+static const command_rec plain_auth_cmds[] =
 {
-    {"AuthUserFile", set_auth_slot,
-     (void *) XtOffsetOf(auth_config_rec, auth_pwfile), OR_AUTHCFG, TAKE12,
+    {"AuthPlainUserFile", ap_set_file_slot,
+     (void *) XtOffsetOf(plain_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,
+    {"AuthPlainGroupFile", ap_set_file_slot,
+     (void *) XtOffsetOf(plain_auth_config_rec, auth_grpfile), OR_AUTHCFG, TAKE12,
      "text file containing group names and member user IDs"},
-    {"AuthAuthoritative", ap_set_flag_slot,
-     (void *) XtOffsetOf(auth_config_rec, auth_authoritative),
+    {"AuthUserFile", set_plain_slot,
+     (void *) XtOffsetOf(plain_auth_config_rec, auth_pwfile), OR_AUTHCFG, TAKE12, NULL},
+    {"AuthGroupFile", set_plain_slot,
+     (void *) XtOffsetOf(plain_auth_config_rec, auth_grpfile), OR_AUTHCFG, TAKE12, NULL},
+    {"AuthPlainAuthoritative", ap_set_flag_slot,
+     (void *) XtOffsetOf(plain_auth_config_rec, auth_authoritative),
      OR_AUTHCFG, FLAG,
      "Set to 'off' to allow access control to be passed along to lower modules if the UserID is not known to this module"},
@@ -116,7 +125,7 @@
 };
 
-module MODULE_VAR_EXPORT auth_module;
+module MODULE_VAR_EXPORT plain_auth_module;
 
-static char *get_pw(request_rec *r, char *user, char *auth_pwfile)
+static char *get_plain_pw(request_rec *r, char *user, char *auth_pwfile)
 {
     configfile_t *f;
@@ -144,5 +153,5 @@
 }
 
-static table *groups_for_user(pool *p, char *user, char *grpfile)
+static table *plain_groups_for_user(pool *p, char *user, char *grpfile)
 {
     configfile_t *f;
@@ -195,8 +204,8 @@
  */
 
-static int authenticate_basic_user(request_rec *r)
+static int plain_authenticate_basic_user(request_rec *r)
 {
-    auth_config_rec *sec =
-    (auth_config_rec *) ap_get_module_config(r->per_dir_config, &auth_module);
+    plain_auth_config_rec *sec =
+    (plain_auth_config_rec *) ap_get_module_config(r->per_dir_config, &plain_auth_module);
     conn_rec *c = r->connection;
     const char *sent_pw;
@@ -211,5 +220,5 @@
 	return DECLINED;
 
-    if (!(real_pw = get_pw(r, c->user, sec->auth_pwfile))) {
+    if (!(real_pw = get_plain_pw(r, c->user, sec->auth_pwfile))) {
 	if (!(sec->auth_authoritative))
 	    return DECLINED;
@@ -219,5 +228,5 @@
 	return AUTH_REQUIRED;
     }
-    invalid_pw = ap_validate_password(sent_pw, real_pw);
+    invalid_pw = (strcmp(sent_pw, real_pw) == 0) ? NULL : "password mismatch";
     if (invalid_pw != NULL) {
 	ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
@@ -232,8 +241,8 @@
 /* Checking ID */
 
-static int check_user_access(request_rec *r)
+static int plain_check_user_access(request_rec *r)
 {
-    auth_config_rec *sec =
-    (auth_config_rec *) ap_get_module_config(r->per_dir_config, &auth_module);
+    plain_auth_config_rec *sec =
+    (plain_auth_config_rec *) ap_get_module_config(r->per_dir_config, &plain_auth_module);
     char *user = r->connection->user;
     int m = r->method_number;
@@ -253,5 +262,5 @@
 
     if (sec->auth_grpfile)
-	grpstatus = groups_for_user(r->pool, user, sec->auth_grpfile);
+	grpstatus = plain_groups_for_user(r->pool, user, sec->auth_grpfile);
     else
 	grpstatus = NULL;
@@ -311,17 +320,17 @@
 }
 
-module MODULE_VAR_EXPORT auth_module =
+module MODULE_VAR_EXPORT plain_auth_module =
 {
     STANDARD_MODULE_STUFF,
     NULL,			/* initializer */
-    create_auth_dir_config,	/* dir config creater */
+    create_plain_auth_dir_config,	/* dir config creater */
     NULL,			/* dir merger --- default is to override */
     NULL,			/* server config */
     NULL,			/* merge server config */
-    auth_cmds,			/* command table */
+    plain_auth_cmds,		/* command table */
     NULL,			/* handlers */
     NULL,			/* filename translation */
-    authenticate_basic_user,	/* check_user_id */
-    check_user_access,		/* check auth */
+    plain_authenticate_basic_user,	/* check_user_id */
+    plain_check_user_access,	/* check auth */
     NULL,			/* check access */
     NULL,			/* type_checker */
