summaryrefslogtreecommitdiff
path: root/cmd/podman/main.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-07-09 14:53:46 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-07-27 16:53:02 -0400
commit8f7ed50cb20c04bbbb7c4907a183c07912d4bffb (patch)
tree14001f06bc0a278d0e34c6e7312ffd08c3afe526 /cmd/podman/main.go
parent2b7bc9b101887a789a9fc0282d448efad824404f (diff)
downloadpodman-8f7ed50cb20c04bbbb7c4907a183c07912d4bffb.tar.gz
podman-8f7ed50cb20c04bbbb7c4907a183c07912d4bffb.tar.bz2
podman-8f7ed50cb20c04bbbb7c4907a183c07912d4bffb.zip
Cleanup handling of podman mount/unmount
We should default to the user name unmount rather then the internal name of umount. Also User namespace was not being handled correctly. We want to inform the user that if they do a mount when in rootless mode that they have to be first in the podman unshare state. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
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 f46f74547..d0e89c2f5 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -40,13 +40,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