diff --git a/usr.sbin/pkg/config.h b/usr.sbin/pkg/config.h --- a/usr.sbin/pkg/config.h +++ b/usr.sbin/pkg/config.h @@ -44,6 +44,7 @@ FINGERPRINTS, REPOS_DIR, PUBKEY, + PKG_ENV, CONFIG_SIZE } pkg_config_key; @@ -51,6 +52,7 @@ PKG_CONFIG_STRING=0, PKG_CONFIG_BOOL, PKG_CONFIG_LIST, + PKG_CONFIG_OBJECT } pkg_config_t; typedef enum { diff --git a/usr.sbin/pkg/config.c b/usr.sbin/pkg/config.c --- a/usr.sbin/pkg/config.c +++ b/usr.sbin/pkg/config.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "config.h" @@ -134,6 +135,15 @@ NULL, false, false + }, + [PKG_ENV] = { + PKG_CONFIG_OBJECT, + "PKG_ENV", + NULL, + NULL, + NULL, + false, + false, } }; @@ -205,11 +215,11 @@ config_parse(const ucl_object_t *obj, pkg_conf_file_t conftype) { struct sbuf *buf = sbuf_new_auto(); - const ucl_object_t *cur, *seq; - ucl_object_iter_t it = NULL, itseq = NULL; + const ucl_object_t *cur, *seq, *tmp; + ucl_object_iter_t it = NULL, itseq = NULL, it_obj = NULL; struct config_entry *temp_config; struct config_value *cv; - const char *key; + const char *key, *evkey; int i; size_t j; @@ -224,7 +234,7 @@ if (conftype == CONFFILE_PKG) { for (j = 0; j < strlen(key); ++j) - sbuf_putc(buf, key[j]); + sbuf_putc(buf, toupper(key[j])); sbuf_finish(buf); } else if (conftype == CONFFILE_REPO) { if (strcasecmp(key, "url") == 0) @@ -285,6 +295,17 @@ temp_config[i].value = strdup(ucl_object_toboolean(cur) ? "yes" : "no"); break; + case PKG_CONFIG_OBJECT: + if (strcmp(c[i].key, "PKG_ENV") == 0) { + while ((tmp = + ucl_iterate_object(cur, &it_obj, true))) { + evkey = ucl_object_key(tmp); + if (evkey != NULL && *evkey != '\0') { + setenv(evkey, ucl_object_tostring_forced(tmp), 1); + } + } + } + break; default: /* Normal string value. */ temp_config[i].value = strdup(ucl_object_tostring(cur));