From 2e03926c010902310c8e4903547e379c6eed5ee7 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sat, 24 Oct 2026 21:55:32 +0200 Subject: [PATCH] fix(dev): give ssh key directories to www-data in development Co-Authored-By: Claude Opus 5.5 --- .../PopulateSshKeysDirectorySeeder.php | 4 +-- .../PopulateSshKeysDirectorySeederTest.php | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/Feature/PopulateSshKeysDirectorySeederTest.php diff --git a/database/seeders/PopulateSshKeysDirectorySeeder.php b/database/seeders/PopulateSshKeysDirectorySeeder.php index 87984769ca..0318508c00 100644 --- a/database/seeders/PopulateSshKeysDirectorySeeder.php +++ b/database/seeders/PopulateSshKeysDirectorySeeder.php @@ -24,8 +24,8 @@ class PopulateSshKeysDirectorySeeder extends Seeder }); if (isDev()) { - Process::run('chown -R 9999:9999 '.storage_path('app/ssh/keys')); - Process::run('chown -R 9999:9999 '.storage_path('app/ssh/mux')); + Process::run('chown -R www-data:www-data '.storage_path('app/ssh/keys')); + Process::run('chown -R www-data:www-data '.storage_path('app/ssh/mux')); } else { Process::run('chown -R 9999:root '.storage_path('app/ssh/keys')); Process::run('chown -R 9999:root '.storage_path('app/ssh/mux')); diff --git a/tests/Feature/PopulateSshKeysDirectorySeederTest.php b/tests/Feature/PopulateSshKeysDirectorySeederTest.php new file mode 100644 index 0000000000..b12d7cc3f5 --- /dev/null +++ b/tests/Feature/PopulateSshKeysDirectorySeederTest.php @@ -0,0 +1,33 @@ +set('app.env', 'local'); + + app(PopulateSshKeysDirectorySeeder::class)->run(); + + Process::assertRan('chown -R www-data:www-data '.storage_path('app/ssh/keys')); + Process::assertRan('chown -R www-data:www-data '.storage_path('app/ssh/mux')); + Process::assertDidntRun(fn ($process) => str_contains($process->command, '9999')); +}); + +it('gives the ssh directories to uid 9999 in production', function () { + config()->set('app.env', 'production'); + + app(PopulateSshKeysDirectorySeeder::class)->run(); + + Process::assertRan('chown -R 9999:root '.storage_path('app/ssh/keys')); + Process::assertRan('chown -R 9999:root '.storage_path('app/ssh/mux')); +});