summaryrefslogtreecommitdiff
path: root/cmd/podman/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/main.go')
-rw-r--r--cmd/podman/main.go24
1 files changed, 15 insertions, 9 deletions
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index dbd7c1155..7a669b3fe 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -25,19 +25,12 @@ var (
exitCode = 125
)
+var cmdsNotRequiringRootless = map[string]bool{"help": true, "version": true}
+
func main() {
debug := false
cpuProfile := false
- became, ret, err := rootless.BecomeRootInUserNS()
- if err != nil {
- logrus.Errorf(err.Error())
- os.Exit(1)
- }
- if became {
- os.Exit(ret)
- }
-
if reexec.Init() {
return
}
@@ -97,6 +90,19 @@ func main() {
}
app.Before = func(c *cli.Context) error {
+ args := c.Args()
+ if args.Present() {
+ if _, notRequireRootless := cmdsNotRequiringRootless[args.First()]; !notRequireRootless {
+ became, ret, err := rootless.BecomeRootInUserNS()
+ if err != nil {
+ logrus.Errorf(err.Error())
+ os.Exit(1)
+ }
+ if became {
+ os.Exit(ret)
+ }
+ }
+ }
if c.GlobalBool("syslog") {
hook, err := lsyslog.NewSyslogHook("", "", syslog.LOG_INFO, "")
if err == nil {