File tree 2 files changed +31113
-31094
lines changed
2 files changed +31113
-31094
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ type ConfigProcess struct {
157
157
User string `json:"user,omitempty" env:"SEMAPHORE_PROCESS_USER"`
158
158
UID * int `json:"uid,omitempty" env:"SEMAPHORE_PROCESS_UID"`
159
159
Chroot string `json:"chroot,omitempty" env:"SEMAPHORE_PROCESS_CHROOT"`
160
+ GID * int `json:"gid,omitempty" env:"SEMAPHORE_PROCESS_GID"`
160
161
}
161
162
162
163
// ConfigType mapping between Config and the json file that sets it
@@ -318,22 +319,40 @@ func (conf *ConfigType) GetSysProcAttr() (res *syscall.SysProcAttr) {
318
319
res .Chroot = conf .Process .Chroot
319
320
}
320
321
322
+ var uid * int
323
+ var gid * int
324
+
325
+ uid = nil
326
+ gid = conf .Process .GID
327
+
321
328
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
324
332
}
325
333
326
- u , err := user . Lookup ( conf . Process . User )
334
+ u , err := strconv . Atoi ( usr . Uid )
327
335
if err != nil {
328
336
return
329
337
}
330
338
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
+ }
333
352
334
353
res .Credential = & syscall.Credential {
335
- Uid : uint32 (uid ),
336
- Gid : uint32 (gid ),
354
+ Uid : uint32 (* uid ),
355
+ Gid : uint32 (* gid ),
337
356
}
338
357
}
339
358
You can’t perform that action at this time.
0 commit comments