MCPcopy Index your code
hub / github.com/apache/httpd / ap_check_cmd_context

Function ap_check_cmd_context

server/core.c:1301–1359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1299}
1300
1301AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd,
1302 unsigned forbidden)
1303{
1304 const char *gt = (cmd->cmd->name[0] == '<'
1305 && cmd->cmd->name[strlen(cmd->cmd->name)-1] != '>')
1306 ? ">" : "";
1307 const ap_directive_t *found;
1308
1309 if ((forbidden & NOT_IN_VIRTUALHOST) && cmd->server->is_virtual) {
1310 return apr_pstrcat(cmd->pool, cmd->cmd->name, gt,
1311 " cannot occur within <VirtualHost> section", NULL);
1312 }
1313
1314 if ((forbidden & NOT_IN_DIR_CONTEXT) && cmd->limited != -1) {
1315 return apr_pstrcat(cmd->pool, cmd->cmd->name, gt,
1316 " cannot occur within <Limit> or <LimitExcept> "
1317 "section", NULL);
1318 }
1319
1320 if ((forbidden & NOT_IN_HTACCESS) && (cmd->pool == cmd->temp_pool)) {
1321 return apr_pstrcat(cmd->pool, cmd->cmd->name, gt,
1322 " cannot occur within htaccess files", NULL);
1323 }
1324
1325 if ((forbidden & NOT_IN_DIR_LOC_FILE) == NOT_IN_DIR_LOC_FILE) {
1326 if (cmd->path != NULL) {
1327 return apr_pstrcat(cmd->pool, cmd->cmd->name, gt,
1328 " cannot occur within directory context", NULL);
1329 }
1330 if (cmd->cmd->req_override & EXEC_ON_READ) {
1331 /* EXEC_ON_READ must be NOT_IN_DIR_LOC_FILE, if not, it will
1332 * (deliberately) segfault below in the individual tests...
1333 */
1334 return NULL;
1335 }
1336 }
1337
1338 if (((forbidden & NOT_IN_DIRECTORY)
1339 && ((found = find_parent(cmd->directive, "<Directory"))
1340 || (found = find_parent(cmd->directive, "<DirectoryMatch"))))
1341 || ((forbidden & NOT_IN_LOCATION)
1342 && ((found = find_parent(cmd->directive, "<Location"))
1343 || (found = find_parent(cmd->directive, "<LocationMatch"))))
1344 || ((forbidden & NOT_IN_FILES)
1345 && ((found = find_parent(cmd->directive, "<Files"))
1346 || (found = find_parent(cmd->directive, "<FilesMatch"))
1347 || (found = find_parent(cmd->directive, "<If"))
1348 || (found = find_parent(cmd->directive, "<ElseIf"))
1349 || (found = find_parent(cmd->directive, "<Else"))))
1350 || ((forbidden & NOT_IN_PROXY)
1351 && ((found = find_parent(cmd->directive, "<Proxy"))
1352 || (found = find_parent(cmd->directive, "<ProxyMatch"))))) {
1353 return apr_pstrcat(cmd->pool, cmd->cmd->name, gt,
1354 " cannot occur within ", found->directive,
1355 "> section", NULL);
1356 }
1357
1358 return NULL;

Callers 15

add_cache_enableFunction · 0.85
add_cache_disableFunction · 0.85
dtraceenableFunction · 0.85
unixd_set_userFunction · 0.85
unixd_set_groupFunction · 0.85
unixd_set_chroot_dirFunction · 0.85
unixd_set_suexecFunction · 0.85
set_secure_listenerFunction · 0.85
set_keep_alive_timeoutFunction · 0.85
set_keep_aliveFunction · 0.85
set_keep_alive_maxFunction · 0.85

Calls 1

find_parentFunction · 0.85

Tested by

no test coverage detected