aboutsummaryrefslogtreecommitdiff
path: root/cmd/fscrypt
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/fscrypt')
-rw-r--r--cmd/fscrypt/commands.go2
-rw-r--r--cmd/fscrypt/errors.go1
-rw-r--r--cmd/fscrypt/setup.go4
3 files changed, 3 insertions, 4 deletions
diff --git a/cmd/fscrypt/commands.go b/cmd/fscrypt/commands.go
index 2f23a0f..2733890 100644
--- a/cmd/fscrypt/commands.go
+++ b/cmd/fscrypt/commands.go
@@ -353,7 +353,7 @@ func purgeAction(c *cli.Context) error {
}
if dropCachesFlag.Value {
- if !util.IsUserRoot() {
+ if util.CurrentUserID() != 0 {
return newExitError(c, ErrDropCachesPerm)
}
}
diff --git a/cmd/fscrypt/errors.go b/cmd/fscrypt/errors.go
index 81a6798..72f8943 100644
--- a/cmd/fscrypt/errors.go
+++ b/cmd/fscrypt/errors.go
@@ -54,7 +54,6 @@ var (
ErrSpecifyKeyFile = errors.New("no key file specified")
ErrKeyFileLength = errors.Errorf("key file must be %d bytes", metadata.InternalKeyLen)
ErrAllLoadsFailed = errors.New("could not load any protectors")
- ErrMustBeRoot = errors.New("this command must be run as root")
ErrPolicyUnlocked = errors.New("this file or directory is already unlocked")
ErrBadOwners = errors.New("you do not own this directory")
ErrNotEmptyDir = errors.New("not an empty directory")
diff --git a/cmd/fscrypt/setup.go b/cmd/fscrypt/setup.go
index 72dfbdb..ac32484 100644
--- a/cmd/fscrypt/setup.go
+++ b/cmd/fscrypt/setup.go
@@ -31,8 +31,8 @@ import (
// createGlobalConfig creates (or overwrites) the global config file
func createGlobalConfig(w io.Writer, path string) error {
- if !util.IsUserRoot() {
- return ErrMustBeRoot
+ if err := util.CheckIfRoot(); err != nil {
+ return err
}
// Ask to create or replace the config file