diff --git a/src/lib66/environ/env_resolve_conf.c b/src/lib66/environ/env_resolve_conf.c index 26317898a17cf15ad75092360127d24029639ab5..5e078288358adad63a9f3936bb93fd25b53259b4 100644 --- a/src/lib66/environ/env_resolve_conf.c +++ b/src/lib66/environ/env_resolve_conf.c @@ -22,20 +22,32 @@ #include <66/environ.h> #include <66/constants.h> #include <66/utils.h> +#include <66/service.h> -int env_resolve_conf(stralloc *env,char const *svname, uid_t owner) +int env_resolve_conf(stralloc *env, resolve_service_t *res) { log_flow() ; - if (!owner) - { - if (!stralloc_cats(env,SS_SERVICE_ADMCONFDIR)) return 0 ; - } - else - { - if (!set_ownerhome(env,owner)) return 0 ; - if (!stralloc_cats(env,SS_SERVICE_USERCONFDIR)) return 0 ; + if (!res->owner) { + + if (!stralloc_cats(env, SS_SERVICE_ADMCONFDIR)) + return 0 ; + + } else { + + if (!set_ownerhome(env, res->owner)) + return 0 ; + + if (!stralloc_cats(env, SS_SERVICE_USERCONFDIR)) + return 0 ; } - if (!auto_stra(env,svname)) return 0 ; + + if (res->inmodule) + if (!auto_stra(env, res->sa.s + res->inmodule, SS_SYM_VERSION, "/")) + return 0 ; + + if (!auto_stra(env, res->sa.s + res->name)) + return 0 ; + return 1 ; } diff --git a/src/lib66/parse/parse_store_environ.c b/src/lib66/parse/parse_store_environ.c index 765e5aef1830153b339da72d614c83ba7f4d65be..7804285cea525ae95f0106436f87a77672cd716e 100644 --- a/src/lib66/parse/parse_store_environ.c +++ b/src/lib66/parse/parse_store_environ.c @@ -49,7 +49,7 @@ int parse_store_environ(resolve_service_t *res, char *store, int idsec, int idke res->environ.env = resolve_add_string(wres, sa.s) ; sa.len = 0 ; - if (!env_resolve_conf(&sa, res->sa.s + res->name, MYUID)) + if (!env_resolve_conf(&sa, res)) goto err ; res->environ.envdir = resolve_add_string(wres, sa.s) ; diff --git a/src/lib66/write/write_common.c b/src/lib66/write/write_common.c index ee2c8c3dc8ae033eb546bebd83b49a392cad9ba5..2672c1cb812aa03c566f9198698419ebbbe8cfdb 100644 --- a/src/lib66/write/write_common.c +++ b/src/lib66/write/write_common.c @@ -50,7 +50,6 @@ int write_common(resolve_service_t *res, char const *dst) log_warnusys_return(LOG_EXIT_ZERO, "write uint file", SS_NOTIFICATION) ; /** timeout family - * * Only write timeout file for classic service. * S6-supervise need it otherwise it's read directly * from the resolve file at start process. */ @@ -72,8 +71,8 @@ int write_common(resolve_service_t *res, char const *dst) if (!write_uint(dst, "down-signal", res->execute.downsignal)) log_warnusys_return(LOG_EXIT_ZERO, "write uint file down-signal") ; - /** environment for module is already written by the parse_module() function */ - if (res->environ.env && res->type != TYPE_MODULE) { + /** environment */ + if (res->environ.env) { stralloc dst = STRALLOC_ZERO ; stralloc contents = STRALLOC_ZERO ; @@ -103,7 +102,6 @@ int write_common(resolve_service_t *res, char const *dst) if (!ob_dirname(basedir, src)) log_warnusys_return(LOG_EXIT_ZERO, "get dirname of: ", src) ; - if (!sastr_clean_string(&sa, res->sa.s + res->hiercopy)) log_warnusys_return(LOG_EXIT_ZERO, "clean string") ; @@ -182,6 +180,7 @@ int write_common(resolve_service_t *res, char const *dst) if (!hiercopy(tmp, dest)) log_warnusys_return(LOG_EXIT_ZERO, "copy: ", tmp, " to: ", dest) ; } + stralloc_free(&sa) ; }