Remove the requirement to run as root

This commit is contained in:
Ewoud Kohl van Wijngaarden
2016-02-23 14:09:19 +01:00
parent 0db38e9d95
commit 1fcd437aaf
3 changed files with 8 additions and 11 deletions

View File

@@ -32,11 +32,16 @@ class Issue implements Command {
private function doExecute(Manager $args): Generator {
if (posix_geteuid() !== 0) {
throw new AcmeException("Please run this script as root!");
$processUser = posix_getpwuid(posix_geteuid());
$currentUsername = $processUser['name'];
$user = $args->get("user") ?? $currentUsername;
if ($currentUsername !== $user) {
throw new AcmeException("Running this script with --user only works as root");
}
} else {
$user = $args->get("user") ?? "www-data";
}
$user = $args->get("user") ?? "www-data";
$server = $args->get("server");
$protocol = substr($server, 0, strpos("://", $server));