Skip to content
New issue

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

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

Already on GitHub? # to your account

do not set the CreateCommand for API users #25092

Merged
merged 1 commit into from
Jan 23, 2025
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
3 changes: 3 additions & 0 deletions cmd/podman/containers/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ func create(cmd *cobra.Command, args []string) error {
}
s.RawImageName = rawImageName

// Include the command used to create the container.
s.ContainerCreateCommand = os.Args

if err := createPodIfNecessary(cmd, s, cliVals.Net); err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/podman/containers/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ func run(cmd *cobra.Command, args []string) error {
return err
}
s.RawImageName = rawImageName

// Include the command used to create the container.
s.ContainerCreateCommand = os.Args

s.ImageOS = cliVals.OS
s.ImageArch = cliVals.Arch
s.ImageVariant = cliVals.Variant
Expand Down
1 change: 0 additions & 1 deletion pkg/api/handlers/libpod/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func PodCreate(w http.ResponseWriter, r *http.Request) {
// a few extra that do not have the same json tags
psg.InfraContainerSpec.Name = psg.InfraName
psg.InfraContainerSpec.ConmonPidFile = psg.InfraConmonPidFile
psg.InfraContainerSpec.ContainerCreateCommand = psg.InfraCommand
psg.InfraContainerSpec.Image = psg.InfraImage
psg.InfraContainerSpec.RawImageName = psg.InfraImage
}
Expand Down
6 changes: 0 additions & 6 deletions pkg/specgenutil/specgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,12 +550,6 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions
s.Entrypoint = entrypoint
}

// Include the command used to create the container.

if len(s.ContainerCreateCommand) == 0 {
s.ContainerCreateCommand = os.Args
}

if len(inputCommand) > 0 {
s.Command = inputCommand
}
Expand Down
10 changes: 9 additions & 1 deletion test/apiv2/20-containers.at
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,15 @@ cid=$(jq -r '.Id' <<<"$output")
t POST libpod/containers/${cid}/start 204
# Container should exit almost immediately. Wait for it, confirm successful run
t POST "libpod/containers/${cid}/wait?condition=stopped&condition=exited" 200 '0'

# Regression check for #15036 (Umask) and #25026 (CreateCommand)
t GET libpod/containers/${cid}/json 200 \
.Id=$cid \
.State.Status~\\\(exited\\\|stopped\\\) \
.State.Running=false \
.State.ExitCode=0 \
.Config.Umask=0022 # regression check for #15036
.Config.Umask=0022 \
.Config.CreateCommand=null
t DELETE libpod/containers/$cid 200 .[0].Id=$cid

CNAME=myfoo
Expand Down Expand Up @@ -309,6 +312,11 @@ t GET containers/$cid/json 200 \
.Path="echo" \
.Args[0]="param1" \
.Args[1]="param2"
# Regression check for #25026 (CreateCommand)
t GET libpod/containers/${cid}/json 200 \
.Id=$cid \
.Config.CreateCommand=null

t DELETE containers/$cid 204

# test only set the entrypoint, Cmd should be []
Expand Down
Loading