diff --git a/cmd/control/cli.go b/cmd/control/cli.go index ec2ecc8b..d8c19eb2 100644 --- a/cmd/control/cli.go +++ b/cmd/control/cli.go @@ -3,6 +3,7 @@ package control import ( "os" + log "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" "github.com/rancher/os/config" ) @@ -15,6 +16,12 @@ func Main() { app.Version = config.VERSION app.Author = "Rancher Labs, Inc." app.EnableBashCompletion = true + app.Before = func(c *cli.Context) error { + if os.Geteuid() != 0 { + log.Fatalf("%s: Need to be root", os.Args[0]) + } + return nil + } app.Commands = []cli.Command{ { diff --git a/cmd/systemdocker/system-docker.go b/cmd/systemdocker/system-docker.go index daa803bf..f925ecca 100644 --- a/cmd/systemdocker/system-docker.go +++ b/cmd/systemdocker/system-docker.go @@ -19,6 +19,10 @@ func Main() { newEnv = append(newEnv, "DOCKER_HOST="+config.DOCKER_SYSTEM_HOST) + if os.Geteuid() != 0 { + log.Fatalf("%s: Need to be root", os.Args[0]) + } + os.Args[0] = config.DOCKER_DIST_BIN if err := syscall.Exec(os.Args[0], os.Args, newEnv); err != nil { log.Fatal(err) diff --git a/tests/integration/rostest/test_06_subdir.py b/tests/integration/rostest/test_06_subdir.py index cc665bd7..078f7640 100644 --- a/tests/integration/rostest/test_06_subdir.py +++ b/tests/integration/rostest/test_06_subdir.py @@ -14,6 +14,6 @@ def test_system_docker_survives_custom_docker_install(qemu): SSH(qemu).check_call('bash', '-c', ''' set -x -e mkdir x - sudo mount $(ros dev LABEL=RANCHER_STATE) x + sudo mount $(sudo ros dev LABEL=RANCHER_STATE) x [ -d x/ros_subdir/home/rancher ] '''.strip())