Skip to content

Commit

Permalink
Merge pull request #16901 from Luap99/service-close-fd
Browse files Browse the repository at this point in the history
podman service: close duplicated /dev/null fd
  • Loading branch information
openshift-merge-robot authored Dec 22, 2022
2 parents 0a34a4f + 4724fa3 commit 5211446
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/podman/system/service_abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,17 @@ func restService(flags *pflag.FlagSet, cfg *entities.PodmanConfig, opts entities
libpodRuntime.SetRemoteURI(uri.String())
}

// Close stdin, so shortnames will not prompt
// Set stdin to /dev/null, so shortnames will not prompt
devNullfile, err := os.Open(os.DevNull)
if err != nil {
return err
}
defer devNullfile.Close()
if err := unix.Dup2(int(devNullfile.Fd()), int(os.Stdin.Fd())); err != nil {
devNullfile.Close()
return err
}
// Close the fd right away to not leak it during the entire time of the service.
devNullfile.Close()

if err := utils.MaybeMoveToSubCgroup(); err != nil {
// it is a best effort operation, so just print the
Expand Down

0 comments on commit 5211446

Please sign in to comment.