LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
Files: This computer (the whole tree read-only as the user, without /proc, /sys, /dev and /run) and every disk in the sidebar: unmounted ones mount on a click, ⏏ ejects or unmounts, unreadable folders show a lock, read-only folders offer no changing actions
Federico Pereira5588379c4556
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e829a2c..c340727 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,12 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),### Added+- **Files: This Computer and every disk.** The sidebar now has This Computer, to browse the whole+ system read-only as your user (the system's own permissions decide; the kernel's `/proc`, `/sys`,+ `/dev` and `/run` stay out), and every disk with a file system: one that isn't mounted shows+ dimmed and a click mounts and opens it (an internal disk asks for an administrator, as in Disks);+ a removable one can be ejected from its ⏏. Folders you can't write show no actions that would+ change them.- **Monitor → Network, second generation.** The app list is now a tree: each app opens into thesites and addresses it talks to, and each address into its ports, with what was sent and receivedeverywhere, a small live meter and an allow/block switch on every destination. One pop-up buttondiff --git a/apps/files/glyphs.jsx b/apps/files/glyphs.jsxindex 7f8dd31..91b0b7c 100644--- a/apps/files/glyphs.jsx+++ b/apps/files/glyphs.jsx@@ -38,6 +38,15 @@ export function DocGlyph({ size: s, kind, ext, dark }) {export function EntryIcon({ e, size, dark, thumb = true }) {if (e.Icon) return <e.Icon size={size} />;const kind = kindOf(e);+ if (kind === 'folder' && e.locked) {+ // a folder the user can't open (This computer): the system's permissions say no+ return (+ <View style={{ width: size, height: size }}>+ <FolderGlyph size={size} special={e.special} />+ <Text style={{ position: 'absolute', right: 0, bottom: 0, fontSize: Math.max(9, Math.round(size * 0.32)) }}>🔒</Text>+ </View>+ );+ }if (kind === 'folder') return <FolderGlyph size={size} special={e.special} />;if (thumb && isImage(e) && size >= 32 && e.size < 24 * 1024 * 1024) {return (diff --git a/apps/files/index.jsx b/apps/files/index.jsxindex b845145..8073f84 100644--- a/apps/files/index.jsx+++ b/apps/files/index.jsx@@ -1,10 +1,12 @@// Files — a file browser: tabs, four views (icons, list, columns and gallery), a sidebar// with Favorites, Locations and Tags, the freedesktop Trash, Quick Preview, Get Info,-// copy/cut/paste, drag and drop, and search.+// copy/cut/paste, drag and drop, and search. Locations also has This computer (the whole tree,+// read-only outside the home folder and the user's disks) and every disk, mounted or not.// Disk operations go through lord.fs (server/src/fsops.c); see docs/FILES.md.import {View, Text, useTheme, useAppWindow, useKeyboard, useStore, useLauncherApps, addListener, wm, fs, clipboard, archive, warmDocs,formatBytes, t as tr, ScrollView, Toolbar, ToolbarButton, ToolbarGroup, SearchField, Hairline, direction, spacing, typeScale, registerDockActions,+ useDisks, admin, systemInfo,} from '@lordos/sdk';import { useEffect, useMemo, useRef, useState } from 'react';import { FolderGlyph, DocGlyph, TAG_COLORS, TrashGlyph, DriveGlyph } from './glyphs.jsx';@@ -38,6 +40,32 @@ const newTab = (loc, from) => ({ id: tabSeq++, loc, back: [], fwd: [], view: froconst winStates = new Map();const homeLoc = () => ({ type: 'dir', path: fs.home() });+const computerLoc = () => ({ type: 'dir', path: '/' });+// This computer is named after the machine+const computerName = () => { try { return systemInfo().hostname || tr('files.place.computer'); } catch (e) { return tr('files.place.computer'); } };+// Partitions (or whole disks without a table) that hold a file system and aren't mounted, off the+// disk the system runs from: the sidebar offers them, mounted with the Disks app's disk-mount.+const NO_MOUNT = ['', 'swap', 'crypto_LUKS', 'LVM2_member', 'linux_raid_member'];+function unmountedDisks(list) {+ const out = [];+ for (const d of list || []) {+ if (d.system) continue;+ for (const p of d.partitions?.length ? d.partitions : [d]) {+ if (!NO_MOUNT.includes(p.fstype || '') && !p.mountpoint) out.push({ name: p.name, label: p.label, size: p.size, removable: d.removable });+ }+ }+ return out;+}+// What ⏏ does for a mounted volume: a removable disk is ejected whole (disk-eject), another disk's+// partition is unmounted (disk-unmount); nothing on the disk the system runs from.+function volumeRelease(list, path) {+ for (const d of list || []) {+ if (d.system) continue;+ const p = (d.partitions?.length ? d.partitions : [d]).find((x) => x.mountpoint === path);+ if (p) return d.removable ? { action: 'disk-eject', name: d.name } : { action: 'disk-unmount', name: p.name };+ }+ return null;+}function argLoc(args) {if (args?.place === 'trash') return { type: 'trash' };if (!args?.path) return null;@@ -72,6 +100,7 @@ function locTitle(loc, dirs) {case 'archive': return loc.inner ? fs.basename(loc.inner) : fs.basename(loc.path);default: {if (loc.path === fs.home()) return tr('files.place.home');+ if (loc.path === '/') return computerName();const d = dirs.find((x) => x.path === loc.path);return d ? tr(`files.place.${d.label}`) : fs.basename(loc.path);}@@ -82,14 +111,19 @@ function locTitle(loc, dirs) {// Source-list row: 28 px, accent-colored icon, a soft highlight when selected and the// accent when something is dragged over it.-function SideItem({ label, icon, selected, onClick, t, drop, hot }) {+function SideItem({ label, icon, selected, onClick, t, drop, hot, dim, trail }) {const [hover, setHover] = useState(false);return (<View onClick={onClick} onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)} {...drop}style={{ height: 28, flexDirection: 'row', alignItems: 'center', gap: 8, paddingHorizontal: 8, borderRadius: 6,backgroundColor: hot ? t.accent : selected ? (t.mode === 'dark' ? 'rgba(255,255,255,0.12)' : 'rgba(0,0,0,0.08)') : hover ? t.hover : 'transparent' }}><View style={{ width: 18, alignItems: 'center', justifyContent: 'center' }}>{icon}</View>- <Text style={{ flex: 1, fontSize: typeScale.body, color: hot ? '#fff' : t.text, whiteSpace: 'nowrap', overflow: 'hidden' }}>{label}</Text>+ <Text style={{ flex: 1, fontSize: typeScale.body, color: hot ? '#fff' : dim ? t.textDim : t.text, whiteSpace: 'nowrap', overflow: 'hidden', textAlign: 'start' }}>{label}</Text>+ {trail && (hover || selected) ? (+ <View onClick={(e) => { e.stopPropagation?.(); trail.onClick(); }} style={{ width: 18, alignItems: 'center' }}>+ <Text style={{ fontSize: 12, color: t.textDim }}>{trail.glyph}</Text>+ </View>+ ) : null}</View>);}@@ -157,6 +191,7 @@ export default function Files() {const [drag, setDrag] = useState(null); // { paths, x, y, alt }const [dropTarget, setDropTarget] = useState(null);const [volumes, setVolumes] = useState(() => fs.volumes());+ const [diskList] = useDisks();useEffect(() => { setTimeout(warmDocs, 800); }, []); // PDF Quick Preview without waiting for the helperconst [msg, setMsg] = useState(null);const root = useRef(null);@@ -176,6 +211,10 @@ export default function Files() {const flat = useMemo(() => groups.flatMap((g) => g.items), [groups]);const byPath = useMemo(() => new Map(flat.map((e) => [e.path, e])), [flat]);const curDir = baseLoc.type === 'dir' ? baseLoc.path : null;+ // outside the home folder and the user's disks a folder is only browsed (lord.fs reads there but+ // doesn't write): the actions that change it are left out+ const readOnly = useMemo(() => { if (!curDir) return false; try { return !fs.stat(curDir).writable; } catch (e) { return true; } }, [curDir, version]);+ const wDir = readOnly ? null : curDir;const title = locTitle(loc, dirs);function navigate(next, push = true) {@@ -207,17 +246,17 @@ export default function Files() {// ---- actions ----const report = (e) => { console.log(`files: ${e?.message || e}`); setMsg(String(e?.message || e)); };const newFolder = (withPaths) => {- if (!curDir) return;- const name = freeName(curDir, tr('files.newFolder'));+ if (!wDir) return;+ const name = freeName(wDir, tr('files.newFolder'));try {- fs.mkdir(`${curDir}/${name}`);- if (withPaths && withPaths.length) transfer(withPaths, `${curDir}/${name}`, true);+ fs.mkdir(`${wDir}/${name}`);+ if (withPaths && withPaths.length) transfer(withPaths, `${wDir}/${name}`, true);bump();- setSelected(new Set([`${curDir}/${name}`]));- setRenaming({ path: `${curDir}/${name}`, value: name });+ setSelected(new Set([`${wDir}/${name}`]));+ setRenaming({ path: `${wDir}/${name}`, value: name });} catch (e) { report(e); }};- const startRename = (e = first) => { if (e && !e.app && !e.trash && curDir !== null) { setSelected(new Set([e.path])); setRenaming({ path: e.path, value: e.name }); } };+ const startRename = (e = first) => { if (e && !e.app && !e.trash && wDir !== null) { setSelected(new Set([e.path])); setRenaming({ path: e.path, value: e.name }); } };const commitRename = () => {const r = renaming;setRenaming(null);@@ -234,15 +273,27 @@ export default function Files() {const askEmpty = () => setConfirm({ text: tr('files.confirm.empty'), detail: tr('files.confirm.cantUndo'), ok: tr('files.menu.emptyTrash'),run: () => { fs.emptyTrash(); bump(); } });const toTrash = (paths = selPaths) => {- if (!paths.length) return;+ if (!paths.length || readOnly) return;if (loc.type === 'trash') { askDelete(paths); return; }let n = 0;for (const p of paths) { try { fs.trash(p); n++; } catch (e) { report(e); } }if (n) { setMsg(tr('files.trashed', { count: n })); bump(); }};const restore = (paths = selPaths) => { let n = 0; for (const p of paths) { try { fs.restore(p); n++; } catch (err) { report(err); } } if (n) { setMsg(tr('files.restored', { count: n })); bump(); } };- const duplicate = (paths = selPaths) => { if (curDir && paths.length) transfer(paths, curDir, false); };- const doPaste = () => { if (curDir) paste(curDir); };+ // disks: the same closed actions as the Disks app (an internal disk asks for an administrator)+ const mount = (p) => {+ setMsg(tr('files.disk.mounting', { name: p.label || p.name }));+ admin.run('disk-mount', p.name, null, { quiet: true }).then(+ (path) => { setVolumes(fs.volumes()); setMsg(null); const at = String(path || '').trim(); if (at.startsWith('/')) navigate(dirLoc(at)); },+ (e) => setMsg(e.message));+ };+ const release = (r, path) => {+ admin.run(r.action, r.name, null, { quiet: true }).then(+ () => { setVolumes(fs.volumes()); setMsg(tr(r.action === 'disk-eject' ? 'disks.ejected' : 'disks.unmounted')); if (curDir && (curDir === path || curDir.startsWith(`${path}/`))) navigate(homeLoc()); },+ (e) => setMsg(e.message));+ };+ const duplicate = (paths = selPaths) => { if (wDir && paths.length) transfer(paths, wDir, false); };+ const doPaste = () => { if (wDir) paste(wDir); };const ctx = { navigate, linuxApps: launcherApps, t: tr, quickLook: (e) => { setSelected(new Set([e.path])); setQuick(true); },openArc: (e) => { setMsg(tr('docs.opening', { name: e.name })); extractEntry(e).then((real) => openEntry({ name: e.name, path: real, size: e.size, mtime: e.mtime }, ctx)).catch((err) => setMsg(tr('docs.extractError', { name: e.name, error: err.message }))); } };const arcReport = (m) => setMsg(m);@@ -319,21 +370,21 @@ export default function Files() {...(e.dir ? [{ label: tr('files.menu.openTab'), onClick: () => newTabAt({ type: 'dir', path: e.path }) }] : []),...(!e.dir && openers.length ? [{ label: tr('files.menu.openWith'), submenu: openers.map((o) => ({ label: o.label, onClick: o.run })) }] : []),'-',- { label: tr('files.menu.trash'), hint: '❖⌫', onClick: () => toTrash(paths) },+ { label: tr('files.menu.trash'), hint: '❖⌫', onClick: () => toTrash(paths), disabled: readOnly },'-',// compress and extract (M9, lord-doc)- ...(curDir && list.length === 1 && isArchiveFile(e) ? [{ label: tr('docs.extractHere'), onClick: () => extractHere(e, arcReport, tr) }] : []),- ...(curDir ? [{ label: list.length === 1 ? tr('docs.compressOne', { name: e.name }) : tr('docs.compressMany', { count: list.length }), onClick: () => compress(paths, curDir, arcReport, tr) }] : []),+ ...(wDir && list.length === 1 && isArchiveFile(e) ? [{ label: tr('docs.extractHere'), onClick: () => extractHere(e, arcReport, tr) }] : []),+ ...(wDir ? [{ label: list.length === 1 ? tr('docs.compressOne', { name: e.name }) : tr('docs.compressMany', { count: list.length }), onClick: () => compress(paths, wDir, arcReport, tr) }] : []),'-',{ label: tr('files.menu.getInfo'), hint: '❖I', onClick: () => setInfo(true) },- { label: tr('files.menu.rename'), hint: '↵', onClick: () => startRename(e), disabled: paths.length > 1 || !curDir },- { label: tr('files.menu.duplicate'), hint: '❖D', onClick: () => duplicate(paths), disabled: !curDir },+ { label: tr('files.menu.rename'), hint: '↵', onClick: () => startRename(e), disabled: paths.length > 1 || !wDir },+ { label: tr('files.menu.duplicate'), hint: '❖D', onClick: () => duplicate(paths), disabled: !wDir },{ label: tr('files.menu.quickLook'), hint: '␣', onClick: () => setQuick(true) },'-',{ label: tr('files.menu.copy'), hint: '❖C', onClick: () => copyFiles(paths) },- { label: tr('files.menu.cut'), hint: '❖X', onClick: () => cutFiles(paths) },+ { label: tr('files.menu.cut'), hint: '❖X', onClick: () => cutFiles(paths), disabled: readOnly },{ label: tr('files.menu.copyPath'), onClick: () => clipboard.set(paths.join('\n')) },- ...(curDir ? [{ label: tr('files.menu.newFolderWith', { count: paths.length }), onClick: () => newFolder(paths) }] : []),+ ...(wDir ? [{ label: tr('files.menu.newFolderWith', { count: paths.length }), onClick: () => newFolder(paths) }] : []),'-',{ header: tr('files.menu.tags') }, tagSwatches(paths),];@@ -344,7 +395,7 @@ export default function Files() {const groupItems = ['none', 'kind', 'date', 'size'].map((k) => ({ label: tr(`files.groupBy.${k}`), checked: tab.group === k, onClick: () => patchTab({ group: k }) }));if (loc.type === 'trash') return [{ label: tr('files.menu.emptyTrash'), danger: true, onClick: askEmpty, disabled: !entries.length }, '-', { label: tr('files.menu.view'), submenu: viewItems }];return [- ...(curDir ? [{ label: tr('files.menu.newFolder'), hint: '❖⇧N', onClick: () => newFolder(null) }, { label: tr('files.menu.paste'), hint: 'Ctrl+V', onClick: doPaste, disabled: !clip }, '-'] : []),+ ...(wDir ? [{ label: tr('files.menu.newFolder'), hint: '❖⇧N', onClick: () => newFolder(null) }, { label: tr('files.menu.paste'), hint: 'Ctrl+V', onClick: doPaste, disabled: !clip }, '-'] : []),{ label: tr('files.menu.view'), submenu: viewItems },{ label: tr('files.menu.sortBy'), submenu: sortItems },{ label: tr('files.menu.groupBy'), submenu: groupItems },@@ -391,7 +442,7 @@ export default function Files() {if (mod && b === 'i') { setInfo((v) => !v); return; }if (mod && b === 'd') { duplicate(); return; }if (mod && b === 'c') { if (selPaths.length) copyFiles(selPaths); return; }- if (mod && b === 'x') { if (selPaths.length) cutFiles(selPaths); return; }+ if (mod && b === 'x') { if (selPaths.length && !readOnly) cutFiles(selPaths); return; }if (e.ctrl && b === 'v') { doPaste(); return; }if (mod && b === 'a') { setSelected(new Set(flat.map((x) => x.path))); return; }if (mod && b === '[') { goBack(); return; }@@ -426,18 +477,18 @@ export default function Files() {{ label: tr('files.menu.file'), items: [{ label: tr('files.menu.newWindow'), hint: '❖N', onClick: () => wm.open('files', { new: true, args: { path: curDir || fs.home() } }) },{ label: tr('files.menu.newTab'), hint: '❖T', onClick: () => newTabAt() },- { label: tr('files.menu.newFolder'), hint: '❖⇧N', onClick: () => newFolder(null), disabled: !curDir }, '-',+ { label: tr('files.menu.newFolder'), hint: '❖⇧N', onClick: () => newFolder(null), disabled: !wDir }, '-',{ label: tr('files.menu.open'), hint: '❖↓', onClick: () => openSel(), disabled: !sel.length },{ label: tr('files.menu.getInfo'), hint: '❖I', onClick: () => setInfo(true) },- { label: tr('files.menu.rename'), hint: '↵', onClick: () => startRename(), disabled: sel.length !== 1 },- { label: tr('files.menu.duplicate'), hint: '❖D', onClick: () => duplicate(), disabled: !sel.length || !curDir },- { label: tr('files.menu.trash'), hint: '❖⌫', onClick: () => toTrash(), disabled: !sel.length }, '-',+ { label: tr('files.menu.rename'), hint: '↵', onClick: () => startRename(), disabled: sel.length !== 1 || !wDir },+ { label: tr('files.menu.duplicate'), hint: '❖D', onClick: () => duplicate(), disabled: !sel.length || !wDir },+ { label: tr('files.menu.trash'), hint: '❖⌫', onClick: () => toTrash(), disabled: !sel.length || readOnly }, '-',{ label: tr('files.menu.closeTab'), hint: '❖W', onClick: () => closeTab(active) },] },{ label: tr('files.menu.edit'), items: [{ label: tr('files.menu.copy'), hint: '❖C', onClick: () => copyFiles(selPaths), disabled: !sel.length },- { label: tr('files.menu.cut'), hint: '❖X', onClick: () => cutFiles(selPaths), disabled: !sel.length },- { label: tr('files.menu.paste'), hint: 'Ctrl+V', onClick: doPaste, disabled: !clip || !curDir },+ { label: tr('files.menu.cut'), hint: '❖X', onClick: () => cutFiles(selPaths), disabled: !sel.length || readOnly },+ { label: tr('files.menu.paste'), hint: 'Ctrl+V', onClick: doPaste, disabled: !clip || !wDir },{ label: tr('files.menu.selectAll'), hint: '❖A', onClick: () => setSelected(new Set(flat.map((x) => x.path))) },] },{ label: tr('files.menu.view'), items: [@@ -450,12 +501,13 @@ export default function Files() {{ label: tr('files.menu.up'), hint: '❖↑', onClick: goUp, disabled: !curDir || curDir === fs.home() }, '-',{ label: tr('files.place.recent'), onClick: () => navigate({ type: 'recent' }) },{ label: tr('files.place.home'), onClick: () => navigate(homeLoc()) },+ { label: computerName(), onClick: () => navigate(computerLoc()) },...dirs.map((d) => ({ label: tr(`files.place.${d.label}`), onClick: () => navigate({ type: 'dir', path: d.path }) })),{ label: tr('files.place.apps'), onClick: () => navigate({ type: 'apps' }) },{ label: tr('files.place.trash'), onClick: () => navigate({ type: 'trash' }) },] },]);- }, [tab.view, tab.back.length, tab.fwd.length, tab.loc, hidden, sel.length, clip, curDir, active, tabs.length]);+ }, [tab.view, tab.back.length, tab.fwd.length, tab.loc, hidden, sel.length, clip, curDir, readOnly, active, tabs.length]);// ---- view ----const cut = new Set(clip?.mode === 'cut' ? clip.paths : []);@@ -526,9 +578,17 @@ export default function Files() {<SideTitle t={t}>{tr('files.locations')}</SideTitle><SideItem t={t} label={tr('files.place.home')} icon={<Glyph ch="⌂" t={t} />} selected={sideSel(homeLoc())} onClick={() => navigate(homeLoc())}drop={{ dropPath: fs.home() }} hot={dropTarget === fs.home()} />- {volumes.map((v) => (- <SideItem key={v.path} t={t} label={v.name} icon={<DriveGlyph color={t.accent} />} selected={sideSel(dirLoc(v.path))} onClick={() => navigate(dirLoc(v.path))}- drop={{ dropPath: v.path }} hot={dropTarget === v.path} />+ <SideItem t={t} label={computerName()} icon={<DriveGlyph color={t.accent} />} selected={sideSel(computerLoc())} onClick={() => navigate(computerLoc())} />+ {volumes.map((v) => {+ const rel = volumeRelease(diskList, v.path);+ return (+ <SideItem key={v.path} t={t} label={v.name} icon={<DriveGlyph color={t.accent} />} selected={sideSel(dirLoc(v.path))} onClick={() => navigate(dirLoc(v.path))}+ drop={{ dropPath: v.path }} hot={dropTarget === v.path} trail={rel ? { glyph: '⏏', onClick: () => release(rel, v.path) } : null} />+ );+ })}+ {unmountedDisks(diskList).map((p) => (+ <SideItem key={p.name} t={t} dim label={p.label || tr('files.disk.unnamed', { size: formatBytes(p.size) })} icon={<DriveGlyph color={t.textDim} />}+ onClick={() => mount(p)} />))}<SideItem t={t} label={tr('files.place.trash')} icon={<TrashGlyph color={t.accent} />} selected={sideSel({ type: 'trash' })} onClick={() => navigate({ type: 'trash' })}drop={{ dropTrash: true }} hot={dropTarget === 'trash:'} />diff --git a/assets/locales/en/files.json b/assets/locales/en/files.jsonindex 2e7a5c5..ce672d4 100644--- a/assets/locales/en/files.json+++ b/assets/locales/en/files.json@@ -13,6 +13,8 @@"other": "Delete {count} items permanently?"},"confirm.empty": "Empty the Trash?",+ "disk.mounting": "Mounting {name}…",+ "disk.unnamed": "{size} volume","empty": "Empty folder","favorites": "Favorites","group.date.month": "Previous 30 Days",@@ -116,6 +118,7 @@"noSelection": "Select items to tag them","noResults": "No results.","place.apps": "Applications",+ "place.computer": "This Computer","place.desktop": "Desktop","place.documents": "Documents","place.downloads": "Downloads",diff --git a/assets/locales/es/files.json b/assets/locales/es/files.jsonindex bbdd1ec..80ad366 100644--- a/assets/locales/es/files.json+++ b/assets/locales/es/files.json@@ -13,6 +13,8 @@"other": "¿Borrar {count} elementos para siempre?"},"confirm.empty": "¿Vaciar la Papelera?",+ "disk.mounting": "Montando {name}…",+ "disk.unnamed": "Volumen de {size}","empty": "Carpeta vacía","favorites": "Favoritos","group.date.month": "Últimos 30 días",@@ -116,6 +118,7 @@"noSelection": "Seleccioná ítems para etiquetarlos","noResults": "No se encontró nada.","place.apps": "Aplicaciones",+ "place.computer": "Este equipo","place.desktop": "Escritorio","place.documents": "Documentos","place.downloads": "Descargas",diff --git a/assets/locales/pt/files.json b/assets/locales/pt/files.jsonindex bc32731..0049104 100644--- a/assets/locales/pt/files.json+++ b/assets/locales/pt/files.json@@ -13,6 +13,8 @@"other": "Apagar {count} itens para sempre?"},"confirm.empty": "Esvaziar o Lixo?",+ "disk.mounting": "Montando {name}…",+ "disk.unnamed": "Volume de {size}","empty": "Pasta vazia","favorites": "Favoritos","group.date.month": "Últimos 30 dias",@@ -116,6 +118,7 @@"noSelection": "Selecione itens para etiquetá-los","noResults": "Nada encontrado.","place.apps": "Aplicativos",+ "place.computer": "Este computador","place.desktop": "Área de Trabalho","place.documents": "Documentos","place.downloads": "Transferências",diff --git a/docs/FILES.md b/docs/FILES.mdindex 8c77f04..ae55965 100644--- a/docs/FILES.md+++ b/docs/FILES.md@@ -1,6 +1,7 @@# Files-`apps/files`. A browser for the home folder and the user's mounted disks, with the useful parts+`apps/files`. A browser for the home folder and the user's mounted disks (and, read-only, the rest+of the computer), with the useful partsof a classic desktop file manager: tabs, four views, Trash, Quick Preview, Get Info, copy/cut/paste, drag anddrop, color tags and search. Disk operations belong to the server (`server/src/fsops.c`,`lord.fs` in `js_sys.c`); the app only requests them.@@ -40,8 +41,12 @@ drop, color tags and search. Disk operations belong to the server (`server/src/f{ path } })`). A file can be dropped onto a folder's tab.- **Sidebar:**- Favorites: Recents, Applications and the user's folders (xdg-user-dirs);- - Locations: Home, the disks and USB sticks mounted in `/media/$USER` or- `/run/media/$USER` (checked every 4 s) and the Trash;+ - Locations: Home, **This Computer** (0.8.5: `/`, read-only, named after the machine; folders+ the user can't open show a lock), the disks and USB sticks mounted in `/media/$USER` or+ `/run/media/$USER` (checked every 4 s; ⏏ on hover ejects a removable disk with `disk-eject` and+ unmounts another disk's partition with `disk-unmount`), every other disk with a file system that isn't mounted+ (dimmed; a click mounts it with `disk-mount` and opens it; an internal one asks for an+ administrator, as in Disks; the disk the system runs from is left out) and the Trash;- Color tags (they filter).Folders and the Trash accept dragged files.@@ -129,8 +134,17 @@ drop, color tags and search. Disk operations belong to the server (`server/src/f| `volumes()` | `[{ path, name, fs, total, free }]` from `/proc/mounts`, only `/media/$USER/…` and `/run/media/$USER/…` |**Security:**-- Everything goes through `resolve_target` / `resolve_in_home` (`js_sys.c`) and `fsops_allowed`:- only the home folder and the user's mounts.+- Changing things goes through `resolve_target` (`js_sys.c`) and `fsops_allowed`: only the home+ folder and the user's mounts.+- Reading (`list`, `read`, `stat`, `du`, `free`, `search`; 0.8.5, This Computer) goes through+ `resolve_readable` and `fsops_readable`: the whole tree as the session user, so the system's own+ permissions decide what can be opened, except `/proc`, `/sys`, `/dev` and `/run` (this process's+ memory, environment and open files, devices, and the session's sockets; `/run/media/$USER` stays).+ Paths are resolved with `realpath` first, so a link into those is refused too. `stat` outside the+ writable roots answers `writable: false`, and Files then leaves out the actions that change the+ folder (new folder, paste, rename, duplicate, Trash, cut, compress, extract). There is no root+ mode. Isolated `.lpk` apps don't get this: their broker only reaches their own data folder.+ «Open with» and the helpers keep the home folder and the user's mounts.- Writing, copying to, moving and sending to the Trash reject the protected folders(`~/.local/share/applications`, `~/.config/autostart`, `~/.local/share/lordos/apps` and`~/.config/lordos/settings.json`). Copying *from* them is allowed.@@ -150,8 +164,9 @@ file:## Tests-- `make -C server build/fsops-test && build/fsops-test` on a temporary home folder: 36/36. It covers:- - roots and protected folders;+- `make -C server build/fsops-test && build/fsops-test` on a temporary home folder: 49/49. It covers:+ - roots, the read-only tree (`fsops_readable`: `/`, `/etc`, the user's mounts; not `/proc`,+ `/sys`, `/dev`, `/run`, another user's mounts or a relative path) and protected folders;- recursive copy with a link and permissions, and that it neither overwrites nor copies into itself;- move;- Trash: repeated names, restore without overwriting, delete only inside, and empty;diff --git a/docs/ROADMAP.md b/docs/ROADMAP.mdindex 224deeb..7bada25 100644--- a/docs/ROADMAP.md+++ b/docs/ROADMAP.md@@ -605,6 +605,11 @@ Details in `MAIL.md`. Tested on VM 123 against local Dovecot, Postfix and Radicaspace; a click mounts it through the existing `disk-mount` action (internal disks ask for anadministrator, removable ones don't), plus unmount and eject. **No "as root" mode** (decided: itwould be generic root file access from the interface); "Open in Terminal here" for `sudo` work.+ *Implemented (not yet checked on screen):* the place, read-only `lord.fs` outside the writable+ roots (`fsops_readable`, without `/proc`, `/sys`, `/dev`, `/run`), the lock, unmounted disks that+ mount on a click, ⏏ to eject or unmount. *Left:* "Open in Terminal here" would need a folder+ argument for `lord.term.create()`, one of the approved launcher exceptions, so it waits for a+ decision; size and free space per disk in the sidebar.- [ ] **Files: network shares (own release after 0.8.5, approved 2026-10-25)** — SMB and NFS sharesfound with mDNS or typed ("Connect to server…", `smb://host/share`), mounted by the kernel throughone new closed admin action, `share-mount` (host, share and user validated; the password ondiff --git a/server/src/fsops.c b/server/src/fsops.cindex 7798bd0..cb3e340 100644--- a/server/src/fsops.c+++ b/server/src/fsops.c@@ -60,6 +60,18 @@ static int under(const char *p, const char *root) {int fsops_allowed(const char *real) { return under(real, home) || under(real, media1) || under(real, media2); }+/* Reading only (0.8.5, Files → This computer): the whole tree as the session user, so the system's+ * own permissions decide, except the kernel's and the runtime's pseudo-filesystems: /proc (this+ * process's memory, environment and open files), /sys, /dev and /run (the session's sockets and+ * runtime files; /run/media/$USER stays a root). Writing keeps fsops_allowed. */+int fsops_readable(const char *real) {+ if (fsops_allowed(real)) return 1;+ if (real[0] != '/') return 0;+ static const char *const pseudo[] = { "/proc", "/sys", "/dev", "/run", NULL };+ for (int i = 0; pseudo[i]; i++) if (under(real, pseudo[i])) return 0;+ return 1;+}+int fsops_protected(const char *real) {static const char *const protect[] = { "/.local/share/applications", "/.config/autostart","/.local/share/lordos/apps", "/.config/lordos/settings.json",diff --git a/server/src/fsops.h b/server/src/fsops.hindex 4edce90..6209fbb 100644--- a/server/src/fsops.h+++ b/server/src/fsops.h@@ -10,6 +10,7 @@/* Allowed roots: the home folder and the user's mounts (/media/$USER, /run/media/$USER). */void fsops_init(const char *home, const char *user);int fsops_allowed(const char *real); /* already resolved path (realpath) inside a root */+int fsops_readable(const char *real); /* (0.8.5) read-only: the whole tree but /proc, /sys, /dev, /run */int fsops_protected(const char *real); /* folders JS does not write to (launcher, apps, settings) *//* ---- copy / move in a thread ---- */diff --git a/server/src/ui/js_sys.c b/server/src/ui/js_sys.cindex 51e8bf2..b932410 100644--- a/server/src/ui/js_sys.c+++ b/server/src/ui/js_sys.c@@ -2,8 +2,9 @@* lord.themes, lord.quit and lord.measureText.** Security rules: the server already runs as the session user (not root);- * lord.fs works only inside the home folder and the user's mounted disks- * (/media/$USER, /run/media/$USER; fsops_allowed): it lists and reads (up to 8 MB), writes (up to+ * lord.fs reads the whole tree as the user except /proc, /sys, /dev and /run (fsops_readable;+ * listing, reading up to 8 MB, stat, du, free, search), and changes things only inside the home+ * folder and the user's mounted disks (/media/$USER, /run/media/$USER; fsops_allowed): it writes (up to* 32 MB), creates folders, renames, copies and moves (in a thread, fsops.c), and sends to the freedesktop* Trash; real deletion is only possible inside the Trash. Writing is atomic (temporary + rename),* doesn't follow symbolic links in the final file and can NOT touch ~/.local/share/applications,@@ -81,6 +82,16 @@ static int resolve_in_home(const char *path, char *out) {return fsops_allowed(out) ? 0 : -1;}+/* The same for reading only (list, read, stat, du, free, search): the whole tree as the session+ * user except the pseudo-filesystems (fsops_readable; Files → This computer, 0.8.5). */+static int resolve_readable(const char *path, char *out) {+ char full[PATH_MAX * 2];+ if (path[0] == '/') snprintf(full, sizeof full, "%s", path);+ else snprintf(full, sizeof full, "%s/%s", home, path);+ if (!realpath(full, out)) return -1;+ return fsops_readable(out) ? 0 : -1;+}+static char *read_small(const char *path, size_t max, size_t *len) {FILE *f = fopen(path, "rb");if (!f) return NULL;@@ -121,7 +132,7 @@ static JSValue f_fs_list(JSContext *c, JSValueConst this_val, int argc, JSValueCconst char *p = JS_ToCString(c, argv[0]);if (!p) return JS_EXCEPTION;char dir[PATH_MAX];- int bad = resolve_in_home(p, dir);+ int bad = resolve_readable(p, dir);JS_FreeCString(c, p);if (bad) return js_throw_code(c, "fs.outsideHome", NULL);DIR *d = opendir(dir);@@ -141,6 +152,8 @@ static JSValue f_fs_list(JSContext *c, JSValueConst this_val, int argc, JSValueCJS_SetPropertyStr(c, o, "name", JS_NewString(c, e->d_name));JS_SetPropertyStr(c, o, "link", JS_NewBool(c, link));JS_SetPropertyStr(c, o, "dir", JS_NewBool(c, S_ISDIR(st.st_mode)));+ /* a folder this user can't open (shown with a lock in This computer) */+ if (S_ISDIR(st.st_mode) && access(fp, R_OK | X_OK)) JS_SetPropertyStr(c, o, "locked", JS_TRUE);JS_SetPropertyStr(c, o, "size", JS_NewFloat64(c, (double)st.st_size));JS_SetPropertyStr(c, o, "mtime", JS_NewFloat64(c, (double)st.st_mtime * 1000));JS_SetPropertyUint32(c, arr, i++, o);@@ -149,8 +162,8 @@ static JSValue f_fs_list(JSContext *c, JSValueConst this_val, int argc, JSValueCreturn arr;}-/* lord.fs.read(path, 'text' | 'binary') — content of a regular file in $HOME- * (UTF-8 text or ArrayBuffer). Used, for example, by the Terminal's profile importer. */+/* lord.fs.read(path, 'text' | 'binary') — content of a regular file in $HOME, the user's disks or+ * (read-only) the rest of the tree (resolve_readable) (UTF-8 text or ArrayBuffer). Used, for example, by the Terminal's profile importer. */static JSValue f_fs_read(JSContext *c, JSValueConst this_val, int argc, JSValueConst *argv) {(void)this_val;const char *p = JS_ToCString(c, argv[0]);@@ -159,7 +172,7 @@ static JSValue f_fs_read(JSContext *c, JSValueConst this_val, int argc, JSValueCint binary = mode && !strcmp(mode, "binary");if (mode) JS_FreeCString(c, mode);char path[PATH_MAX];- int bad = resolve_in_home(p, path);+ int bad = resolve_readable(p, path);JS_FreeCString(c, p);if (bad) return js_throw_code(c, "fs.outsideHome", NULL);struct stat st;@@ -1134,6 +1147,23 @@ static JSValue f_fs_stat(JSContext *c, JSValueConst this_val, int argc, JSValueCif (!p) return JS_EXCEPTION;char target[PATH_MAX + 300];int r = resolve_target(p, target, sizeof target, NULL, 0);+ if (r == -1) {+ /* outside the writable roots: the same answer, read-only, where reading is allowed+ * (its folder resolved, the last name kept, so a link is described, not followed) */+ char full[PATH_MAX * 2], rdir[PATH_MAX];+ if (p[0] == '/') snprintf(full, sizeof full, "%s", p); else snprintf(full, sizeof full, "%s/%s", home, p);+ size_t len = strlen(full);+ while (len > 1 && full[len - 1] == '/') full[--len] = 0;+ char *slash = strrchr(full, '/');+ const char *base = slash ? slash + 1 : "";+ if (slash && !strcmp(full, "/")) { if (fsops_readable("/")) { snprintf(target, sizeof target, "/"); r = 1; } }+ else if (slash && base[0] && strcmp(base, ".") && strcmp(base, "..")) {+ *slash = 0;+ if (realpath(full[0] ? full : "/", rdir) && fsops_readable(rdir) &&+ (size_t)snprintf(target, sizeof target, "%s%s%s", rdir, strcmp(rdir, "/") ? "/" : "", base) < sizeof target &&+ fsops_readable(target)) r = 1;+ }+ }JS_FreeCString(c, p);if (r == -1) return fs_path_error(c, r);struct statx sx;@@ -1179,7 +1209,7 @@ static JSValue f_fs_du(JSContext *c, JSValueConst this_val, int argc, JSValueConif (argc > 1 && JS_IsNumber(argv[1])) JS_ToFloat64(c, &ms, argv[1]);if (ms > 3000) ms = 3000;char path[PATH_MAX];- int bad = resolve_in_home(p, path);+ int bad = resolve_readable(p, path);JS_FreeCString(c, p);if (bad) return fs_path_error(c, -1);FsDu d;@@ -1198,7 +1228,7 @@ static JSValue f_fs_free(JSContext *c, JSValueConst this_val, int argc, JSValueCconst char *p = JS_ToCString(c, argv[0]);if (!p) return JS_EXCEPTION;char path[PATH_MAX];- int bad = resolve_in_home(p, path);+ int bad = resolve_readable(p, path);JS_FreeCString(c, p);if (bad) return fs_path_error(c, -1);struct statvfs vs;@@ -1236,7 +1266,7 @@ static JSValue f_fs_search(JSContext *c, JSValueConst this_val, int argc, JSValu(void)this_val;const char *p = JS_ToCString(c, argv[0]), *q = argc > 1 ? JS_ToCString(c, argv[1]) : NULL;char path[PATH_MAX];- int bad = !p || !q || resolve_in_home(p, path);+ int bad = !p || !q || resolve_readable(p, path);Acc a = { c, JS_NewArray(c), 0 };if (!bad) fs_search(path, q, opt_int(c, argc > 2 ? argv[2] : JS_UNDEFINED, "limit", 200, 1000),opt_int(c, argc > 2 ? argv[2] : JS_UNDEFINED, "depth", 8, 16), hit_cb, &a);diff --git a/server/tests/fsops_test.c b/server/tests/fsops_test.cindex 7d18006..0a22eec 100644--- a/server/tests/fsops_test.c+++ b/server/tests/fsops_test.c@@ -63,6 +63,20 @@ int main(void) {CHECK(fsops_allowed(H));CHECK(!fsops_allowed("/etc/passwd"));CHECK(!fsops_allowed("/tmp"));+ /* reading only: the whole tree but the pseudo-filesystems (Files → This computer) */+ CHECK(fsops_readable("/"));+ CHECK(fsops_readable("/etc/passwd"));+ CHECK(fsops_readable("/usr/share"));+ CHECK(fsops_readable(H));+ CHECK(fsops_readable("/run/media/nadie/USB"));+ CHECK(fsops_readable("/procs"));+ CHECK(!fsops_readable("/proc"));+ CHECK(!fsops_readable("/proc/self/mem"));+ CHECK(!fsops_readable("/sys/class"));+ CHECK(!fsops_readable("/dev/sda"));+ CHECK(!fsops_readable("/run/user/1000/bus"));+ CHECK(!fsops_readable("/run/media/otro/USB"));+ CHECK(!fsops_readable("relative/path"));path(a, ".local/share/applications/x.desktop");CHECK(fsops_protected(a));path(a, "Documentos/x.txt");