Skip to content

Commit 6c6f507

Browse files
committed
Merge branch 'develop' of github.com:semaphoreui/semaphore into develop
2 parents 51dae53 + 91c3173 commit 6c6f507

File tree

2 files changed

+31113
-31094
lines changed

2 files changed

+31113
-31094
lines changed

util/config.go

+26-7
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ type ConfigProcess struct {
157157
User string `json:"user,omitempty" env:"SEMAPHORE_PROCESS_USER"`
158158
UID *int `json:"uid,omitempty" env:"SEMAPHORE_PROCESS_UID"`
159159
Chroot string `json:"chroot,omitempty" env:"SEMAPHORE_PROCESS_CHROOT"`
160+
GID *int `json:"gid,omitempty" env:"SEMAPHORE_PROCESS_GID"`
160161
}
161162

162163
// ConfigType mapping between Config and the json file that sets it
@@ -318,22 +319,40 @@ func (conf *ConfigType) GetSysProcAttr() (res *syscall.SysProcAttr) {
318319
res.Chroot = conf.Process.Chroot
319320
}
320321

322+
var uid *int
323+
var gid *int
324+
325+
uid = nil
326+
gid = conf.Process.GID
327+
321328
if conf.Process.User != "" {
322-
if res == nil {
323-
res = &syscall.SysProcAttr{}
329+
usr, err := user.Lookup(conf.Process.User)
330+
if err != nil {
331+
return
324332
}
325333

326-
u, err := user.Lookup(conf.Process.User)
334+
u, err := strconv.Atoi(usr.Uid)
327335
if err != nil {
328336
return
329337
}
330338

331-
uid, _ := strconv.Atoi(u.Uid)
332-
gid, _ := strconv.Atoi(u.Gid)
339+
g, err := strconv.Atoi(usr.Gid)
340+
if err != nil {
341+
return
342+
}
343+
344+
uid = &u
345+
gid = &g
346+
}
347+
348+
if uid != nil && gid != nil {
349+
if res == nil {
350+
res = &syscall.SysProcAttr{}
351+
}
333352

334353
res.Credential = &syscall.Credential{
335-
Uid: uint32(uid),
336-
Gid: uint32(gid),
354+
Uid: uint32(*uid),
355+
Gid: uint32(*gid),
337356
}
338357
}
339358

0 commit comments

Comments
 (0)