Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run service as particular user for systemd and launchd #11

Merged
merged 1 commit into from
Oct 18, 2023

Commits on Oct 18, 2023

  1. Run service as particular user for systemd and launchd

    It's important to be able to specify which user the service runs as, particularly in a Linux-based
    environment. Therefore, the `ServiceInstallCtx` is extended with an optional `username` field.
    
    It's also possible to run services on Windows with a non-Administrator user account. I tried hard to
    get this to work. I could get the service created with another account, but it would not start. I
    ended up just submitting my PR with support for macOS and Linux.
    
    New system tests were provided, with the base test being extended to check if the service process is
    running as the user specified in the `ServiceInstallCtx` definition. It just does this by checking
    the service definition. I tried to check the running service process to see if it was running as the
    correct user, but this proved to be difficult to do in a cross platform way.
    
    Running with a different user only applies to system-wide services.
    
    I made a small change to the way the plist file was constructed for launchd, preferring to use the
    `plist` crate rather than a hard coded string.
    jacderida committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    3524649 View commit details
    Browse the repository at this point in the history