Skip to content

Conversation

@JakobDev
Copy link

Flatpak has a Bug that Apps didn't start when you give them Permission to talk to a invalid D-Dbus name (flatpak/flatpak#4940). Until this is fixed, it is better to block writing invalid D-Bus names. If someone does accidental use a invalid D-Bus name for global and ignore the warning, no Flatpak App will start until the problem is solved with the Flatpak cli or the overrides file is deleted.

const {FlatsealOverrideStatus} = imports.models.overrideStatus;

/* https://dbus.freedesktop.org/doc/dbus-specification.html */
const EXP = /^(([A-Z]|[a-z]|[0-9]|_|-)+)(\.(([A-Z]|[a-z]|[0-9]|_|-)+))+(\.\*){0,1}$/;

Choose a reason for hiding this comment

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

  • hyphens are not allowed
  • regex can be simplified (([A-Z]|[a-z]) -> ([A-Za-z]))
  • names must not start with an digit
Suggested change
const EXP = /^(([A-Z]|[a-z]|[0-9]|_|-)+)(\.(([A-Z]|[a-z]|[0-9]|_|-)+))+(\.\*){0,1}$/;
const EXP = /^([A-Za-z_][A-Za-z0-9_]+)(\.[A-Za-z_][A-Za-z0-9_]+)+(\.\*)?$/;

(untested suggestion)

Copy link
Author

Choose a reason for hiding this comment

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

This RegEx is not from me. It is already used in Flatseal.

/* https://dbus.freedesktop.org/doc/dbus-specification.html */
const EXP = /^(([A-Z]|[a-z]|[0-9]|_|-)+)(\.(([A-Z]|[a-z]|[0-9]|_|-)+))+(\.\*){0,1}$/;

It is used to display the valid icon in the D-Bus edit field. If it is wrong, it should be fixed in both places.

Copy link
Contributor

Choose a reason for hiding this comment

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

hypens are allowed, but just on the last segment of the name

const group = this.constructor.getGroup();
Object.entries(this._overrides).forEach(([key, value]) => {
keyFile.set_value(group, key, value);
if (this._expression.test(key)) {
Copy link
Owner

Choose a reason for hiding this comment

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

For consistency, instead of doing this here, can you move this to updateFromProxyProperty? Like I do it here https://github.com/tchx84/Flatseal/blob/master/src/models/variables.js#L86

const {FlatsealOverrideStatus} = imports.models.overrideStatus;

/* https://dbus.freedesktop.org/doc/dbus-specification.html */
const EXP = /^(([A-Z]|[a-z]|[0-9]|_|-)+)(\.(([A-Z]|[a-z]|[0-9]|_|-)+))+(\.\*){0,1}$/;
Copy link
Owner

Choose a reason for hiding this comment

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

To make this better than I currently do it, how about we officially move the definition of this esoteric regexp to this model (e.g. var BUS_NAME_REGEX = ...), and then we import this constant here https://github.com/tchx84/Flatseal/blob/master/src/widgets/busNameRow.js#L28 (instead of duplicating it)

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.

4 participants