Skip to main content

Module machine

Module machine 

Source
Expand description

Stable per-machine identifier used to deduplicate device rows on the relay.

The relay uses machine_id to recognize when the CLI and desktop on the same Mac are signing in independently and should share a single device row instead of producing two. The value is opaque (SHA-256 of the OS-provided UUID, truncated to 16 hex chars) so the underlying hardware identifier is never sent in cleartext.

Sources by platform: macOS — IOPlatformUUID via ioreg -rd1 -c IOPlatformExpertDevice Linux — /etc/machine-id (or /var/lib/dbus/machine-id fallback) Windows — HKLM\SOFTWARE\Microsoft\Cryptography\MachineGuid

Returns an empty string when the source is unavailable; callers treat that the same as “no dedup hint” and the relay falls back to today’s behavior.

Functions§

hostname_or_unknown
Returns the OS-level hostname via gethostname(3), or "unknown" if the syscall fails or yields an empty value. Identical on CLI and desktop so the relay’s source_key dedup matches across both clients on the same Mac.
in_ssh_session
Returns true if the current process appears to be running inside an SSH session, based on the SSH_* environment variables OpenSSH’s sshd sets when forking a login shell. Suppresses browser auto-open and desktop handoff during cinch auth login.
self_source_key
Returns the source value used when this device pushes a clip.
stable_machine_id
Returns a stable, opaque identifier for this machine, or an empty string if no source is available. The value is suitable for sending to the relay (no raw hardware ID) and is consistent across CLI and desktop on the same machine.