diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2018-08-14 10:58:32 +0200 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-14 14:33:31 +0000 |
commit | a04ce6893ba00dd184f7b223c74d1901c898880d (patch) | |
tree | 41ac64e5b47ba214c3a637c07e7ac5d021de563a /cmd | |
parent | 9563f314370010d8658ec527dec5f45b648191c9 (diff) | |
download | podman-a04ce6893ba00dd184f7b223c74d1901c898880d.tar.gz podman-a04ce6893ba00dd184f7b223c74d1901c898880d.tar.bz2 podman-a04ce6893ba00dd184f7b223c74d1901c898880d.zip |
rootless: not require userns for help/version
these commands do not require to be root in an userns
Closes: https://github.com/containers/libpod/issues/1263
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #1268
Approved by: vrothberg
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/main.go | 24 |
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 { |