Skip to content

context: Emit valid option names for D-Bus name policies - #6807

Merged
swick merged 1 commit into
flatpak:mainfrom
AbhinavMir:bus-policy-to-args-option-names
Sep 18, 2026
Merged

swick merged 1 commit into
flatpak:mainfrom
AbhinavMir:bus-policy-to-args-option-names

Conversation

@AbhinavMir

Copy link
Copy Markdown
Contributor

Comment thread common/flatpak-context.c Outdated
Comment on lines +1300 to +1301
/* There is no command-line option for FLATPAK_POLICY_SEE */
return NULL;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do FLATPAK_POLICY_NONE and FLATPAK_POLICY_SEE have different results? I would expect them to either both be --[system-]no-talk-name, or both be the absence of an option.

As a general style thing, when we convert an enum to some derived fact, it's often best to use a switch, because that way the compiler will warn us if we miss a possibility. Something like this:

switch (policy)
  {
  case FLATPAK_POLICY_TALK:
    return "talk-name";

  case FLATPAK_POLICY_OWN:
    return "own-name";

  case FLATPAK_POLICY_NONE:
  case FLATPAK_POLICY_SEE:
    return "no-talk-name"; /* or maybe NULL, I'm not sure which would be better */

  default:
    g_return_val_if_reached ("no-talk-name"); /* or maybe NULL */
  }

flatpak_context_to_args() built the D-Bus name options from
flatpak_policy_to_string(). That function gives the values used in the
[Session Bus Policy] and [System Bus Policy] metadata groups. Two of
them, "none" and "see", are not command-line options. A context that
contained such a policy gave --none-name= and --system-none-name=.

flatpak-run(1) writes these arguments to the [Instance] extra-args of
/.flatpak-info. flatpak-portal gives them back to flatpak(1) when a
sandboxed app calls flatpak-spawn(1). flatpak(1) then rejected the whole
command line with "Unknown option --none-name=...", so --no-talk-name
and --system-no-talk-name broke flatpak-spawn(1).

Map each policy to the option that sets it: --no-talk-name for
FLATPAK_POLICY_NONE, --talk-name for FLATPAK_POLICY_TALK, and --own-name
for FLATPAK_POLICY_OWN. FLATPAK_POLICY_SEE has no command-line option,
so emit nothing for it. It cannot occur here: the only caller serializes
a context that comes from the command line.
@AbhinavMir
AbhinavMir force-pushed the bus-policy-to-args-option-names branch from fec0e3f to 5bc32eb Compare August 26, 2026 18:38
@swick

swick commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

@smcv want to take another look?

@swick
swick added this pull request to the merge queue Sep 18, 2026
Merged via the queue into flatpak:main with commit 7c764d2 Sep 18, 2026
11 checks passed
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.

3 participants