Skip to content

fix: honour the documented opt-out, keep the machine name out and the Linux queue private (backport #35) - #37

Merged
agneszitte merged 9 commits into
release/stable/1.4from
dev/agzi/backport-35-telemetry-privacy-1.4
Nov 12, 2026
Merged

agneszitte merged 9 commits into
release/stable/1.4from
dev/agzi/backport-35-telemetry-privacy-1.4

Conversation

@agneszitte

Copy link
Copy Markdown
Member

GitHub Issue (If applicable): related to https://github.com/unoplatform/private/issues/1262 (Uno Platform 7.0 SR1)

Backport of #35 to release/stable/1.4, for Telemetry 1.4.2. #35 merged on main the day after 1.4 was cut, so Uno 7.0 (Telemetry 1.4.1) doesn't have it. Uno core picks up 1.4.2 for 7.0 SR1.

All 9 commits of #35, cherry-picked with -x. They applied cleanly, and the result is identical to #35's diff on main. The full description and review are on #35.

PR Type

  • Bugfix

What is the current behavior?

  • The documented opt-out UNO_PLATFORM_TELEMETRY_OPTOUT=1 is ignored: only true turns telemetry off.
  • Desktop telemetry carries the machine's host name.
  • On Linux, unsent telemetry waits in a shared folder under /tmp, readable by other users.

What is the new behavior?

  • 1, yes, on and true turn telemetry off.
  • The host name is replaced with "anonymous".
  • On Linux, the queue is a private per-user folder ($XDG_CACHE_HOME or ~/.cache/uno/telemetry/outbox, owner only). A folder another user controls is refused, and queued items are sent only to the configured endpoint.

Validated locally: Uno.DevTools.Telemetry.Tests on this branch: 264 passed, 27 skipped (Linux-only on Windows), 0 failed.

PR Checklist

🤖 Generated with Claude Code

Jen-Uno and others added 9 commits November 12, 2026 00:30
UNO_PLATFORM_TELEMETRY_OPTOUT was read with bool.TryParse, so the
documented value 1 left telemetry on. 1, true, yes and on now opt out,
ignoring case and surrounding whitespace. Only the literal false still
forces telemetry on over a product's own opt-out; 0, no, off and any
other value read as unset, so the product decides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 69bc1e3)
…figured endpoint

On Linux the desktop queue lived in the shared /tmp with default
permissions, and a queued file was sent to the address stored in it, so
another local user could read queued items, block the queue, or plant a
file that would be posted elsewhere. On Linux the queue now lives under
$XDG_CACHE_HOME/uno/telemetry/outbox (or ~/.cache/uno/telemetry/outbox),
created with mode 0700 where the framework allows it, and files owned by
another user are skipped. On every platform a queued file is sent only to
the channel's configured endpoint. Windows and macOS keep their per-user
temp folders.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 2c03326)
The Application Insights SDK fills an empty cloud role instance with the
machine's name, with its domain when there is one, and then fills the
internal node name the same way, so every desktop item carried the
hostname. Both are now set to a constant on the client context, which is
copied onto every item. A test reads queued items back and checks them
for the machine and host names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit a2f9b92)
…ithout native calls

The previous commit's private queue folder was often never private:
only the net8.0 and net9.0 builds set mode 0700, and only when they
created the folder, so a folder the netstandard2.0 build (MSBuild tasks,
the XAML generator) created first stayed 0755. Its per-file owner check
called statx and geteuid through P/Invoke, could skip every file on NFS
or sshfs, and never ran in CI.

Outside Windows the queue folder is now settled once, when telemetry
starts, in every build:

- The folder that holds the ones the library names (~/.cache,
  $XDG_CACHE_HOME, ~/Library/Caches or $TMPDIR) must not be writable by
  users outside its owner and group, unless it has the sticky bit.
  Group-writable is accepted: where each user has a group of their own,
  as on Ubuntu, ~/.cache is usually 0775.
- uno (or .uno), telemetry and outbox must not be symbolic links, are
  created at 0700, then set to 0700 and read back. Only a folder's owner,
  or root, may change its mode, so this also shows they are the user's.
  The netstandard2.0 build makes the same calls through reflection.
- Only Windows, and macOS with TMPDIR set, queue in the temp folder.
  macOS without it uses ~/Library/Caches; other systems the XDG cache.
- Root is refused only under sudo or doas with a home that isn't root's.
- Without a usable folder the instance sends nothing and writes one
  Trace line naming the reason, and the machine id isn't stored without
  a home. A queue folder deleted while telemetry runs isn't recreated.

FileOwner.cs and the per-file owner check are removed, so no P/Invoke
remains. Paths are built from single folder names, so nothing appended
can replace the base. CI gains two Linux unit-test jobs, glibc as an
ordinary user and Alpine (musl) as root, which fail rather than skip the
tests they exist to run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit f77026c)
…ndows

The test faked root under sudo but used the runtime's own folder-mode
calls, which Windows doesn't have, so TryPrepare stopped at "this runtime
can't set a folder's Unix permissions" before reaching the sudo check.
It now passes fake modes, as the same case in TelemetryQueueFolderTests
does. The library is unchanged: on Windows it returns before either check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit c50d30b)
…lect in IsHomeOfRoot

Addresses the code-quality review of f77026c:

- The four test classes this PR adds clean up their folders catching
  only IOException and UnauthorizedAccessException, instead of every
  exception; anything else now fails the test.
- The sudo test asserts the failure reason isn't null before reading it.
- IsHomeOfRoot maps each /etc/passwd line to its fields with Select. It
  behaves as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 4a86b71)
…y is off

Addresses findings 1, 2, 4 and 5 of the review panel on a2f9b92..4a86b71:

- The folder that holds the queue folder is refused when other users
  can write to it even with the sticky bit, since the owner of a sticky
  folder such as /tmp may still rename entries in it. It must also be
  the user's own: setting its mode to the one it has succeeds only for
  its owner, or root. The folders the library names are checked for
  symbolic links again at the end, for one swapped in meanwhile.
- The reason telemetry is disabled also goes to the console when
  UNO_TELEMETRY_ENABLE_PERSISTENCE_CHANNEL_DEBUG_OUTPUT is set: no host
  listens to Trace.
- Under sudo or doas, root creates nothing outside root's home, judged
  by the folder that would hold the queue folder rather than HOME, so
  sudo keeping XDG_CACHE_HOME is caught too. SUDO_UID=0 and
  SUDO_USER=root, as when root runs sudo itself, no longer count.
- A queued file is read only up to its own length, and only if it is
  seekable and no longer than the storage's capacity: a link to a pipe
  or to /dev/zero is set aside as corrupt instead of being read without
  end.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 604ad66)
The code-quality check still read the failure reason as possibly null:
the same test null-checks it earlier. It now asserts on the reason or
an empty string, so a missing reason still fails the test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 3a9231c)
…me, and let the opt-out only opt out

From the review of this PR:

- When no queue folder of the user's own is usable, the instance sends from
  memory instead of turning off: every 5 seconds, and on Flush, FlushAsync and
  Dispose (at most 2 seconds). Each item carries a "Queue Refused" property with
  a fixed code, never a path, so the loss shows instead of looking like fewer
  users. The machine id isn't stored then either. docs/usage.md lists the codes
  and UNO_TELEMETRY_ENABLE_PERSISTENCE_CHANNEL_DEBUG_OUTPUT.
- As root, no folder outside root's home is used, whether or not sudo or doas
  started the process. The SUDO_*/DOAS_USER check is removed.
- UNO_PLATFORM_TELEMETRY_OPTOUT can only opt out: false reads as unset, so the
  product decides. The docs list 1 and true, as the public telemetry page does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit a2e58e8)
@mergify

mergify Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

This pull request is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants