` as that account. * * Environment values are passed on the docker invocation itself and handed * through with `-e`, because an assignment placed before the `cd` would not * survive the `&&` — this is how OC_PASS reaches `user:add * --password-from-env` without the password ever appearing in an occ * argument (and so in the guest's process list). * * @param array $env */ public static function command(string $arguments, array $env = []): string { $assignments = ''; $forwards = ''; foreach ($env as $name => $value) { $assignments .= $name.'='.escapeshellarg($value).' '; $forwards .= '-e '.$name.' '; } return 'cd '.self::DIRECTORY.' && '.$assignments .'docker compose exec -T -u '.self::USER.' '.$forwards.'app php occ '.$arguments; } /** * A guest shell command inside the SAME container, for anything that is not * `occ` — FailedLoginReader's `stat`/`tail` on Nextcloud's own log file, for * instance. Same account, same "one place" rule as command() above: nothing * else in app/ may spell `docker compose exec` out by hand, and the test * next to that rule only exempts this file. */ public static function exec(string $arguments): string { return 'cd '.self::DIRECTORY.' && docker compose exec -T -u '.self::USER.' app '.$arguments; } }