Page MenuHomePhabricator

deploy-local (TargetContext) should not default to utils.get_real_username()
Closed, ResolvedPublic

Description

When deploy-local is called directly, either from the shell or from puppet, the active pty might refer to a user other than the current effective uid. For the deployment host, looking up the real logged in user makes sense, but deploy-local shouldn't try to sudo back to root ( whatever user happens to be running sudo puppet agent --test)

So I'm thinking we should either 1) provide a constructor in TargetContext that overrides super:

class TargetContext(Context):
    """Manages target host paths and execution context."""

    def __init__(self, root, environment=None, user=None):
        if user is None:
            user = utils.get_username()
        super(self.__class__, self).__init__(root, environment, user)

Or, 2) pass the current effective user explicitly to TargetContext() in deploy.py line 64

@thcipriani, @dduvall: thoughts?

Revisions and Commits

rMSCA Scap
Restricted Differential Revision

Event Timeline

mmodell raised the priority of this task from to Medium.
mmodell updated the task description. (Show Details)
mmodell added a project: scap2.

This makes total sense but I think it's a bit moot if we're to remove use of sudo_check_call everywhere. I think once that's done, we can probably remove context.user altogether?

@dduvall: I think the user still matters on the master, just not on the targets.

dduvall set Security to None.
dduvall added a revision: Restricted Differential Revision.Feb 12 2016, 9:50 PM