Skip to content

Commit 88a7a32

Browse files
cleanup
1 parent 1c23341 commit 88a7a32

File tree

1 file changed

+2
-43
lines changed

1 file changed

+2
-43
lines changed

jail/linux.go

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import (
1313

1414
// LinuxJail implements Jailer using Linux network namespaces
1515
type LinuxJail struct {
16-
logger *slog.Logger
17-
//namespace string
16+
logger *slog.Logger
1817
vethHost string // Host-side veth interface name for iptables rules
1918
commandEnv []string
2019
httpProxyPort int
@@ -28,8 +27,7 @@ type LinuxJail struct {
2827

2928
func NewLinuxJail(config Config) (*LinuxJail, error) {
3029
return &LinuxJail{
31-
logger: config.Logger,
32-
//namespace: newNamespaceName(),
30+
logger: config.Logger,
3331
httpProxyPort: config.HttpProxyPort,
3432
configDir: config.ConfigDir,
3533
caCertPath: config.CACertPath,
@@ -58,12 +56,6 @@ func (l *LinuxJail) ConfigureChildProcess(pid int) error {
5856
// return fmt.Errorf("failed to setup DNS: %v", err)
5957
//}
6058

61-
// Create namespace
62-
//err = l.createNamespace()
63-
//if err != nil {
64-
// return fmt.Errorf("failed to create namespace: %v", err)
65-
//}
66-
6759
// Setup networking within namespace
6860
err := l.setupNetworking(pid)
6961
if err != nil {
@@ -82,13 +74,6 @@ func (l *LinuxJail) ConfigureChildProcess(pid int) error {
8274
// Command returns an exec.Cmd configured to run within the network namespace
8375
func (l *LinuxJail) Command(command []string) *exec.Cmd {
8476
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
9277

9378
cmd := exec.Command(command[0], command[1:]...)
9479
cmd.SysProcAttr = &syscall.SysProcAttr{
@@ -131,25 +116,9 @@ func (l *LinuxJail) Close() error {
131116
// // Continue with other cleanup
132117
//}
133118

134-
// Remove network namespace
135-
//err = l.removeNamespace()
136-
//if err != nil {
137-
// return fmt.Errorf("failed to remove namespace: %v", err)
138-
//}
139-
140119
return nil
141120
}
142121

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-
153122
// setupNetworking configures networking within the namespace
154123
func (l *LinuxJail) setupNetworking(pidInt int) error {
155124
PID := fmt.Sprintf("%v", pidInt)
@@ -297,13 +266,3 @@ func (l *LinuxJail) cleanupNetworking() error {
297266

298267
return nil
299268
}
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

Comments
 (0)