Export a reset-permission utility

This will be reused for uninstall --delete-data.

Closes: #2314
Approved by: matthiasclasen
This commit is contained in:
Matthias Clasen
2018-11-14 01:22:56 -05:00
committed by Atomic Bot
parent 9ada2721de
commit ca109c14f8
2 changed files with 29 additions and 18 deletions

View File

@@ -94,30 +94,14 @@ remove_for_app (XdpDbusPermissionStore *store,
}
gboolean
flatpak_builtin_permission_reset (int argc, char **argv,
GCancellable *cancellable,
GError **error)
reset_permissions_for_app (const char *app_id,
GError **error)
{
g_autoptr(GOptionContext) context = NULL;
g_autoptr(GDBusConnection) session_bus = NULL;
XdpDbusPermissionStore *store = NULL;
const char *app_id;
int i;
g_auto(GStrv) tables = NULL;
context = g_option_context_new (_("APP_ID - Reset permissions for an app"));
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
if (!flatpak_option_context_parse (context, options, &argc, &argv,
FLATPAK_BUILTIN_FLAG_NO_DIR,
NULL, cancellable, error))
return FALSE;
if (argc != 2)
return usage_error (context, _("Wrong number of arguments"), error);
app_id = argv[1];
session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
if (session_bus == NULL)
return FALSE;
@@ -139,6 +123,30 @@ flatpak_builtin_permission_reset (int argc, char **argv,
return TRUE;
}
gboolean
flatpak_builtin_permission_reset (int argc, char **argv,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GOptionContext) context = NULL;
const char *app_id;
context = g_option_context_new (_("APP_ID - Reset permissions for an app"));
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
if (!flatpak_option_context_parse (context, options, &argc, &argv,
FLATPAK_BUILTIN_FLAG_NO_DIR,
NULL, cancellable, error))
return FALSE;
if (argc != 2)
return usage_error (context, _("Wrong number of arguments"), error);
app_id = argv[1];
return reset_permissions_for_app (app_id, error);
}
gboolean
flatpak_complete_permission_reset (FlatpakCompletion *completion)
{

View File

@@ -89,6 +89,9 @@ gboolean update_appstream (GPtrArray *dirs,
GError **error);
char ** get_permission_tables (XdpDbusPermissionStore *store);
gboolean reset_permissions_for_app (const char *app_id,
GError **error);
/* --columns handling */