Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ws-manager] Revert #4338 and fix /dev/net/tun permissions #4596

Merged
merged 1 commit into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/blobserve/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down
24 changes: 24 additions & 0 deletions components/ws-daemon/nsinsider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,30 @@ func main() {
return os.Chmod("/dev/fuse", os.FileMode(0666))
},
},
{
Name: "mknod-devnettun",
Usage: "creates /dev/net/tun",
Action: func(c *cli.Context) error {
_ = os.MkdirAll("/dev/net", 0755)

err := unix.Mknod("/dev/net/tun", 0666|unix.S_IFCHR, int(unix.Mkdev(10, 200)))
if err != nil {
return err
}

err = os.Chmod("/dev/net/tun", os.FileMode(0666))
if err != nil {
return err
}

err = os.Chown("/dev/net/tun", c.Int("uid"), c.Int("gid"))
if err != nil {
return err
}

return nil
},
},
},
}

Expand Down
7 changes: 7 additions & 0 deletions components/ws-daemon/pkg/iws/iws.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ func (wbs *InWorkspaceServiceServer) PrepareForUserNS(ctx context.Context, req *
log.WithError(err).WithFields(wbs.Session.OWI()).Error("PrepareForUserNS: cannot mknod fuse")
return nil, status.Errorf(codes.Internal, "cannot prepare FUSE")
}
err = nsinsider(wbs.Session.InstanceID, int(containerPID), func(c *exec.Cmd) {
c.Args = append(c.Args, "mknod-devnettun")
})
if err != nil {
log.WithError(err).WithFields(wbs.Session.OWI()).Error("PrepareForUserNS: cannot create /dev/net/tun")
return nil, status.Errorf(codes.Internal, "cannot create /dev/net/tun")
}

// create overlayfs directories to be used in ring2 as rootfs and also upper layer to track changes in the workspace
_ = os.MkdirAll(filepath.Join(wbs.Session.ServiceLocDaemon, "upper"), 0755)
Expand Down
14 changes: 0 additions & 14 deletions components/ws-manager/pkg/manager/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ func (m *Manager) createDefiniteWorkspacePod(startContext *startWorkspaceContext
// - the TAP driver documentation says so (see https://www.kernel.org/doc/Documentation/networking/tuntap.txt)
// - systemd's nspawn does the same thing (if it's good enough for them, it's good enough for us)
var (
devType = corev1.HostPathFile
hostPathOrCreate = corev1.HostPathDirectoryOrCreate
daemonVolumeName = "daemon-mount"
)
Expand All @@ -328,15 +327,6 @@ func (m *Manager) createDefiniteWorkspacePod(startContext *startWorkspaceContext
RestartPolicy: corev1.RestartPolicyNever,
Volumes: []corev1.Volume{
workspaceVolume,
{
Name: "dev-net-tun",
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: "/dev/net/tun",
Type: &devType,
},
},
},
{
Name: daemonVolumeName,
VolumeSource: corev1.VolumeSource{
Expand Down Expand Up @@ -490,10 +480,6 @@ func (m *Manager) createWorkspaceContainer(startContext *startWorkspaceContext)
ReadOnly: false,
MountPropagation: &mountPropagation,
},
{
MountPath: "/dev/net/tun",
Name: "dev-net-tun",
},
{
MountPath: "/.workspace",
Name: "daemon-mount",
Expand Down
11 changes: 0 additions & 11 deletions components/ws-manager/pkg/manager/testdata/cdwp_admission.golden
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@
"type": "DirectoryOrCreate"
}
},
{
"name": "dev-net-tun",
"hostPath": {
"path": "/dev/net/tun",
"type": "File"
}
},
{
"name": "daemon-mount",
"hostPath": {
Expand Down Expand Up @@ -157,10 +150,6 @@
"mountPath": "/workspace",
"mountPropagation": "HostToContainer"
},
{
"name": "dev-net-tun",
"mountPath": "/dev/net/tun"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@
"type": "DirectoryOrCreate"
}
},
{
"name": "dev-net-tun",
"hostPath": {
"path": "/dev/net/tun",
"type": "File"
}
},
{
"name": "daemon-mount",
"hostPath": {
Expand Down Expand Up @@ -151,10 +144,6 @@
"mountPath": "/workspace",
"mountPropagation": "HostToContainer"
},
{
"name": "dev-net-tun",
"mountPath": "/dev/net/tun"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@
"type": "DirectoryOrCreate"
}
},
{
"name": "dev-net-tun",
"hostPath": {
"path": "/dev/net/tun",
"type": "File"
}
},
{
"name": "daemon-mount",
"hostPath": {
Expand Down Expand Up @@ -154,10 +147,6 @@
"mountPath": "/workspace",
"mountPropagation": "HostToContainer"
},
{
"name": "dev-net-tun",
"mountPath": "/dev/net/tun"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@
},
"spec": {
"volumes": [
{
"name": "dev-net-tun",
"hostPath": {
"path": "/dev/net/tun",
"type": "File"
}
},
{
"name": "daemon-mount",
"hostPath": {
Expand Down Expand Up @@ -143,10 +136,6 @@
}
},
"volumeMounts": [
{
"name": "dev-net-tun",
"mountPath": "/dev/net/tun"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
Expand Down
11 changes: 0 additions & 11 deletions components/ws-manager/pkg/manager/testdata/cdwp_ghost.golden
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@
"type": "DirectoryOrCreate"
}
},
{
"name": "dev-net-tun",
"hostPath": {
"path": "/dev/net/tun",
"type": "File"
}
},
{
"name": "daemon-mount",
"hostPath": {
Expand Down Expand Up @@ -157,10 +150,6 @@
"mountPath": "/workspace",
"mountPropagation": "HostToContainer"
},
{
"name": "dev-net-tun",
"mountPath": "/dev/net/tun"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
Expand Down
11 changes: 0 additions & 11 deletions components/ws-manager/pkg/manager/testdata/cdwp_prebuild.golden
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@
"type": "DirectoryOrCreate"
}
},
{
"name": "dev-net-tun",
"hostPath": {
"path": "/dev/net/tun",
"type": "File"
}
},
{
"name": "daemon-mount",
"hostPath": {
Expand Down Expand Up @@ -157,10 +150,6 @@
"mountPath": "/workspace",
"mountPropagation": "HostToContainer"
},
{
"name": "dev-net-tun",
"mountPath": "/dev/net/tun"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@
"type": "DirectoryOrCreate"
}
},
{
"name": "dev-net-tun",
"hostPath": {
"path": "/dev/net/tun",
"type": "File"
}
},
{
"name": "daemon-mount",
"hostPath": {
Expand Down Expand Up @@ -161,10 +154,6 @@
"mountPath": "/workspace",
"mountPropagation": "HostToContainer"
},
{
"name": "dev-net-tun",
"mountPath": "/dev/net/tun"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@
"type": "DirectoryOrCreate"
}
},
{
"name": "dev-net-tun",
"hostPath": {
"path": "/dev/net/tun",
"type": "File"
}
},
{
"name": "daemon-mount",
"hostPath": {
Expand Down Expand Up @@ -161,10 +154,6 @@
"mountPath": "/workspace",
"mountPropagation": "HostToContainer"
},
{
"name": "dev-net-tun",
"mountPath": "/dev/net/tun"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
Expand Down
11 changes: 0 additions & 11 deletions components/ws-manager/pkg/manager/testdata/cdwp_probe.golden
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@
"type": "DirectoryOrCreate"
}
},
{
"name": "dev-net-tun",
"hostPath": {
"path": "/dev/net/tun",
"type": "File"
}
},
{
"name": "daemon-mount",
"hostPath": {
Expand Down Expand Up @@ -157,10 +150,6 @@
"mountPath": "/workspace",
"mountPropagation": "HostToContainer"
},
{
"name": "dev-net-tun",
"mountPath": "/dev/net/tun"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@
"type": "DirectoryOrCreate"
}
},
{
"name": "dev-net-tun",
"hostPath": {
"path": "/dev/net/tun",
"type": "File"
}
},
{
"name": "daemon-mount",
"hostPath": {
Expand Down Expand Up @@ -153,10 +146,6 @@
"mountPath": "/workspace",
"mountPropagation": "HostToContainer"
},
{
"name": "dev-net-tun",
"mountPath": "/dev/net/tun"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
Expand Down
11 changes: 0 additions & 11 deletions components/ws-manager/pkg/manager/testdata/cdwp_tasks.golden
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@
"type": "DirectoryOrCreate"
}
},
{
"name": "dev-net-tun",
"hostPath": {
"path": "/dev/net/tun",
"type": "File"
}
},
{
"name": "daemon-mount",
"hostPath": {
Expand Down Expand Up @@ -157,10 +150,6 @@
"mountPath": "/workspace",
"mountPropagation": "HostToContainer"
},
{
"name": "dev-net-tun",
"mountPath": "/dev/net/tun"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
Expand Down
11 changes: 0 additions & 11 deletions components/ws-manager/pkg/manager/testdata/cdwp_template.golden
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@
"type": "DirectoryOrCreate"
}
},
{
"name": "dev-net-tun",
"hostPath": {
"path": "/dev/net/tun",
"type": "File"
}
},
{
"name": "daemon-mount",
"hostPath": {
Expand Down Expand Up @@ -157,10 +150,6 @@
"mountPath": "/workspace",
"mountPropagation": "HostToContainer"
},
{
"name": "dev-net-tun",
"mountPath": "/dev/net/tun"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
Expand Down
Loading