1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
use BTreeMap;
/// The env every spawned child starts from, before the app's own `env` map
/// is folded on top (app config always wins on conflict), plus `PATH`:
/// without one, a bare program or interpreter name can never be found by
/// exec, so it's seeded unconditionally rather than left to `keys`.
///
/// [`build`](crate::assemble::spawn_spec::build) calls this with the platform-selected [`INHERITED`] and a
/// `std::env::var` reader; a test can pass [`INHERITED_WINDOWS`] and a fake
/// reader instead, on any host, without touching real process env.
/// Mutating that from a test is unsound under a parallel test binary, and
/// `std::env::set_var` is itself `unsafe` since edition 2024.
pub
/// The `PATH` a child gets when the daemon itself has none.
const DEFAULT_PATH: &str = "/usr/local/bin:/usr/bin:/bin";
/// The `PATH` a child gets when the daemon itself has none.
///
/// Not expanded via `%SystemRoot%`: these literal paths are correct on
/// every standard Windows install and need no variable to resolve.
const DEFAULT_PATH: &str = r"C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem";
/// Variables inherited from the daemon's own environment, on top of `PATH`.
const INHERITED_UNIX: & = &;
/// Variables inherited from the daemon's own environment, on top of `PATH`.
///
/// Longer than the unix list because Windows children need it: many Win32
/// APIs read `%SystemRoot%` directly, and `PATHEXT`/`COMSPEC` let a child
/// resolve and run `.cmd` files at all. `TEMP`/`TMP` and the
/// `USERPROFILE`/`APPDATA`/`LOCALAPPDATA` trio are where most runtimes keep
/// per-user state. Still a closed allowlist, not inherit-everything.
///
/// `PYTHONUTF8`/`PYTHONIOENCODING` are here for one specific failure: a
/// non-console stdio handle (a pipe, which is what every spawned child gets)
/// makes CPython up to 3.14 fall back to the legacy ANSI code page for
/// `sys.stdout`/`sys.stderr` on Windows, and any non-ASCII byte an app prints
/// then raises `UnicodeEncodeError`. CPython 3.15 turns UTF-8 mode on by
/// default (PEP 686), so these two matter for an older interpreter and for
/// anything that sets `PYTHONUTF8=0`. Neither has a unix equivalent to piggyback
/// on. `LANG` is what decides a child's stdio encoding there and
/// [`INHERITED_UNIX`] forwards it, which is not the same as setting one: a
/// daemon started with no `LANG`, or with one naming a non-UTF-8 locale,
/// hands that to its children. Windows has no variable in that role to
/// forward at all. Setting either in the daemon's own environment now
/// reaches every spawned app; an app can still set them itself, per-app, in
/// its Flockfile `env`.
pub const INHERITED_WINDOWS: & = &;
/// The list [`build`](crate::assemble::spawn_spec::build) actually reads on this build. Picked with `cfg!`
/// rather than `#[cfg(...)]` gating [`INHERITED_UNIX`]/[`INHERITED_WINDOWS`]
/// themselves: both stay referenced on every target this way, so a test can
/// run either platform's list (and [`inherited_env`]'s filtering) on any
/// host, the same way this crate's unit-file renderers are pinned by text
/// on a Mac without a systemd host, and `-D warnings` never calls the other
/// platform's list dead code.
pub const INHERITED: & = if cfg! else ;
/// [`inherited_env`]'s two arguments bundled into one: a key list plus a
/// reader, so [`build`](crate::assemble::spawn_spec::build) takes one parameter for this instead of two, and a
/// test can substitute both without touching real process env.
pub