]> granicus.if.org Git - apache/blobdiff - modules/aaa/mod_access_compat.c
hostname: Test and log useragent_host per-request across various modules,
[apache] / modules / aaa / mod_access_compat.c
index 8b53465e6a1f52eeb30596cca6b722a45e78deb8..e9f1abe4835b03d1d90bb5e75f24d58fec4d5990 100644 (file)
@@ -147,7 +147,6 @@ static const char *allow_cmd(cmd_parms *cmd, void *dv, const char *from,
     allowdeny *a;
     char *where = apr_pstrdup(cmd->pool, where_c);
     char *s;
-    char msgbuf[120];
     apr_status_t rv;
 
     if (strcasecmp(from, "from"))
@@ -178,19 +177,19 @@ static const char *allow_cmd(cmd_parms *cmd, void *dv, const char *from,
             return "An IP address was expected";
         }
         else if (rv != APR_SUCCESS) {
-            apr_strerror(rv, msgbuf, sizeof msgbuf);
-            return apr_pstrdup(cmd->pool, msgbuf);
+            return apr_psprintf(cmd->pool, "%pm", &rv);
         }
         a->type = T_IP;
     }
     else if (!APR_STATUS_IS_EINVAL(rv = apr_ipsubnet_create(&a->x.ip, where,
                                                             NULL, cmd->pool))) {
-        if (rv != APR_SUCCESS) {
-            apr_strerror(rv, msgbuf, sizeof msgbuf);
-            return apr_pstrdup(cmd->pool, msgbuf);
-        }
+        if (rv != APR_SUCCESS)
+            return apr_psprintf(cmd->pool, "%pm", &rv);
         a->type = T_IP;
     }
+    else if (ap_strchr(where, '#')) {
+        return "No comments are allowed here";
+    }
     else { /* no slash, didn't look like an IP address => must be a host */
         a->type = T_HOST;
     }
@@ -271,7 +270,7 @@ static int find_allowdeny(request_rec *r, apr_array_header_t *a, int method)
             return 1;
 
         case T_IP:
-            if (apr_ipsubnet_test(ap[i].x.ip, r->connection->remote_addr)) {
+            if (apr_ipsubnet_test(ap[i].x.ip, r->useragent_addr)) {
                 return 1;
             }
             break;
@@ -280,10 +279,8 @@ static int find_allowdeny(request_rec *r, apr_array_header_t *a, int method)
             if (!gothost) {
                 int remotehost_is_ip;
 
-                remotehost = ap_get_remote_host(r->connection,
-                                                r->per_dir_config,
-                                                REMOTE_DOUBLE_REV,
-                                                &remotehost_is_ip);
+                remotehost = ap_get_useragent_host(r, REMOTE_DOUBLE_REV,
+                                                   &remotehost_is_ip);
 
                 if ((remotehost == NULL) || remotehost_is_ip) {
                     gothost = 1;
@@ -350,7 +347,7 @@ static int check_dir_access(request_rec *r)
     }
 
     if (ret == HTTP_FORBIDDEN) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01797)
                       "client denied by server configuration: %s%s",
                       r->filename ? "" : "uri ",
                       r->filename ? r->filename : r->uri);
@@ -368,7 +365,7 @@ static void register_hooks(apr_pool_t *p)
                          AP_AUTH_INTERNAL_PER_CONF);
 }
 
-module AP_MODULE_DECLARE_DATA access_compat_module =
+AP_DECLARE_MODULE(access_compat) =
 {
     STANDARD20_MODULE_STUFF,
     create_access_compat_dir_config,   /* dir config creater */