summaryrefslogtreecommitdiff
path: root/cmd/podman/main.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-08-20 22:08:25 +0200
committerGitHub <noreply@github.com>2020-08-20 22:08:25 +0200
commit84180d99bc808795a1f91747436a42745ddececb (patch)
tree52070eed2d7619f1a33c40ff826c681fb6dc6e7f /cmd/podman/main.go
parent386de7a1fbfef0c266e04f6471f9382a5d39a02f (diff)
parent4e31c8136dffd2272e49715b83fba092621ffd2a (diff)
downloadpodman-84180d99bc808795a1f91747436a42745ddececb.tar.gz
podman-84180d99bc808795a1f91747436a42745ddececb.tar.bz2
podman-84180d99bc808795a1f91747436a42745ddececb.zip
Merge pull request #7353 from rhatdan/v2.0
Cleanup handling of podman mount/unmount
Diffstat (limited to 'cmd/podman/main.go')
-rw-r--r--cmd/podman/main.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index 5f740a006..4bdb020af 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -39,13 +39,21 @@ func main() {
for _, m := range c.Mode {
if cfg.EngineMode == m {
// Command cannot be run rootless
- _, found := c.Command.Annotations[registry.ParentNSRequired]
- if rootless.IsRootless() && found {
- c.Command.RunE = func(cmd *cobra.Command, args []string) error {
- return fmt.Errorf("cannot run command %q in rootless mode", cmd.CommandPath())
+ _, found := c.Command.Annotations[registry.UnshareNSRequired]
+ if found {
+ if rootless.IsRootless() && found && os.Getuid() != 0 {
+ c.Command.RunE = func(cmd *cobra.Command, args []string) error {
+ return fmt.Errorf("cannot run command %q in rootless mode, must execute `podman unshare` first", cmd.CommandPath())
+ }
+ }
+ } else {
+ _, found = c.Command.Annotations[registry.ParentNSRequired]
+ if rootless.IsRootless() && found {
+ c.Command.RunE = func(cmd *cobra.Command, args []string) error {
+ return fmt.Errorf("cannot run command %q in rootless mode", cmd.CommandPath())
+ }
}
}
-
parent := rootCmd
if c.Parent != nil {
parent = c.Parent