@@ -13,8 +13,7 @@ import (
13
13
14
14
// LinuxJail implements Jailer using Linux network namespaces
15
15
type LinuxJail struct {
16
- logger * slog.Logger
17
- //namespace string
16
+ logger * slog.Logger
18
17
vethHost string // Host-side veth interface name for iptables rules
19
18
commandEnv []string
20
19
httpProxyPort int
@@ -28,8 +27,7 @@ type LinuxJail struct {
28
27
29
28
func NewLinuxJail (config Config ) (* LinuxJail , error ) {
30
29
return & LinuxJail {
31
- logger : config .Logger ,
32
- //namespace: newNamespaceName(),
30
+ logger : config .Logger ,
33
31
httpProxyPort : config .HttpProxyPort ,
34
32
configDir : config .ConfigDir ,
35
33
caCertPath : config .CACertPath ,
@@ -58,12 +56,6 @@ func (l *LinuxJail) ConfigureChildProcess(pid int) error {
58
56
// return fmt.Errorf("failed to setup DNS: %v", err)
59
57
//}
60
58
61
- // Create namespace
62
- //err = l.createNamespace()
63
- //if err != nil {
64
- // return fmt.Errorf("failed to create namespace: %v", err)
65
- //}
66
-
67
59
// Setup networking within namespace
68
60
err := l .setupNetworking (pid )
69
61
if err != nil {
@@ -82,13 +74,6 @@ func (l *LinuxJail) ConfigureChildProcess(pid int) error {
82
74
// Command returns an exec.Cmd configured to run within the network namespace
83
75
func (l * LinuxJail ) Command (command []string ) * exec.Cmd {
84
76
l .logger .Debug ("Creating command with namespace" )
85
- //l.logger.Debug("Creating command with namespace", "namespace", l.namespace)
86
-
87
- //cmdArgs := []string{"netns", "exec", l.namespace}
88
- //cmdArgs = append(cmdArgs, command...)
89
- //
90
- //cmd := exec.Command("ip", cmdArgs...)
91
- //cmd.Env = l.commandEnv
92
77
93
78
cmd := exec .Command (command [0 ], command [1 :]... )
94
79
cmd .SysProcAttr = & syscall.SysProcAttr {
@@ -131,25 +116,9 @@ func (l *LinuxJail) Close() error {
131
116
// // Continue with other cleanup
132
117
//}
133
118
134
- // Remove network namespace
135
- //err = l.removeNamespace()
136
- //if err != nil {
137
- // return fmt.Errorf("failed to remove namespace: %v", err)
138
- //}
139
-
140
119
return nil
141
120
}
142
121
143
- // createNamespace creates a new network namespace
144
- //func (l *LinuxJail) createNamespace() error {
145
- // cmd := exec.Command("ip", "netns", "add", l.namespace)
146
- // err := cmd.Run()
147
- // if err != nil {
148
- // return fmt.Errorf("failed to create namespace: %v", err)
149
- // }
150
- // return nil
151
- //}
152
-
153
122
// setupNetworking configures networking within the namespace
154
123
func (l * LinuxJail ) setupNetworking (pidInt int ) error {
155
124
PID := fmt .Sprintf ("%v" , pidInt )
@@ -297,13 +266,3 @@ func (l *LinuxJail) cleanupNetworking() error {
297
266
298
267
return nil
299
268
}
300
-
301
- // removeNamespace removes the network namespace
302
- //func (l *LinuxJail) removeNamespace() error {
303
- // cmd := exec.Command("ip", "netns", "del", l.namespace)
304
- // err := cmd.Run()
305
- // if err != nil {
306
- // return fmt.Errorf("failed to remove namespace: %v", err)
307
- // }
308
- // return nil
309
- //}
0 commit comments