Skip to content

Commit

Permalink
cmd/initContainer: Avoid RPM failures due to unexpected file owners
Browse files Browse the repository at this point in the history
When running rootless, files and directories bind mounted from the
host operating system can have their ownership listed as
nobody:nobody. This is because the UIDs and GIDs that actually own
those locations are not available inside the container.

Some distribution packages are particular about the file ownerships of
some of these locations. eg., Fedora's filesystem RPM. Encountering
nobody:nobody as the owner can fail package management transactions
involving such packages leading to unforeseen consequences.

Therefore, configure RPM to leave these locations alone.
  • Loading branch information
debarshiray committed Dec 2, 2020
1 parent dcdfa3a commit 14afafa
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/cmd/initContainer.go
Expand Up @@ -252,6 +252,23 @@ func initContainer(cmd *cobra.Command, args []string) error {
}
}

if utils.PathExists("/usr/lib/rpm") {
logrus.Debug("Configuring RPM to ignore bind mounts")

rpmConfigString := `# Written by Toolbox
# https://github.com/containers/toolbox
%_netsharedpath /dev:/media:/proc:/sys:/tmp:/var/lib/flatpak
`

rpmConfigBytes := []byte(rpmConfigString)
if err := ioutil.WriteFile("/usr/lib/rpm/toolbox",
rpmConfigBytes,
0644); err != nil {
return errors.New("failed to configure RPM to ignore bind mounts")
}
}

logrus.Debug("Setting up daily ticker")

daily, err := time.ParseDuration("24h")
Expand Down

0 comments on commit 14afafa

Please sign in to comment.