Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[usb-moded] Use group from configuration. JB#49458
Use group from configuration to test if user is allowed to use dynamic
mode.

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
  • Loading branch information
Tomin1 committed May 29, 2020
1 parent 422b845 commit 8a5825a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/usb_moded.c
Expand Up @@ -357,6 +357,7 @@ bool usbmoded_is_mode_permitted(const char *modename, uid_t uid)

bool allowed = true;
modedata_t *data = 0;
char *group = 0;

/* all modes are allowed for root */
if( uid == 0 )
Expand All @@ -366,11 +367,14 @@ bool usbmoded_is_mode_permitted(const char *modename, uid_t uid)
if( !(data = usbmoded_dup_modedata(modename)) )
goto EXIT;

/* dynamic modes are allowed for device owner and denied for others */
allowed = sailfish_access_control_hasgroup(uid, "sailfish-system");
/* dynamic modes are allowed based on group,
* which defaults to sailfish-system meaning device owner only */
group = config_get_group_for_mode(modename);
allowed = sailfish_access_control_hasgroup(uid, group);

EXIT:

g_free(group);
modedata_free(data);

return allowed;
Expand Down

0 comments on commit 8a5825a

Please sign in to comment.