summaryrefslogtreecommitdiffstats
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/instance.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/service/instance.c b/service/instance.c
index 1fb65fa..3367885 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -282,12 +282,15 @@ instance_run(struct service_instance *in, int _stdout, int _stderr)
closefd(_stderr);
}
- if (in->uid || in->gid) {
- if (setuid(in->uid) || setgid(in->gid)) {
- ERROR("failed to set uid:%d, gid:%d\n", in->uid, in->gid);
- exit(127);
- }
+ if (in->gid && setgid(in->gid)) {
+ ERROR("failed to set group id %d: %d (%s)\n", in->gid, errno, strerror(errno));
+ exit(127);
+ }
+ if (in->uid && setuid(in->uid)) {
+ ERROR("failed to set user id %d: %d (%s)\n", in->uid, errno, strerror(errno));
+ exit(127);
}
+
execvp(argv[0], argv);
exit(127);
}