Scripts: commands read through the gate in runs the person starts, and the grants file is not written over when it cannot be read

- A command a script runs reads only where the script may, also in a run the person started; only
  reads of the app's own folders inside the command are exempt.
- Always and script.grants.revoke leave a grants file they cannot read as it is, and fail.
- script.grants names a path outside the automation read roots by its file name alone.
- copy reads the source once, within the 8 MiB limit, writes those bytes, and gives the copy the
  source's permissions.
- write joins its values as UTF-16 before making them text, so a surrogate pair split between two
  values is one character.
This commit is contained in:
dotCooCoo
2026-11-13 10:09:27 -08:00
parent 4f8e1d5ed2
commit dbfffc8ecb
8 changed files with 186 additions and 43 deletions
+11 -1
View File
@@ -341,7 +341,17 @@ fn list_installed(s: &mut Session, _: &Value) -> Result<Value> {
fn grants(s: &mut Session, _: &Value) -> Result<Value> {
let Some(dir) = s.script_data_dir() else { return Ok(json!({"grants": [], "file": null})) };
let file = dir.with_file_name(script::files::GRANTS_FILE);
Ok(json!({"grants": script::files::stored_grants(dir), "file": file.to_string_lossy()}))
// A script or a granted path outside the automation read roots is named by its file name alone.
let mut grants = script::files::stored_grants(dir);
for g in &mut grants {
for key in ["script", "path"] {
if let Some(name) = g[key].as_str().and_then(hidden_name) {
g[key] = json!(name);
}
}
}
let file = file.to_string_lossy();
Ok(json!({"grants": grants, "file": super::fileio::shown_path(&file)}))
}
fn grants_revoke(s: &mut Session, p: &Value) -> Result<Value> {