Skip to content

ubus: propagate _luci_bg=1 query flag as session/access notouch - #39

Open
micpf wants to merge 1 commit into
openwrt:masterfrom
micpf:idle-timeout-luci-bg
Open

ubus: propagate _luci_bg=1 query flag as session/access notouch#39
micpf wants to merge 1 commit into
openwrt:masterfrom
micpf:idle-timeout-luci-bg

Conversation

@micpf

@micpf micpf commented Aug 7, 2026

Copy link
Copy Markdown

Problem

LuCI's Poll callbacks issue XHRs every few seconds and each XHR goes through /ubus/. rpcd's session/access refreshes the session idle timer on every call, so option sessiontime in /etc/config/rpcd never fires while any LuCI page is open. See the rpcd PR (openwrt/rpcd#39) for the full write-up.

Fix

Recognise a _luci_bg=1 query parameter on /ubus/ and forward the hint to rpcd as the new notouch boolean on session/access.

Two paths reach session/access:

  1. uhttpd's internal permission check via uh_ubus_allowed(). Pass notouch=1 into the request when the flag is set.
  2. Direct client invocation – LuCI's per-page callSessionAccess() ACL probes go this route. Inject notouch=1 into the RPC's own args in uh_ubus_send_request() when the caller did not already set it, so the semantics match regardless of how the browser reaches session/access.

The injected notouch key is a plain blobmsg attribute that any other ubus object ignores via ordinary policy handling, so unrelated services are unaffected. Requests without _luci_bg=1 are byte-for-byte identical to before.

Dependencies

On older rpcd the notouch blob key is silently ignored, so it's safe to land this before the LuCI part.

LuCI's Poll callbacks issue XHRs continuously (typically every few
seconds) and each XHR goes through the /ubus/ endpoint. rpcd's
session/access ubus method refreshes the session idle timer on every
call, so the "sessiontime" idle timeout documented in /etc/config/rpcd
is never reached and the session lives forever.

Give LuCI a way to mark those background requests: when the request
URL carries "_luci_bg=1" (or "&_luci_bg=1"), forward the hint to rpcd
as the new "notouch" boolean on session/access.

Two paths reach session/access:

  * uhttpd's internal permission check via uh_ubus_allowed(). Pass the
    hint into the request when the flag is set.

  * The JSON-RPC client can also invoke session/access directly (LuCI's
    per-page callSessionAccess() ACL probes go this route). Inject the
    hint into the RPC's own args in uh_ubus_send_request() when the
    caller did not already set it, so the semantics match regardless
    of how the browser reaches session/access.

The injected "notouch" key is a plain blobmsg attribute that any other
ubus object ignores via ordinary policy handling, so unrelated
services are unaffected. Requests without the query parameter behave
exactly as before, so behaviour is unchanged for callers that don't
opt in.

Depends on rpcd support for the "notouch" argument.

Signed-off-by: Michael Pfeifroth <micpf@westermo.com>
@jow-

jow- commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

I don't like the design, it's essentially hacking a LuCI specifc special case into the ubus HTTP gateway. My gut feeling is that this either should be an HTTP header (no query string, no ubus method call arg) or maybe even a property of the ubus ACL, shifting control entirely to the rpcd side and avoiding the need to expose any of that to uhttpd or LuCI while also paving the way for other potential flags in the future.

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