Skip to content

Commit 1a6a182

Browse files
committed
fix(process): disable chroot for Windows
1 parent 219b8ab commit 1a6a182

File tree

3 files changed

+70
-50
lines changed

3 files changed

+70
-50
lines changed

util/config.go

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@ import (
88
"encoding/json"
99
"errors"
1010
"fmt"
11-
"golang.org/x/crypto/bcrypt"
1211
"io"
1312
"net/url"
1413
"os"
1514
"os/exec"
16-
"os/user"
1715
"path"
1816
"path/filepath"
1917
"reflect"
2018
"regexp"
2119
"strconv"
2220
"strings"
23-
"syscall"
21+
22+
"golang.org/x/crypto/bcrypt"
2423

2524
"github.com/google/go-github/github"
2625
"github.com/gorilla/securecookie"
@@ -312,53 +311,6 @@ func ClearDir(dir string, preserveFiles bool, prefix string) error {
312311
return nil
313312
}
314313

315-
func (conf *ConfigType) GetSysProcAttr() (res *syscall.SysProcAttr) {
316-
317-
if conf.Process.Chroot != "" {
318-
res = &syscall.SysProcAttr{}
319-
res.Chroot = conf.Process.Chroot
320-
}
321-
322-
var uid *int
323-
var gid *int
324-
325-
uid = nil
326-
gid = conf.Process.GID
327-
328-
if conf.Process.User != "" {
329-
usr, err := user.Lookup(conf.Process.User)
330-
if err != nil {
331-
return
332-
}
333-
334-
u, err := strconv.Atoi(usr.Uid)
335-
if err != nil {
336-
return
337-
}
338-
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-
}
352-
353-
res.Credential = &syscall.Credential{
354-
Uid: uint32(*uid),
355-
Gid: uint32(*gid),
356-
}
357-
}
358-
359-
return
360-
}
361-
362314
func (conf *ConfigType) ClearTmpDir() error {
363315
return ClearDir(conf.TmpPath, false, "")
364316
}

util/config_sysproc.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//go:build !windows
2+
3+
package util
4+
5+
import (
6+
"os/user"
7+
"strconv"
8+
"syscall"
9+
)
10+
11+
func (conf *ConfigType) GetSysProcAttr() (res *syscall.SysProcAttr) {
12+
13+
if conf.Process.Chroot != "" {
14+
res = &syscall.SysProcAttr{}
15+
res.Chroot = conf.Process.Chroot
16+
}
17+
18+
var uid *int
19+
var gid *int
20+
21+
uid = nil
22+
gid = conf.Process.GID
23+
24+
if conf.Process.User != "" {
25+
usr, err := user.Lookup(conf.Process.User)
26+
if err != nil {
27+
return
28+
}
29+
30+
u, err := strconv.Atoi(usr.Uid)
31+
if err != nil {
32+
return
33+
}
34+
35+
g, err := strconv.Atoi(usr.Gid)
36+
if err != nil {
37+
return
38+
}
39+
40+
uid = &u
41+
gid = &g
42+
}
43+
44+
if uid != nil && gid != nil {
45+
if res == nil {
46+
res = &syscall.SysProcAttr{}
47+
}
48+
49+
res.Credential = &syscall.Credential{
50+
Uid: uint32(*uid),
51+
Gid: uint32(*gid),
52+
}
53+
}
54+
55+
return
56+
}

util/config_sysproc_windows.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//go:build windows
2+
3+
package util
4+
5+
import (
6+
"syscall"
7+
)
8+
9+
func (conf *ConfigType) GetSysProcAttr() (res *syscall.SysProcAttr) {
10+
11+
return
12+
}

0 commit comments

Comments
 (0)