From: Tim Düsterhus Date: Thu, 2 Jul 2020 10:48:10 +0000 (+0200) Subject: Pass the sessionID using the environment instead of argv X-Git-Tag: 5.3.0_Alpha_1~161^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4b9fff3a4976e0941cb79fa68522e3a7db8190dd;p=GitHub%2FWoltLab%2FWCF.git Pass the sessionID using the environment instead of argv --- diff --git a/wcfsetup/install/files/lib/system/CLIWCF.class.php b/wcfsetup/install/files/lib/system/CLIWCF.class.php index 6178e57279..e1ce465a39 100644 --- a/wcfsetup/install/files/lib/system/CLIWCF.class.php +++ b/wcfsetup/install/files/lib/system/CLIWCF.class.php @@ -87,7 +87,7 @@ class CLIWCF extends WCF { $this->initArgv(); $this->initPHPLine(); - $this->initAuth(self::getArgvParser()->sessionID); + $this->initAuth(); $this->checkForUpdates(); $this->initCommands(); } @@ -96,8 +96,8 @@ class CLIWCF extends WCF { * @inheritDoc */ public static function destruct() { - // Giving a sessionID disables saving of the command history. - if (!self::getArgvParser()->sessionID) { + // Giving WCF_SESSION_ID disables saving of the command history. + if (empty($_ENV['WCF_SESSION_ID'])) { if (self::getReader() !== null && self::getReader()->getHistory() instanceof DatabaseCLICommandHistory) { /** @var DatabaseCLICommandHistory $history */ $history = self::getReader()->getHistory(); @@ -107,7 +107,7 @@ class CLIWCF extends WCF { } } - if (!self::getArgvParser()->sessionID) { + if (empty($_ENV['WCF_SESSION_ID'])) { self::getSession()->delete(); } } @@ -133,7 +133,6 @@ class CLIWCF extends WCF { 'disableUpdateCheck' => WCF::getLanguage()->get('wcf.cli.help.disableUpdateCheck'), 'exitOnFail' => WCF::getLanguage()->get('wcf.cli.help.exitOnFail'), 'packageID=i' => WCF::getLanguage()->get('wcf.cli.help.packageID'), - 'sessionID=s' => WCF::getLanguage()->get('wcf.cli.help.sessionID'), ]); self::getArgvParser()->setOptions([ ArgvParser::CONFIG_CUMULATIVE_FLAGS => true, @@ -234,10 +233,10 @@ class CLIWCF extends WCF { /** * Does the user authentification. */ - protected function initAuth($sessionID = null) { - if ($sessionID !== null) { + protected function initAuth() { + if (!empty($_ENV['WCF_SESSION_ID'])) { self::getSession()->delete(); - self::getSession()->load(SessionEditor::class, $sessionID); + self::getSession()->load(SessionEditor::class, $_ENV['WCF_SESSION_ID']); if (!self::getUser()->userID) { self::getReader()->println('Invalid sessionID'); exit(1); diff --git a/wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php b/wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php index 8a2b18e5b3..3e2789bb90 100644 --- a/wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php +++ b/wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php @@ -192,10 +192,8 @@ class WorkerCLICommand implements IArgumentedCLICommand { // Invoke the worker processes with the same command line ... $arguments = $_SERVER['argv']; - // ... with the quiet argument ... + // ... with the quiet argument. $arguments[] = '-qqqqq'; - // ... reusing the current session. - $arguments[] = '--sessionID='.CLIWCF::getSession()->sessionID; $commandLine = PHP_BINARY.' '.implode(' ', array_map('escapeshellarg', $arguments)); Log::debug('Using "'.$commandLine.'" as the worker command line.'); @@ -203,10 +201,12 @@ class WorkerCLICommand implements IArgumentedCLICommand { // Reuse the environment. // - Specify TERM=dumb to prevent the worker from messing around with our terminal. // - Specify WORKER_STATUS_FD to prevent the administrator from manually giving a threadId, - // causing the worker to write into an arbitrary file descriptor (most likely the DB connectio.). + // causing the worker to write into an arbitrary file descriptor (most likely the DB connection). + // - Specify WCF_SESSION_ID to perform the login. $env = array_merge($_ENV, [ 'TERM' => 'dumb', 'WORKER_STATUS_FD' => 3, + 'WCF_SESSION_ID' => CLIWCF::getSession()->sessionID, ]); // 1) Spawn the processes. diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index ac46d052ee..5885a50271 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -3365,7 +3365,6 @@ Fehler sind beispielsweise: - Befehle, welche ihre Aktion nicht erfolgreich ausführen konnten - Systemfehler]]> - diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index e4c785415a..1b6d8a8cb5 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -3288,7 +3288,6 @@ Errors are: - Failing commands - Core errors]]> -