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 { private function doExecute(Manager $args): Generator {
if (posix_geteuid() !== 0) { 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"); $server = $args->get("server");
$protocol = substr($server, 0, strpos("://", $server)); $protocol = substr($server, 0, strpos("://", $server));

View File

@@ -29,10 +29,6 @@ class Register implements Command {
} }
public function doExecute(Manager $args): Generator { public function doExecute(Manager $args): Generator {
if (posix_geteuid() !== 0) {
throw new AcmeException("Please run this script as root!");
}
$email = $args->get("email"); $email = $args->get("email");
yield resolve($this->checkEmail($email)); yield resolve($this->checkEmail($email));

View File

@@ -27,10 +27,6 @@ class Revoke implements Command {
} }
private function doExecute(Manager $args): Generator { private function doExecute(Manager $args): Generator {
if (posix_geteuid() !== 0) {
throw new AcmeException("Please run this script as root!");
}
$server = $args->get("server"); $server = $args->get("server");
$protocol = substr($server, 0, strpos("://", $server)); $protocol = substr($server, 0, strpos("://", $server));