Skip to content

Feature: Context manager for sudo. #778

Open
@Yzupnick

Description

@Yzupnick

Being able to switch which user the code is acting as for a given block would be very useful.

Something like:

with c.sudo("application-user"):
   c.run("mkdir /var/www/some-dir") # some-dir has roles/permissions for "application-user"
   c.run("something application-user has permissions for")

I think this would be especially helpful when trying to encapsulate a body of work as a function that takes a context.

Thanks so much for all y'all's work on this library. I am happy to implement this feature if you think it fits into the project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions