Merge branch 'inclusive-terminology' into 'master'

tree-wide: Replace usages of whitelist/blacklist

See merge request pwithnall/malcontent!72
This commit is contained in:
Philip Withnall 2020-06-10 08:55:23 +00:00
commit f97b9e0c64
9 changed files with 135 additions and 135 deletions

View File

@ -61,7 +61,7 @@ set parental controls policies for users.
```
$ # This sets the parental controls policy for user philip to allow no \\
installation of apps with anything more than none for realistic violence, \\
and to blacklist running the org.freedesktop.Bustle flatpak:
and to blocklist running the org.freedesktop.Bustle flatpak:
$ malcontent-client set philip \\
violence-realistic=none \\
app/org.freedesktop.Bustle/x86_64/stable

View File

@ -24,8 +24,8 @@
The string list contains flatpak application IDs (containing at least one
dot and no leading slash) and absolute binary paths (containing a leading
slash). The boolean value indicates whether this is a whitelist (true) or
blacklist (false).
slash). The boolean value indicates whether this is an allowlist (true)
or blocklist (false).
-->
<property name="AppFilter" type="(bas)" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue"

View File

@ -64,7 +64,7 @@ struct _MctRestrictApplicationsSelector
GListStore *apps; /* (owned) */
GAppInfoMonitor *app_info_monitor; /* (owned) */
gulong app_info_monitor_changed_id;
GHashTable *blacklisted_apps; /* (owned) (element-type GAppInfo) */
GHashTable *blocklisted_apps; /* (owned) (element-type GAppInfo) */
MctAppFilter *app_filter; /* (owned) */
@ -149,7 +149,7 @@ mct_restrict_applications_selector_dispose (GObject *object)
{
MctRestrictApplicationsSelector *self = (MctRestrictApplicationsSelector *)object;
g_clear_pointer (&self->blacklisted_apps, g_hash_table_unref);
g_clear_pointer (&self->blocklisted_apps, g_hash_table_unref);
g_clear_object (&self->apps);
if (self->app_info_monitor != NULL && self->app_info_monitor_changed_id != 0)
@ -237,7 +237,7 @@ mct_restrict_applications_selector_init (MctRestrictApplicationsSelector *self)
self,
NULL);
self->blacklisted_apps = g_hash_table_new_full (g_direct_hash,
self->blocklisted_apps = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
g_object_unref,
NULL);
@ -266,18 +266,18 @@ on_switch_active_changed_cb (GtkSwitch *s,
{
gboolean removed;
g_debug ("Removing %s from blacklisted apps", g_app_info_get_id (app));
g_debug ("Removing %s from blocklisted apps", g_app_info_get_id (app));
removed = g_hash_table_remove (self->blacklisted_apps, app);
removed = g_hash_table_remove (self->blocklisted_apps, app);
g_assert (removed);
}
else
{
gboolean added;
g_debug ("Blacklisting %s", g_app_info_get_id (app));
g_debug ("Blocklisting %s", g_app_info_get_id (app));
added = g_hash_table_add (self->blacklisted_apps, g_object_ref (app));
added = g_hash_table_add (self->blocklisted_apps, g_object_ref (app));
g_assert (added);
}
@ -345,9 +345,9 @@ create_row_for_app_cb (gpointer item,
g_object_set_data_full (G_OBJECT (w), "GAppInfo", g_object_ref (app), g_object_unref);
if (allowed)
g_hash_table_remove (self->blacklisted_apps, app);
g_hash_table_remove (self->blocklisted_apps, app);
else
g_hash_table_add (self->blacklisted_apps, g_object_ref (app));
g_hash_table_add (self->blocklisted_apps, g_object_ref (app));
g_signal_connect (w, "notify::active", G_CALLBACK (on_switch_active_changed_cb), self);
@ -427,7 +427,7 @@ reload_apps (MctRestrictApplicationsSelector *self)
g_str_has_prefix (g_app_info_get_id (app), "eos-link") ||
/* FIXME: Only list flatpak apps and apps with X-Parental-Controls
* key set for now; we really need a system-wide MAC to be able to
* reliably support blacklisting system programs. */
* reliably support blocklisting system programs. */
(!g_desktop_app_info_has_key (G_DESKTOP_APP_INFO (app), "X-Flatpak") &&
!g_desktop_app_info_has_key (G_DESKTOP_APP_INFO (app), "X-Parental-Controls")) ||
/* Web browsers are special cased */
@ -587,7 +587,7 @@ mct_restrict_applications_selector_build_app_filter (MctRestrictApplicationsSele
g_return_if_fail (MCT_IS_RESTRICT_APPLICATIONS_SELECTOR (self));
g_return_if_fail (builder != NULL);
g_hash_table_iter_init (&iter, self->blacklisted_apps);
g_hash_table_iter_init (&iter, self->blocklisted_apps);
while (g_hash_table_iter_next (&iter, (gpointer) &app, NULL))
{
g_autofree gchar *flatpak_id = NULL;
@ -602,12 +602,12 @@ mct_restrict_applications_selector_build_app_filter (MctRestrictApplicationsSele
if (!flatpak_ref)
{
g_warning ("Skipping blacklisting Flatpak ID %s due to it not being installed", flatpak_id);
g_warning ("Skipping blocklisting Flatpak ID %s due to it not being installed", flatpak_id);
continue;
}
g_debug ("\t\t → Blacklisting Flatpak ref: %s", flatpak_ref);
mct_app_filter_builder_blacklist_flatpak_ref (builder, flatpak_ref);
g_debug ("\t\t → Blocklisting Flatpak ref: %s", flatpak_ref);
mct_app_filter_builder_blocklist_flatpak_ref (builder, flatpak_ref);
}
else
{
@ -616,12 +616,12 @@ mct_restrict_applications_selector_build_app_filter (MctRestrictApplicationsSele
if (!path)
{
g_warning ("Skipping blacklisting executable %s due to it not being found", executable);
g_warning ("Skipping blocklisting executable %s due to it not being found", executable);
continue;
}
g_debug ("\t\t → Blacklisting path: %s", path);
mct_app_filter_builder_blacklist_path (builder, path);
g_debug ("\t\t → Blocklisting path: %s", path);
mct_app_filter_builder_blocklist_path (builder, path);
}
}
}

View File

@ -107,7 +107,7 @@ struct _MctUserControls
MctAppFilter *filter; /* (owned) (nullable) */
guint selected_age; /* @oars_disabled_age to disable OARS */
guint blacklist_apps_source_id;
guint blocklist_apps_source_id;
gboolean flushed_on_dispose;
ActUserAccountType user_account_type;
@ -115,7 +115,7 @@ struct _MctUserControls
gchar *user_display_name; /* (nullable) (owned) */
};
static gboolean blacklist_apps_cb (gpointer data);
static gboolean blocklist_apps_cb (gpointer data);
static void on_restrict_installation_switch_active_changed_cb (GtkSwitch *s,
GParamSpec *pspec,
@ -254,26 +254,26 @@ get_user_display_name (ActUser *user)
}
static void
schedule_update_blacklisted_apps (MctUserControls *self)
schedule_update_blocklisted_apps (MctUserControls *self)
{
if (self->blacklist_apps_source_id > 0)
if (self->blocklist_apps_source_id > 0)
return;
/* Use a timeout to batch multiple quick changes into a single
* update. 1 second is an arbitrary sufficiently small number */
self->blacklist_apps_source_id = g_timeout_add_seconds (1, blacklist_apps_cb, self);
self->blocklist_apps_source_id = g_timeout_add_seconds (1, blocklist_apps_cb, self);
}
static void
flush_update_blacklisted_apps (MctUserControls *self)
flush_update_blocklisted_apps (MctUserControls *self)
{
if (self->blacklist_apps_source_id > 0)
if (self->blocklist_apps_source_id > 0)
{
/* Remove the timer and forcefully call the timer callback. */
g_source_remove (self->blacklist_apps_source_id);
self->blacklist_apps_source_id = 0;
g_source_remove (self->blocklist_apps_source_id);
self->blocklist_apps_source_id = 0;
blacklist_apps_cb (self);
blocklist_apps_cb (self);
}
}
@ -560,14 +560,14 @@ setup_parental_control_settings (MctUserControls *self)
/* Callbacks */
static gboolean
blacklist_apps_cb (gpointer data)
blocklist_apps_cb (gpointer data)
{
g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT ();
g_autoptr(MctAppFilter) new_filter = NULL;
g_autoptr(GError) error = NULL;
MctUserControls *self = data;
self->blacklist_apps_source_id = 0;
self->blocklist_apps_source_id = 0;
if (self->user == NULL)
{
@ -615,7 +615,7 @@ on_restrict_installation_switch_active_changed_cb (GtkSwitch *s,
}
/* Save the changes. */
schedule_update_blacklisted_apps (self);
schedule_update_blocklisted_apps (self);
}
static void
@ -624,7 +624,7 @@ on_restrict_web_browsers_switch_active_changed_cb (GtkSwitch *s,
MctUserControls *self)
{
/* Save the changes. */
schedule_update_blacklisted_apps (self);
schedule_update_blocklisted_apps (self);
}
static void
@ -660,7 +660,7 @@ on_restrict_applications_dialog_delete_event_cb (GtkWidget *widget,
gtk_widget_hide (GTK_WIDGET (self->restrict_applications_dialog));
/* Schedule an update to the saved state. */
schedule_update_blacklisted_apps (self);
schedule_update_blocklisted_apps (self);
return TRUE;
}
@ -728,7 +728,7 @@ on_set_age_action_activated (GSimpleAction *action,
self->selected_age = age;
schedule_update_blacklisted_apps (self);
schedule_update_blocklisted_apps (self);
}
static void
@ -783,7 +783,7 @@ mct_user_controls_finalize (GObject *object)
{
MctUserControls *self = (MctUserControls *)object;
g_assert (self->blacklist_apps_source_id == 0);
g_assert (self->blocklist_apps_source_id == 0);
g_cancellable_cancel (self->cancellable);
g_clear_object (&self->action_group);
@ -823,7 +823,7 @@ mct_user_controls_dispose (GObject *object)
* do it multiple times, and after the first g_object_run_dispose() call,
* none of our child widgets are still around to extract data from anyway. */
if (!self->flushed_on_dispose)
flush_update_blacklisted_apps (self);
flush_update_blocklisted_apps (self);
self->flushed_on_dispose = TRUE;
G_OBJECT_CLASS (mct_user_controls_parent_class)->dispose (object);
@ -1171,7 +1171,7 @@ mct_user_controls_set_user (MctUserControls *self,
/* If we have pending unsaved changes from the previous user, force them to be
* saved first. */
flush_update_blacklisted_apps (self);
flush_update_blocklisted_apps (self);
old_user = (self->user != NULL) ? g_object_ref (self->user) : NULL;
@ -1314,7 +1314,7 @@ mct_user_controls_set_app_filter (MctUserControls *self,
/* If we have pending unsaved changes from the previous configuration, force
* them to be saved first. */
flush_update_blacklisted_apps (self);
flush_update_blocklisted_apps (self);
if (self->filter == app_filter)
return;
@ -1363,7 +1363,7 @@ mct_user_controls_set_user_account_type (MctUserControls *self,
/* If we have pending unsaved changes from the previous user, force them to be
* saved first. */
flush_update_blacklisted_apps (self);
flush_update_blocklisted_apps (self);
if (self->user_account_type == user_account_type)
return;
@ -1414,7 +1414,7 @@ mct_user_controls_set_user_locale (MctUserControls *self,
/* If we have pending unsaved changes from the previous user, force them to be
* saved first. */
flush_update_blacklisted_apps (self);
flush_update_blocklisted_apps (self);
if (g_strcmp0 (self->user_locale, user_locale) == 0)
return;
@ -1466,7 +1466,7 @@ mct_user_controls_set_user_display_name (MctUserControls *self,
/* If we have pending unsaved changes from the previous user, force them to be
* saved first. */
flush_update_blacklisted_apps (self);
flush_update_blocklisted_apps (self);
if (g_strcmp0 (self->user_display_name, user_display_name) == 0)
return;
@ -1504,9 +1504,9 @@ mct_user_controls_build_app_filter (MctUserControls *self,
g_debug ("Building parental controls settings…");
/* Blacklist */
/* Blocklist */
g_debug ("\t → Blacklisting apps");
g_debug ("\t → Blocklisting apps");
mct_restrict_applications_dialog_build_app_filter (self->restrict_applications_dialog, builder);
@ -1536,7 +1536,7 @@ mct_user_controls_build_app_filter (MctUserControls *self,
g_debug ("\t → %s web browsers", restrict_web_browsers ? "Restricting" : "Allowing");
if (restrict_web_browsers)
mct_app_filter_builder_blacklist_content_type (builder, WEB_BROWSERS_CONTENT_TYPE);
mct_app_filter_builder_blocklist_content_type (builder, WEB_BROWSERS_CONTENT_TYPE);
/* App installation */
if (self->user_account_type != ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR)

View File

@ -31,9 +31,9 @@ G_BEGIN_DECLS
/**
* MctAppFilterListType:
* @MCT_APP_FILTER_LIST_BLACKLIST: Any program in the list is not allowed to
* @MCT_APP_FILTER_LIST_BLOCKLIST: Any program in the list is not allowed to
* be run.
* @MCT_APP_FILTER_LIST_WHITELIST: Any program not in the list is not allowed
* @MCT_APP_FILTER_LIST_ALLOWLIST: Any program not in the list is not allowed
* to be run.
*
* Different semantics for interpreting an application list.
@ -42,8 +42,8 @@ G_BEGIN_DECLS
*/
typedef enum
{
MCT_APP_FILTER_LIST_BLACKLIST,
MCT_APP_FILTER_LIST_WHITELIST,
MCT_APP_FILTER_LIST_BLOCKLIST,
MCT_APP_FILTER_LIST_ALLOWLIST,
} MctAppFilterListType;
struct _MctAppFilter

View File

@ -164,9 +164,9 @@ mct_app_filter_is_enabled (MctAppFilter *filter)
/* Check all fields against their default values. Ignore
* `allow_system_installation` since its false by default, so the default
* value is already the most restrictive. */
return ((filter->app_list_type == MCT_APP_FILTER_LIST_BLACKLIST &&
return ((filter->app_list_type == MCT_APP_FILTER_LIST_BLOCKLIST &&
filter->app_list[0] != NULL) ||
filter->app_list_type == MCT_APP_FILTER_LIST_WHITELIST ||
filter->app_list_type == MCT_APP_FILTER_LIST_ALLOWLIST ||
!oars_ratings_all_intense_or_unknown ||
!filter->allow_user_installation);
}
@ -202,9 +202,9 @@ mct_app_filter_is_path_allowed (MctAppFilter *filter,
switch (filter->app_list_type)
{
case MCT_APP_FILTER_LIST_BLACKLIST:
case MCT_APP_FILTER_LIST_BLOCKLIST:
return !path_in_list;
case MCT_APP_FILTER_LIST_WHITELIST:
case MCT_APP_FILTER_LIST_ALLOWLIST:
return path_in_list;
default:
g_assert_not_reached ();
@ -265,9 +265,9 @@ mct_app_filter_is_flatpak_ref_allowed (MctAppFilter *filter,
switch (filter->app_list_type)
{
case MCT_APP_FILTER_LIST_BLACKLIST:
case MCT_APP_FILTER_LIST_BLOCKLIST:
return !ref_in_list;
case MCT_APP_FILTER_LIST_WHITELIST:
case MCT_APP_FILTER_LIST_ALLOWLIST:
return ref_in_list;
default:
g_assert_not_reached ();
@ -281,7 +281,7 @@ mct_app_filter_is_flatpak_ref_allowed (MctAppFilter *filter,
*
* Check whether the flatpak app with the given @app_id is allowed to be run
* according to this app filter. This is a globbing match, matching @app_id
* against potentially multiple entries in the blacklist, as the blacklist
* against potentially multiple entries in the blocklist, as the blocklist
* contains flatpak refs (for example, `app/org.gnome.Builder/x86_64/master`)
* which contain architecture and branch information. App IDs (for example,
* `org.gnome.Builder`) do not contain architecture or branch information.
@ -315,9 +315,9 @@ mct_app_filter_is_flatpak_app_allowed (MctAppFilter *filter,
switch (filter->app_list_type)
{
case MCT_APP_FILTER_LIST_BLACKLIST:
case MCT_APP_FILTER_LIST_BLOCKLIST:
return !id_in_list;
case MCT_APP_FILTER_LIST_WHITELIST:
case MCT_APP_FILTER_LIST_ALLOWLIST:
return id_in_list;
default:
g_assert_not_reached ();
@ -431,8 +431,8 @@ is_valid_content_type (const gchar *content_type)
* according to this app filter.
*
* Note that this method doesnt match content subtypes. For example, if
* `application/xml` is added to the blacklist but `application/xspf+xml` is not,
* a check for whether `application/xspf+xml` is blacklisted would return false.
* `application/xml` is added to the blocklist but `application/xspf+xml` is not,
* a check for whether `application/xspf+xml` is blocklisted would return false.
*
* Returns: %TRUE if the user this @filter corresponds to is allowed to run
* programs handling @content_type according to the @filter policy;
@ -453,9 +453,9 @@ mct_app_filter_is_content_type_allowed (MctAppFilter *filter,
switch (filter->app_list_type)
{
case MCT_APP_FILTER_LIST_BLACKLIST:
case MCT_APP_FILTER_LIST_BLOCKLIST:
return !ref_in_list;
case MCT_APP_FILTER_LIST_WHITELIST:
case MCT_APP_FILTER_LIST_ALLOWLIST:
return ref_in_list;
default:
g_assert_not_reached ();
@ -606,7 +606,7 @@ _mct_app_filter_build_app_filter_variant (MctAppFilter *filter)
g_return_val_if_fail (filter->ref_count >= 1, NULL);
g_variant_builder_add (&builder, "b",
(filter->app_list_type == MCT_APP_FILTER_LIST_WHITELIST));
(filter->app_list_type == MCT_APP_FILTER_LIST_ALLOWLIST));
g_variant_builder_open (&builder, G_VARIANT_TYPE ("as"));
for (gsize i = 0; filter->app_list[i] != NULL; i++)
@ -675,7 +675,7 @@ mct_app_filter_deserialize (GVariant *variant,
uid_t user_id,
GError **error)
{
gboolean is_whitelist;
gboolean is_allowlist;
g_auto(GStrv) app_list = NULL;
const gchar *content_rating_kind;
g_autoptr(GVariant) oars_variant = NULL;
@ -700,10 +700,10 @@ mct_app_filter_deserialize (GVariant *variant,
* kept in sync with those in the `com.endlessm.ParentalControls.AppFilter`
* D-Bus interface. */
if (!g_variant_lookup (variant, "AppFilter", "(b^as)",
&is_whitelist, &app_list))
&is_allowlist, &app_list))
{
/* Default value. */
is_whitelist = FALSE;
is_allowlist = FALSE;
app_list = g_new0 (gchar *, 1);
}
@ -747,7 +747,7 @@ mct_app_filter_deserialize (GVariant *variant,
app_filter->user_id = user_id;
app_filter->app_list = g_steal_pointer (&app_list);
app_filter->app_list_type =
is_whitelist ? MCT_APP_FILTER_LIST_WHITELIST : MCT_APP_FILTER_LIST_BLACKLIST;
is_allowlist ? MCT_APP_FILTER_LIST_ALLOWLIST : MCT_APP_FILTER_LIST_BLOCKLIST;
app_filter->oars_ratings = g_steal_pointer (&oars_variant);
app_filter->allow_user_installation = allow_user_installation;
app_filter->allow_system_installation = allow_system_installation;
@ -762,7 +762,7 @@ mct_app_filter_deserialize (GVariant *variant,
*/
typedef struct
{
GPtrArray *blacklist; /* (nullable) (owned) (element-type utf8) */
GPtrArray *blocklist; /* (nullable) (owned) (element-type utf8) */
GHashTable *oars; /* (nullable) (owned) (element-type utf8 MctAppFilterOarsValue) */
gboolean allow_user_installation;
gboolean allow_system_installation;
@ -800,7 +800,7 @@ mct_app_filter_builder_init (MctAppFilterBuilder *builder)
MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder;
g_return_if_fail (_builder != NULL);
g_return_if_fail (_builder->blacklist == NULL);
g_return_if_fail (_builder->blocklist == NULL);
g_return_if_fail (_builder->oars == NULL);
memcpy (builder, &local_builder, sizeof (local_builder));
@ -826,7 +826,7 @@ mct_app_filter_builder_clear (MctAppFilterBuilder *builder)
g_return_if_fail (_builder != NULL);
g_clear_pointer (&_builder->blacklist, g_ptr_array_unref);
g_clear_pointer (&_builder->blocklist, g_ptr_array_unref);
g_clear_pointer (&_builder->oars, g_hash_table_unref);
}
@ -876,8 +876,8 @@ mct_app_filter_builder_copy (MctAppFilterBuilder *builder)
_copy = (MctAppFilterBuilderReal *) copy;
mct_app_filter_builder_clear (copy);
if (_builder->blacklist != NULL)
_copy->blacklist = g_ptr_array_ref (_builder->blacklist);
if (_builder->blocklist != NULL)
_copy->blocklist = g_ptr_array_ref (_builder->blocklist);
if (_builder->oars != NULL)
_copy->oars = g_hash_table_ref (_builder->oars);
_copy->allow_user_installation = _builder->allow_user_installation;
@ -927,11 +927,11 @@ mct_app_filter_builder_end (MctAppFilterBuilder *builder)
g_autoptr(GVariant) oars_variant = NULL;
g_return_val_if_fail (_builder != NULL, NULL);
g_return_val_if_fail (_builder->blacklist != NULL, NULL);
g_return_val_if_fail (_builder->blocklist != NULL, NULL);
g_return_val_if_fail (_builder->oars != NULL, NULL);
/* Ensure the paths list is %NULL-terminated. */
g_ptr_array_add (_builder->blacklist, NULL);
g_ptr_array_add (_builder->blocklist, NULL);
/* Build the OARS variant. */
g_hash_table_iter_init (&iter, _builder->oars);
@ -962,8 +962,8 @@ mct_app_filter_builder_end (MctAppFilterBuilder *builder)
app_filter = g_new0 (MctAppFilter, 1);
app_filter->ref_count = 1;
app_filter->user_id = -1;
app_filter->app_list = (gchar **) g_ptr_array_free (g_steal_pointer (&_builder->blacklist), FALSE);
app_filter->app_list_type = MCT_APP_FILTER_LIST_BLACKLIST;
app_filter->app_list = (gchar **) g_ptr_array_free (g_steal_pointer (&_builder->blocklist), FALSE);
app_filter->app_list_type = MCT_APP_FILTER_LIST_BLOCKLIST;
app_filter->oars_ratings = g_steal_pointer (&oars_variant);
app_filter->allow_user_installation = _builder->allow_user_installation;
app_filter->allow_system_installation = _builder->allow_system_installation;
@ -974,24 +974,24 @@ mct_app_filter_builder_end (MctAppFilterBuilder *builder)
}
/**
* mct_app_filter_builder_blacklist_path:
* mct_app_filter_builder_blocklist_path:
* @builder: an initialised #MctAppFilterBuilder
* @path: (type filename): an absolute path to blacklist
* @path: (type filename): an absolute path to blocklist
*
* Add @path to the blacklist of app paths in the filter under construction. It
* Add @path to the blocklist of app paths in the filter under construction. It
* will be canonicalised (without doing any I/O) before being added.
* The canonicalised @path will not be added again if its already been added.
*
* Since: 0.2.0
*/
void
mct_app_filter_builder_blacklist_path (MctAppFilterBuilder *builder,
mct_app_filter_builder_blocklist_path (MctAppFilterBuilder *builder,
const gchar *path)
{
MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder;
g_return_if_fail (_builder != NULL);
g_return_if_fail (_builder->blacklist != NULL);
g_return_if_fail (_builder->blocklist != NULL);
g_return_if_fail (path != NULL);
g_return_if_fail (g_path_is_absolute (path));
@ -1000,67 +1000,67 @@ mct_app_filter_builder_blacklist_path (MctAppFilterBuilder *builder,
NULL, NULL, NULL);
g_return_if_fail (canonical_path_utf8 != NULL);
if (!g_ptr_array_find_with_equal_func (_builder->blacklist,
if (!g_ptr_array_find_with_equal_func (_builder->blocklist,
canonical_path_utf8, g_str_equal, NULL))
g_ptr_array_add (_builder->blacklist, g_steal_pointer (&canonical_path_utf8));
g_ptr_array_add (_builder->blocklist, g_steal_pointer (&canonical_path_utf8));
}
/**
* mct_app_filter_builder_blacklist_flatpak_ref:
* mct_app_filter_builder_blocklist_flatpak_ref:
* @builder: an initialised #MctAppFilterBuilder
* @app_ref: a flatpak app ref to blacklist
* @app_ref: a flatpak app ref to blocklist
*
* Add @app_ref to the blacklist of flatpak refs in the filter under
* Add @app_ref to the blocklist of flatpak refs in the filter under
* construction. The @app_ref will not be added again if its already been
* added.
*
* Since: 0.2.0
*/
void
mct_app_filter_builder_blacklist_flatpak_ref (MctAppFilterBuilder *builder,
mct_app_filter_builder_blocklist_flatpak_ref (MctAppFilterBuilder *builder,
const gchar *app_ref)
{
MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder;
g_return_if_fail (_builder != NULL);
g_return_if_fail (_builder->blacklist != NULL);
g_return_if_fail (_builder->blocklist != NULL);
g_return_if_fail (app_ref != NULL);
g_return_if_fail (is_valid_flatpak_ref (app_ref));
if (!g_ptr_array_find_with_equal_func (_builder->blacklist,
if (!g_ptr_array_find_with_equal_func (_builder->blocklist,
app_ref, g_str_equal, NULL))
g_ptr_array_add (_builder->blacklist, g_strdup (app_ref));
g_ptr_array_add (_builder->blocklist, g_strdup (app_ref));
}
/**
* mct_app_filter_builder_blacklist_content_type:
* mct_app_filter_builder_blocklist_content_type:
* @builder: an initialised #MctAppFilterBuilder
* @content_type: a content type to blacklist
* @content_type: a content type to blocklist
*
* Add @content_type to the blacklist of content types in the filter under
* Add @content_type to the blocklist of content types in the filter under
* construction. The @content_type will not be added again if its already been
* added.
*
* Note that this method doesnt handle content subtypes. For example, if
* `application/xml` is added to the blacklist but `application/xspf+xml` is not,
* a check for whether `application/xspf+xml` is blacklisted would return false.
* `application/xml` is added to the blocklist but `application/xspf+xml` is not,
* a check for whether `application/xspf+xml` is blocklisted would return false.
*
* Since: 0.4.0
*/
void
mct_app_filter_builder_blacklist_content_type (MctAppFilterBuilder *builder,
mct_app_filter_builder_blocklist_content_type (MctAppFilterBuilder *builder,
const gchar *content_type)
{
MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder;
g_return_if_fail (_builder != NULL);
g_return_if_fail (_builder->blacklist != NULL);
g_return_if_fail (_builder->blocklist != NULL);
g_return_if_fail (content_type != NULL);
g_return_if_fail (is_valid_content_type (content_type));
if (!g_ptr_array_find_with_equal_func (_builder->blacklist,
if (!g_ptr_array_find_with_equal_func (_builder->blocklist,
content_type, g_str_equal, NULL))
g_ptr_array_add (_builder->blacklist, g_strdup (content_type));
g_ptr_array_add (_builder->blocklist, g_strdup (content_type));
}
/**

View File

@ -165,11 +165,11 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (MctAppFilterBuilder, mct_app_filter_builder_free)
MctAppFilter *mct_app_filter_builder_end (MctAppFilterBuilder *builder);
void mct_app_filter_builder_blacklist_path (MctAppFilterBuilder *builder,
void mct_app_filter_builder_blocklist_path (MctAppFilterBuilder *builder,
const gchar *path);
void mct_app_filter_builder_blacklist_flatpak_ref (MctAppFilterBuilder *builder,
void mct_app_filter_builder_blocklist_flatpak_ref (MctAppFilterBuilder *builder,
const gchar *app_ref);
void mct_app_filter_builder_blacklist_content_type (MctAppFilterBuilder *builder,
void mct_app_filter_builder_blocklist_content_type (MctAppFilterBuilder *builder,
const gchar *content_type);
void mct_app_filter_builder_set_oars_value (MctAppFilterBuilder *builder,

View File

@ -275,13 +275,13 @@ test_app_filter_builder_non_empty (BuilderFixture *fixture,
g_autoptr(MctAppFilter) filter = NULL;
g_autofree const gchar **sections = NULL;
mct_app_filter_builder_blacklist_path (fixture->builder, "/bin/true");
mct_app_filter_builder_blacklist_path (fixture->builder, "/usr/bin/gnome-software");
mct_app_filter_builder_blocklist_path (fixture->builder, "/bin/true");
mct_app_filter_builder_blocklist_path (fixture->builder, "/usr/bin/gnome-software");
mct_app_filter_builder_blacklist_flatpak_ref (fixture->builder,
mct_app_filter_builder_blocklist_flatpak_ref (fixture->builder,
"app/org.doom.Doom/x86_64/master");
mct_app_filter_builder_blacklist_content_type (fixture->builder,
mct_app_filter_builder_blocklist_content_type (fixture->builder,
"x-scheme-handler/http");
mct_app_filter_builder_set_oars_value (fixture->builder, "drugs-alcohol",
@ -380,8 +380,8 @@ test_app_filter_builder_copy_empty (void)
builder_copy = mct_app_filter_builder_copy (builder);
mct_app_filter_builder_init (builder_copy);
mct_app_filter_builder_blacklist_path (builder_copy, "/bin/true");
mct_app_filter_builder_blacklist_content_type (builder_copy,
mct_app_filter_builder_blocklist_path (builder_copy, "/bin/true");
mct_app_filter_builder_blocklist_content_type (builder_copy,
"x-scheme-handler/http");
filter = mct_app_filter_builder_end (builder_copy);
@ -405,8 +405,8 @@ test_app_filter_builder_copy_full (void)
g_autoptr(MctAppFilterBuilder) builder_copy = NULL;
g_autoptr(MctAppFilter) filter = NULL;
mct_app_filter_builder_blacklist_path (builder, "/bin/true");
mct_app_filter_builder_blacklist_content_type (builder,
mct_app_filter_builder_blocklist_path (builder, "/bin/true");
mct_app_filter_builder_blocklist_content_type (builder,
"x-scheme-handler/http");
mct_app_filter_builder_set_allow_user_installation (builder, FALSE);
mct_app_filter_builder_set_allow_system_installation (builder, TRUE);
@ -545,9 +545,9 @@ test_app_filter_appinfo (void)
"MimeType=x-scheme-handler/http\n" },
};
mct_app_filter_builder_blacklist_path (&builder, "/bin/false");
mct_app_filter_builder_blacklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable");
mct_app_filter_builder_blacklist_content_type (&builder, "x-scheme-handler/http");
mct_app_filter_builder_blocklist_path (&builder, "/bin/false");
mct_app_filter_builder_blocklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable");
mct_app_filter_builder_blocklist_content_type (&builder, "x-scheme-handler/http");
filter = mct_app_filter_builder_end (&builder);
@ -751,13 +751,13 @@ test_app_filter_bus_get (BusFixture *fixture,
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Chess"));
}
/* Test that getting an #MctAppFilter containing a whitelist from the mock D-Bus
* service works, and that the #MctAppFilter methods handle the whitelist
/* Test that getting an #MctAppFilter containing a allowlist from the mock D-Bus
* service works, and that the #MctAppFilter methods handle the allowlist
* correctly.
*
* The mock D-Bus replies are generated in get_app_filter_server_cb(). */
static void
test_app_filter_bus_get_whitelist (BusFixture *fixture,
test_app_filter_bus_get_allowlist (BusFixture *fixture,
gconstpointer test_data)
{
g_autoptr(MctAppFilter) app_filter = NULL;
@ -769,8 +769,8 @@ test_app_filter_bus_get_whitelist (BusFixture *fixture,
"'AllowUserInstallation': <true>,"
"'AllowSystemInstallation': <true>,"
"'AppFilter': <(true, ["
"'app/org.gnome.Whitelisted1/x86_64/stable',"
"'app/org.gnome.Whitelisted2/x86_64/stable',"
"'app/org.gnome.Allowlisted1/x86_64/stable',"
"'app/org.gnome.Allowlisted2/x86_64/stable',"
"'/usr/bin/true',"
"'text/plain'"
"])>,"
@ -789,15 +789,15 @@ test_app_filter_bus_get_whitelist (BusFixture *fixture,
g_assert_no_error (local_error);
g_assert_nonnull (app_filter);
/* Check the app filter properties. The returned filter is a whitelist,
* whereas typically a blacklist is returned. */
/* Check the app filter properties. The returned filter is a allowlist,
* whereas typically a blocklist is returned. */
g_assert_cmpuint (mct_app_filter_get_user_id (app_filter), ==, fixture->valid_uid);
g_assert_true (mct_app_filter_is_enabled (app_filter));
g_assert_false (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Builder"));
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Whitelisted1"));
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Whitelisted2"));
g_assert_true (mct_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Whitelisted1/x86_64/stable"));
g_assert_false (mct_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Whitelisted1/x86_64/unknown"));
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Allowlisted1"));
g_assert_true (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Allowlisted2"));
g_assert_true (mct_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Allowlisted1/x86_64/stable"));
g_assert_false (mct_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Allowlisted1/x86_64/unknown"));
g_assert_true (mct_app_filter_is_path_allowed (app_filter, "/usr/bin/true"));
g_assert_false (mct_app_filter_is_path_allowed (app_filter, "/usr/bin/false"));
g_assert_true (mct_app_filter_is_content_type_allowed (app_filter,
@ -1300,10 +1300,10 @@ test_app_filter_bus_set (BusFixture *fixture,
};
/* Build an app filter. */
mct_app_filter_builder_blacklist_path (&builder, "/usr/bin/false");
mct_app_filter_builder_blacklist_path (&builder, "/usr/bin/banned");
mct_app_filter_builder_blacklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable");
mct_app_filter_builder_blacklist_content_type (&builder, "x-scheme-handler/http");
mct_app_filter_builder_blocklist_path (&builder, "/usr/bin/false");
mct_app_filter_builder_blocklist_path (&builder, "/usr/bin/banned");
mct_app_filter_builder_blocklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable");
mct_app_filter_builder_blocklist_content_type (&builder, "x-scheme-handler/http");
mct_app_filter_builder_set_oars_value (&builder, "violence-fantasy", MCT_APP_FILTER_OARS_VALUE_INTENSE);
mct_app_filter_builder_set_allow_user_installation (&builder, TRUE);
mct_app_filter_builder_set_allow_system_installation (&builder, TRUE);
@ -1552,8 +1552,8 @@ main (int argc,
bus_set_up, test_app_filter_bus_get, bus_tear_down);
g_test_add ("/app-filter/bus/get/sync", BusFixture, GUINT_TO_POINTER (FALSE),
bus_set_up, test_app_filter_bus_get, bus_tear_down);
g_test_add ("/app-filter/bus/get/whitelist", BusFixture, NULL,
bus_set_up, test_app_filter_bus_get_whitelist, bus_tear_down);
g_test_add ("/app-filter/bus/get/allowlist", BusFixture, NULL,
bus_set_up, test_app_filter_bus_get_allowlist, bus_tear_down);
g_test_add ("/app-filter/bus/get/all-oars-values", BusFixture, NULL,
bus_set_up, test_app_filter_bus_get_all_oars_values, bus_tear_down);
g_test_add ("/app-filter/bus/get/defaults", BusFixture, NULL,

View File

@ -385,12 +385,12 @@ def command_set_app_filter(user, allow_user_installation=True,
file=sys.stderr)
raise SystemExit(EXIT_INVALID_OPTION)
elif is_maybe_flatpak_ref:
builder.blacklist_flatpak_ref(arg)
builder.blocklist_flatpak_ref(arg)
elif is_maybe_content_type:
builder.blacklist_content_type(arg)
builder.blocklist_content_type(arg)
elif is_maybe_path:
path = os.path.abspath(arg)
builder.blacklist_path(path)
builder.blocklist_path(path)
else:
raise AssertionError('code should not be reached')
@ -523,7 +523,7 @@ def main():
'flatpak repo')
parser_set_app_filter.add_argument('app_filter_args', nargs='*',
help='paths, content types or flatpak '
'refs to blacklist and OARS '
'refs to blocklist and OARS '
'section=value pairs to store')
parser_set_app_filter.set_defaults(allow_user_installation=True,
allow_system_installation=False)