Move check for root to Go
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
parent
ce823c03c1
commit
2538b49e07
@ -16,8 +16,7 @@ __attribute__((constructor)) void init(void) {
|
||||
int ret;
|
||||
|
||||
if (geteuid() != 0) {
|
||||
fprintf(stderr, "Need to run as root\n");
|
||||
_exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
// Unshare a new mntns so our mounts don't leak
|
||||
@ -130,6 +129,11 @@ func run(c *cli.Context) error {
|
||||
arch string
|
||||
)
|
||||
|
||||
// Sanity checks
|
||||
if os.Geteuid() != 0 {
|
||||
return fmt.Errorf("You must be root to run this tool")
|
||||
}
|
||||
|
||||
os.RemoveAll(c.GlobalString("cache-dir"))
|
||||
os.MkdirAll(c.GlobalString("cache-dir"), 0755)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user