@ai-ecoverse/slicc-kernel 1.196.28 → 1.196.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1399,12 +1399,12 @@ With `users: 'enforce'` the kernel checks every file call that reaches it agains
1399
1399
  `sudo` is a command of the kernel itself, in `/usr/bin` (a package's `sudo` never wins over it): `sudo [-kn] [-u user] [--] command [args…]` runs `command` as `user` (root by default), and `sudo -l` lists what the caller may run (`visudo -c` checks the policy, below). `-n` never asks: a command that needs approval fails with `sudo: a password is required`, unless a [timestamp](#sudo-timestamps) lets it run. `sudo -v`, `sudo -k` and `sudo -K` start, end and remove timestamps, as in sudo(8) (below). Any other combination, a command after `-v`, `-l` or `-K`, or no command and no mode, prints the usage. The decision, the credentials and the environment are all made in the kernel; the command only passes its arguments and its own environment on (`ctx.sudo`, see [JS programs](#js-programs)), so no program can grant itself more by calling the kernel some other way.
1400
1400
 
1401
1401
  - **`sudo` elevates only under `users: 'enforce'`.** With `'off'` and `'report'`, `sudo command` just runs `command`, as the caller, with its environment. Under `'report'` nothing is refused, so anyone could rewrite the policy or a command; `sudo` grants nothing until the kernel enforces.
1402
- - **The policy** is `/etc/sudoers` and the files in `/etc/sudoers.d/` (in name order, skipping names that start with `.` or end in `~`), which the kernel writes at start when they're missing, with owners on: `/etc/sudoers` root's `0440` with the one line `%sudo Cmnd *`, and `/etc/sudoers.d` root's `0750`. There is no API: an admin (bios, as root) edits `/etc/sudoers.d/<user>`. A line is `[NOPASSWD] <user|%group|ALL> [(<target>)] [Cwd <dir>] [Stdin none] [ChainSha256 <sha256>] [RouteSha256 <sha256>] [Sha256 none|<file>=<sha256>…] Cmnd <argv…|*>`: who (a user name, a group, or anyone), the user it may run as (`root` by default, or `ALL`), the directory it may run in, whether it needs a standard input that carries nothing the approver didn't see, the contents of the command's user-writable files, and the command, or `*` for any command. The command is shell-quoted words whose first is an absolute path, matched exactly against the resolved path (a `*` in it is a literal `*`). The arguments follow sudoers(5): **none written** (`Cmnd /usr/bin/mcpcat`) allows the program with any arguments, none included; **`""` as the only argument** (`Cmnd /usr/bin/mcpcat ""`) allows it with no arguments (`''` is one empty argument); **otherwise** each word matches one argument, exactly, except that an unquoted `*` is a wildcard. A word that is `*` alone matches any number of arguments, none included (`Cmnd /usr/bin/mcpcat list *`), and a `*` inside a word matches any text within that one argument (`--log=*.txt`). A quoted or escaped `*` (`\*`, `'*'`, `"*"`) is a literal `*`, and `*` is the only wildcard: `?` and `[` are literal. **Unlike sudo**, which matches the arguments joined by spaces as one string, so that `/bin/cat /var/log/*` also allows `cat /var/log/x /etc/shadow`, a `*` here never reaches past the argument it is in: that line allows one argument under `/var/log/`, while `/bin/cat *` allows any arguments. `sudo -l` shows the command as it reads, `*` unquoted and a literal `*` as `\*`. **Upgrading:** before this, a command with no arguments allowed only a bare call and `*` was literal, so a hand-written line without arguments now allows any arguments, and an unquoted `*` now matches. Narrow such a line with `""` or the exact arguments if a bare call is what it meant. A hand-written `""` used to be one empty argument and is now no arguments; write `''` for the empty argument. A line in the exact format an `'always'` answer wrote for a bare call in a kernel from before, `NOPASSWD <user> (<target>) [Cwd <dir>] Cmnd <path>` in `/etc/sudoers.d/<user>`, character for character (trailing whitespace on the line ignored), is always read as if it ended in `""`, so it keeps allowing only that bare call, and `sudo -l` shows it with the `""`. That holds for a line an older kernel appends later, on the same root, too. A hand-written line that is character for character in that format is read the same way, so add arguments or `*`, or drop the `(<target>)`, to make it wider. Recorded lines with arguments still match the same arguments, since the kernel quoted each `*` it wrote. `Cwd` takes one shell-quoted absolute path, and the line then matches only when the caller's directory, resolved to its real path (the one the request shows and the command runs in), is that path, so write it without symlinks: one that has a symlink in it never matches. A line without `Cwd` matches in any directory. `sudo -l` shows the clause as `CWD=<dir>`. `Stdin none` makes the line match only when the caller's standard input is a terminal, `/dev/null` or closed, so a rule for `tee /etc/hosts` typed at a terminal never covers `echo … | sudo tee /etc/hosts` or `< file`. A terminal is any terminal, which a program can also drive through a pseudo-terminal of its own (`/dev/ptmx`, as `script` and `expect` do), so `Stdin none` keeps piped, redirected and file input out, not every input a person didn't type; `none` is the only value, and any other makes the line not parse. A line without `Stdin` matches whatever the input, as before. `sudo -l` shows it as `STDIN=none`, after `CWD=`. `Sha256 <file>=<sha256>`, one clause per file, pins the command to its contents: the line matches only when the [user-writable files](#sudo) that would run for the command are exactly the files it names, by real path (each a shell-quoted `<file>=<sha256>` word with an absolute path and 64 hex digits), and each still has that sha256. An `'always'` answer writes one for each user-writable input, or `Sha256 none` for an empty set, so a provider that becomes relevant later cannot inherit an approval for an empty set. Older kernels omitted `Sha256` when they recorded an `'always'` approval with no user-writable files. In `/etc/sudoers.d/<user>`, a line in the exact format an older kernel wrote for that user now counts as `Sha256 none`: it still matches while all inputs are root-held, but a newly user-writable input needs fresh approval. This is checked when the line is read, without rewriting the file. Other rules without `Sha256` still match whatever the files hold. For an admin rule with exactly the same text but no digest check, put it in another policy file. `ChainSha256` pins the catalog entry or interpreter choice and requires a `Sha256` clause. A new `'always'` rule records the chain digest when a file is user-writable or a catalog environment value depends on a package path whose existence is not known to be root-controlled. This includes a missing file under a writable directory and a route through a symlink. With no files to hash it still records `Sha256 none`. If the environment paths are root-controlled too, it omits the chain digest so a root-held package can be upgraded without another approval. An empty binding without a chain digest stops matching if an environment path becomes writable. Existing explicit chain pins remain effective. A hand-written rule with file digests alone does not pin the resolved environment: for example, a relative catalog value `opt/input` becomes an absolute package path if that file appears, even when the manifest bytes are unchanged. Include the approval’s `ChainSha256` to pin that choice as well. `sudo -l` shows the clauses as `CHAIN_SHA256=`, `SHA256=none` or `SHA256=<file>:<sha256>`. When any hashed path goes through a link to another name, an `'always'` rule also records `RouteSha256`: the sha256 of the UTF-8 JSON array of `[requested path, real path]` pairs for all hashed paths, sorted by requested path. A hash-bound rule must match this field too. A rule from an older kernel with `Sha256` but no route digest cannot authorize a hashed route that needs one; approve again to record the routes. Root-only files reached through root-held links need neither a file hash nor a route digest. A line in the bare-call format below with `Stdin none ` before `Cmnd` is read as ending in `""` too. `#` lines and blank lines are ignored. Groups are the caller's process groups, as `id` shows them.
1402
+ - **The policy** is `/etc/sudoers` and the files in `/etc/sudoers.d/` (in name order, skipping names that start with `.` or end in `~`), which the kernel writes at start when they're missing, with owners on: `/etc/sudoers` root's `0440` with the one line `%sudo Cmnd *`, and `/etc/sudoers.d` root's `0750`. There is no API: an admin (bios, as root) edits `/etc/sudoers.d/<user>`. A line is `[NOPASSWD] <user|%group|ALL> [(<target>)] [Cwd <dir>] [Stdin none] [ChainSha256 <sha256>] [RouteSha256 <sha256>] [Sha256 none|<file>=<sha256>…] Cmnd <argv…|*>`: who (a user name, a group, or anyone), the user it may run as (`root` by default, or `ALL`), the directory it may run in, whether it needs a standard input that carries nothing the approver didn't see, the contents of the command's user-writable files, and the command, or `*` for any command. The command is shell-quoted words whose first is an absolute path, matched exactly against the resolved path (a `*` in it is a literal `*`). The arguments follow sudoers(5): **none written** (`Cmnd /usr/bin/mcpcat`) allows the program with any arguments, none included; **`""` as the only argument** (`Cmnd /usr/bin/mcpcat ""`) allows it with no arguments (`''` is one empty argument); **otherwise** each word matches one argument, exactly, except that an unquoted `*` is a wildcard. A word that is `*` alone matches any number of arguments, none included (`Cmnd /usr/bin/mcpcat list *`), and a `*` inside a word matches any text within that one argument (`--log=*.txt`). A quoted or escaped `*` (`\*`, `'*'`, `"*"`) is a literal `*`, and `*` is the only wildcard: `?` and `[` are literal. **Unlike sudo**, which matches the arguments joined by spaces as one string, so that `/bin/cat /var/log/*` also allows `cat /var/log/x /etc/shadow`, a `*` here never reaches past the argument it is in: that line allows one argument under `/var/log/`, while `/bin/cat *` allows any arguments. `sudo -l` shows the command as it reads, `*` unquoted and a literal `*` as `\*`. **Upgrading:** before this, a command with no arguments allowed only a bare call and `*` was literal, so a hand-written line without arguments now allows any arguments, and an unquoted `*` now matches. Narrow such a line with `""` or the exact arguments if a bare call is what it meant. A hand-written `""` used to be one empty argument and is now no arguments; write `''` for the empty argument. A line in the exact format an `'always'` answer wrote for a bare call in a kernel from before, `NOPASSWD <user> (<target>) [Cwd <dir>] Cmnd <path>` in `/etc/sudoers.d/<user>`, character for character (trailing whitespace on the line ignored), is always read as if it ended in `""`, so it keeps allowing only that bare call, and `sudo -l` shows it with the `""`. That holds for a line an older kernel appends later, on the same root, too. A hand-written line that is character for character in that format is read the same way, so add arguments or `*`, or drop the `(<target>)`, to make it wider. Recorded lines with arguments still match the same arguments, since the kernel quoted each `*` it wrote. `Cwd` takes one shell-quoted absolute path, and the line then matches only when the caller's directory, resolved to its real path (the one the request shows and the command runs in), is that path, so write it without symlinks: one that has a symlink in it never matches. A line without `Cwd` matches in any directory. `sudo -l` shows the clause as `CWD=<dir>`. `Stdin none` makes the line match only when the caller's standard input is a terminal, `/dev/null` or closed, so a rule for `tee /etc/hosts` typed at a terminal never covers `echo … | sudo tee /etc/hosts` or `< file`. A terminal is any terminal, which a program can also drive through a pseudo-terminal of its own (`/dev/ptmx`, as `script` and `expect` do), so `Stdin none` keeps piped, redirected and file input out, not every input a person didn't type; `none` is the only value, and any other makes the line not parse. A line without `Stdin` matches whatever the input, as before. `sudo -l` shows it as `STDIN=none`, after `CWD=`. `Sha256 <file>=<sha256>`, one clause per file, pins the command to its contents: the line matches only when the [user-writable files](#sudo) that would run for the command are exactly the files it names, by real path (each a shell-quoted `<file>=<sha256>` word with an absolute path and 64 hex digits), and each still has that sha256. An `'always'` answer writes one for each user-writable input, or `Sha256 none` for an empty set, so a provider that becomes relevant later cannot inherit an approval for an empty set. Older kernels omitted `Sha256` when they recorded an `'always'` approval with no user-writable files. In `/etc/sudoers.d/<user>`, a line in the exact format an older kernel wrote for that user now counts as `Sha256 none`: it still matches while all inputs are root-held, but a newly user-writable input needs fresh approval. This is checked when the line is read, without rewriting the file. Other rules without `Sha256` still match whatever the files hold. For an admin rule with exactly the same text but no digest check, put it in another policy file. `ChainSha256` pins the catalog entry or interpreter choice and requires a `Sha256` clause. A new `'always'` rule records the chain digest when a file is user-writable or a catalog environment value depends on a package path whose existence is not known to be root-controlled. This includes a missing file under a writable directory. Root-owned symlinks are allowed if the directories on both sides are root-held; an absent path is root-controlled only when every existing component traversed is root-held. An untrusted link, an invalid walk, or an unexpected lookup failure keeps the chain pinned. With no files to hash it still records `Sha256 none`. If the environment paths are root-controlled too, it omits the chain digest so a root-held package can be upgraded without another approval. An empty binding without a chain digest stops matching if an environment path becomes writable. Existing explicit chain pins remain effective. A hand-written rule with file digests alone does not pin the resolved environment: for example, a relative catalog value `opt/input` becomes an absolute package path if that file appears, even when the manifest bytes are unchanged. Include the approval’s `ChainSha256` to pin that choice as well. `sudo -l` shows the clauses as `CHAIN_SHA256=`, `SHA256=none` or `SHA256=<file>:<sha256>`. When any hashed path goes through a link to another name, an `'always'` rule also records `RouteSha256`: the sha256 of the UTF-8 JSON array of `[requested path, real path]` pairs for all hashed paths, sorted by requested path. A hash-bound rule must match this field too. A rule from an older kernel with `Sha256` but no route digest cannot authorize a hashed route that needs one; approve again to record the routes. Root-only files reached through root-held links need neither a file hash nor a route digest. A line in the bare-call format below with `Stdin none ` before `Cmnd` is read as ending in `""` too. `#` lines and blank lines are ignored. Groups are the caller's process groups, as `id` shows them.
1403
1403
  - **The sudoers(5) form:** a line can also be written the way sudoers(5) writes one, for the common subset: `<user|%group|ALL> ALL=[(<target>[,<target>…][:<group>…])] [NOPASSWD:|PASSWD:] <command…|ALL>`, with optional spaces around `=`. The host must be `ALL`. The run-as list is user names or `ALL`, root when it is left out, and a line with several (`cone ALL=(cone-32,cone-33) …`) is one rule per user, as if written once per user in the kernel form; a `:<group>` part is accepted and ignored: the kernel's `sudo` has no `-g`, and the rule runs with the target's own groups, so `(root:restricted)` can differ from sudo, which would run it with that group. `NOPASSWD:` is the kernel's `NOPASSWD`, `PASSWD:` (the default) asks `approve`, and the command `ALL` is the kernel's `*`. So `cone ALL=(cone-32,cone-33) /usr/local/bin/agent send cone --file /tmp/msg-*.md` reads as `cone (cone-32) Cmnd /usr/local/bin/agent send cone --file /tmp/msg-*.md` and the same for `cone-33`, and `%sudo ALL=(ALL:ALL) ALL` as `%sudo (ALL) Cmnd *`. **The command keeps the kernel's stricter meaning, not sudo's:** an unquoted `*` stays within the argument it is in (the line above allows `--file /tmp/msg-a.md` but not `--file /tmp/msg-a.md /etc/shadow.md`, which sudo's `*` would), `?` and `[` are literal, no arguments allows any, and `""` allows none. A `\` escapes the next character (`\,` for a comma in an argument), as in sudoers. Anything else of sudoers is refused rather than guessed at, so it grants nothing: another host, a `%group`, `#uid` or `!user` to run as, `(:group)` alone, a tag other than `NOPASSWD:`/`PASSWD:` (`NOEXEC:`, `SETENV:`, …), an option such as `CWD=` (use the kernel form's `Cwd`, which limits where the caller may run it rather than choosing where it runs), several commands separated by `,` or a `:` that starts another entry (write one line each), a negated `!command`, a digest (`sha256:<hex> <command>`; use the kernel form's `Sha256`), a wildcard or a directory as the command path, quotes (write a quoted argument in the kernel form), a `#` comment after the rule, a line continued with `\`, a user list, `Defaults` other than the [timestamp ones](#sudo-timestamps) and `env_keep` (**The environment**, below), `*_Alias`, a `#uid` as who, and `@include`/`#include` (`#includedir /etc/sudoers.d` is ignored, since the kernel reads that directory anyway). **Upgrading:** kernels before this skipped every line in this form (with only a `console.warn`), so such a line already in `/etc/sudoers.d` starts to count; `visudo -c` as root lists what the policy holds.
1404
1404
  - **A line that doesn't parse is never dropped silently:** it is skipped, so it grants nothing, while the rest of the file still counts (as sudo's error recovery does), and every `sudo` and `sudo -l` says so on standard error before anything else. A caller with an effective uid of 0 gets one line per problem, with the file, the line number and what was expected: `sudo: /etc/sudoers.d/memory-handoff:1: line skipped: the SETENV: tag isn't supported: only NOPASSWD: and PASSWD: are`, or, for a line in neither form, `expected '[NOPASSWD] <user|%group|ALL> [(<target>)] [Cwd <dir>] [Stdin none] [ChainSha256 <sha256>] [RouteSha256 <sha256>] [Sha256 none|<file>=<sha256>…] Cmnd <command…|*>' or '<user|%group|ALL> ALL=[(<target>[,<target>…])] [NOPASSWD:] <command…|ALL>'`. A policy file that isn't root's, is a symlink, or is writable by group or others, and every file in a directory that is, is skipped the same way and reported as `sudo: <path> skipped: it must be root's, no symlink, and writable by root only`. Any other caller can't read the policy, so it gets only a count, without file names or anything from the lines: `sudo: 2 policy lines or files were skipped and grant nothing; ask an administrator to run sudo visudo -c`, and nothing when nothing was skipped. To check a line before installing it, run `visudo -c -f <file>` on your own copy, which reports it in full. Each problem is also logged once, in full, with `console.warn`.
1405
1405
  - **`visudo -c`** is a command of the kernel itself, in `/usr/bin`, that checks the policy without running anything: `visudo -c -f <file>` (or `visudo -c <file>`, several allowed, `-` for standard input, shown as `stdin`) checks a file the caller can read, before it is installed, and prints `<file>: parsed OK` on standard output, or `visudo: <file>:<line>: <what was expected>` on standard error for each bad line, and exits with 1. `visudo -c` alone checks `/etc/sudoers` and the files in `/etc/sudoers.d` as `sudo` reads them, the ownership and mode included (`visudo: <path>: sudo skips it: …`), and needs an effective uid of 0, as reading those files does on Linux: `sudo visudo -c`. After the files, it prints the [timestamp values](#sudo-timestamps) on standard output: `Defaults timestamp_timeout=<minutes>, timestamp_type=<type>` for everyone (the kernel's 5 and `tty` where no line sets them), then each `Defaults:<user|%group>` line, as read, in the order they apply, so a later one wins; the first line ends with `, env_keep="<names>"` when the lines for everyone keep any variable (**The environment**, below); `-f` prints them only when the files have a `Defaults` line. `-q` prints nothing and only sets the status, `-s` is accepted (the check is always strict), and `visudo` without `-c` refuses to edit: write the file as root with mode `0440` (`install -m 0440 -o root -g root <file> /etc/sudoers.d/<name>`).
1406
1406
  - **The embedders' recipe** puts cones in `sudo` (`groups: ['sudo']`) and scoops not, so a cone may ask for any command and a scoop for none.
1407
- - **The command** is found once, on `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin` for a bare name or against the caller's directory for a path, and its real path (symlinks resolved) is what runs and what the policy sees; the caller's `PATH` is never searched, as with sudo's `secure_path`, so a bare name doesn't find a user's own bin directory. The policy decides whether it runs, not who owns it: a command the caller can change runs as the target user when a line allows it. What the kernel adds is a binding to its contents. It looks at that file and every file that will really run for it (a catalog command's glue, module and imports module, and the `package.json` that defines it, a script and the interpreter its `#!` line or `binfmt` rule names, with the `package.json` that defines the rule). A file is omitted from the binding when it and every directory on its path are root-owned and not writable by group or others, and every symlink traversed, including links in a link target, is root-owned. Thus a root-only file behind root's own links counts like a direct path. Every other file is **user-writable**: its real path and sha256 go into the approval request (`userWritable`, below), and an `'always'` answer records them in its rule (`Sha256`). When the command starts, just before the kernel loads it, it hashes those files again; if one differs, is gone, or another user-writable file now runs for the command, nothing runs and `sudo` fails with `sudo: <word> changed since it was approved`, using the command name as typed, not the changed backing file (`EPERM`). Each requested path must still name the real file it identified at approval: exchanging two hashed files' links is refused even if their contents are identical. For a script the kernel plans each interpreter and its arguments from the same read it hashes. A `..` in a command or interpreter name goes to the parent of the directory actually reached, including when it occurs inside a symlink target. Each such lookup can follow at most 40 links in total, counting both directory and final-name links. Sudo checks that the target user can search every directory on the named command’s route, even one later left by `..`. After a grant, if that route can no longer be walked to the approved executable, nothing starts: sudo reports the supplied command name as changed (`EPERM`), not a fresh lookup error. It binds the requested route to the physical interpreter and checks execute permission on the file it will run. A missing directory before `..` cannot be skipped to find another executable. Sudo builds the command catalog and `binfmt` rules for that plan from the manifest bytes it verifies, even when `package.json` links outside the watched roots. Lookups within one plan reuse the same scoped tables and one read per real manifest. Binding is narrower than scanning. It includes writable manifests of providers that name the selected command or an interpreter, including competing or replacing providers, and the global project manifests that determine their dependency precedence. For binfmt it includes declarations of matching rule keys, even an earlier nonmatching declaration that hides a matching one. An unrelated sibling is not an approval input; if it becomes a provider, the next plan sees it. Root-held manifests stay out of `userWritable`. `sudo -l` shares one catalog scan across its rules but computes each rule's writable inputs separately. At start, and after a package-replacement wait, the selected interpreter chain must also match the approved chain; a vanished rule cannot silently become a different interpreter. The modules and glue the kernel loads itself (a wasm module, a JS program's module, an Emscripten glue or imports module) are taken from the bytes it read and hashed then, never from its cache of compiled programs, which keys a file by its size and modification time, so a user-writable module swapped for another of the same size and time runs as approved or not at all. If a directly named Wasm file vanishes after the final hash, a warm entry keyed by that digest can still run the approved bytes. A file the kernel loads for the command that `sudo` didn't hash, such as the module of a [variant](#commands) the environment picked, must be root's and writable by root only, with every directory above it the same, and reached only through symlinks that root owns, so that no other user can change which file the path names; otherwise nothing runs (`sudo: <word> changed since it was approved`). Being root-only at the end of a link another user can repoint isn't enough, so a link repointed at another root-only program after the check doesn't run it. That holds whatever allowed the run (an approval, a `NOPASSWD` line, a [timestamp](#sudo-timestamps), an effective uid of 0): the hashes are the ones `sudo` saw when it decided. This also binds the script the interpreter opens. For each user-writable interpreted input (a `#!` script or a `binfmt` file), the child inherits a read-only, seekable descriptor for the very bytes used to plan the interpreter and verify the digest. The script argument becomes `/dev/fd/N`, including at each user-writable level of a nested interpreter chain. A rewrite or unlink after the check cannot substitute new contents. Each open of the descriptor path starts at offset zero, so a script can read `$0` without moving the interpreter's cursor. `dup` and `fork` still share the offset of the description they inherit. This applies to `sudoRun` too. **Compatibility:** bash sees `$0=/dev/fd/N`; Python sees the same descriptor path as `sys.argv[0]`. Self-relative lookups through `dirname "$0"` no longer find the script's directory. Pass the directory separately if needed. A bash script cannot re-exec the descriptor path directly with `exec "$0"`: exec looks up programs in the filesystem, not the process's fd table. Use `bash "$0"` to read the same snapshot again. Opening the snapshot path for write is `EACCES`, including from Emscripten. For an ordinary unlinked regular file, reopening `/dev/fd/N` uses the caller’s permissions on the held inode: opening the original descriptor read-only does not itself prohibit a write reopen. Writing to an already-open read-only descriptor is `EBADF`. The snapshot stays in memory until the last descriptor holding it closes, including in a descendant; this can matter for large binfmt inputs. Root-only scripts (including ones behind root-held links) and scripts run outside sudo keep their original path. `sudo --help` describes this difference. Files that are root-only throughout are not listed or pinned, and a command whose files all are behaves as before. `sudo -l` ends the line of a rule whose command is user-writable with ` # user-writable command`. A command that wouldn't start as the target user (a `#!` line naming an interpreter that is only the caller's, say) fails with `command not found` before anything is asked. Other files a program loads at run time (a package's libraries) are the admin's to keep safe, as on Linux. The caller's directory, which the program passes on, must be a directory the caller may enter, or `sudo` refuses (`EACCES`). The kernel resolves it to its real path once, shows that in the request, and runs the command there; if it no longer resolves the same, or the caller can no longer enter it, when the answer comes or when the command starts, nothing runs.
1407
+ - **The command** is found once, on `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin` for a bare name or against the caller's directory for a path, and its real path (symlinks resolved) is what runs and what the policy sees; the caller's `PATH` is never searched, as with sudo's `secure_path`, so a bare name doesn't find a user's own bin directory. The policy decides whether it runs, not who owns it: a command the caller can change runs as the target user when a line allows it. What the kernel adds is a binding to its contents. It looks at that file and every file that will really run for it (a catalog command's glue, module and imports module, and the `package.json` that defines it, a script and the interpreter its `#!` line or `binfmt` rule names, with the `package.json` that defines the rule). A file is omitted from the binding when it and every directory on its path are root-owned and not writable by group or others, and every symlink traversed, including links in a link target, is root-owned. Thus a root-only file behind root's own links counts like a direct path. Every other file is **user-writable**: its real path and sha256 go into the approval request (`userWritable`, below), and an `'always'` answer records them in its rule (`Sha256`). When the command starts, just before the kernel loads it, it hashes those files again; if one differs, is gone, or another user-writable file now runs for the command, nothing runs and `sudo` fails with `sudo: <word> changed since it was approved`, using the command name as typed, not the changed backing file (`EPERM`). Each requested path must still name the real file it identified at approval: exchanging two hashed files' links is refused even if their contents are identical. For a script the kernel plans each interpreter and its arguments from the same read it hashes. A `..` in a command or interpreter name goes to the parent of the directory actually reached, including when it occurs inside a symlink target. Each such lookup can follow at most 40 links in total, counting both directory and final-name links. Sudo checks that the target user can search every directory on the named command’s route, even one later left by `..`. After a grant, if that route can no longer be walked to the approved executable, nothing starts: sudo reports the supplied command name as changed (`EPERM`), not a fresh lookup error. It binds the requested route to the physical interpreter and checks execute permission on the file it will run. A missing directory before `..` cannot be skipped to find another executable. Sudo builds the command catalog and `binfmt` rules for that plan from the manifest bytes it verifies, even when `package.json` links outside the watched roots. Lookups within one plan reuse the same scoped tables and one read per real manifest. Binding is narrower than scanning. It includes writable manifests of providers that name the selected command or an interpreter, including competing or replacing providers, and the global project manifests that determine their dependency precedence. For binfmt it includes declarations of matching rule keys, even an earlier nonmatching declaration that hides a matching one. An unrelated sibling is not an approval input; if it becomes a provider, the next plan sees it. Root-held manifests stay out of `userWritable`. `sudo -l` shares one catalog scan across its rules but computes each rule's writable inputs separately. At start, and after a package-replacement wait, the selected interpreter chain must also match the approved chain; a vanished rule cannot silently become a different interpreter. The modules and glue the kernel loads itself (a wasm module, a JS program's module, an Emscripten glue or imports module) are taken from the bytes it read and hashed then, never from its cache of compiled programs, which keys a file by its size and modification time, so a user-writable module swapped for another of the same size and time runs as approved or not at all. If a directly named Wasm file vanishes after the final hash, a warm entry keyed by that digest can still run the approved bytes. A file the kernel loads for the command that `sudo` didn't hash, such as the module of a [variant](#commands) the environment picked, must be root's and writable by root only, with every directory above it the same, and reached only through symlinks that root owns, so that no other user can change which file the path names; otherwise nothing runs (`sudo: <word> changed since it was approved`). Being root-only at the end of a link another user can repoint isn't enough, so a link repointed at another root-only program after the check doesn't run it. That holds whatever allowed the run (an approval, a `NOPASSWD` line, a [timestamp](#sudo-timestamps), an effective uid of 0): the hashes are the ones `sudo` saw when it decided. This also binds the script the interpreter opens. For each user-writable interpreted input (a `#!` script or a `binfmt` file), the child inherits a read-only, seekable descriptor for the very bytes used to plan the interpreter and verify the digest. The script argument becomes `/dev/fd/N`, including at each user-writable level of a nested interpreter chain. A rewrite or unlink after the check cannot substitute new contents. Each open of the descriptor path starts at offset zero, so a script can read `$0` without moving the interpreter's cursor. `dup` and `fork` still share the offset of the description they inherit. This applies to `sudoRun` too. **Compatibility:** bash sees `$0=/dev/fd/N`; Python sees the same descriptor path as `sys.argv[0]`. Self-relative lookups through `dirname "$0"` no longer find the script's directory. Pass the directory separately if needed. A bash script cannot re-exec the descriptor path directly with `exec "$0"`: exec looks up programs in the filesystem, not the process's fd table. Use `bash "$0"` to read the same snapshot again. Opening the snapshot path for write is `EACCES`, including from Emscripten. For an ordinary unlinked regular file, reopening `/dev/fd/N` uses the caller’s permissions on the held inode: opening the original descriptor read-only does not itself prohibit a write reopen. Writing to an already-open read-only descriptor is `EBADF`. The snapshot stays in memory until the last descriptor holding it closes, including in a descendant; this can matter for large binfmt inputs. Root-only scripts (including ones behind root-held links) and scripts run outside sudo keep their original path. `sudo --help` describes this difference. Files that are root-only throughout are not listed or pinned, and a command whose files all are behaves as before. `sudo -l` appends ` # user-writable command` when a command file is user-writable or a catalog environment path is not root-controlled. The latter can affect the command even when no file needs hashing. A command that wouldn't start as the target user (a `#!` line naming an interpreter that is only the caller's, say) fails with `command not found` before anything is asked. Other files a program loads at run time (a package's libraries) are the admin's to keep safe, as on Linux. The caller's directory, which the program passes on, must be a directory the caller may enter, or `sudo` refuses (`EACCES`). The kernel resolves it to its real path once, shows that in the request, and runs the command there; if it no longer resolves the same, or the caller can no longer enter it, when the answer comes or when the command starts, nothing runs.
1408
1408
  - **The environment** is the kernel's, as sudo's is under `env_reset`: the kernel's own variables (`HOSTNAME`, `TZ`, the proxy and CA settings, and its `env` option), the target user's `HOME`, `USER`, `LOGNAME`, `SHELL`, `PNPM_HOME` and `NPM_CONFIG_PREFIX`, the fixed `PATH` above, `PWD`, the caller's `TERM` when it is a plain terminal name, and `SUDO_USER`, `SUDO_UID`, `SUDO_GID` and `SUDO_COMMAND`. Nothing else of the caller's environment reaches the command unless the policy keeps it with sudoers(5)'s `env_keep`, so a tool that reads a token from the environment works under `sudo` as it does on Linux:
1409
1409
  ```
1410
1410
  Defaults env_keep += "GH_TOKEN GITHUB_TOKEN"
@@ -1429,6 +1429,7 @@ As in sudo(8), a person's approval is remembered for a few minutes: until then,
1429
1429
 
1430
1430
  - **Only a person's approval writes one.** The approver says so by answering `{ answer: 'once', timestamp: true }` or `{ answer: 'always', timestamp: true }` (`SudoApproval`; every request carries `timestamp: true` to say the kernel takes it). A plain `'once'` or `'always'` runs the command and writes nothing, so an approver from before this, a judge or another program can't open the window. `'always'` writes it only once its rule is recorded (or, for a command line that can't be recorded, once it ran).
1431
1431
  - **What it skips:** only the question. The policy, the checks of the directory and the command, and `NOPASSWD` stay as they are, so a timestamp never lets a caller run a command no line allows it to ask for. A caller with an effective uid of 0, and a command a `NOPASSWD` line allows, neither use nor write one. Every run a timestamp allowed is refreshed (the window starts again from it, as sudo updates its record on each run) and logged on the kernel's console, through the same `console.warn` sudo already logs skipped policy lines to, in sudo's format: `sudo: cone : TTY=unknown ; PWD=/home/cone ; USER=root ; TIMESTAMP=ppid ; COMMAND=/usr/bin/id -un`. Nothing else shows it.
1432
+ - **What it covers:** starting a timestamp with `sudo -v`, or by approving an unrelated root-held command, does not cover a command whose catalog environment depends on a writable path, even if all of its command files are root-held. A personal approval for that command covers its current file binding and chain, including how the environment value expanded. If that expansion changes, `sudo` asks again and `sudo -n` refuses.
1432
1433
  - **Whose:** a timestamp belongs to the user who asked (the caller's real uid), whoever the command runs as, and to the place `timestamp_type` names:
1433
1434
  - `tty` (the default): the caller's controlling terminal and its session, kept with the session leader's start time, so every command typed in one terminal shares it, a nested shell included, and nothing outside the terminal does. A caller without a terminal (an agent's `kernel.run`, a cron job, a pipe) falls back to `ppid`, as sudo does.
1434
1435
  - `ppid`: the process that ran `sudo`, kept with its start time. So a script or a loop of `sudo` calls asks once, and the next script, another shell or the next `kernel.run` asks again. A `sudo` with no parent in the kernel (one the embedder started, or one a shell the embedder started execs as its last command, as `bash -c 'a; sudo b'` does) counts that top process as its parent, so the last `sudo` of a script shares the script's timestamp; one whose parent has ended uses and writes none.
@@ -1576,7 +1576,7 @@ function createParentRefreshCount() {
1576
1576
  }
1577
1577
 
1578
1578
  // src/version.ts
1579
- var KERNEL_VERSION = true ? "1.196.28" : "0.0.0-dev";
1579
+ var KERNEL_VERSION = true ? "1.196.29" : "0.0.0-dev";
1580
1580
  var OS_RELEASE = "6.0.0-slicc";
1581
1581
  function procVersion() {
1582
1582
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC