mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-04-20 06:10:41 +02:00
eis: differ between eis vs ei property updates
If we have libreis setting properties on the connection, this looks to the server like they're coming from the ei connection. But libreis is a different context than the libei context later, so when libei initializes, it may set the same properties again. Since the libei context doesn't know about the properties, it can't filter internally and will send the properties to the server. So we need to do all the permissions checks in the server to make sure we don't overwrite values that we're not allowed to overwrite. There are no real restrictions on changing properties from within the eis implementation (other than not being able to set the reserved namespaces). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
b77b9dc059
commit
1ae193160e
3 changed files with 38 additions and 13 deletions
|
|
@ -545,13 +545,7 @@ client_msg_property(struct eis_client *client,
|
|||
const char *name, const char *value,
|
||||
uint32_t permissions)
|
||||
{
|
||||
struct eis_property *prop = eis_property_find(client, name);
|
||||
|
||||
/* The client cannot increase property permissions */
|
||||
if (prop)
|
||||
permissions = prop->permissions & permissions;
|
||||
|
||||
eis_property_update(client, name, value, permissions);
|
||||
eis_property_update_from_client(client, name, value, permissions);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,11 +205,8 @@ struct eis_property *
|
|||
eis_property_unref(struct eis_property *prop);
|
||||
|
||||
void
|
||||
eis_property_update(struct eis_client *client, const char *name,
|
||||
const char *value, uint32_t permissions);
|
||||
|
||||
struct eis_property *
|
||||
eis_property_find(struct eis_client *client, const char *name);
|
||||
eis_property_update_from_client(struct eis_client *client, const char *name,
|
||||
const char *value, uint32_t permissions);
|
||||
|
||||
void
|
||||
eis_init_object(struct eis *eis, struct object *parent);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,12 @@ static
|
|||
OBJECT_IMPLEMENT_CREATE(eis_property);
|
||||
OBJECT_IMPLEMENT_UNREF(eis_property);
|
||||
|
||||
struct eis_property *
|
||||
#define _PERM(p_, mask_) (((p_) & (mask_)) == (mask_))
|
||||
#define PERM_R(p_) _PERM((p_)->permissions, EIS_PROPERTY_PERM_READ)
|
||||
#define PERM_RW(p_) _PERM((p_)->permissions, EIS_PROPERTY_PERM_READ|EIS_PROPERTY_PERM_WRITE)
|
||||
#define PERM_RD(p_) _PERM((p_)->permissions, EIS_PROPERTY_PERM_READ|EIS_PROPERTY_PERM_DELETE)
|
||||
|
||||
static struct eis_property *
|
||||
eis_property_find(struct eis_client *client, const char *name)
|
||||
{
|
||||
struct eis_property *prop;
|
||||
|
|
@ -93,6 +98,35 @@ eis_property_change(struct eis_client *client, struct eis_property *prop,
|
|||
}
|
||||
|
||||
void
|
||||
eis_property_update_from_client(struct eis_client *client, const char *name,
|
||||
const char *value, uint32_t permissions)
|
||||
{
|
||||
|
||||
/* Client can't set eis. namespace properties */
|
||||
if (strstartswith(name, "eis."))
|
||||
return;
|
||||
|
||||
struct eis_property *prop = eis_property_find(client, name);
|
||||
if (!prop) {
|
||||
eis_client_property_new(client, name, value, permissions);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PERM_RW(prop))
|
||||
return;
|
||||
|
||||
if (!value) {
|
||||
if (PERM_RD(prop))
|
||||
eis_property_delete(client, prop);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Permissions can only be lowered by the client */
|
||||
permissions = prop->permissions & permissions;
|
||||
eis_property_change(client, prop, value, permissions);
|
||||
}
|
||||
|
||||
static void
|
||||
eis_property_update(struct eis_client *client, const char *name,
|
||||
const char *value, uint32_t permissions)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue