From 03d3a29b70c85f083adf3c12cba60c0374f06d3e Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 27 Nov 2019 11:40:47 -0800 Subject: Rename some variables from 'target' to 'targetUser' Refer to the target User as 'targetUser' rather than simply 'target'. This will help avoid confusion when we add support for the filesystem keyring, since then the Mount will also be a "target". --- actions/context.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'actions/context.go') diff --git a/actions/context.go b/actions/context.go index 894d941..5a56789 100644 --- a/actions/context.go +++ b/actions/context.go @@ -66,10 +66,10 @@ 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 -// to the current effective user if none is specified. -func NewContextFromPath(path string, target *user.User) (*Context, error) { - ctx, err := newContextFromUser(target) +// success, the Context contains a valid Config and Mount. The target user +// defaults to the current effective user if none is specified. +func NewContextFromPath(path string, targetUser *user.User) (*Context, error) { + ctx, err := newContextFromUser(targetUser) if err != nil { return nil, err } @@ -84,10 +84,10 @@ 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 -// to the current effective user if none is specified. -func NewContextFromMountpoint(mountpoint string, target *user.User) (*Context, error) { - ctx, err := newContextFromUser(target) +// success, the Context contains a valid Config and Mount. The target user +// defaults to the current effective user if none is specified. +func NewContextFromMountpoint(mountpoint string, targetUser *user.User) (*Context, error) { + ctx, err := newContextFromUser(targetUser) if err != nil { return nil, err } @@ -101,22 +101,22 @@ 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 -// effective user is used. -func newContextFromUser(target *user.User) (*Context, error) { +// whose Config is loaded from the global config file. If the target user is +// nil, the effective user is used. +func newContextFromUser(targetUser *user.User) (*Context, error) { var err error - if target == nil { - if target, err = util.EffectiveUser(); err != nil { + if targetUser == nil { + if targetUser, err = util.EffectiveUser(); err != nil { return nil, err } } - ctx := &Context{TargetUser: target} + ctx := &Context{TargetUser: targetUser} if ctx.Config, err = getConfig(); err != nil { return nil, err } - log.Printf("creating context for %q", target.Username) + log.Printf("creating context for user %q", targetUser.Username) return ctx, nil } -- cgit v1.2.3