Skip to content

Commit

Permalink
feat:[close #283] Allow creating unshared containers in Apx core (#285)
Browse files Browse the repository at this point in the history
* feat: Allow creating unshared containers in Apx core

* follow-up rootfull/unshared flags
  • Loading branch information
mirkobrombin authored Sep 2, 2023
1 parent b708de9 commit 6327d3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/dbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ func (d *dbox) RunCommand(command string, args []string, engineFlags []string, u
// ignored in commands like "enter"
finalArgs := []string{command}

// NOTE: for engine-specific commands, we need to use pkexec for rootfull
// containers, since podman does not offer a dedicated flag for this.
if rootFull && useEngine {
entrypoint = "pkexec"
finalArgs = []string{d.EngineBinary, command}
}

cmd := exec.Command(entrypoint, finalArgs...)

if !captureOutput && !muteOutput {
Expand Down Expand Up @@ -115,7 +122,7 @@ func (d *dbox) RunCommand(command string, args []string, engineFlags []string, u

// NOTE: the root flag is not being used by the Apx CLI, but it's useful
// for those using Apx as a library, e.g. VSO.
if rootFull {
if rootFull && !useEngine {
cmd.Args = append(cmd.Args, "--root")
}

Expand Down
6 changes: 6 additions & 0 deletions core/subSystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ func (s *SubSystem) Create() error {
labels["hasInit"] = "true"
}

if s.IsUnshared {
labels["unshared"] = "true"
}

err = dbox.CreateContainer(
s.InternalName,
s.Stack.Base,
Expand Down Expand Up @@ -167,6 +171,8 @@ func LoadSubSystem(name string, isRootFull bool) (*SubSystem, error) {
Status: container.Status,
HasInit: container.Labels["hasInit"] == "true",
IsManaged: container.Labels["managed"] == "true",
IsRootfull: isRootFull,
IsUnshared: container.Labels["unshared"] == "true",
}, nil
}

Expand Down

0 comments on commit 6327d3d

Please sign in to comment.