diff --git a/src/Commands/Issue.php b/src/Commands/Issue.php index 6c3f372..c9301cc 100644 --- a/src/Commands/Issue.php +++ b/src/Commands/Issue.php @@ -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)); diff --git a/src/Commands/Register.php b/src/Commands/Register.php index 8ca0055..cf1de23 100644 --- a/src/Commands/Register.php +++ b/src/Commands/Register.php @@ -29,10 +29,6 @@ class Register implements Command { } public function doExecute(Manager $args): Generator { - if (posix_geteuid() !== 0) { - throw new AcmeException("Please run this script as root!"); - } - $email = $args->get("email"); yield resolve($this->checkEmail($email)); diff --git a/src/Commands/Revoke.php b/src/Commands/Revoke.php index 6927a66..7b2f801 100644 --- a/src/Commands/Revoke.php +++ b/src/Commands/Revoke.php @@ -27,10 +27,6 @@ class Revoke implements Command { } private function doExecute(Manager $args): Generator { - if (posix_geteuid() !== 0) { - throw new AcmeException("Please run this script as root!"); - } - $server = $args->get("server"); $protocol = substr($server, 0, strpos("://", $server));