Commit Graph
7 Commits
Author SHA1 Message Date
Iuri Matias 949fec18bc fix: authenticate token-handoff socket peer by uid and restrict it to 0600 (#136)
fix: authenticate token-handoff socket peer by uid and restrict it to 0600

fix

update doctests
2026-06-08 14:30:33 -04:00
Iuri Matias 6715b59326 fix: F-011: sanitize module names used for sockets (#137) 2026-06-08 14:06:25 -04:00
Dario Lipicar 2321de0365 fix: ensure consistent token socket path on the sender and receiver end (#129)
* fix: ensure consistent token socket path on the sender and receiver end

* address PR #129 review comments

- unix_socket_path.h: replace fixed-size PATH_MAX buffer with a
  two-step confstr probe (nullptr/0 to learn the size, then a
  std::vector<char>). Apple's per-user temp dir can exceed PATH_MAX
  on some configurations; the truncated fallback to /tmp would
  reintroduce the exact parent/child path mismatch this helper is
  meant to prevent.

- token_receiver.cpp: stack-allocate QLocalServer instead of new +
  deleteLater. The Qt event loop is not guaranteed to be running on
  the receiver thread, so deleteLater would leak; RAII makes every
  exit path (including listen() failure) clean up.

- tests/test_token_exchange.cpp: add a regression test that pins the
  TMPDIR-unset behaviour. The new test
  RoundTrip_SucceedsWithTmpdirUnset unsets TMPDIR (and
  LOGOS_INSTANCE_ID, which earlier tests may have left set via
  LogosInstance::id) and asserts both sender and receiver agree on
  the helper-resolved socket path. Also re-route the existing
  tmpDir() helper through ::logos::qtCompatibleTempDir() so the
  instance-id tests stay correct under the same conditions.
2026-05-08 15:00:23 -03:00
Dario Lipicar 87b5c2e337 sendTokenToProcess: deadline-driven retry + sun_path length check (#124)
Two related fixes to the parent-side token handoff to a child module
process, both motivated by races / silent failures observed in the
docker smoke matrix.

1. Replace the hard-coded 10×100ms retry loop with a deadline-driven
   loop, default budget 5000ms (configurable via a new max_wait_ms
   parameter). The previous 900ms cap was tight enough that on a cold
   child — dynamic loader + Qt platform bring-up + CLI11 parse +
   plugin loadFromPath — the parent would give up before the child
   bound its QtTokenReceiver socket, leaving a half-loaded module
   with a misleading "Failed to connect to token socket" error. New
   tests pin both ends of the contract:
       SendToken_FailsFast_WhenSocketNeverAppears  — bails within budget
       SendToken_SucceedsAfterDelay                — accepts late binders

   test_token_exchange's WrongName_FailsCleanlyWithinTimeout bound
   loosened from <5000ms to <5500ms because the deadline check can
   overshoot by ~one poll interval (50ms) plus syscall slack.

2. Validate the computed Unix socket path against
   sockaddr_un::sun_path (~104 bytes on macOS, ~108 on Linux) before
   strncpy. Long TMPDIR + module name + LOGOS_INSTANCE_ID combos
   would otherwise silently truncate, leaving the parent connecting
   to the wrong socket while the child binds the full path. Fail
   loudly instead.
2026-05-01 17:05:17 -03:00
Iuri Matias b82145ce9a rename plugins to modules (#122) 2026-04-23 09:20:45 -04:00
Dario Lipicar d2d6ec7695 add instance id to token exchange socket name (#121)
* add instance id to token exchange socket name

* pr comments
2026-04-22 11:35:21 -03:00
Iuri Matias 198c261b5a add more tests to catch potential regressions (#107)
* add more tests to catch potential regressions

* remove qt from the tests

remove qt from the tests

revert changes made to src; update tests
2026-04-09 15:38:57 -04:00