Fix .env Files for Isolated Users (#496)

This commit is contained in:
Richard Anderson
2025-02-22 08:23:03 +00:00
committed by GitHub
parent 2356e44f5b
commit 1223ea1499
5 changed files with 39 additions and 8 deletions

View File

@ -198,16 +198,34 @@ public function editFile(string $path, ?string $content = null): void
}
}
/**
* @throws SSHError
*/
public function editFileAs(string $path, string $user, ?string $content = null): void
{
$sudo = $user === 'root';
$actualUser = $sudo ? $this->server->getSshUser() : $user;
$this->server->ssh($actualUser)->exec(
view('ssh.os.edit-file', [
'path' => $path,
'content' => $content,
'sudo' => $sudo,
]),
'edit-file'
);
}
/**
* @throws SSHError
*/
public function readFile(string $path): string
{
return $this->server->ssh()->exec(
return trim($this->server->ssh()->exec(
view('ssh.os.read-file', [
'path' => $path,
])
);
));
}
/**