Skip to content

Commit 2f65022

Browse files
committed
fix(ci): remove network setting on the ftp server
1 parent 4ac97d2 commit 2f65022

3 files changed

Lines changed: 7 additions & 12 deletions

File tree

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ env:
77
FTP_USER: username
88
FTP_PASSWORD: password
99
FTP_PORT: 21
10-
FTP_ROOT: /home/vsftpd/username
10+
FTP_ROOT: /tmp
1111

1212
jobs:
1313
lunix-tests:
@@ -42,7 +42,7 @@ jobs:
4242
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysql, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, redis
4343
coverage: none
4444

45-
- run: docker run --net=host -p 21:21 -p 20:20 -p 12020:12020 -p 12021:12021 -p 12022:12022 -p 12023:12023 -p 12024:12024 -p 12025:12025 -e USER=$FTP_USER -e PASS=$FTP_PASSWORD -d --name ftp -v $(pwd)/:/ftp/$FTP_USER papacdev/vsftpd
45+
- run: docker run -p 21:21 -p 20:20 -p 12020:12020 -p 12021:12021 -p 12022:12022 -p 12023:12023 -p 12024:12024 -p 12025:12025 -e USER=$FTP_USER -e PASS=$FTP_PASSWORD -d --name ftp papacdev/vsftpd
4646
- run: docker run -p 1080:1080 -p 1025:1025 -d --name maildev soulteary/maildev
4747
- run: docker run -p 6379:6379 -d --name redis redis
4848
- run: docker run -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres -e POSTGRES_PASSWORD=postgres -d postgis/postgis

src/Storage/Service/FTPService.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function connect()
112112

113113
$this->login();
114114
$this->changePath();
115-
$this->setConnectionPassiveMode();
115+
$this->activePassiveMode();
116116
}
117117

118118
/**
@@ -139,15 +139,8 @@ private function login(): bool
139139
{
140140
['username' => $username, 'password' => $password] = $this->config;
141141

142-
// We disable error handling to avoid credentials leak :+1:
143-
set_error_handler(
144-
fn () => error_log("set_error_handler muted for hidden the ftp credential to user")
145-
);
146-
147142
$is_logged_in = ftp_login($this->connection, $username, $password);
148143

149-
restore_error_handler();
150-
151144
if ($is_logged_in) {
152145
return true;
153146
}
@@ -642,8 +635,10 @@ private function readStream(string $path): mixed
642635
*
643636
* @throws RuntimeException
644637
*/
645-
private function setConnectionPassiveMode()
638+
private function activePassiveMode()
646639
{
640+
ftp_set_option($this->connection, FTP_USEPASVADDRESS, false);
641+
647642
if (!ftp_pasv($this->connection, $this->use_passive_mode)) {
648643
throw new RuntimeException(
649644
'Could not set passive mode for connection: '

tests/Config/stubs/storage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
'password' => app_env('FTP_PASSWORD', 'password'),
2828
'username' => app_env('FTP_USERNAME', 'username'),
2929
'port' => app_env('FTP_PORT', 21),
30-
'root' => app_env('FTP_ROOT', sys_get_temp_dir()), // Start directory
30+
'root' => app_env('FTP_ROOT', '/tmp'), // Start directory
3131
'tls' => app_env('FTP_SSL', false), // `true` enable the secure connexion.
3232
'timeout' => app_env('FTP_TIMEOUT', 90) // Temps d'attente de connection
3333
],

0 commit comments

Comments
 (0)