refactor(simulator): --log output path respects --segregate
What changed, and why it matters
This is a small cleanup change to the COLDCARD simulator's command-line logging behavior. It makes the `--log` option place its log file in the same per-process directory used by the `--segregate` option, instead of always using a hard-coded `/tmp/cc-simulators/<pid>/` path. The README is updated to match. There is no security-relevant change here.
No security action needed. Treat as a normal simulator usability/refactor commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors unix/simulator.py so that when --segregate is active, the simulator log file is written under the already-created per-PID work directory (/tmp/cc-simulators/<pid>/cc_simulator.log). When --segregate is not used, the log now goes to /tmp/cc_simulator.log. Previously the code always constructed a /tmp/cc-simulators/<pid>/ path and created that directory even when --segregate was not active. The change removes redundant directory creation and aligns the log path with the documented behavior. No cryptographic, authentication, or firmware-security code is touched.
Changed components
unix/simulator.pyunix/README.mdInspect captured patch +5 / −6
diff --git a/unix/README.md b/unix/README.md
index c44b244..03e79d7 100644
--- a/unix/README.md
+++ b/unix/README.md
@@ -63,7 +63,7 @@ wallet (on testnet, always with the same seed). But there are other options:
- `--segregate` => scroll down to `Running simulators in parallel` section
- `--bricked` => simulate a system w/ bricked SE1: no more pin tries, etc.
- `--fails N` => simulate N wrong PIN attempts before login, where (1 <= N <= 13)
-- `--log` => enable logging to `/tmp/cc-simulators/<pid>/cc_simulator.log`
+- `--log` => enable logging to `/tmp/cc_simulator.log`, or to `/tmp/cc-simulators/<pid>/cc_simulator.log` when used with `--segregate`
See `variant/sim_settings.py` for the details of settings-related options.
diff --git a/unix/simulator.py b/unix/simulator.py
index e0e8219..624d1e1 100755
--- a/unix/simulator.py
+++ b/unix/simulator.py
@@ -863,12 +863,15 @@ Q1 specials:
cc_mpy = os.path.join(cwd, "coldcard-mpy")
sim_boot = os.path.join(cwd, "sim_boot.py")
+ log_base_dir = "/tmp"
+
if segregate:
os.makedirs("/tmp/cc-simulators", exist_ok=True)
os.chdir("/tmp/cc-simulators")
# our new work /tmp/cc-simulators/<PID>
os.mkdir(str(pid))
os.chdir(str(pid))
+ log_base_dir = os.getcwd()
os.mkdir("MicroSD")
os.mkdir("settings")
os.mkdir("VirtDisk")
@@ -907,11 +910,7 @@ Q1 specials:
log = ("--log" in sys.argv)
if log:
- logfile = '/tmp/cc-simulators/%d/cc_simulator.log' % pid
-
- # create dir for the file in /tmp
- os.makedirs(os.path.dirname(logfile), exist_ok=True)
-
+ logfile = os.path.join(log_base_dir, 'cc_simulator.log')
# create or truncate logfile and set correct permissions before starting xterm
file_desc = os.open(logfile, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o644)
os.close(file_desc)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.