diff options
author | Valentin Bartenev <vbart@nginx.com> | 2019-02-27 16:44:52 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2019-02-27 16:44:52 +0300 |
commit | c24c0deb19034726b6450efcd5bce17632177f1b (patch) | |
tree | cdd8e0bb5b5bcee2ccd7f79afae38c157d09b050 | |
parent | d4ccaae900f78b13923a9bd9ee7bbaa33c99b18b (diff) | |
download | unit-c24c0deb19034726b6450efcd5bce17632177f1b.tar.gz unit-c24c0deb19034726b6450efcd5bce17632177f1b.tar.bz2 |
Controller: added "pass" configuration option.
-rw-r--r-- | src/nxt_conf_validation.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c index b1e30955..3485b4e3 100644 --- a/src/nxt_conf_validation.c +++ b/src/nxt_conf_validation.c @@ -54,6 +54,8 @@ static nxt_int_t nxt_conf_vldt_listener(nxt_conf_validation_t *vldt, static nxt_int_t nxt_conf_vldt_certificate(nxt_conf_validation_t *vldt, nxt_conf_value_t *value, void *data); #endif +static nxt_int_t nxt_conf_vldt_pass(nxt_conf_validation_t *vldt, + nxt_conf_value_t *value, void *data); static nxt_int_t nxt_conf_vldt_app_name(nxt_conf_validation_t *vldt, nxt_conf_value_t *value, void *data); static nxt_int_t nxt_conf_vldt_app(nxt_conf_validation_t *vldt, @@ -158,6 +160,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_tls_members[] = { static nxt_conf_vldt_object_t nxt_conf_vldt_listener_members[] = { + { nxt_string("pass"), + NXT_CONF_VLDT_STRING, + &nxt_conf_vldt_pass, + NULL }, + { nxt_string("application"), NXT_CONF_VLDT_STRING, &nxt_conf_vldt_app_name, @@ -495,6 +502,61 @@ nxt_conf_vldt_listener(nxt_conf_validation_t *vldt, nxt_str_t *name, } +static nxt_int_t +nxt_conf_vldt_pass(nxt_conf_validation_t *vldt, nxt_conf_value_t *value, + void *data) +{ + u_char *p; + nxt_str_t pass, first, second; + + nxt_conf_get_string(value, &pass); + + p = nxt_memchr(pass.start, '/', pass.length); + + if (p != NULL) { + first.length = p - pass.start; + first.start = pass.start; + + if (pass.length - first.length == 1) { + goto error; + } + + second.length = pass.length - first.length - 1; + second.start = p + 1; + + } else { + first = pass; + second.length = 0; + } + + if (nxt_str_eq(&first, "applications", 12)) { + + if (second.length == 0) { + goto error; + } + + value = nxt_conf_get_object_member(vldt->conf, &first, NULL); + + if (nxt_slow_path(value == NULL)) { + goto error; + } + + value = nxt_conf_get_object_member(value, &second, NULL); + + if (nxt_slow_path(value == NULL)) { + goto error; + } + + return NXT_OK; + } + +error: + + return nxt_conf_vldt_error(vldt, "Request \"pass\" points to invalid " + "location \"%V\".", &pass); +} + + #if (NXT_TLS) static nxt_int_t |