fix(dev): give ssh key directories to www-data in development

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-10-24 21:55:32 +02:00
co-authored by Claude Opus 5.5
parent d8d33c69ce
commit 2e03926c01
2 changed files with 35 additions and 2 deletions
@@ -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'));
@@ -0,0 +1,33 @@
<?php
use Database\Seeders\PopulateSshKeysDirectorySeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Process;
use Illuminate\Support\Facades\Storage;
uses(RefreshDatabase::class);
beforeEach(function () {
Storage::fake('ssh-keys');
Storage::fake('ssh-mux');
Process::fake();
});
it('gives the ssh directories to the php-fpm user in development', function () {
config()->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'));
});