From 4bb8a1279070cbbde17790132145fd74b17fe28c Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 12 Mar 2002 19:47:16 +0000 Subject: [PATCH] fold duplication of SSL{Proxy}Protocol directives into ssl_cmd_protocol_parse function. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93865 13f79535-47bb-0310-9956-ffa450edef68 --- modules/ssl/ssl_engine_config.c | 77 ++++++++++----------------------- 1 file changed, 23 insertions(+), 54 deletions(-) diff --git a/modules/ssl/ssl_engine_config.c b/modules/ssl/ssl_engine_config.c index 4ff11a1eab..1003b1dc01 100644 --- a/modules/ssl/ssl_engine_config.c +++ b/modules/ssl/ssl_engine_config.c @@ -1060,14 +1060,16 @@ const char *ssl_cmd_SSLRequire(cmd_parms *cmd, void *ctx, return NULL; } -const char *ssl_cmd_SSLProtocol(cmd_parms *cmd, void *ctx, - const char *opt) +static const char *ssl_cmd_protocol_parse(cmd_parms *parms, + const char *arg, + ssl_proto_t *options) { - SSLSrvConfigRec *sc = mySrvConfig(cmd->server); - ssl_proto_t thisopt, options = SSL_PROTOCOL_NONE; + ssl_proto_t thisopt; + + *options = SSL_PROTOCOL_NONE; - while (*opt) { - char *w = ap_getword_conf(cmd->pool, &opt); + while (*arg) { + char *w = ap_getword_conf(parms->temp_pool, &arg); char action = '\0'; if ((*w == '+') || (*w == '-')) { @@ -1087,75 +1089,42 @@ const char *ssl_cmd_SSLProtocol(cmd_parms *cmd, void *ctx, thisopt = SSL_PROTOCOL_ALL; } else { - return apr_pstrcat(cmd->pool, - "SSLProtocol: Illegal protocol '", + return apr_pstrcat(parms->temp_pool, + parms->cmd->name, + ": Illegal protocol '", w, "'", NULL); } if (action == '-') { - options &= ~thisopt; + *options &= ~thisopt; } else if (action == '+') { - options |= thisopt; + *options |= thisopt; } else { - options = thisopt; + *options = thisopt; } } - sc->nProtocol = options; - return NULL; } +const char *ssl_cmd_SSLProtocol(cmd_parms *cmd, void *ctx, + const char *opt) +{ + SSLSrvConfigRec *sc = mySrvConfig(cmd->server); + + return ssl_cmd_protocol_parse(cmd, opt, &sc->nProtocol); +} + #ifdef SSL_EXPERIMENTAL_PROXY const char *ssl_cmd_SSLProxyProtocol(cmd_parms *cmd, char *struct_ptr, const char *opt) { SSLSrvConfigRec *sc = mySrvConfig(cmd->server); - ssl_proto_t thisopt, options = SSL_PROTOCOL_NONE; - - while (*opt) { - char *w = ap_getword_conf(cmd->pool, &opt); - char action = '\0'; - - if ((*w == '+') || (*w == '-')) { - action = *(w++); - } - - if (strcEQ(w, "SSLv2")) { - thisopt = SSL_PROTOCOL_SSLV2; - } - else if (strcEQ(w, "SSLv3")) { - thisopt = SSL_PROTOCOL_SSLV3; - } - else if (strcEQ(w, "TLSv1")) { - thisopt = SSL_PROTOCOL_TLSV1; - } - else if (strcEQ(w, "all")) { - thisopt = SSL_PROTOCOL_ALL; - } - else { - return apr_pstrcat(cmd->pool, - "SSLProxyProtocol: Illegal protocol '", - w, "'", NULL); - } - - if (action == '-') { - options &= ~thisopt; - } - else if (action == '+') { - options |= thisopt; - } - else { - options = thisopt; - } - } - - sc->nProxyProtocol = options; - return NULL; + return ssl_cmd_protocol_parse(cmd, opt, &sc->nProxyProtocol); } const char *ssl_cmd_SSLProxyCipherSuite(cmd_parms *cmd, char *struct_ptr, -- 2.40.0