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

fix write execute script with runas use

parent 0b34e228
No related branches found
No related tags found
No related merge requests found
......@@ -170,7 +170,7 @@ static void compute_wrapper_scripts(resolve_service_t *res, resolve_service_addo
if (res->environ.env && build)
/** call execl-envfile if a custom @execute is asked.
* its call will be made at run.user file for execlineb script*/
auto_strings(run + FAKELEN, "execl-envfile ", res->sa.s + res->environ.envdir, SS_SYM_VERSION "\n") ;
auto_strings(run + FAKELEN, "execl-envfile -v4 ", res->sa.s + res->environ.envdir, SS_SYM_VERSION "\n") ;
/** log redirection for oneshot service */
if (res->logger.want && res->type == TYPE_ONESHOT) {
......
......@@ -19,6 +19,7 @@
#include <oblibs/log.h>
#include <oblibs/string.h>
#include <oblibs/files.h>
#include <oblibs/types.h>
#include <66/utils.h>
......@@ -47,11 +48,27 @@ int write_execute_scripts(char const *file, char const *contents, char const *ds
if (runas) {
size_t len = strlen(runas) ;
uid_t uid ;
gid_t gid ;
if (!youruid(&uid, runas) ||
!yourgid(&gid, uid))
log_warnu_return(LOG_EXIT_ZERO,"get uid and gid of: ", runas) ;
char file[len + 1] ;
auto_strings(file, runas) ;
char *colon ;
colon = strchr(file,':') ;
if (colon) {
uid = file ;
gid = colon + 1 ;
} else {
if (!youruid(&uid, runas) ||
!yourgid(&gid, uid))
log_warnu_return(LOG_EXIT_ZERO,"get uid and gid of: ", runas) ;
}
if (chown(write, uid, gid) < 0)
log_warnusys_return(LOG_EXIT_ZERO, "chown: ", write) ;
......
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