mirror of
https://github.com/flatpak/flatpak.git
synced 2026-05-14 03:24:50 -04:00
Fix a thinko in the permission commands
Better to only call g_dir_close() if dir isn't NULL. Take this opportunity to move the function to utils, instead of carrying 4 identical copies. Closes: https://github.com/flatpak/flatpak/issues/2130 Closes: #2133 Approved by: alexlarsson
This commit is contained in:
committed by
Atomic Bot
parent
9091749a27
commit
8f9aa2f35f
@@ -32,6 +32,7 @@
|
||||
#include "flatpak-permission-dbus-generated.h"
|
||||
|
||||
#include "flatpak-builtins.h"
|
||||
#include "flatpak-builtins-utils.h"
|
||||
#include "flatpak-table-printer.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-run-private.h"
|
||||
@@ -40,33 +41,6 @@ static GOptionEntry options[] = {
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static char **
|
||||
get_permission_tables (XdpDbusPermissionStore *store)
|
||||
{
|
||||
g_autofree char *path = NULL;
|
||||
GDir *dir;
|
||||
const char *name;
|
||||
GPtrArray *tables = NULL;
|
||||
|
||||
tables = g_ptr_array_new ();
|
||||
|
||||
path = g_build_filename (g_get_user_data_dir (), "flatpak/db", NULL);
|
||||
dir = g_dir_open (path, 0, NULL);
|
||||
if (dir != NULL)
|
||||
{
|
||||
while ((name = g_dir_read_name (dir)) != NULL)
|
||||
{
|
||||
g_ptr_array_add (tables, g_strdup (name));
|
||||
}
|
||||
}
|
||||
|
||||
g_dir_close (dir);
|
||||
|
||||
g_ptr_array_add (tables, NULL);
|
||||
|
||||
return (char **) g_ptr_array_free (tables, FALSE);
|
||||
}
|
||||
|
||||
static char **
|
||||
get_ids_for_table (XdpDbusPermissionStore *store,
|
||||
const char *table)
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "flatpak-permission-dbus-generated.h"
|
||||
|
||||
#include "flatpak-builtins.h"
|
||||
#include "flatpak-builtins-utils.h"
|
||||
#include "flatpak-table-printer.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-run-private.h"
|
||||
@@ -40,33 +41,6 @@ static GOptionEntry options[] = {
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static char **
|
||||
get_permission_tables (XdpDbusPermissionStore *store)
|
||||
{
|
||||
g_autofree char *path = NULL;
|
||||
GDir *dir;
|
||||
const char *name;
|
||||
GPtrArray *tables = NULL;
|
||||
|
||||
tables = g_ptr_array_new ();
|
||||
|
||||
path = g_build_filename (g_get_user_data_dir (), "flatpak/db", NULL);
|
||||
dir = g_dir_open (path, 0, NULL);
|
||||
if (dir != NULL)
|
||||
{
|
||||
while ((name = g_dir_read_name (dir)) != NULL)
|
||||
{
|
||||
g_ptr_array_add (tables, g_strdup (name));
|
||||
}
|
||||
}
|
||||
|
||||
g_dir_close (dir);
|
||||
|
||||
g_ptr_array_add (tables, NULL);
|
||||
|
||||
return (char **) g_ptr_array_free (tables, FALSE);
|
||||
}
|
||||
|
||||
static char **
|
||||
get_ids_for_table (XdpDbusPermissionStore *store,
|
||||
const char *table)
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "flatpak-permission-dbus-generated.h"
|
||||
|
||||
#include "flatpak-builtins.h"
|
||||
#include "flatpak-builtins-utils.h"
|
||||
#include "flatpak-table-printer.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-run-private.h"
|
||||
@@ -40,33 +41,6 @@ static GOptionEntry options[] = {
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static char **
|
||||
get_permission_tables (XdpDbusPermissionStore *store)
|
||||
{
|
||||
g_autofree char *path = NULL;
|
||||
GDir *dir;
|
||||
const char *name;
|
||||
GPtrArray *tables = NULL;
|
||||
|
||||
tables = g_ptr_array_new ();
|
||||
|
||||
path = g_build_filename (g_get_user_data_dir (), "flatpak/db", NULL);
|
||||
dir = g_dir_open (path, 0, NULL);
|
||||
if (dir != NULL)
|
||||
{
|
||||
while ((name = g_dir_read_name (dir)) != NULL)
|
||||
{
|
||||
g_ptr_array_add (tables, g_strdup (name));
|
||||
}
|
||||
}
|
||||
|
||||
g_dir_close (dir);
|
||||
|
||||
g_ptr_array_add (tables, NULL);
|
||||
|
||||
return (char **) g_ptr_array_free (tables, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
remove_for_app (XdpDbusPermissionStore *store,
|
||||
const char *table,
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "flatpak-permission-dbus-generated.h"
|
||||
|
||||
#include "flatpak-builtins.h"
|
||||
#include "flatpak-builtins-utils.h"
|
||||
#include "flatpak-table-printer.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-run-private.h"
|
||||
@@ -40,33 +41,6 @@ static GOptionEntry options[] = {
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static char **
|
||||
get_permission_tables (XdpDbusPermissionStore *store)
|
||||
{
|
||||
g_autofree char *path = NULL;
|
||||
GDir *dir;
|
||||
const char *name;
|
||||
GPtrArray *tables = NULL;
|
||||
|
||||
tables = g_ptr_array_new ();
|
||||
|
||||
path = g_build_filename (g_get_user_data_dir (), "flatpak/db", NULL);
|
||||
dir = g_dir_open (path, 0, NULL);
|
||||
if (dir != NULL)
|
||||
{
|
||||
while ((name = g_dir_read_name (dir)) != NULL)
|
||||
{
|
||||
g_ptr_array_add (tables, g_strdup (name));
|
||||
}
|
||||
}
|
||||
|
||||
g_dir_close (dir);
|
||||
|
||||
g_ptr_array_add (tables, NULL);
|
||||
|
||||
return (char **) g_ptr_array_free (tables, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
list_for_app (XdpDbusPermissionStore *store,
|
||||
const char *table,
|
||||
|
||||
@@ -555,3 +555,29 @@ update_appstream (GPtrArray *dirs,
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char **
|
||||
get_permission_tables (XdpDbusPermissionStore *store)
|
||||
{
|
||||
g_autofree char *path = NULL;
|
||||
GDir *dir;
|
||||
const char *name;
|
||||
GPtrArray *tables = NULL;
|
||||
|
||||
tables = g_ptr_array_new ();
|
||||
|
||||
path = g_build_filename (g_get_user_data_dir (), "flatpak/db", NULL);
|
||||
dir = g_dir_open (path, 0, NULL);
|
||||
if (dir != NULL)
|
||||
{
|
||||
while ((name = g_dir_read_name (dir)) != NULL)
|
||||
{
|
||||
g_ptr_array_add (tables, g_strdup (name));
|
||||
}
|
||||
g_dir_close (dir);
|
||||
}
|
||||
|
||||
g_ptr_array_add (tables, NULL);
|
||||
|
||||
return (char **) g_ptr_array_free (tables, FALSE);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "libglnx/libglnx.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-dir-private.h"
|
||||
#include "flatpak-permission-dbus-generated.h"
|
||||
|
||||
/* Appstream data expires after a day */
|
||||
#define FLATPAK_APPSTREAM_TTL 86400
|
||||
@@ -63,4 +64,7 @@ gboolean update_appstream (GPtrArray *dirs,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
char ** get_permission_tables (XdpDbusPermissionStore *store);
|
||||
|
||||
|
||||
#endif /* __FLATPAK_BUILTINS_UTILS_H__ */
|
||||
|
||||
Reference in New Issue
Block a user