diff options
| author | Joseph Richey <joerichey94@gmail.com> | 2017-10-19 03:15:28 -0700 |
|---|---|---|
| committer | Joseph Richey <joerichey94@gmail.com> | 2017-10-19 03:34:51 -0700 |
| commit | b7de8535f899f2b88d61f4f1264fe6a272196536 (patch) | |
| tree | 4caf8a0e426caf45440b5115664baba12749a11f /actions | |
| parent | 7885d63f644bb49d8da1d8313d5f4870d586a9c1 (diff) | |
util: Add better user lookup functions
When looking up users in fscrypt, we often want to proceed even if the
requested uid doesn't appear to be a valid user on the system. This
mainly occurs when a user is deleted, but they still have a login
protector on disk.
Thus, GetUser() with a bad uid creates a fake user with a pretty
placeholder name. The corresponding call sites of util.EffectiveUser are
changed (often simplifying logic). Various documentation is updated and
typos are fixed.
Diffstat (limited to 'actions')
| -rw-r--r-- | actions/context.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/actions/context.go b/actions/context.go index 8ad1357..ed7729d 100644 --- a/actions/context.go +++ b/actions/context.go @@ -67,7 +67,7 @@ type Context struct { // NewContextFromPath makes a context for the filesystem containing the // specified path and whose Config is loaded from the global config file. On // success, the Context contains a valid Config and Mount. The target defaults -// the the current effective user if none is specified. +// the the current user if none is specified. func NewContextFromPath(path string, target *user.User) (*Context, error) { ctx, err := newContextFromUser(target) if err != nil { @@ -85,7 +85,7 @@ func NewContextFromPath(path string, target *user.User) (*Context, error) { // NewContextFromMountpoint makes a context for the filesystem at the specified // mountpoint and whose Config is loaded from the global config file. On // success, the Context contains a valid Config and Mount. The target defaults -// the the current effective user if none is specified. +// the the current user if none is specified. func NewContextFromMountpoint(mountpoint string, target *user.User) (*Context, error) { ctx, err := newContextFromUser(target) if err != nil { @@ -102,13 +102,11 @@ func NewContextFromMountpoint(mountpoint string, target *user.User) (*Context, e // newContextFromUser makes a context with the corresponding target user, and // whose Config is loaded from the global config file. If the target is nil, the -// effecitive user is used. +// current user is used. func newContextFromUser(target *user.User) (*Context, error) { var err error if target == nil { - if target, err = util.EffectiveUser(); err != nil { - return nil, err - } + target = util.CurrentUser() } ctx := &Context{TargetUser: target} |