Skip to content

Commit

Permalink
feat: execute ip command in root network and mount ns
Browse files Browse the repository at this point in the history
  • Loading branch information
bertschneider committed Jan 8, 2025
1 parent 9291b2a commit e3efa18
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go/action_kit_commons/runc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,10 @@ func ListNamespaces(ctx context.Context, pid int, types ...string) ([]LinuxNames
}

func executeListNamedNetworkNamespace(ctx context.Context, pid int) (*LinuxNamespace, error) {
// Execute the ip with the network and mount namespaces of the root process
// to actually be able to list named network namespaces.
var sout, serr bytes.Buffer
cmd := RootCommandContext(ctx, "ip", "netns", "identify", strconv.Itoa(pid))
cmd := RootCommandContext(ctx, "nsenter", "-t", "1", "-m", "-n", "--", "ip", "netns", "identify", strconv.Itoa(pid))
cmd.Stdout = &sout
cmd.Stderr = &serr
err := cmd.Run()
Expand Down

0 comments on commit e3efa18

Please sign in to comment.