From 11b31826334bc3faa4d4c7ee05a3b2996a88c969 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Wed, 30 Aug 2017 18:16:16 -0700 Subject: cmd/fscrypt: Add --user flag for running as root The --user flag can now be used to have the targe user (the one whose keyring and password will be used in fscrypt) be different than the calling user. Very usefull for things like sudo fscrypt purge /media/joerichey/usb --user=joerichey which will now have privileges to drop caches, but will properly clear the keys from the user's keyring. --- cmd/fscrypt/protector.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cmd/fscrypt/protector.go') diff --git a/cmd/fscrypt/protector.go b/cmd/fscrypt/protector.go index f54d3a4..32ba4ab 100644 --- a/cmd/fscrypt/protector.go +++ b/cmd/fscrypt/protector.go @@ -119,5 +119,7 @@ func modifiedContext(ctx *actions.Context) (*actions.Context, error) { return nil, err } - return &actions.Context{Config: ctx.Config, Mount: mnt}, nil + modifiedCtx := *ctx + modifiedCtx.Mount = mnt + return &modifiedCtx, nil } -- cgit v1.2.3