[gnome-software/1722-flatpak-handle-more-well-known-filesystem-permissions: 4/5] app: Turn 'permissions' flags into a GsAppPermissions object
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1722-flatpak-handle-more-well-known-filesystem-permissions: 4/5] app: Turn 'permissions' flags into a GsAppPermissions object
- Date: Wed, 22 Jun 2022 20:27:15 +0000 (UTC)
commit 96fa7ad7b7f935f458057e4d2dde6df6ff5ad832
Author: Milan Crha <mcrha redhat com>
Date: Fri Jun 17 11:19:52 2022 +0200
app: Turn 'permissions' flags into a GsAppPermissions object
Modify also related parts, to avoid unbuildable sources.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1722
lib/gs-app.c | 60 +++++++++++++-----
lib/gs-app.h | 6 +-
plugins/epiphany/gs-plugin-epiphany.c | 5 +-
plugins/flatpak/gs-flatpak.c | 3 +-
src/gs-app-context-bar.c | 19 +++---
src/gs-safety-context-dialog.c | 114 ++++++++++++++++++++--------------
6 files changed, 131 insertions(+), 76 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index a4905efae..7889d1651 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -135,7 +135,7 @@ typedef struct
AsScreenshot *action_screenshot; /* (nullable) (owned) */
GCancellable *cancellable;
GsPluginAction pending_action;
- GsAppPermissionsFlags permissions;
+ GsAppPermissions *permissions;
gboolean is_update_downloaded;
GPtrArray *version_history; /* (element-type AsRelease) (nullable) (owned) */
GPtrArray *relations; /* (nullable) (element-type AsRelation) (owned) */
@@ -5328,7 +5328,7 @@ gs_app_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *
break;
}
case PROP_PERMISSIONS:
- g_value_set_flags (value, priv->permissions);
+ g_value_take_object (value, gs_app_dup_permissions (app));
break;
case PROP_RELATIONS:
g_value_take_boxed (value, gs_app_get_relations (app));
@@ -5456,7 +5456,7 @@ gs_app_set_property (GObject *object, guint prop_id, const GValue *value, GParam
gs_app_set_size_user_data (app, priv->size_user_data_type, g_value_get_uint64 (value));
break;
case PROP_PERMISSIONS:
- gs_app_set_permissions (app, g_value_get_flags (value));
+ gs_app_set_permissions (app, g_value_get_object (value));
break;
case PROP_RELATIONS:
gs_app_set_relations (app, g_value_get_boxed (value));
@@ -5538,6 +5538,7 @@ gs_app_finalize (GObject *object)
g_clear_object (&priv->content_rating);
g_clear_object (&priv->action_screenshot);
g_clear_object (&priv->update_permissions);
+ g_clear_object (&priv->permissions);
G_OBJECT_CLASS (gs_app_parent_class)->finalize (object);
}
@@ -5928,16 +5929,16 @@ gs_app_class_init (GsAppClass *klass)
/**
* GsApp:permissions
*
- * The permissions the app requires to run.
+ * The permissions the app requires to run, as a #GsAppPermissions object.
*
- * This is %GS_APP_PERMISSIONS_FLAGS_UNKNOWN if the permissions are unknown.
+ * This is %NULL, if the permissions are unknown.
*
- * Since: 41
+ * Since: 43
*/
obj_props[PROP_PERMISSIONS] =
- g_param_spec_flags ("permissions", NULL, NULL,
- GS_TYPE_APP_PERMISSIONS_FLAGS, GS_APP_PERMISSIONS_FLAGS_UNKNOWN,
- G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+ g_param_spec_object ("permissions", NULL, NULL,
+ GS_TYPE_APP_PERMISSIONS,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GsApp:relations: (nullable) (element-type AsRelation)
@@ -6316,24 +6317,53 @@ gs_app_subsume_metadata (GsApp *app, GsApp *donor)
}
}
-GsAppPermissionsFlags
-gs_app_get_permissions (GsApp *app)
+/**
+ * gs_app_dup_permissions:
+ * @app: a #GsApp
+ *
+ * Get a reference to the @app permissions. The returned value can
+ * be %NULL, when the app's permissions are unknown. Free the returned pointer,
+ * if not %NULL, with g_object_unref(), when no longer needed.
+ *
+ * Returns: (nullable) (transfer full): referenced #GsAppPermissions,
+ * or %NULL
+ *
+ * Since: 43
+ **/
+GsAppPermissions *
+gs_app_dup_permissions (GsApp *app)
{
GsAppPrivate *priv = gs_app_get_instance_private (app);
- g_return_val_if_fail (GS_IS_APP (app), GS_APP_PERMISSIONS_FLAGS_UNKNOWN);
- return priv->permissions;
+ g_autoptr(GMutexLocker) locker = NULL;
+ g_return_val_if_fail (GS_IS_APP (app), NULL);
+ locker = g_mutex_locker_new (&priv->mutex);
+ return priv->permissions ? g_object_ref (priv->permissions) : NULL;
}
+/**
+ * gs_app_set_permissions:
+ * @app: a #GsApp
+ * @permissions: (nullable) (transfer none): a #GsAppPermissions, or %NULL
+ *
+ * Set permissions for the @app. The @permissions is referenced,
+ * if not %NULL.
+ *
+ * Since: 43
+ **/
void
gs_app_set_permissions (GsApp *app,
- GsAppPermissionsFlags permissions)
+ GsAppPermissions *permissions)
{
GsAppPrivate *priv = gs_app_get_instance_private (app);
+ g_autoptr(GMutexLocker) locker = NULL;
g_return_if_fail (GS_IS_APP (app));
+ locker = g_mutex_locker_new (&priv->mutex);
if (priv->permissions == permissions)
return;
- priv->permissions = permissions;
+ g_clear_object (&priv->permissions);
+ if (permissions != NULL)
+ priv->permissions = g_object_ref (permissions);
gs_app_queue_notify (app, obj_props[PROP_PERMISSIONS]);
}
diff --git a/lib/gs-app.h b/lib/gs-app.h
index 56a5ff7bf..d78503c3e 100644
--- a/lib/gs-app.h
+++ b/lib/gs-app.h
@@ -491,10 +491,10 @@ gchar *gs_app_get_packaging_format (GsApp *app);
const gchar *gs_app_get_packaging_format_raw(GsApp *app);
void gs_app_subsume_metadata (GsApp *app,
GsApp *donor);
-GsAppPermissionsFlags
- gs_app_get_permissions (GsApp *app);
+GsAppPermissions *
+ gs_app_dup_permissions (GsApp *app);
void gs_app_set_permissions (GsApp *app,
- GsAppPermissionsFlags permissions);
+ GsAppPermissions *permissions);
GsAppPermissions *
gs_app_dup_update_permissions (GsApp *app);
void gs_app_set_update_permissions (GsApp *app,
diff --git a/plugins/epiphany/gs-plugin-epiphany.c b/plugins/epiphany/gs-plugin-epiphany.c
index 1f7e20072..f0b346bfb 100644
--- a/plugins/epiphany/gs-plugin-epiphany.c
+++ b/plugins/epiphany/gs-plugin-epiphany.c
@@ -455,6 +455,7 @@ refine_app (GsPluginEpiphany *self,
{ "stackedit.io", "Apache-2.0" },
{ "squoosh.app", "Apache-2.0" },
};
+ g_autoptr(GsAppPermissions) permissions = NULL;
g_return_if_fail (GS_IS_APP (app));
g_return_if_fail (uri != NULL);
@@ -487,7 +488,9 @@ refine_app (GsPluginEpiphany *self,
gs_app_set_size_download (app, GS_SIZE_TYPE_VALID, 0);
- gs_app_set_permissions (app, GS_APP_PERMISSIONS_FLAGS_NETWORK);
+ permissions = gs_app_permissions_new ();
+ gs_app_permissions_set_flags (permissions, GS_APP_PERMISSIONS_FLAGS_NETWORK);
+ gs_app_set_permissions (app, permissions);
if (gs_app_get_url (app, AS_URL_KIND_HOMEPAGE) == NULL)
gs_app_set_url (app, AS_URL_KIND_HOMEPAGE, url);
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index b4b1803ba..0dbb5f41a 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -2652,8 +2652,7 @@ gs_flatpak_set_app_metadata (GsFlatpak *self,
}
permissions = perms_from_metadata (kf);
- /* Use only flags, until the GsApp holds the GsAppPermissions */
- gs_app_set_permissions (app, gs_app_permissions_get_flags (permissions));
+ gs_app_set_permissions (app, permissions);
/* this is actually quite hard to achieve */
if (secure)
gs_app_add_kudo (app, GS_APP_KUDO_SANDBOXED_SECURE);
diff --git a/src/gs-app-context-bar.c b/src/gs-app-context-bar.c
index 31202f83c..2a21c870b 100644
--- a/src/gs-app-context-bar.c
+++ b/src/gs-app-context-bar.c
@@ -254,9 +254,10 @@ static void
update_safety_tile (GsAppContextBar *self)
{
const gchar *icon_name, *title, *css_class;
- g_autoptr(GPtrArray) descriptions = g_ptr_array_new_with_free_func (NULL);
g_autofree gchar *description = NULL;
- GsAppPermissionsFlags permissions;
+ g_autoptr(GPtrArray) descriptions = g_ptr_array_new_with_free_func (NULL);
+ g_autoptr(GsAppPermissions) permissions = NULL;
+ GsAppPermissionsFlags perm_flags = GS_APP_PERMISSIONS_FLAGS_UNKNOWN;
GtkStyleContext *context;
/* Treat everything as safe to begin with, and downgrade its safety
@@ -265,9 +266,11 @@ update_safety_tile (GsAppContextBar *self)
g_assert (self->app != NULL);
- permissions = gs_app_get_permissions (self->app);
+ permissions = gs_app_dup_permissions (self->app);
+ if (permissions != NULL)
+ perm_flags = gs_app_permissions_get_flags (permissions);
for (GsAppPermissionsFlags i = GS_APP_PERMISSIONS_FLAGS_NONE; i < GS_APP_PERMISSIONS_FLAGS_LAST; i
<<= 1) {
- if (!(permissions & i))
+ if (!(perm_flags & i))
continue;
switch (i) {
@@ -313,7 +316,7 @@ update_safety_tile (GsAppContextBar *self)
case GS_APP_PERMISSIONS_FLAGS_HOME_FULL:
case GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL:
/* Don’t add twice. */
- if (i == GS_APP_PERMISSIONS_FLAGS_HOME_FULL && (permissions &
GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL))
+ if (i == GS_APP_PERMISSIONS_FLAGS_HOME_FULL && (perm_flags &
GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL))
break;
add_to_safety_rating (&chosen_rating, descriptions,
@@ -325,7 +328,7 @@ update_safety_tile (GsAppContextBar *self)
case GS_APP_PERMISSIONS_FLAGS_HOME_READ:
case GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_READ:
/* Don’t add twice. */
- if (i == GS_APP_PERMISSIONS_FLAGS_HOME_READ && (permissions &
GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_READ))
+ if (i == GS_APP_PERMISSIONS_FLAGS_HOME_READ && (perm_flags &
GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_READ))
break;
add_to_safety_rating (&chosen_rating, descriptions,
@@ -393,7 +396,7 @@ update_safety_tile (GsAppContextBar *self)
* FIXME: We could do better by potentially adding a ‘trusted’ state
* to indicate that something is probably safe, but isn’t sandboxed.
* See https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1451 */
- if (permissions == GS_APP_PERMISSIONS_FLAGS_UNKNOWN &&
+ if (perm_flags == GS_APP_PERMISSIONS_FLAGS_UNKNOWN &&
gs_app_has_quirk (self->app, GS_APP_QUIRK_PROVENANCE))
add_to_safety_rating (&chosen_rating, descriptions,
SAFETY_SAFE,
@@ -401,7 +404,7 @@ update_safety_tile (GsAppContextBar *self)
* by the user’s distribution and is safe.
* It’s used in a context tile, so should be short. */
_("Reviewed by your distribution"));
- else if (permissions == GS_APP_PERMISSIONS_FLAGS_UNKNOWN)
+ else if (perm_flags == GS_APP_PERMISSIONS_FLAGS_UNKNOWN)
add_to_safety_rating (&chosen_rating, descriptions,
SAFETY_POTENTIALLY_UNSAFE,
/* Translators: This indicates that an application has been packaged
diff --git a/src/gs-safety-context-dialog.c b/src/gs-safety-context-dialog.c
index dbf42d06d..68b1a33d6 100644
--- a/src/gs-safety-context-dialog.c
+++ b/src/gs-safety-context-dialog.c
@@ -108,9 +108,10 @@ update_permissions_list (GsSafetyContextDialog *self)
{
const gchar *icon_name, *css_class;
g_autofree gchar *title = NULL;
- g_autoptr(GPtrArray) descriptions = g_ptr_array_new_with_free_func (NULL);
g_autofree gchar *description = NULL;
- GsAppPermissionsFlags permissions;
+ g_autoptr(GPtrArray) descriptions = g_ptr_array_new_with_free_func (NULL);
+ g_autoptr(GsAppPermissions) permissions = NULL;
+ GsAppPermissionsFlags perm_flags = GS_APP_PERMISSIONS_FLAGS_UNKNOWN;
GtkStyleContext *context;
GsContextDialogRowImportance chosen_rating;
@@ -124,7 +125,9 @@ update_permissions_list (GsSafetyContextDialog *self)
if (self->app == NULL)
return;
- permissions = gs_app_get_permissions (self->app);
+ permissions = gs_app_dup_permissions (self->app);
+ if (permissions != NULL)
+ perm_flags = gs_app_permissions_get_flags (permissions);
/* Handle unknown permissions. This means the application isn’t
* sandboxed, so we can only really base decisions on whether it was
@@ -132,7 +135,7 @@ update_permissions_list (GsSafetyContextDialog *self)
*
* FIXME: See the comment for GS_APP_PERMISSIONS_FLAGS_UNKNOWN in
* gs-app-context-bar.c. */
- if (permissions == GS_APP_PERMISSIONS_FLAGS_UNKNOWN) {
+ if (perm_flags == GS_APP_PERMISSIONS_FLAGS_UNKNOWN) {
add_permission_row (self->permissions_list, &chosen_rating,
!gs_app_has_quirk (self->app, GS_APP_QUIRK_PROVENANCE),
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_WARNING,
@@ -143,8 +146,14 @@ update_permissions_list (GsSafetyContextDialog *self)
_("Reviewed by your distribution"),
_("Application isn’t sandboxed but the distribution has checked that it
is not malicious"));
} else {
+ const GPtrArray *filesystem_read, *filesystem_full;
+
+ filesystem_read = gs_app_permissions_get_filesystem_read (permissions);
+ filesystem_full = gs_app_permissions_get_filesystem_full (permissions);
+
add_permission_row (self->permissions_list, &chosen_rating,
- (permissions & GS_APP_PERMISSIONS_FLAGS_NONE) != 0,
+ (perm_flags & GS_APP_PERMISSIONS_FLAGS_NONE) != 0 &&
+ filesystem_read == NULL && filesystem_full == NULL,
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_UNIMPORTANT,
"folder-documents-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
@@ -152,7 +161,7 @@ update_permissions_list (GsSafetyContextDialog *self)
_("App is fully sandboxed"),
NULL, NULL, NULL);
add_permission_row (self->permissions_list, &chosen_rating,
- (permissions & GS_APP_PERMISSIONS_FLAGS_NETWORK) != 0,
+ (perm_flags & GS_APP_PERMISSIONS_FLAGS_NETWORK) != 0,
/* This isn’t actually unimportant (network access can expand a local
* vulnerability into a remotely exploitable one), but it’s
* needed commonly enough that marking it as
@@ -167,7 +176,7 @@ update_permissions_list (GsSafetyContextDialog *self)
_("No Network Access"),
_("Cannot access the internet"));
add_permission_row (self->permissions_list, &chosen_rating,
- (permissions & GS_APP_PERMISSIONS_FLAGS_SYSTEM_BUS) != 0,
+ (perm_flags & GS_APP_PERMISSIONS_FLAGS_SYSTEM_BUS) != 0,
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_WARNING,
"emblem-system-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
@@ -175,7 +184,7 @@ update_permissions_list (GsSafetyContextDialog *self)
_("Can request data from system services"),
NULL, NULL, NULL);
add_permission_row (self->permissions_list, &chosen_rating,
- (permissions & GS_APP_PERMISSIONS_FLAGS_SESSION_BUS) != 0,
+ (perm_flags & GS_APP_PERMISSIONS_FLAGS_SESSION_BUS) != 0,
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_IMPORTANT,
"emblem-system-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
@@ -183,7 +192,7 @@ update_permissions_list (GsSafetyContextDialog *self)
_("Can request data from session services"),
NULL, NULL, NULL);
add_permission_row (self->permissions_list, &chosen_rating,
- (permissions & GS_APP_PERMISSIONS_FLAGS_DEVICES) != 0,
+ (perm_flags & GS_APP_PERMISSIONS_FLAGS_DEVICES) != 0,
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_WARNING,
"camera-photo-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
@@ -194,7 +203,7 @@ update_permissions_list (GsSafetyContextDialog *self)
_("No Device Access"),
_("Cannot access devices such as webcams or gaming controllers"));
add_permission_row (self->permissions_list, &chosen_rating,
- (permissions & GS_APP_PERMISSIONS_FLAGS_X11) != 0,
+ (perm_flags & GS_APP_PERMISSIONS_FLAGS_X11) != 0,
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_IMPORTANT,
"desktop-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
@@ -202,7 +211,7 @@ update_permissions_list (GsSafetyContextDialog *self)
_("Uses a legacy windowing system"),
NULL, NULL, NULL);
add_permission_row (self->permissions_list, &chosen_rating,
- (permissions & GS_APP_PERMISSIONS_FLAGS_ESCAPE_SANDBOX) != 0,
+ (perm_flags & GS_APP_PERMISSIONS_FLAGS_ESCAPE_SANDBOX) != 0,
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_IMPORTANT,
"dialog-warning-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
@@ -210,7 +219,7 @@ update_permissions_list (GsSafetyContextDialog *self)
_("Can acquire arbitrary permissions"),
NULL, NULL, NULL);
add_permission_row (self->permissions_list, &chosen_rating,
- (permissions & GS_APP_PERMISSIONS_FLAGS_SETTINGS) != 0,
+ (perm_flags & GS_APP_PERMISSIONS_FLAGS_SETTINGS) != 0,
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_WARNING,
"preferences-system-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
@@ -222,7 +231,7 @@ update_permissions_list (GsSafetyContextDialog *self)
* varying scopes of what’s readable/writable, and a difference between
* read-only and writable access. */
add_permission_row (self->permissions_list, &chosen_rating,
- (permissions & GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL) != 0,
+ (perm_flags & GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL) != 0,
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_IMPORTANT,
"folder-documents-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
@@ -230,8 +239,8 @@ update_permissions_list (GsSafetyContextDialog *self)
_("Can read and write all data on the file system"),
NULL, NULL, NULL);
add_permission_row (self->permissions_list, &chosen_rating,
- ((permissions & GS_APP_PERMISSIONS_FLAGS_HOME_FULL) != 0 &&
- !(permissions & GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL)),
+ ((perm_flags & GS_APP_PERMISSIONS_FLAGS_HOME_FULL) != 0 &&
+ !(perm_flags & GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL)),
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_IMPORTANT,
"user-home-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
@@ -239,8 +248,8 @@ update_permissions_list (GsSafetyContextDialog *self)
_("Can read and write all data in your home directory"),
NULL, NULL, NULL);
add_permission_row (self->permissions_list, &chosen_rating,
- ((permissions & GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_READ) != 0 &&
- !(permissions & GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL)),
+ ((perm_flags & GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_READ) != 0 &&
+ !(perm_flags & GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL)),
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_IMPORTANT,
"folder-documents-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
@@ -248,9 +257,9 @@ update_permissions_list (GsSafetyContextDialog *self)
_("Can read all data on the file system"),
NULL, NULL, NULL);
add_permission_row (self->permissions_list, &chosen_rating,
- ((permissions & GS_APP_PERMISSIONS_FLAGS_HOME_READ) != 0 &&
- !(permissions & (GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL |
- GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_READ))),
+ ((perm_flags & GS_APP_PERMISSIONS_FLAGS_HOME_READ) != 0 &&
+ !(perm_flags & (GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL |
+ GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_READ))),
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_IMPORTANT,
"user-home-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
@@ -258,9 +267,9 @@ update_permissions_list (GsSafetyContextDialog *self)
_("Can read all data in your home directory"),
NULL, NULL, NULL);
add_permission_row (self->permissions_list, &chosen_rating,
- ((permissions & GS_APP_PERMISSIONS_FLAGS_DOWNLOADS_FULL) != 0 &&
- !(permissions & (GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL |
- GS_APP_PERMISSIONS_FLAGS_HOME_FULL))),
+ ((perm_flags & GS_APP_PERMISSIONS_FLAGS_DOWNLOADS_FULL) != 0 &&
+ !(perm_flags & (GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL |
+ GS_APP_PERMISSIONS_FLAGS_HOME_FULL))),
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_WARNING,
"folder-download-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
@@ -268,38 +277,49 @@ update_permissions_list (GsSafetyContextDialog *self)
_("Can read and write all data in your downloads directory"),
NULL, NULL, NULL);
add_permission_row (self->permissions_list, &chosen_rating,
- ((permissions & GS_APP_PERMISSIONS_FLAGS_DOWNLOADS_READ) != 0 &&
- !(permissions & (GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL |
- GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_READ |
- GS_APP_PERMISSIONS_FLAGS_HOME_FULL |
- GS_APP_PERMISSIONS_FLAGS_HOME_READ))),
+ ((perm_flags & GS_APP_PERMISSIONS_FLAGS_DOWNLOADS_READ) != 0 &&
+ !(perm_flags & (GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL |
+ GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_READ |
+ GS_APP_PERMISSIONS_FLAGS_HOME_FULL |
+ GS_APP_PERMISSIONS_FLAGS_HOME_READ))),
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_WARNING,
"folder-download-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
_("Download Folder Read Access"),
_("Can read all data in your downloads directory"),
NULL, NULL, NULL);
- add_permission_row (self->permissions_list, &chosen_rating,
- ((permissions & GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_OTHER) != 0 &&
- !(permissions & (GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL |
- GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_READ |
- GS_APP_PERMISSIONS_FLAGS_HOME_FULL |
- GS_APP_PERMISSIONS_FLAGS_HOME_READ))),
- GS_CONTEXT_DIALOG_ROW_IMPORTANCE_WARNING,
- "folder-documents-symbolic",
- /* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
- _("Access arbitrary files"),
- _("Can access arbitrary files on the file system"),
- NULL, NULL, NULL);
+
+ for (guint i = 0; filesystem_read != NULL && i < filesystem_read->len; i++) {
+ const gchar *fs_title = g_ptr_array_index (filesystem_read, i);
+ add_permission_row (self->permissions_list, &chosen_rating,
+ TRUE,
+ GS_CONTEXT_DIALOG_ROW_IMPORTANCE_WARNING,
+ "folder-documents-symbolic",
+ fs_title,
+ _("Can read all data in the directory"),
+ NULL, NULL, NULL);
+ }
+
+ for (guint i = 0; filesystem_full != NULL && i < filesystem_full->len; i++) {
+ const gchar *fs_title = g_ptr_array_index (filesystem_full, i);
+ add_permission_row (self->permissions_list, &chosen_rating,
+ TRUE,
+ GS_CONTEXT_DIALOG_ROW_IMPORTANCE_WARNING,
+ "folder-documents-symbolic",
+ fs_title,
+ _("Can read and write all data in the directory"),
+ NULL, NULL, NULL);
+ }
add_permission_row (self->permissions_list, &chosen_rating,
- !(permissions & (GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL |
- GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_READ |
- GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_OTHER |
- GS_APP_PERMISSIONS_FLAGS_HOME_FULL |
- GS_APP_PERMISSIONS_FLAGS_HOME_READ |
- GS_APP_PERMISSIONS_FLAGS_DOWNLOADS_FULL |
- GS_APP_PERMISSIONS_FLAGS_DOWNLOADS_READ)),
+ !(perm_flags & (GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_FULL |
+ GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_READ |
+ GS_APP_PERMISSIONS_FLAGS_FILESYSTEM_OTHER |
+ GS_APP_PERMISSIONS_FLAGS_HOME_FULL |
+ GS_APP_PERMISSIONS_FLAGS_HOME_READ |
+ GS_APP_PERMISSIONS_FLAGS_DOWNLOADS_FULL |
+ GS_APP_PERMISSIONS_FLAGS_DOWNLOADS_READ)) &&
+ filesystem_read == NULL && filesystem_full == NULL,
GS_CONTEXT_DIALOG_ROW_IMPORTANCE_UNIMPORTANT,
"folder-documents-symbolic",
/* Translators: This refers to permissions (for example, from flatpak)
which an app requests from the user. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]