Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

podman service: close duplicated /dev/null fd #16901

Merged
merged 1 commit into from
Dec 22, 2022
Merged
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
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