summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf_validation.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2018-05-28 20:55:23 +0300
committerValentin Bartenev <vbart@nginx.com>2018-05-28 20:55:23 +0300
commitd7e6e2bd8cb81d47c9e7300937cb08ec35b6c21b (patch)
tree6472a83f7b6acc1962f0a7449d74ddc577306b85 /src/nxt_conf_validation.c
parent3befb08204f64983e684904ecd2cb20ff45dd3c2 (diff)
downloadunit-d7e6e2bd8cb81d47c9e7300937cb08ec35b6c21b.tar.gz
unit-d7e6e2bd8cb81d47c9e7300937cb08ec35b6c21b.tar.bz2
Configuration of environment variables for application processes.
Diffstat (limited to '')
-rw-r--r--src/nxt_conf_validation.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index 62ca4b06..f31f3f15 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -62,6 +62,8 @@ static nxt_int_t nxt_conf_vldt_system(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_user(nxt_conf_validation_t *vldt, char *name);
static nxt_int_t nxt_conf_vldt_group(nxt_conf_validation_t *vldt, char *name);
+static nxt_int_t nxt_conf_vldt_environment(nxt_conf_validation_t *vldt,
+ nxt_str_t *name, nxt_conf_value_t *value);
static nxt_conf_vldt_object_t nxt_conf_vldt_root_members[] = {
@@ -165,6 +167,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_common_members[] = {
NULL,
NULL },
+ { nxt_string("environment"),
+ NXT_CONF_VLDT_OBJECT,
+ &nxt_conf_vldt_object_iterator,
+ (void *) &nxt_conf_vldt_environment },
+
NXT_CONF_VLDT_END
};
@@ -724,3 +731,40 @@ nxt_conf_vldt_group(nxt_conf_validation_t *vldt, char *group)
return NXT_ERROR;
}
+
+
+static nxt_int_t
+nxt_conf_vldt_environment(nxt_conf_validation_t *vldt, nxt_str_t *name,
+ nxt_conf_value_t *value)
+{
+ nxt_str_t str;
+
+ if (name->length == 0) {
+ return nxt_conf_vldt_error(vldt,
+ "The environment name must not be empty.");
+ }
+
+ if (nxt_memchr(name->start, '\0', name->length) != NULL) {
+ return nxt_conf_vldt_error(vldt, "The environment name must not "
+ "contain null character.");
+ }
+
+ if (nxt_memchr(name->start, '=', name->length) != NULL) {
+ return nxt_conf_vldt_error(vldt, "The environment name must not "
+ "contain '=' character.");
+ }
+
+ if (nxt_conf_type(value) != NXT_CONF_STRING) {
+ return nxt_conf_vldt_error(vldt, "The \"%V\" environment value must be "
+ "a string.", name);
+ }
+
+ nxt_conf_get_string(value, &str);
+
+ if (nxt_memchr(str.start, '\0', str.length) != NULL) {
+ return nxt_conf_vldt_error(vldt, "The \"%V\" environment value must "
+ "not contain null character.", name);
+ }
+
+ return NXT_OK;
+}