Skip to content

Commit f70c742

Browse files
csweichelfntlnz
authored andcommitted
[ws-daemon] Properly chown /dev/fuse
1 parent 7aede5b commit f70c742

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

components/ws-daemon/nsinsider/main.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,32 @@ func main() {
193193
{
194194
Name: "mknod-fuse",
195195
Usage: "creates /dev/fuse",
196+
Flags: []cli.Flag{
197+
&cli.IntFlag{
198+
Name: "uid",
199+
Required: true,
200+
},
201+
&cli.IntFlag{
202+
Name: "gid",
203+
Required: true,
204+
},
205+
},
196206
Action: func(c *cli.Context) error {
197207
err := unix.Mknod("/dev/fuse", 0666|unix.S_IFCHR, int(unix.Mkdev(10, 229)))
198208
if err != nil {
199209
return err
200210
}
201211

202-
return os.Chmod("/dev/fuse", os.FileMode(0666))
212+
err = os.Chmod("/dev/fuse", os.FileMode(0666))
213+
if err != nil {
214+
return err
215+
}
216+
err = os.Chown("/dev/fuse", c.Int("uid"), c.Int("gid"))
217+
if err != nil {
218+
return err
219+
}
220+
221+
return nil
203222
},
204223
},
205224
{

components/ws-daemon/pkg/iws/iws.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"os"
1313
"os/exec"
1414
"path/filepath"
15+
"strconv"
1516
"sync"
1617
"syscall"
1718
"time"
@@ -215,7 +216,7 @@ func (wbs *InWorkspaceServiceServer) PrepareForUserNS(ctx context.Context, req *
215216
// - https://lists.linuxcontainers.org/pipermail/lxc-devel/2014-July/009797.html
216217
// - https://lists.linuxcontainers.org/pipermail/lxc-users/2014-October/007948.html
217218
err = nsinsider(wbs.Session.InstanceID, int(containerPID), func(c *exec.Cmd) {
218-
c.Args = append(c.Args, "mknod-fuse")
219+
c.Args = append(c.Args, "mknod-fuse", "--uid", strconv.Itoa(wsinit.GitpodUID), "--gid", strconv.Itoa(wsinit.GitpodGID))
219220
})
220221
if err != nil {
221222
log.WithError(err).WithFields(wbs.Session.OWI()).Error("PrepareForUserNS: cannot mknod fuse")

0 commit comments

Comments
 (0)