Fix rm not accepting absolute paths

rm always glued its argument onto the player's current directory, so
typing an absolute path (e.g. sudo rm /var/arrest/handle.sh) built a
garbage path that matched no file and was rejected as "not allowed" -
even with full rm/sudo rights. cd already special-cased a leading '/'
as absolute; rm now does the same.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Frank
2026-08-22 20:15:05 +02:00
co-authored by Claude Sonnet 5
parent 51c542c7bb
commit ffa2b12786
+3 -1
View File
@@ -240,7 +240,9 @@ class GameResponseService
} }
$filename = $messagePart[1]; $filename = $messagePart[1];
$fullPath = ($pwd === '/' ? '' : $pwd) . '/' . $filename; $fullPath = str_starts_with($filename, '/')
? $filename
: ($pwd === '/' ? '' : $pwd) . '/' . $filename;
if(!$this->isAllowedToRemove($fullPath, $player, $sudo)) if(!$this->isAllowedToRemove($fullPath, $player, $sudo))
return ['result' => ['You are not allowed to remove this file.']]; return ['result' => ['You are not allowed to remove this file.']];