Skip to content

new(bus): allow exposing clight API on system bus via use_system_bus - #329

Open
anton-sugl wants to merge 1 commit into
FedeDP:masterfrom
anton-sugl:pr/system-bus-config
Open

anton-sugl wants to merge 1 commit into
FedeDP:masterfrom
anton-sugl:pr/system-bus-config

Conversation

@anton-sugl

Copy link
Copy Markdown

Allow exposing clight API on system bus

Adds an opt-in switch to register org.clight.clight on the system bus instead of the user bus,
for setups without a user session (e.g. embedded devices running clight as a system service).
Default behaviour is unchanged.

Usage

  • config: use_system_bus = true; or cmdline: --system-bus
  • -DENABLE_SYSTEM_BUS=ON (default OFF) installs a D-Bus policy (clight group may call clight),
    a system D-Bus activation file, a systemd unit and a sysusers.d entry creating the clight group.

Implementation

  • bus.c: the user bus is connected lazily in get_user_bus(), since config is not yet parsed in
    module_pre_start(). In system-bus mode it returns a new reference to the system bus connection,
    which is polled only once; interface.c drops its reference instead of closing the shared connection.
  • In system-bus mode the org.freedesktop.ScreenSaver API (and its fallback bus monitor) is not
    exposed, as it only makes sense in a user session. clight's own Inhibit method keeps working.
  • NoAutoCalib and NoSmooth are marked SD_BUS_VTABLE_UNPRIVILEGED, like IncBl/DecBl/Pause
    already are, so that non-root clients (allowed by the D-Bus policy) can toggle them on the system bus.
    On the user bus this changes nothing, as sd-bus does no per-member access checks there.

Notes

  • Modules needing a graphical session (gamma, dpms, dimmer, screen) may not work when clight runs as
    a system service; documented in the sample config.

Testing

Built with the CI dependencies (Ubuntu, libmodule 5.0.1), no new warnings. Runtime-tested with private
system and session dbus-daemons plus Clightd:

  • default / use_system_bus = false: name owned on user bus only (unchanged)
  • use_system_bus = true and --system-bus: name owned on system bus only, API calls work there
  • unprivileged caller on system bus can set NoSmooth/NoAutoCalib, gets "Access denied" on others
  • clean shutdown on SIGTERM in both modes
  • install files only installed with -DENABLE_SYSTEM_BUS=ON

🤖 Generated with Claude Code

Signed-off-by: Anton S-G <257776033+anton-sugl@users.noreply.github.com>
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.

1 participant