feat: Option „Ganzes System (ab /)“
- Neue Einstellung zeigt zusätzlich zu /mnt/user das Dateisystem ab / (Bestätigungsdialog beim Aktivieren, U_NAV_ROOTS hat Vorrang). - Geschützt vor Löschen/Verschieben/Rechteänderung: Wurzeln, Ordner direkt unter /, Mountpunkte unter /mnt. - /proc, /sys, /dev, /run: nur anzeigen; keine Jobs, Downloads, Vorschau oder Rekursion hinein. - Größe von Systemordnern nur auf Knopfdruck (weckt sonst alle Disks). - Pfade unter / ohne doppelten Schrägstrich; kaputte Symlinks erzeugen keine PHP-Warnungen mehr in der Antwort. - Paket 2026.11.21.r005. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a7e8325853
commit
0592a02c8e
17 files changed
+196
-43
No files matched your search
@@ -72,7 +72,9 @@ http://127.0.0.1:8088
|
||||
- ZIP erstellen, ZIP/TAR(.gz/.bz2/.xz) entpacken (mit Schutz gegen Pfade außerhalb des Ziels)
|
||||
- Prüfsummen (MD5, SHA-256) und Dateivergleich
|
||||
- Unraid: physischer Ort (disk/cache-Pool) und freier Speicher, „Unraid-Rechte reparieren“ (nobody:users, 777/666)
|
||||
- Wurzelordner (z. B. `/mnt/user`) können nicht gelöscht, verschoben oder in den Rechten geändert werden
|
||||
- Optional „Ganzes System (ab /)“ in den Einstellungen: zeigt zusätzlich das komplette Dateisystem
|
||||
- Wurzelordner, Ordner direkt unter `/` (z. B. `/boot`, `/etc`, `/usr`) und Mountpunkte unter `/mnt` können nicht
|
||||
gelöscht, verschoben oder in den Rechten geändert werden; `/proc`, `/sys`, `/dev` und `/run` werden nur angezeigt
|
||||
|
||||
Tastatur: Pfeiltasten, Enter, Backspace (hoch), Alt+←/→, Entf, F2, Strg+A/C/X/V, Strg+F, Strg+Shift+N, Esc.
|
||||
Dateien aus der Zwischenablage des eigenen Rechners werden mit Strg+V hochgeladen.
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ set -eu
|
||||
export COPYFILE_DISABLE=1
|
||||
|
||||
PLUGIN="u-navigator"
|
||||
VERSION="2026.11.21.r004"
|
||||
VERSION="2026.11.21.r005"
|
||||
PKG_DIR="packages"
|
||||
WORK_DIR=".plugin-build"
|
||||
PKG_NAME="${PLUGIN}-${VERSION}.tgz"
|
||||
|
||||
Binary file not shown.
@@ -4,6 +4,9 @@ const UNAV_DEFAULT_ROOT = '/mnt/user';
|
||||
const UNAV_JOB_DIR = '/tmp/u-navigator/jobs';
|
||||
const UNAV_SETTINGS_FILE = '/boot/config/plugins/u-navigator/settings.json';
|
||||
const UNAV_MAX_FAVORITES = 50;
|
||||
const UNAV_SYSTEM_ROOT = '/';
|
||||
// Kernel/virtual filesystems: never walked recursively (endless or device files).
|
||||
const UNAV_PSEUDO_FS = ['/proc', '/sys', '/dev', '/run'];
|
||||
|
||||
function unav_settings_file(): string {
|
||||
return getenv('U_NAV_SETTINGS_FILE') ?: UNAV_SETTINGS_FILE;
|
||||
@@ -23,6 +26,7 @@ function unav_settings(): array {
|
||||
'readOnly' => true,
|
||||
'debug' => false,
|
||||
'thumbnails' => true,
|
||||
'systemRoot' => false,
|
||||
'favorites' => [],
|
||||
];
|
||||
$file = unav_settings_file();
|
||||
@@ -37,6 +41,7 @@ function unav_settings(): array {
|
||||
'readOnly' => filter_var($settings['readOnly'] ?? $defaults['readOnly'], FILTER_VALIDATE_BOOLEAN),
|
||||
'debug' => filter_var($settings['debug'] ?? $defaults['debug'], FILTER_VALIDATE_BOOLEAN),
|
||||
'thumbnails' => filter_var($settings['thumbnails'] ?? $defaults['thumbnails'], FILTER_VALIDATE_BOOLEAN),
|
||||
'systemRoot' => filter_var($settings['systemRoot'] ?? $defaults['systemRoot'], FILTER_VALIDATE_BOOLEAN),
|
||||
'favorites' => unav_clean_favorites($settings['favorites'] ?? [], false),
|
||||
]);
|
||||
}
|
||||
@@ -84,6 +89,7 @@ function unav_settings_write(array $settings): array {
|
||||
'readOnly' => filter_var($settings['readOnly'] ?? $current['readOnly'], FILTER_VALIDATE_BOOLEAN),
|
||||
'debug' => filter_var($settings['debug'] ?? $current['debug'], FILTER_VALIDATE_BOOLEAN),
|
||||
'thumbnails' => filter_var($settings['thumbnails'] ?? $current['thumbnails'], FILTER_VALIDATE_BOOLEAN),
|
||||
'systemRoot' => filter_var($settings['systemRoot'] ?? $current['systemRoot'], FILTER_VALIDATE_BOOLEAN),
|
||||
'favorites' => array_key_exists('favorites', $settings)
|
||||
? unav_clean_favorites($settings['favorites'], true)
|
||||
: $current['favorites'],
|
||||
@@ -94,14 +100,39 @@ function unav_settings_write(array $settings): array {
|
||||
unav_error(500, 'Could not create settings directory');
|
||||
}
|
||||
file_put_contents($file, json_encode($next, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT), LOCK_EX);
|
||||
unav_roots(true);
|
||||
return $next;
|
||||
}
|
||||
|
||||
function unav_roots(): array {
|
||||
$configured = getenv('U_NAV_ROOTS') ?: UNAV_DEFAULT_ROOT;
|
||||
$roots = array_values(array_filter(array_map('trim', explode(',', $configured))));
|
||||
function unav_default_root(): string {
|
||||
return getenv('U_NAV_DEFAULT_ROOT') ?: UNAV_DEFAULT_ROOT;
|
||||
}
|
||||
|
||||
// U_NAV_ROOTS (if set) fixes the roots; otherwise the user shares, plus "/" when the
|
||||
// "whole system" setting is enabled.
|
||||
function unav_roots_from_env(): bool {
|
||||
return (string)getenv('U_NAV_ROOTS') !== '';
|
||||
}
|
||||
|
||||
function unav_roots(bool $reset = false): array {
|
||||
static $cache = null;
|
||||
if ($reset) {
|
||||
$cache = null;
|
||||
return [];
|
||||
}
|
||||
if ($cache !== null) {
|
||||
return $cache;
|
||||
}
|
||||
if (unav_roots_from_env()) {
|
||||
$roots = array_values(array_filter(array_map('trim', explode(',', (string)getenv('U_NAV_ROOTS')))));
|
||||
} else {
|
||||
$roots = [unav_default_root()];
|
||||
if (unav_settings()['systemRoot']) {
|
||||
$roots[] = UNAV_SYSTEM_ROOT;
|
||||
}
|
||||
}
|
||||
if (!$roots) {
|
||||
$roots = [UNAV_DEFAULT_ROOT];
|
||||
$roots = [unav_default_root()];
|
||||
}
|
||||
|
||||
$resolved = [];
|
||||
@@ -119,9 +150,45 @@ function unav_roots(): array {
|
||||
if (!$resolved) {
|
||||
unav_error(500, 'No usable U-Navigator root found');
|
||||
}
|
||||
$cache = $resolved;
|
||||
return $resolved;
|
||||
}
|
||||
|
||||
// Joins a directory and a name without producing "//name" when the directory is "/".
|
||||
function unav_join(string $dir, string $name): string {
|
||||
return rtrim($dir, '/') . '/' . ltrim($name, '/');
|
||||
}
|
||||
|
||||
function unav_is_pseudo_fs(string $path): bool {
|
||||
foreach (UNAV_PSEUDO_FS as $pseudo) {
|
||||
if ($path === $pseudo || str_starts_with($path, $pseudo . '/')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reading files below /proc, /sys, /dev or /run can block forever or return endless data.
|
||||
function unav_assert_not_pseudo_fs(string $path): void {
|
||||
if (unav_is_pseudo_fs($path)) {
|
||||
unav_error(400, 'Files in /proc, /sys, /dev and /run cannot be opened here');
|
||||
}
|
||||
}
|
||||
|
||||
// Roots, top-level system folders (/boot, /etc, /usr, ...) and Unraid mount points
|
||||
// (/mnt/user, /mnt/disk1, /mnt/cache, ...) must never be moved, deleted or re-permissioned.
|
||||
function unav_is_protected(string $real): bool {
|
||||
if (unav_is_root($real)) {
|
||||
return true;
|
||||
}
|
||||
$trimmed = rtrim($real, '/');
|
||||
if ($trimmed === '' || dirname($trimmed) === '/') {
|
||||
return true;
|
||||
}
|
||||
$mnt = unav_mnt_dir();
|
||||
return $trimmed === $mnt || dirname($trimmed) === $mnt || unav_is_pseudo_fs($trimmed);
|
||||
}
|
||||
|
||||
function unav_read_only(): bool {
|
||||
$env = getenv('U_NAV_READ_ONLY');
|
||||
if ($env === '1') {
|
||||
@@ -170,8 +237,8 @@ function unav_is_root(string $real): bool {
|
||||
|
||||
// Destructive operations must never act on a configured root itself (e.g. /mnt/user).
|
||||
function unav_assert_not_root(string $real): void {
|
||||
if (unav_is_root($real)) {
|
||||
unav_error(403, 'Root folders cannot be moved, deleted or changed');
|
||||
if (unav_is_protected($real)) {
|
||||
unav_error(403, 'Wurzel- und Systemordner können nicht verschoben, gelöscht oder in den Rechten geändert werden');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +273,7 @@ function unav_destination_path(?string $input): array {
|
||||
unav_error(404, 'Destination parent not found');
|
||||
}
|
||||
$root = unav_root_for_real($parentReal);
|
||||
return ['root' => $root, 'path' => $parentReal . '/' . basename($candidate)];
|
||||
return ['root' => $root, 'path' => unav_join($parentReal, basename($candidate))];
|
||||
}
|
||||
|
||||
function unav_assert_writable(): void {
|
||||
@@ -243,7 +310,7 @@ function unav_copy_recursive(string $source, string $destination): void {
|
||||
if ($entry === '.' || $entry === '..') {
|
||||
continue;
|
||||
}
|
||||
unav_copy_recursive($source . '/' . $entry, $destination . '/' . $entry);
|
||||
unav_copy_recursive(unav_join($source, $entry), unav_join($destination, $entry));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -267,7 +334,7 @@ function unav_delete_recursive(string $path): void {
|
||||
if ($entry === '.' || $entry === '..') {
|
||||
continue;
|
||||
}
|
||||
unav_delete_recursive($path . '/' . $entry);
|
||||
unav_delete_recursive(unav_join($path, $entry));
|
||||
}
|
||||
if (!rmdir($path)) {
|
||||
unav_error(500, 'Could not remove source directory after move');
|
||||
@@ -379,7 +446,7 @@ function unav_unique_path(string $path): string {
|
||||
// "Datei (2).txt" continues with "Datei (3).txt" instead of "Datei (2) (2).txt".
|
||||
$stem = preg_replace('/ \(\d+\)$/', '', $stem);
|
||||
for ($i = 2; $i < 10000; $i++) {
|
||||
$candidate = $dir . '/' . $stem . ' (' . $i . ')' . $ext;
|
||||
$candidate = rtrim($dir, '/') . '/' . $stem . ' (' . $i . ')' . $ext;
|
||||
if (!file_exists($candidate) && !is_link($candidate)) {
|
||||
return $candidate;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ function unav_config_payload(array $settings): array {
|
||||
'readOnly' => unav_read_only(),
|
||||
'debug' => $settings['debug'],
|
||||
'thumbnails' => $settings['thumbnails'],
|
||||
'systemRoot' => $settings['systemRoot'],
|
||||
'rootsFromEnv' => unav_roots_from_env(),
|
||||
'favorites' => $settings['favorites'],
|
||||
'roots' => unav_roots(),
|
||||
'thumbnailSupport' => function_exists('imagecreatefromstring'),
|
||||
|
||||
@@ -4,7 +4,9 @@ require_once __DIR__ . '/common.php';
|
||||
$paths = unav_download_paths();
|
||||
$items = [];
|
||||
foreach ($paths as $path) {
|
||||
$items[] = unav_existing_path($path);
|
||||
$item = unav_existing_path($path);
|
||||
unav_assert_not_pseudo_fs($item['path']);
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
if (count($items) === 1 && is_file($items[0]['path']) && !is_link($items[0]['path'])) {
|
||||
@@ -94,7 +96,7 @@ function unav_zip_add_path(ZipArchive $zip, string $path, string $zipPath): void
|
||||
if ($entry === '.' || $entry === '..') {
|
||||
continue;
|
||||
}
|
||||
unav_zip_add_path($zip, $real . '/' . $entry, $zipPath . '/' . unav_zip_safe_name($entry));
|
||||
unav_zip_add_path($zip, unav_join($real, $entry), $zipPath . '/' . unav_zip_safe_name($entry));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,11 @@ if ($action === 'compress') {
|
||||
if (in_array($action, ['move', 'delete', 'permissions', 'fixperms'], true)) {
|
||||
unav_assert_not_root($job['source']);
|
||||
}
|
||||
foreach ($job['sources'] ?? [$job['source']] as $path) {
|
||||
if (unav_is_pseudo_fs($path)) {
|
||||
unav_error(400, 'System pseudo filesystems (/proc, /sys, /dev, /run) are not supported for this action');
|
||||
}
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'move':
|
||||
|
||||
@@ -107,7 +107,7 @@ function unav_worker_guard(array $job): void {
|
||||
throw new RuntimeException('Destination parent not found');
|
||||
}
|
||||
unav_worker_assert_inside_root($parentReal);
|
||||
$destinationPath = $parentReal . '/' . basename($destination);
|
||||
$destinationPath = unav_join($parentReal, basename($destination));
|
||||
$exists = file_exists($destinationPath) || is_link($destinationPath);
|
||||
if ($exists && ($job['conflict'] ?? 'fail') !== 'overwrite') {
|
||||
throw new RuntimeException('Destination already exists');
|
||||
@@ -136,8 +136,8 @@ function unav_worker_guard_source(string $source): string {
|
||||
|
||||
function unav_worker_assert_not_root(string $path): void {
|
||||
$real = realpath($path);
|
||||
if ($real !== false && unav_is_root($real)) {
|
||||
throw new RuntimeException('Root folders cannot be moved, deleted or changed');
|
||||
if ($real !== false && unav_is_protected($real)) {
|
||||
throw new RuntimeException('Wurzel- und Systemordner können nicht verschoben, gelöscht oder in den Rechten geändert werden');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,6 +210,9 @@ function unav_worker_copy(string $source, string $destination, array &$job, stri
|
||||
if (is_link($source)) {
|
||||
throw new RuntimeException('Copying symlinks is not allowed');
|
||||
}
|
||||
if (unav_is_pseudo_fs($source)) {
|
||||
return;
|
||||
}
|
||||
if (is_dir($source)) {
|
||||
if (!mkdir($destination, 0777, true) && !is_dir($destination)) {
|
||||
throw new RuntimeException('Could not create destination directory');
|
||||
@@ -218,7 +221,7 @@ function unav_worker_copy(string $source, string $destination, array &$job, stri
|
||||
if ($entry === '.' || $entry === '..') {
|
||||
continue;
|
||||
}
|
||||
unav_worker_copy($source . '/' . $entry, $destination . '/' . $entry, $job, $label);
|
||||
unav_worker_copy(unav_join($source, $entry), unav_join($destination, $entry), $job, $label);
|
||||
}
|
||||
@chmod($destination, fileperms($source) & 07777);
|
||||
@touch($destination, filemtime($source) ?: time());
|
||||
@@ -282,7 +285,7 @@ function unav_worker_delete(string $path, ?array &$job = null): void {
|
||||
if ($entry === '.' || $entry === '..') {
|
||||
continue;
|
||||
}
|
||||
unav_worker_delete($path . '/' . $entry, $job);
|
||||
unav_worker_delete(unav_join($path, $entry), $job);
|
||||
}
|
||||
if (!rmdir($path)) {
|
||||
throw new RuntimeException('Could not delete directory ' . basename($path));
|
||||
@@ -291,7 +294,7 @@ function unav_worker_delete(string $path, ?array &$job = null): void {
|
||||
}
|
||||
|
||||
function unav_worker_size_recursive(string $path): array {
|
||||
if (is_link($path)) {
|
||||
if (is_link($path) || unav_is_pseudo_fs($path)) {
|
||||
return ['size' => 0, 'files' => 0, 'directories' => 0];
|
||||
}
|
||||
if (is_file($path)) {
|
||||
@@ -306,7 +309,7 @@ function unav_worker_size_recursive(string $path): array {
|
||||
if ($entry === '.' || $entry === '..') {
|
||||
continue;
|
||||
}
|
||||
$child = unav_worker_size_recursive($path . '/' . $entry);
|
||||
$child = unav_worker_size_recursive(unav_join($path, $entry));
|
||||
$total['size'] += $child['size'];
|
||||
$total['files'] += $child['files'];
|
||||
$total['directories'] += $child['directories'];
|
||||
@@ -358,7 +361,7 @@ function unav_worker_permissions_apply(string $path, ?string $mode, ?string $own
|
||||
if ($entry === '.' || $entry === '..') {
|
||||
continue;
|
||||
}
|
||||
unav_worker_permissions_apply($path . '/' . $entry, $mode, $owner, $group, true, $job, $count);
|
||||
unav_worker_permissions_apply(unav_join($path, $entry), $mode, $owner, $group, true, $job, $count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,7 +380,7 @@ function unav_worker_fixperms(array &$job): void {
|
||||
}
|
||||
foreach (scandir($path) ?: [] as $entry) {
|
||||
if ($entry !== '.' && $entry !== '..') {
|
||||
$walk($path . '/' . $entry);
|
||||
$walk(unav_join($path, $entry));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -413,7 +416,7 @@ function unav_worker_search(array &$job): void {
|
||||
if ($name === '.' || $name === '..') {
|
||||
continue;
|
||||
}
|
||||
$path = $dir . '/' . $name;
|
||||
$path = unav_join($dir, $name);
|
||||
$isLink = is_link($path);
|
||||
$isDir = !$isLink && is_dir($path);
|
||||
$job['result']['scanned']++;
|
||||
@@ -430,7 +433,7 @@ function unav_worker_search(array &$job): void {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ($isDir) {
|
||||
if ($isDir && !unav_is_pseudo_fs($path)) {
|
||||
$stack[] = $path;
|
||||
}
|
||||
}
|
||||
@@ -512,7 +515,7 @@ function unav_worker_extract(array &$job): void {
|
||||
throw new RuntimeException('Destination parent not found');
|
||||
}
|
||||
unav_worker_assert_inside_root($parent);
|
||||
$destination = $parent . '/' . basename($destination);
|
||||
$destination = unav_join($parent, basename($destination));
|
||||
if (file_exists($destination) || is_link($destination)) {
|
||||
throw new RuntimeException('Destination already exists');
|
||||
}
|
||||
@@ -652,7 +655,7 @@ function unav_worker_compress(array &$job): void {
|
||||
throw new RuntimeException('Destination parent not found');
|
||||
}
|
||||
unav_worker_assert_inside_root($parent);
|
||||
$destination = $parent . '/' . basename($destination);
|
||||
$destination = unav_join($parent, basename($destination));
|
||||
if (file_exists($destination)) {
|
||||
throw new RuntimeException('Destination already exists');
|
||||
}
|
||||
@@ -708,14 +711,14 @@ function unav_worker_compress(array &$job): void {
|
||||
}
|
||||
|
||||
function unav_worker_zip_add(ZipArchive $zip, string $path, string $name, array &$job): void {
|
||||
if (is_link($path)) {
|
||||
if (is_link($path) || unav_is_pseudo_fs($path)) {
|
||||
return;
|
||||
}
|
||||
if (is_dir($path)) {
|
||||
$zip->addEmptyDir($name);
|
||||
foreach (scandir($path) ?: [] as $entry) {
|
||||
if ($entry !== '.' && $entry !== '..') {
|
||||
unav_worker_zip_add($zip, $path . '/' . $entry, $name . '/' . $entry, $job);
|
||||
unav_worker_zip_add($zip, unav_join($path, $entry), $name . '/' . $entry, $job);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -11,17 +11,17 @@ foreach (scandir($resolved['path']) ?: [] as $name) {
|
||||
if ($name === '.' || $name === '..') {
|
||||
continue;
|
||||
}
|
||||
$full = $resolved['path'] . '/' . $name;
|
||||
$full = unav_join($resolved['path'], $name);
|
||||
$type = is_link($full) ? 'symlink' : (is_dir($full) ? 'directory' : (is_file($full) ? 'file' : 'other'));
|
||||
$ownerId = fileowner($full);
|
||||
$groupId = filegroup($full);
|
||||
$perms = fileperms($full);
|
||||
$ownerId = @fileowner($full);
|
||||
$groupId = @filegroup($full);
|
||||
$perms = @fileperms($full);
|
||||
$entries[] = [
|
||||
'name' => $name,
|
||||
'path' => $full,
|
||||
'type' => $type,
|
||||
'size' => is_file($full) ? filesize($full) : 0,
|
||||
'modifiedAt' => date(DATE_ATOM, filemtime($full) ?: time()),
|
||||
'size' => is_file($full) ? (@filesize($full) ?: 0) : 0,
|
||||
'modifiedAt' => date(DATE_ATOM, @filemtime($full) ?: (@lstat($full)['mtime'] ?? time())),
|
||||
'owner' => unav_owner_name($ownerId),
|
||||
'ownerId' => $ownerId,
|
||||
'group' => unav_group_name($groupId),
|
||||
|
||||
@@ -14,7 +14,7 @@ $name = trim((string)($data['name'] ?? ''));
|
||||
if (!unav_valid_name($name)) {
|
||||
unav_error(400, 'Ungültiger Ordnername');
|
||||
}
|
||||
$path = $parent['path'] . '/' . $name;
|
||||
$path = unav_join($parent['path'], $name);
|
||||
if (file_exists($path) || is_link($path)) {
|
||||
unav_error(409, 'Destination already exists');
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ require_once __DIR__ . '/common.php';
|
||||
const UNAV_TEXT_PREVIEW_MAX_BYTES = 1048576;
|
||||
|
||||
$resolved = unav_existing_path($_GET['path'] ?? null);
|
||||
unav_assert_not_pseudo_fs($resolved['path']);
|
||||
if (!is_file($resolved['path'])) {
|
||||
unav_error(400, 'Preview target must be a file');
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ const UNAV_THUMB_MAX_BYTES = 52428800;
|
||||
|
||||
$resolved = unav_existing_path($_GET['path'] ?? null);
|
||||
$path = $resolved['path'];
|
||||
unav_assert_not_pseudo_fs($path);
|
||||
$size = max(32, min(512, (int)($_GET['size'] ?? 192)));
|
||||
if (!is_file($path) || !preg_match('/\.(jpe?g|png|gif|webp)$/i', $path)) {
|
||||
unav_error(415, 'No thumbnail for this file type');
|
||||
|
||||
@@ -105,13 +105,13 @@ function unav_prepare_upload_destination(string $targetPath, string $relativeNam
|
||||
$safeName = unav_upload_safe_relative_path($relativeName);
|
||||
$relativeParent = dirname($safeName);
|
||||
if ($relativeParent !== '.') {
|
||||
$parentCandidate = $targetPath . '/' . $relativeParent;
|
||||
$parentCandidate = unav_join($targetPath, $relativeParent);
|
||||
unav_root_for_real($targetPath);
|
||||
if (!is_dir($parentCandidate) && !mkdir($parentCandidate, 0777, true) && !is_dir($parentCandidate)) {
|
||||
unav_error(500, 'Could not create upload directory');
|
||||
}
|
||||
}
|
||||
$destination = unav_destination_path($targetPath . '/' . $safeName);
|
||||
$destination = unav_destination_path(unav_join($targetPath, $safeName));
|
||||
if (file_exists($destination['path'])) {
|
||||
if (!$overwrite) {
|
||||
unav_error(409, 'Destination already exists');
|
||||
|
||||
+47
-2
@@ -830,7 +830,18 @@ function renderProperties(body) {
|
||||
</dl>
|
||||
`;
|
||||
if (entry.type === 'directory') {
|
||||
ensureDirectorySize(entry);
|
||||
if (isSystemRootPath(entry.path)) {
|
||||
if (!state.sizeResults.has(entry.path) && !state.sizeJobs.has(entry.path)) {
|
||||
const sizeCell = body.querySelectorAll('dd')[3];
|
||||
sizeCell.innerHTML = '<button type="button" class="link-button" data-action="calc-size">Größe berechnen</button>';
|
||||
sizeCell.querySelector('button').addEventListener('click', () => {
|
||||
ensureDirectorySize(entry);
|
||||
updatePropertiesWindows();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
ensureDirectorySize(entry);
|
||||
}
|
||||
}
|
||||
ensureStorageInfo(entry.path);
|
||||
}
|
||||
@@ -1305,6 +1316,13 @@ function renderSettingsPanel() {
|
||||
</span>
|
||||
<input type="checkbox" data-setting="thumbnails" ${state.config?.thumbnails !== false ? 'checked' : ''} ${state.config?.thumbnailSupport === false ? 'disabled' : ''}>
|
||||
</label>
|
||||
<label class="setting-row">
|
||||
<span>
|
||||
<strong>Ganzes System (ab /)</strong>
|
||||
<small>${state.config?.rootsFromEnv ? 'Durch U_NAV_ROOTS fest vorgegeben' : 'Zusätzlich zu /mnt/user das komplette Dateisystem zeigen'}</small>
|
||||
</span>
|
||||
<input type="checkbox" data-setting="systemRoot" ${state.config?.systemRoot ? 'checked' : ''} ${state.config?.rootsFromEnv ? 'disabled' : ''}>
|
||||
</label>
|
||||
</div>
|
||||
`;
|
||||
if (!existing) {
|
||||
@@ -1329,6 +1347,27 @@ function renderSettingsPanel() {
|
||||
panel.querySelector('[data-setting="thumbnails"]').addEventListener('change', (event) => {
|
||||
saveSettings({ thumbnails: event.currentTarget.checked });
|
||||
});
|
||||
panel.querySelector('[data-setting="systemRoot"]').addEventListener('change', async (event) => {
|
||||
const input = event.currentTarget;
|
||||
if (input.checked) {
|
||||
const confirmed = await showConfirmDialog(
|
||||
'Ganzes System anzeigen',
|
||||
'Der Navigator zeigt dann zusätzlich das komplette Dateisystem ab "/" – mit Root-Rechten.',
|
||||
'Ordner direkt unter "/", /boot und die Mountpunkte unter /mnt bleiben vor Löschen, Verschieben und Rechteänderungen geschützt. Alles darunter lässt sich bei aktivem Schreibzugriff ändern – auch Systemdateien. /proc, /sys, /dev und /run werden nur angezeigt.',
|
||||
{ confirmLabel: 'Aktivieren', danger: true }
|
||||
);
|
||||
if (!confirmed) {
|
||||
input.checked = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
await saveSettings({ systemRoot: input.checked });
|
||||
if (!input.checked) {
|
||||
for (const win of state.windows.filter((item) => item.kind === 'explorer' && !rootForPath(item.data.path))) {
|
||||
loadExplorer(win, state.config.roots[0].path);
|
||||
}
|
||||
}
|
||||
});
|
||||
settingsButton.classList.add('active');
|
||||
settingsButton.setAttribute('aria-expanded', 'true');
|
||||
}
|
||||
@@ -1340,6 +1379,7 @@ async function saveSettings(changes) {
|
||||
body.set('readOnly', readOnly ? '1' : '0');
|
||||
body.set('debug', debug ? '1' : '0');
|
||||
body.set('thumbnails', (changes.thumbnails ?? state.config.thumbnails) ? '1' : '0');
|
||||
body.set('systemRoot', (changes.systemRoot ?? state.config.systemRoot) ? '1' : '0');
|
||||
appendCsrf(body);
|
||||
try {
|
||||
state.config = await api(apiUrl('config.php'), {
|
||||
@@ -3051,7 +3091,7 @@ function windowTitle(win) {
|
||||
|
||||
function parentPath(value) {
|
||||
const parts = String(value || '').split('/').filter(Boolean);
|
||||
if (parts.length <= 1) return value;
|
||||
if (parts.length <= 1) return '/';
|
||||
return `/${parts.slice(0, -1).join('/')}`;
|
||||
}
|
||||
|
||||
@@ -3101,6 +3141,11 @@ function formatBytes(bytes) {
|
||||
return `${(value / 1024 / 1024 / 1024).toFixed(1)} GB`;
|
||||
}
|
||||
|
||||
// Outside the user shares (system root) a size scan can wake every disk, so it only runs on request.
|
||||
function isSystemRootPath(path) {
|
||||
return normalizePath(rootForPath(path)?.path || '') === '/';
|
||||
}
|
||||
|
||||
function directorySizeLabel(entry) {
|
||||
const result = state.sizeResults.get(entry.path);
|
||||
if (!result) {
|
||||
|
||||
+24
-1
@@ -20,7 +20,7 @@ file_put_contents($mnt . '/cache/media/movies/b.mkv', 'y');
|
||||
file_put_contents($outside . '/secret.txt', 'secret');
|
||||
|
||||
$env = [
|
||||
'U_NAV_ROOTS' => $user,
|
||||
'U_NAV_DEFAULT_ROOT' => $user,
|
||||
'U_NAV_READ_ONLY' => '0',
|
||||
'U_NAV_SETTINGS_FILE' => $base . '/settings.json',
|
||||
'U_NAV_JOB_DIR' => $base . '/jobs',
|
||||
@@ -179,6 +179,21 @@ check('raw svg is sandboxed', (bool)preg_grep('/^Content-Security-Policy: sandbo
|
||||
$r = call('POST', 'config.php', ['favorites' => json_encode([$share, $outside, $share . '/missing'])]);
|
||||
check('favorites keep only folders inside roots', ($r['json']['favorites'] ?? null) === [$share], json_encode($r['json']['favorites'] ?? null));
|
||||
|
||||
// whole system root (opt-in)
|
||||
$r = call('GET', 'list.php?path=/');
|
||||
check('system root is hidden by default', $r['status'] === 403);
|
||||
$r = call('POST', 'config.php', ['systemRoot' => '1']);
|
||||
check('system root can be enabled', ($r['json']['systemRoot'] ?? null) === true && in_array('/', array_column($r['json']['roots'] ?? [], 'path'), true));
|
||||
$r = call('GET', 'list.php?path=/');
|
||||
check('system root lists /', $r['status'] === 200 && in_array('usr', array_column($r['json']['entries'] ?? [], 'name'), true), $r['status'] . ' ' . substr($r['body'], 0, 300));
|
||||
$r = job('size', ['source' => '/dev']);
|
||||
check('pseudo filesystems are rejected for jobs', $r['status'] === 400);
|
||||
$r = call('GET', 'download.php?path=' . urlencode('/dev/null'));
|
||||
check('pseudo filesystem files cannot be downloaded', $r['status'] === 400);
|
||||
$r = job('copy', ['source' => $share . '/alpha.txt', 'destination' => $share . '/alpha-sys.txt']);
|
||||
check('shares still work with system root', ($r['json']['status'] ?? '') === 'completed');
|
||||
call('POST', 'config.php', ['systemRoot' => '0']);
|
||||
|
||||
// cancellation (worker in-process with a pre-set cancel marker)
|
||||
require_once $apiDir . '/job_worker.php';
|
||||
$big = $share . '/big.bin';
|
||||
@@ -188,6 +203,14 @@ unav_job_write(['id' => $jobId, 'type' => 'copy', 'status' => 'queued', 'source'
|
||||
touch(unav_job_cancel_path($jobId));
|
||||
unav_run_job($jobId);
|
||||
$cancelled = unav_job_read($jobId);
|
||||
putenv('U_NAV_SETTINGS_FILE=' . $base . '/settings-system.json');
|
||||
file_put_contents($base . '/settings-system.json', json_encode(['systemRoot' => true]));
|
||||
unav_roots(true);
|
||||
check('top-level system folders are protected', unav_is_protected('/usr') && unav_is_protected('/boot') && unav_is_protected('/') && !unav_is_protected('/usr/local'));
|
||||
check('Unraid mount points are protected', unav_is_protected($mnt . '/disk1') && unav_is_protected($user) && unav_is_protected($mnt) && !unav_is_protected($share));
|
||||
check('pseudo filesystems are protected', unav_is_protected('/proc/1') && unav_is_pseudo_fs('/sys/kernel') && !unav_is_pseudo_fs('/system'));
|
||||
putenv('U_NAV_SETTINGS_FILE=' . $base . '/settings.json');
|
||||
unav_roots(true);
|
||||
check('cancelled copy leaves nothing behind', $cancelled['status'] === 'cancelled' && !file_exists($share . '/big-copy.bin') && !glob($share . '/.u-nav-*'), json_encode($cancelled));
|
||||
|
||||
echo "\n$count checks, $failures failed\n";
|
||||
|
||||
+3
-2
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE PLUGIN [
|
||||
<!ENTITY name "u-navigator">
|
||||
<!ENTITY author "Michael Roll">
|
||||
<!ENTITY version "2026.11.21.r004">
|
||||
<!ENTITY version "2026.11.21.r005">
|
||||
<!ENTITY package "&name;-&version;.tgz">
|
||||
<!ENTITY pluginURL "https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/u-navigator.plg">
|
||||
<!ENTITY support "https://git.casaderoll.de/michael/Unraid-Navigator">
|
||||
@@ -18,6 +18,7 @@
|
||||
&description;
|
||||
|
||||
### &version;
|
||||
- Option „Ganzes System (ab /)“ in den Einstellungen; Systemordner, /boot und Mountpunkte bleiben geschützt.
|
||||
- Folgt dem Unraid-Theme (black/gray dunkel, white/azure hell) statt nur der Systemeinstellung.
|
||||
- Neuer Ordner, Tastaturbedienung, Kopieren/Ausschneiden/Einfügen, Zurück/Vorwärts, anklickbare Pfadleiste.
|
||||
- Filter und rekursive Suche, Favoriten, Vorschaubilder, Nebeneinander-Ansicht, Statusleiste mit freiem Speicher.
|
||||
@@ -28,7 +29,7 @@
|
||||
|
||||
<FILE Name="/boot/config/plugins/&name;/&package;">
|
||||
<URL>https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/packages/&package;</URL>
|
||||
<MD5>39df497b7df11629b3e857c896c48bfc</MD5>
|
||||
<MD5>c0dd54cb308a2de3542429300705ecde</MD5>
|
||||
</FILE>
|
||||
|
||||
<FILE Run="/bin/bash">
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
&description;
|
||||
|
||||
### &version;
|
||||
- Option „Ganzes System (ab /)“ in den Einstellungen; Systemordner, /boot und Mountpunkte bleiben geschützt.
|
||||
- Folgt dem Unraid-Theme (black/gray dunkel, white/azure hell) statt nur der Systemeinstellung.
|
||||
- Neuer Ordner, Tastaturbedienung, Kopieren/Ausschneiden/Einfügen, Zurück/Vorwärts, anklickbare Pfadleiste.
|
||||
- Filter und rekursive Suche, Favoriten, Vorschaubilder, Nebeneinander-Ansicht, Statusleiste mit freiem Speicher.
|
||||
|
||||
Reference in new issue
Block a user