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: /proc, /sys, /dev and /run show a lock in This computer and opening one says Files doesn't show the system's internal folders (fs.systemFolder), not that it is outside the home folder
Federico Pereira462b5de4e5be
diff --git a/assets/locales/en/errors.json b/assets/locales/en/errors.jsonindex ff38e30..4384951 100644--- a/assets/locales/en/errors.json+++ b/assets/locales/en/errors.json@@ -144,6 +144,7 @@"fs.notRegular": "It is not a regular file (is it a link?)","fs.openFailed": "Could not open the file: {errno}","fs.outsideHome": "That location is outside your home folder or is not valid",+ "fs.systemFolder": "Files doesn't show the system's internal folders (/proc, /sys, /dev and /run)","fs.protected": "That folder is protected","fs.tooLarge": "The file is too large (max. {max})","fs.tooManyCopies": "Too many copies in progress; try again when one finishes",diff --git a/assets/locales/es/errors.json b/assets/locales/es/errors.jsonindex 081ee85..dcc53c5 100644--- a/assets/locales/es/errors.json+++ b/assets/locales/es/errors.json@@ -144,6 +144,7 @@"fs.notRegular": "No es un archivo común (¿es un enlace?)","fs.openFailed": "No se pudo abrir el archivo: {errno}","fs.outsideHome": "Ese lugar está fuera de tu carpeta personal o no es válido",+ "fs.systemFolder": "Archivos no muestra las carpetas internas del sistema (/proc, /sys, /dev y /run)","fs.protected": "Esa carpeta está protegida","fs.tooLarge": "El archivo es demasiado grande (máx. {max})","fs.tooManyCopies": "Hay demasiadas copias en curso; probá de nuevo cuando termine una",diff --git a/assets/locales/pt/errors.json b/assets/locales/pt/errors.jsonindex dfe26a2..ffba506 100644--- a/assets/locales/pt/errors.json+++ b/assets/locales/pt/errors.json@@ -144,6 +144,7 @@"fs.notRegular": "Não é um arquivo comum (é um link?)","fs.openFailed": "Não foi possível abrir o arquivo: {errno}","fs.outsideHome": "Esse local está fora da sua pasta pessoal ou não é válido",+ "fs.systemFolder": "O Arquivos não mostra as pastas internas do sistema (/proc, /sys, /dev e /run)","fs.protected": "Essa pasta é protegida","fs.tooLarge": "O arquivo é grande demais (máx. {max})","fs.tooManyCopies": "Há cópias demais em andamento; tente de novo quando uma terminar",diff --git a/docs/FILES.md b/docs/FILES.mdindex ae55965..913c389 100644--- a/docs/FILES.md+++ b/docs/FILES.md@@ -42,7 +42,8 @@ drop, color tags and search. Disk operations belong to the server (`server/src/f- **Sidebar:**- Favorites: Recents, Applications and the user's folders (xdg-user-dirs);- 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+ the user can't open, and `/proc`, `/sys`, `/dev` and `/run`, show a lock; opening one says+ "Permission denied", or that Files doesn't show the system's internal folders), 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` andunmounts 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@@ -140,7 +141,8 @@ drop, color tags and search. Disk operations belong to the server (`server/src/f`resolve_readable` and `fsops_readable`: the whole tree as the session user, so the system's ownpermissions decide what can be opened, except `/proc`, `/sys`, `/dev` and `/run` (this process'smemory, 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+ Paths are resolved with `realpath` first, so a link into those is refused too; `list` refuses+ them with `fs.systemFolder` (not `fs.outsideHome`). `stat` outside thewritable roots answers `writable: false`, and Files then leaves out the actions that change thefolder (new folder, paste, rename, duplicate, Trash, cut, compress, extract). There is no rootmode. Isolated `.lpk` apps don't get this: their broker only reaches their own data folder.diff --git a/server/src/ui/js_sys.c b/server/src/ui/js_sys.cindex b932410..9329a81 100644--- a/server/src/ui/js_sys.c+++ b/server/src/ui/js_sys.c@@ -89,7 +89,15 @@ static int resolve_readable(const char *path, char *out) {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;+ return fsops_readable(out) ? 0 : -2; /* -2: exists, but one of the folders not read */+}++/* A folder Files shows with a lock: the system's permissions don't let this user open it, or it is+ * one of the pseudo-filesystems lord.fs doesn't read (fsops_readable). */+static int dir_locked(const char *path) {+ char real[PATH_MAX];+ if (!realpath(path, real) || !fsops_readable(real)) return 1;+ return access(real, R_OK | X_OK) != 0;}static char *read_small(const char *path, size_t max, size_t *len) {@@ -134,7 +142,11 @@ static JSValue f_fs_list(JSContext *c, JSValueConst this_val, int argc, JSValueCchar dir[PATH_MAX];int bad = resolve_readable(p, dir);JS_FreeCString(c, p);- if (bad) return js_throw_code(c, "fs.outsideHome", NULL);+ if (bad) {+ /* an existing folder that is not read on purpose (/proc, /sys, /dev, /run) says so */+ if (bad == -2) return js_throw_code(c, "fs.systemFolder", NULL);+ return js_throw_code(c, "fs.outsideHome", NULL);+ }DIR *d = opendir(dir);if (!d) return js_throw_code(c, "sys.errno", "errno", lerr_errno(errno), NULL);JSValue arr = JS_NewArray(c);@@ -153,7 +165,7 @@ static JSValue f_fs_list(JSContext *c, JSValueConst this_val, int argc, JSValueCJS_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);+ if (S_ISDIR(st.st_mode) && dir_locked(fp)) 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);