MCPcopy Create free account
hub / github.com/apache/httpd / set_document_root

Function set_document_root

server/core.c:1605–1646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1603}
1604
1605static const char *set_document_root(cmd_parms *cmd, void *dummy,
1606 const char *arg)
1607{
1608 void *sconf = cmd->server->module_config;
1609 core_server_config *conf = ap_get_core_module_config(sconf);
1610
1611 const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_CONTEXT);
1612 if (err != NULL) {
1613 return err;
1614 }
1615
1616 /* When ap_document_root_check is false; skip all the stuff below */
1617 if (!ap_document_root_check) {
1618 conf->ap_document_root = arg;
1619 return NULL;
1620 }
1621
1622 /* Make it absolute, relative to ServerRoot */
1623 arg = ap_server_root_relative(cmd->pool, arg);
1624 if (arg == NULL) {
1625 return "DocumentRoot must be a directory";
1626 }
1627
1628 /* TODO: ap_configtestonly */
1629 if (apr_filepath_merge((char**)&conf->ap_document_root, NULL, arg,
1630 APR_FILEPATH_TRUENAME, cmd->pool) != APR_SUCCESS
1631 || !ap_is_directory(cmd->temp_pool, arg)) {
1632 if (cmd->server->is_virtual) {
1633 ap_log_perror(APLOG_MARK, APLOG_STARTUP, 0,
1634 cmd->pool, APLOGNO(00112)
1635 "Warning: DocumentRoot [%s] does not exist",
1636 arg);
1637 conf->ap_document_root = arg;
1638 }
1639 else {
1640 return apr_psprintf(cmd->pool,
1641 "DocumentRoot '%s' is not a directory, or is not readable",
1642 arg);
1643 }
1644 }
1645 return NULL;
1646}
1647
1648AP_DECLARE(void) ap_custom_response(request_rec *r, int status,
1649 const char *string)

Callers

nothing calls this directly

Calls 4

ap_check_cmd_contextFunction · 0.85
ap_server_root_relativeFunction · 0.85
ap_is_directoryFunction · 0.85

Tested by

no test coverage detected