feat: add --log flag to enable simulator logging
What changed, and why it matters
This commit adds an optional --log command-line flag to the COLDCARD simulator. When used, it creates a per-process log directory under /tmp and records an xterm session log. By default, logging is now disabled unless the flag is provided. There is no security vulnerability here; it is a minor developer/debugging convenience change.
No security action required. This is a benign feature addition for simulator diagnostics.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies unix/simulator.py so that xterm logging is only enabled when –log is present in sys.argv. Previously the simulator always wrote to /tmp/cc_simulator.log. With the change, the log path becomes /tmp/cc-simulators/
Changed components
unix/simulator.pyunix/README.mdInspect captured patch +17 / −6
diff --git a/unix/README.md b/unix/README.md
index 27e2575..c44b244 100644
--- a/unix/README.md
+++ b/unix/README.md
@@ -63,6 +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`
See `variant/sim_settings.py` for the details of settings-related options.
diff --git a/unix/simulator.py b/unix/simulator.py
index 9840eb1..e0e8219 100755
--- a/unix/simulator.py
+++ b/unix/simulator.py
@@ -903,14 +903,24 @@ Q1 specials:
child.kill()
return
- logfile = '/tmp/cc_simulator.log'
+ xterm_args = ['xterm', '-title', 'Coldcard Simulator REPL', '-geom', '132x40+650+40']
- # truncate logfile and set correct permissions before starting xterm
- open(logfile, 'w').close()
- os.chmod(logfile, 0o644)
+ log = ("--log" in sys.argv)
+ if log:
+ logfile = '/tmp/cc-simulators/%d/cc_simulator.log' % pid
- xterm = subprocess.Popen(['xterm', '-title', 'Coldcard Simulator REPL',
- '-geom', '132x40+650+40', '-l', '-lf', logfile, '-e'] + cc_cmd,
+ # create dir for the file in /tmp
+ os.makedirs(os.path.dirname(logfile), exist_ok=True)
+
+ # 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)
+
+ xterm_args.extend(['-l', '-lf', logfile, '-e'])
+ else:
+ xterm_args.extend(['-e'])
+
+ xterm = subprocess.Popen(xterm_args + cc_cmd,
env=env,
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
pass_fds=pass_fds, shell=False)
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.