| 141 | } |
| 142 | |
| 143 | static const char *allow_cmd(cmd_parms *cmd, void *dv, const char *from, |
| 144 | const char *where_c) |
| 145 | { |
| 146 | access_compat_dir_conf *d = (access_compat_dir_conf *) dv; |
| 147 | allowdeny *a; |
| 148 | char *where = apr_pstrdup(cmd->pool, where_c); |
| 149 | char *s; |
| 150 | apr_status_t rv; |
| 151 | |
| 152 | if (strcasecmp(from, "from")) |
| 153 | return "allow and deny must be followed by 'from'"; |
| 154 | |
| 155 | a = (allowdeny *) apr_array_push(cmd->info ? d->allows : d->denys); |
| 156 | a->x.from = where; |
| 157 | a->limited = cmd->limited; |
| 158 | |
| 159 | if (!strncasecmp(where, "env=!", 5)) { |
| 160 | a->type = T_NENV; |
| 161 | a->x.from += 5; |
| 162 | |
| 163 | } |
| 164 | else if (!strncasecmp(where, "env=", 4)) { |
| 165 | a->type = T_ENV; |
| 166 | a->x.from += 4; |
| 167 | |
| 168 | } |
| 169 | else if (!strcasecmp(where, "all")) { |
| 170 | a->type = T_ALL; |
| 171 | } |
| 172 | else if ((s = ap_strchr(where, '/'))) { |
| 173 | *s++ = '\0'; |
| 174 | rv = apr_ipsubnet_create(&a->x.ip, where, s, cmd->pool); |
| 175 | if(APR_STATUS_IS_EINVAL(rv)) { |
| 176 | /* looked nothing like an IP address */ |
| 177 | return "An IP address was expected"; |
| 178 | } |
| 179 | else if (rv != APR_SUCCESS) { |
| 180 | return apr_psprintf(cmd->pool, "%pm", &rv); |
| 181 | } |
| 182 | a->type = T_IP; |
| 183 | } |
| 184 | else if (!APR_STATUS_IS_EINVAL(rv = apr_ipsubnet_create(&a->x.ip, where, |
| 185 | NULL, cmd->pool))) { |
| 186 | if (rv != APR_SUCCESS) |
| 187 | return apr_psprintf(cmd->pool, "%pm", &rv); |
| 188 | a->type = T_IP; |
| 189 | } |
| 190 | else if (ap_strchr(where, '#')) { |
| 191 | return "No comments are allowed here"; |
| 192 | } |
| 193 | else { /* no slash, didn't look like an IP address => must be a host */ |
| 194 | a->type = T_HOST; |
| 195 | } |
| 196 | |
| 197 | return NULL; |
| 198 | } |
| 199 | |
| 200 | static char its_an_allow; |
nothing calls this directly
no test coverage detected