diff options
| author | Eric Biggers <ebiggers@google.com> | 2019-12-15 19:31:39 -0800 |
|---|---|---|
| committer | Eric Biggers <ebiggers@google.com> | 2020-01-05 10:02:13 -0800 |
| commit | 0829eb74863bd279ae012779e52040ecc7f7178e (patch) | |
| tree | 6f43409dc24be3e7e0aa66fb4ed53b668125972f /cmd/fscrypt/protector.go | |
| parent | 9003a0331a112e8901fae8279f4897a825ee8069 (diff) | |
cmd/fscrypt: adjust user and keyring validation and preparation
Don't force the user to provide a --user argument when running fscrypt
as root if they're doing something where the TargetUser isn't actually
needed, such as provisioning/deprovisioning a v1 encryption policy
to/from the filesystem keyring, or creating a non-login protector.
Also don't set up the user keyring (or check for it being set up) if it
won't actually be used.
Finally, if we'll be provisioning/deprovisioning a v1 encryption policy
to/from the filesystem keyring, make sure the command is running as
root, since the kernel requires this.
Diffstat (limited to 'cmd/fscrypt/protector.go')
| -rw-r--r-- | cmd/fscrypt/protector.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd/fscrypt/protector.go b/cmd/fscrypt/protector.go index 8cbcf03..25f1984 100644 --- a/cmd/fscrypt/protector.go +++ b/cmd/fscrypt/protector.go @@ -26,6 +26,7 @@ import ( "github.com/google/fscrypt/actions" "github.com/google/fscrypt/filesystem" "github.com/google/fscrypt/metadata" + "github.com/google/fscrypt/util" ) // createProtector makes a new protector on either ctx.Mount or if the requested @@ -37,6 +38,11 @@ func createProtectorFromContext(ctx *actions.Context) (*actions.Protector, error } log.Printf("using source: %s", ctx.Config.Source.String()) + if ctx.Config.Source == metadata.SourceType_pam_passphrase && + userFlag.Value == "" && util.IsUserRoot() { + return nil, ErrSpecifyUser + } + name, err := promptForName(ctx) if err != nil { return nil, err |