From 78e9ac8113a4959a6af2270b58b62e24e0c3569d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 1 Apr 2025 12:28:22 +0200 Subject: [PATCH] #7407 --- src/CommandLine.php | 14 ++++++++++++-- src/CommandLine/Owncloud.php | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/CommandLine.php b/src/CommandLine.php index 55602b4..5f6e819 100644 --- a/src/CommandLine.php +++ b/src/CommandLine.php @@ -26,6 +26,7 @@ class CommandLine protected $sudo = false; protected $unique = false; protected $uniqueCommand = null; + protected $docker = null; function __construct($program, $output = null, $error = true, $outputPrefix = null) { @@ -54,6 +55,11 @@ class CommandLine $this->error = $error; } + public function docker($container) + { + $this->docker = $container; + } + public function setArg($name = null, $val = null) { if (null === $name && null === $val) { @@ -161,7 +167,7 @@ class CommandLine $key = ' -i ' . $this->ssh['key']; } - $c = 'echo "' . $this->commande . '" | ssh ' . $key . ' -p ' . $this->ssh['port'] . ' ' . $this->ssh['username'] . '@' . $this->ssh['host'] . ' \'bash -s\''; + $c = 'echo "' . addcslashes($this->commande, '"') . '" | ssh ' . $key . ' -p ' . $this->ssh['port'] . ' ' . $this->ssh['username'] . '@' . $this->ssh['host'] . ' \'bash -s\''; $c .= ' > ' . $this->output; if ($this->error) { $c .= ' 2>&1 '; @@ -214,7 +220,11 @@ class CommandLine public function makeCommande($output = false, $error = false) { - $commande = $this->program; + $commande = ''; + if (null !== $this->docker) { + $commande = 'docker exec ' . $this->docker . ' '; + } + $commande .= $this->program; $commandes = array(); foreach ($this->args as $arg) { if (null === $arg[0]) { diff --git a/src/CommandLine/Owncloud.php b/src/CommandLine/Owncloud.php index 4cfe19d..48bfb16 100644 --- a/src/CommandLine/Owncloud.php +++ b/src/CommandLine/Owncloud.php @@ -27,6 +27,7 @@ class Owncloud extends CommandLine // user:add [--password-from-env] [--generate-password] [--display-name [DISPLAY-NAME]] [-g|--group [GROUP]] [--email EMAIL] [--] $this->setArg(null, 'user:add'); + $this->setArg(null, $userID ?? $email); if (null === $password) { $this->setArg('generate-password'); } else { @@ -37,7 +38,6 @@ class Owncloud extends CommandLine $this->setArg('display-name', $name); } $this->setArg('email', $email); - $this->setArg(null, $userID ?? $email); $this->execute(); $this->debug(); } -- 2.39.5