Skip to content
Snippets Groups Projects
Commit 2fc674db authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

fix write of module environment file

parent 39ea43fe
No related branches found
No related tags found
No related merge requests found
...@@ -22,20 +22,32 @@ ...@@ -22,20 +22,32 @@
#include <66/environ.h> #include <66/environ.h>
#include <66/constants.h> #include <66/constants.h>
#include <66/utils.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() ; log_flow() ;
if (!owner) if (!res->owner) {
{
if (!stralloc_cats(env,SS_SERVICE_ADMCONFDIR)) return 0 ; if (!stralloc_cats(env, SS_SERVICE_ADMCONFDIR))
} return 0 ;
else
{ } else {
if (!set_ownerhome(env,owner)) return 0 ;
if (!stralloc_cats(env,SS_SERVICE_USERCONFDIR)) return 0 ; 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 ; return 1 ;
} }
...@@ -49,7 +49,7 @@ int parse_store_environ(resolve_service_t *res, char *store, int idsec, int idke ...@@ -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) ; res->environ.env = resolve_add_string(wres, sa.s) ;
sa.len = 0 ; sa.len = 0 ;
if (!env_resolve_conf(&sa, res->sa.s + res->name, MYUID)) if (!env_resolve_conf(&sa, res))
goto err ; goto err ;
res->environ.envdir = resolve_add_string(wres, sa.s) ; res->environ.envdir = resolve_add_string(wres, sa.s) ;
......
...@@ -50,7 +50,6 @@ int write_common(resolve_service_t *res, char const *dst) ...@@ -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) ; log_warnusys_return(LOG_EXIT_ZERO, "write uint file", SS_NOTIFICATION) ;
/** timeout family /** timeout family
*
* Only write timeout file for classic service. * Only write timeout file for classic service.
* S6-supervise need it otherwise it's read directly * S6-supervise need it otherwise it's read directly
* from the resolve file at start process. */ * from the resolve file at start process. */
...@@ -72,8 +71,8 @@ int write_common(resolve_service_t *res, char const *dst) ...@@ -72,8 +71,8 @@ int write_common(resolve_service_t *res, char const *dst)
if (!write_uint(dst, "down-signal", res->execute.downsignal)) if (!write_uint(dst, "down-signal", res->execute.downsignal))
log_warnusys_return(LOG_EXIT_ZERO, "write uint file down-signal") ; log_warnusys_return(LOG_EXIT_ZERO, "write uint file down-signal") ;
/** environment for module is already written by the parse_module() function */ /** environment */
if (res->environ.env && res->type != TYPE_MODULE) { if (res->environ.env) {
stralloc dst = STRALLOC_ZERO ; stralloc dst = STRALLOC_ZERO ;
stralloc contents = STRALLOC_ZERO ; stralloc contents = STRALLOC_ZERO ;
...@@ -103,7 +102,6 @@ int write_common(resolve_service_t *res, char const *dst) ...@@ -103,7 +102,6 @@ int write_common(resolve_service_t *res, char const *dst)
if (!ob_dirname(basedir, src)) if (!ob_dirname(basedir, src))
log_warnusys_return(LOG_EXIT_ZERO, "get dirname of: ", src) ; log_warnusys_return(LOG_EXIT_ZERO, "get dirname of: ", src) ;
if (!sastr_clean_string(&sa, res->sa.s + res->hiercopy)) if (!sastr_clean_string(&sa, res->sa.s + res->hiercopy))
log_warnusys_return(LOG_EXIT_ZERO, "clean string") ; log_warnusys_return(LOG_EXIT_ZERO, "clean string") ;
...@@ -182,6 +180,7 @@ int write_common(resolve_service_t *res, char const *dst) ...@@ -182,6 +180,7 @@ int write_common(resolve_service_t *res, char const *dst)
if (!hiercopy(tmp, dest)) if (!hiercopy(tmp, dest))
log_warnusys_return(LOG_EXIT_ZERO, "copy: ", tmp, " to: ", dest) ; log_warnusys_return(LOG_EXIT_ZERO, "copy: ", tmp, " to: ", dest) ;
} }
stralloc_free(&sa) ; stralloc_free(&sa) ;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment