View | Details | Raw Unified | Return to bug 37201
Collapse All | Expand All

(-)server/core.c.orig (+74 lines)
Lines 1965-1970 Link Here
1965
    }
1965
    }
1966
}
1966
}
1967
1967
1968
static const char *start_ifbind(cmd_parms *cmd, void *dummy, const char *arg)
1969
{
1970
    const char *endp;
1971
    int ipconfigured = 0;
1972
    int not = 0;
1973
    char *host, *scope_id;
1974
    apr_port_t port; 
1975
    apr_status_t rv;
1976
    apr_socket_t *tmp_sock;
1977
    apr_sockaddr_t *sa;
1978
1979
    endp = ap_strrchr_c(arg, '>');
1980
    if (endp == NULL) {
1981
        return unclosed_directive(cmd);
1982
    }
1983
1984
    arg = apr_pstrndup(cmd->pool, arg, endp - arg);
1985
1986
    if (arg[0] == '!') {
1987
        not = 1;
1988
        arg++;
1989
    }
1990
1991
    rv = apr_parse_addr_port(&host, &scope_id, &port, arg, cmd->pool);
1992
    if (rv != APR_SUCCESS) {
1993
        return "Invalid address or port";
1994
    }
1995
1996
    if (!host || !strcmp(host, "*")) {
1997
        return "A host IP address must be set";
1998
    }
1999
2000
    if (scope_id) {
2001
        /* XXX scope id support is useful with link-local IPv6 addresses */
2002
        return "Scope id is not supported";
2003
    }
2004
2005
    if ((rv = apr_sockaddr_info_get(&sa, host, APR_UNSPEC, 0, 0, cmd->pool)) == APR_SUCCESS) {
2006
        if ((rv = apr_socket_create(&tmp_sock, sa->family, SOCK_STREAM, cmd->pool))
2007
            == APR_SUCCESS) {
2008
            if ((rv = apr_bind(tmp_sock, sa)) == APR_SUCCESS) {
2009
                ipconfigured = 1;
2010
            }
2011
            apr_socket_close(tmp_sock);
2012
        }
2013
    }
2014
2015
    if (ipconfigured) {
2016
        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, cmd->server,
2017
            "IfBind: IP %s exists on network interface", arg);
2018
    }
2019
    else {
2020
        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, rv, cmd->server,
2021
            "IfBind: IP %s does not exist on network interface", arg);
2022
    }
2023
2024
    if ((!not && ipconfigured) || (not && !ipconfigured)) {  
2025
        ap_directive_t *parent = NULL;
2026
        ap_directive_t *current = NULL;
2027
        const char *retval;
2028
  
2029
        retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd,
2030
                                      &current, &parent, "<IfBind");
2031
        *(ap_directive_t **)dummy = current;
2032
        return retval;
2033
    }
2034
    else {
2035
        *(ap_directive_t **)dummy = NULL;
2036
        return ap_soak_end_container(cmd, "<IfBind");
2037
    }
2038
}
2039
1968
/* httpd.conf commands... beginning with the <VirtualHost> business */
2040
/* httpd.conf commands... beginning with the <VirtualHost> business */
1969
2041
1970
static const char *virtualhost_section(cmd_parms *cmd, void *dummy,
2042
static const char *virtualhost_section(cmd_parms *cmd, void *dummy,
Lines 3170-3175 Link Here
3170
  "Container for directives based on existance of specified modules"),
3242
  "Container for directives based on existance of specified modules"),
3171
AP_INIT_TAKE1("<IfDefine", start_ifdefine, NULL, EXEC_ON_READ | OR_ALL,
3243
AP_INIT_TAKE1("<IfDefine", start_ifdefine, NULL, EXEC_ON_READ | OR_ALL,
3172
  "Container for directives based on existance of command line defines"),
3244
  "Container for directives based on existance of command line defines"),
3245
AP_INIT_TAKE1("<IfBind", start_ifbind, NULL, EXEC_ON_READ | OR_ALL,
3246
  "Container for directives based on an IP Address configured on the host network interface"),
3173
AP_INIT_RAW_ARGS("<DirectoryMatch", dirsection, (void*)1, RSRC_CONF,
3247
AP_INIT_RAW_ARGS("<DirectoryMatch", dirsection, (void*)1, RSRC_CONF,
3174
  "Container for directives affecting resources located in the "
3248
  "Container for directives affecting resources located in the "
3175
  "specified directories"),
3249
  "specified directories"),

Return to bug 37201