diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-context.c | 10 | ||||
-rw-r--r-- | src/mm-filter.c | 94 | ||||
-rw-r--r-- | src/mm-filter.h | 24 | ||||
-rw-r--r-- | src/mm-plugin-manager.c | 26 |
4 files changed, 79 insertions, 75 deletions
diff --git a/src/mm-context.c b/src/mm-context.c index 8c341667..e86c57da 100644 --- a/src/mm-context.c +++ b/src/mm-context.c @@ -48,8 +48,12 @@ filter_policy_option_arg (const gchar *option_name, gpointer data, GError **error) { - if (!g_ascii_strcasecmp (value, "whitelist-only")) { - filter_policy = MM_FILTER_POLICY_WHITELIST_ONLY; + if (!g_ascii_strcasecmp (value, "allowlist-only") +#ifndef MM_DISABLE_DEPRECATED + || !g_ascii_strcasecmp (value, "whitelist-only") +#endif + ) { + filter_policy = MM_FILTER_POLICY_ALLOWLIST_ONLY; return TRUE; } @@ -67,7 +71,7 @@ filter_policy_option_arg (const gchar *option_name, static const GOptionEntry entries[] = { { "filter-policy", 0, 0, G_OPTION_ARG_CALLBACK, filter_policy_option_arg, - "Filter policy: one of WHITELIST-ONLY, STRICT", + "Filter policy: one of ALLOWLIST-ONLY, STRICT", "[POLICY]" }, { diff --git a/src/mm-filter.c b/src/mm-filter.c index b7a9d2f8..90d9b68d 100644 --- a/src/mm-filter.c +++ b/src/mm-filter.c @@ -38,67 +38,67 @@ enum { struct _MMFilterPrivate { MMFilterRule enabled_rules; - GList *plugin_whitelist_tags; - GArray *plugin_whitelist_vendor_ids; - GArray *plugin_whitelist_product_ids; + GList *plugin_allowlist_tags; + GArray *plugin_allowlist_vendor_ids; + GArray *plugin_allowlist_product_ids; }; /*****************************************************************************/ void -mm_filter_register_plugin_whitelist_tag (MMFilter *self, +mm_filter_register_plugin_allowlist_tag (MMFilter *self, const gchar *tag) { - if (!g_list_find_custom (self->priv->plugin_whitelist_tags, tag, (GCompareFunc) g_strcmp0)) { - mm_obj_dbg (self, "registered plugin whitelist tag: %s", tag); - self->priv->plugin_whitelist_tags = g_list_prepend (self->priv->plugin_whitelist_tags, g_strdup (tag)); + if (!g_list_find_custom (self->priv->plugin_allowlist_tags, tag, (GCompareFunc) g_strcmp0)) { + mm_obj_dbg (self, "registered plugin allowlist tag: %s", tag); + self->priv->plugin_allowlist_tags = g_list_prepend (self->priv->plugin_allowlist_tags, g_strdup (tag)); } } void -mm_filter_register_plugin_whitelist_vendor_id (MMFilter *self, +mm_filter_register_plugin_allowlist_vendor_id (MMFilter *self, guint16 vid) { guint i; - if (!self->priv->plugin_whitelist_vendor_ids) - self->priv->plugin_whitelist_vendor_ids = g_array_sized_new (FALSE, FALSE, sizeof (guint16), 64); + if (!self->priv->plugin_allowlist_vendor_ids) + self->priv->plugin_allowlist_vendor_ids = g_array_sized_new (FALSE, FALSE, sizeof (guint16), 64); - for (i = 0; i < self->priv->plugin_whitelist_vendor_ids->len; i++) { + for (i = 0; i < self->priv->plugin_allowlist_vendor_ids->len; i++) { guint16 item; - item = g_array_index (self->priv->plugin_whitelist_vendor_ids, guint16, i); + item = g_array_index (self->priv->plugin_allowlist_vendor_ids, guint16, i); if (item == vid) return; } - g_array_append_val (self->priv->plugin_whitelist_vendor_ids, vid); - mm_obj_dbg (self, "registered plugin whitelist vendor id: %04x", vid); + g_array_append_val (self->priv->plugin_allowlist_vendor_ids, vid); + mm_obj_dbg (self, "registered plugin allowlist vendor id: %04x", vid); } void -mm_filter_register_plugin_whitelist_product_id (MMFilter *self, +mm_filter_register_plugin_allowlist_product_id (MMFilter *self, guint16 vid, guint16 pid) { mm_uint16_pair new_item; guint i; - if (!self->priv->plugin_whitelist_product_ids) - self->priv->plugin_whitelist_product_ids = g_array_sized_new (FALSE, FALSE, sizeof (mm_uint16_pair), 10); + if (!self->priv->plugin_allowlist_product_ids) + self->priv->plugin_allowlist_product_ids = g_array_sized_new (FALSE, FALSE, sizeof (mm_uint16_pair), 10); - for (i = 0; i < self->priv->plugin_whitelist_product_ids->len; i++) { + for (i = 0; i < self->priv->plugin_allowlist_product_ids->len; i++) { mm_uint16_pair *item; - item = &g_array_index (self->priv->plugin_whitelist_product_ids, mm_uint16_pair, i); + item = &g_array_index (self->priv->plugin_allowlist_product_ids, mm_uint16_pair, i); if (item->l == vid && item->r == pid) return; } new_item.l = vid; new_item.r = pid; - g_array_append_val (self->priv->plugin_whitelist_product_ids, new_item); - mm_obj_dbg (self, "registered plugin whitelist product id: %04x:%04x", vid, pid); + g_array_append_val (self->priv->plugin_allowlist_product_ids, new_item); + mm_obj_dbg (self, "registered plugin allowlist product id: %04x:%04x", vid, pid); } /*****************************************************************************/ @@ -114,33 +114,33 @@ mm_filter_port (MMFilter *self, subsystem = mm_kernel_device_get_subsystem (port); name = mm_kernel_device_get_name (port); - /* If the device is explicitly whitelisted, we process every port. Also + /* If the device is explicitly allowlisted, we process every port. Also * allow specifying this flag per-port instead of for the full device, e.g. * for platform tty ports where there's only one port anyway. */ - if ((self->priv->enabled_rules & MM_FILTER_RULE_EXPLICIT_WHITELIST) && + if ((self->priv->enabled_rules & MM_FILTER_RULE_EXPLICIT_ALLOWLIST) && (mm_kernel_device_get_global_property_as_boolean (port, ID_MM_DEVICE_PROCESS) || mm_kernel_device_get_property_as_boolean (port, ID_MM_DEVICE_PROCESS))) { - mm_obj_dbg (self, "(%s/%s) port allowed: device is whitelisted", subsystem, name); + mm_obj_dbg (self, "(%s/%s) port allowed: device is allowlisted", subsystem, name); return TRUE; } /* If the device is explicitly blacklisted, we ignore every port. */ - if ((self->priv->enabled_rules & MM_FILTER_RULE_EXPLICIT_BLACKLIST) && + if ((self->priv->enabled_rules & MM_FILTER_RULE_EXPLICIT_BLOCKLIST) && (mm_kernel_device_get_global_property_as_boolean (port, ID_MM_DEVICE_IGNORE))) { - mm_obj_dbg (self, "(%s/%s): port filtered: device is blacklisted", subsystem, name); + mm_obj_dbg (self, "(%s/%s): port filtered: device is blocklisted", subsystem, name); return FALSE; } - /* If the device is whitelisted by a plugin, we allow it. */ - if (self->priv->enabled_rules & MM_FILTER_RULE_PLUGIN_WHITELIST) { + /* If the device is allowlisted by a plugin, we allow it. */ + if (self->priv->enabled_rules & MM_FILTER_RULE_PLUGIN_ALLOWLIST) { GList *l; guint16 vid = 0; guint16 pid = 0; - for (l = self->priv->plugin_whitelist_tags; l; l = g_list_next (l)) { + for (l = self->priv->plugin_allowlist_tags; l; l = g_list_next (l)) { if (mm_kernel_device_get_global_property_as_boolean (port, (const gchar *)(l->data)) || mm_kernel_device_get_property_as_boolean (port, (const gchar *)(l->data))) { - mm_obj_dbg (self, "(%s/%s) port allowed: device is whitelisted by plugin (tag)", subsystem, name); + mm_obj_dbg (self, "(%s/%s) port allowed: device is allowlisted by plugin (tag)", subsystem, name); return TRUE; } } @@ -149,29 +149,29 @@ mm_filter_port (MMFilter *self, if (vid) pid = mm_kernel_device_get_physdev_pid (port); - if (vid && pid && self->priv->plugin_whitelist_product_ids) { + if (vid && pid && self->priv->plugin_allowlist_product_ids) { guint i; - for (i = 0; i < self->priv->plugin_whitelist_product_ids->len; i++) { + for (i = 0; i < self->priv->plugin_allowlist_product_ids->len; i++) { mm_uint16_pair *item; - item = &g_array_index (self->priv->plugin_whitelist_product_ids, mm_uint16_pair, i); + item = &g_array_index (self->priv->plugin_allowlist_product_ids, mm_uint16_pair, i); if (item->l == vid && item->r == pid) { - mm_obj_dbg (self, "(%s/%s) port allowed: device is whitelisted by plugin (vid/pid)", subsystem, name); + mm_obj_dbg (self, "(%s/%s) port allowed: device is allowlisted by plugin (vid/pid)", subsystem, name); return TRUE; } } } - if (vid && self->priv->plugin_whitelist_vendor_ids) { + if (vid && self->priv->plugin_allowlist_vendor_ids) { guint i; - for (i = 0; i < self->priv->plugin_whitelist_vendor_ids->len; i++) { + for (i = 0; i < self->priv->plugin_allowlist_vendor_ids->len; i++) { guint16 item; - item = g_array_index (self->priv->plugin_whitelist_vendor_ids, guint16, i); + item = g_array_index (self->priv->plugin_allowlist_vendor_ids, guint16, i); if (item == vid) { - mm_obj_dbg (self, "(%s/%s) port allowed: device is whitelisted by plugin (vid)", subsystem, name); + mm_obj_dbg (self, "(%s/%s) port allowed: device is allowlisted by plugin (vid)", subsystem, name); return TRUE; } } @@ -228,9 +228,9 @@ mm_filter_port (MMFilter *self, const gchar *physdev_subsystem; const gchar *driver; - /* Mixed blacklist/whitelist rules */ + /* Mixed blocklist/allowlist rules */ - /* If the physdev is a 'platform' or 'pnp' device that's not whitelisted, ignore it */ + /* If the physdev is a 'platform' or 'pnp' device that's not allowlisted, ignore it */ physdev_subsystem = mm_kernel_device_get_physdev_subsystem (port); if ((self->priv->enabled_rules & MM_FILTER_RULE_TTY_PLATFORM_DRIVER) && (!g_strcmp0 (physdev_subsystem, "platform") || @@ -241,7 +241,7 @@ mm_filter_port (MMFilter *self, return FALSE; } - /* Whitelist rules last */ + /* Allowlist rules last */ /* If the TTY kernel driver is one expected modem kernel driver, allow it */ driver = mm_kernel_device_get_driver (port); @@ -440,9 +440,9 @@ mm_filter_new (MMFilterRule enabled_rules, #define RULE_ENABLED_STR(flag) ((self->priv->enabled_rules & flag) ? "yes" : "no") mm_obj_dbg (self, "created"); - mm_obj_dbg (self, " explicit whitelist: %s", RULE_ENABLED_STR (MM_FILTER_RULE_EXPLICIT_WHITELIST)); - mm_obj_dbg (self, " explicit blacklist: %s", RULE_ENABLED_STR (MM_FILTER_RULE_EXPLICIT_BLACKLIST)); - mm_obj_dbg (self, " plugin whitelist: %s", RULE_ENABLED_STR (MM_FILTER_RULE_PLUGIN_WHITELIST)); + mm_obj_dbg (self, " explicit allowlist: %s", RULE_ENABLED_STR (MM_FILTER_RULE_EXPLICIT_ALLOWLIST)); + mm_obj_dbg (self, " explicit blocklist: %s", RULE_ENABLED_STR (MM_FILTER_RULE_EXPLICIT_BLOCKLIST)); + mm_obj_dbg (self, " plugin allowlist: %s", RULE_ENABLED_STR (MM_FILTER_RULE_PLUGIN_ALLOWLIST)); mm_obj_dbg (self, " qrtr devices allowed: %s", RULE_ENABLED_STR (MM_FILTER_RULE_QRTR)); mm_obj_dbg (self, " virtual devices forbidden: %s", RULE_ENABLED_STR (MM_FILTER_RULE_VIRTUAL)); mm_obj_dbg (self, " net devices allowed: %s", RULE_ENABLED_STR (MM_FILTER_RULE_NET)); @@ -514,9 +514,9 @@ finalize (GObject *object) { MMFilter *self = MM_FILTER (object); - g_clear_pointer (&self->priv->plugin_whitelist_vendor_ids, g_array_unref); - g_clear_pointer (&self->priv->plugin_whitelist_product_ids, g_array_unref); - g_list_free_full (self->priv->plugin_whitelist_tags, g_free); + g_clear_pointer (&self->priv->plugin_allowlist_vendor_ids, g_array_unref); + g_clear_pointer (&self->priv->plugin_allowlist_product_ids, g_array_unref); + g_list_free_full (self->priv->plugin_allowlist_tags, g_free); G_OBJECT_CLASS (mm_filter_parent_class)->finalize (object); } diff --git a/src/mm-filter.h b/src/mm-filter.h index 6c38568d..de561dab 100644 --- a/src/mm-filter.h +++ b/src/mm-filter.h @@ -47,9 +47,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMFilter, g_object_unref) typedef enum { /*< underscore_name=mm_filter_rule >*/ MM_FILTER_RULE_NONE = 0, - MM_FILTER_RULE_EXPLICIT_WHITELIST = 1 << 0, - MM_FILTER_RULE_EXPLICIT_BLACKLIST = 1 << 1, - MM_FILTER_RULE_PLUGIN_WHITELIST = 1 << 2, + MM_FILTER_RULE_EXPLICIT_ALLOWLIST = 1 << 0, + MM_FILTER_RULE_EXPLICIT_BLOCKLIST = 1 << 1, + MM_FILTER_RULE_PLUGIN_ALLOWLIST = 1 << 2, MM_FILTER_RULE_QRTR = 1 << 3, MM_FILTER_RULE_VIRTUAL = 1 << 4, MM_FILTER_RULE_NET = 1 << 5, @@ -65,11 +65,11 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/ } MMFilterRule; /* This is a stricter policy which will only automatically probe device ports - * if they are allowed by any of the automatic whitelist rules. */ + * if they are allowed by any of the automatic allowlist rules. */ #define MM_FILTER_POLICY_STRICT \ - (MM_FILTER_RULE_EXPLICIT_WHITELIST | \ - MM_FILTER_RULE_EXPLICIT_BLACKLIST | \ - MM_FILTER_RULE_PLUGIN_WHITELIST | \ + (MM_FILTER_RULE_EXPLICIT_ALLOWLIST | \ + MM_FILTER_RULE_EXPLICIT_BLOCKLIST | \ + MM_FILTER_RULE_PLUGIN_ALLOWLIST | \ MM_FILTER_RULE_QRTR | \ MM_FILTER_RULE_VIRTUAL | \ MM_FILTER_RULE_NET | \ @@ -83,9 +83,9 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/ MM_FILTER_RULE_TTY_WITH_NET | \ MM_FILTER_RULE_TTY_DEFAULT_FORBIDDEN) -/* This policy only allows using device ports explicitly whitelisted via +/* This policy only allows using device ports explicitly allowlisted via * udev rules. i.e. ModemManager won't do any kind of automatic probing. */ -#define MM_FILTER_POLICY_WHITELIST_ONLY MM_FILTER_RULE_EXPLICIT_WHITELIST +#define MM_FILTER_POLICY_ALLOWLIST_ONLY MM_FILTER_RULE_EXPLICIT_ALLOWLIST /* The strict policy has all supported rules */ #define MM_FILTER_RULE_ALL MM_FILTER_POLICY_STRICT @@ -101,11 +101,11 @@ gboolean mm_filter_device_and_port (MMFilter *self, MMDevice *device, MMKernelDevice *port); -void mm_filter_register_plugin_whitelist_tag (MMFilter *self, +void mm_filter_register_plugin_allowlist_tag (MMFilter *self, const gchar *tag); -void mm_filter_register_plugin_whitelist_vendor_id (MMFilter *self, +void mm_filter_register_plugin_allowlist_vendor_id (MMFilter *self, guint16 vid); -void mm_filter_register_plugin_whitelist_product_id (MMFilter *self, +void mm_filter_register_plugin_allowlist_product_id (MMFilter *self, guint16 vid, guint16 pid); diff --git a/src/mm-plugin-manager.c b/src/mm-plugin-manager.c index 4e9f3008..f0bdba0d 100644 --- a/src/mm-plugin-manager.c +++ b/src/mm-plugin-manager.c @@ -1614,48 +1614,48 @@ mm_plugin_manager_get_subsystems (MMPluginManager *self) /*****************************************************************************/ static void -register_plugin_whitelist_tags (MMPluginManager *self, +register_plugin_allowlist_tags (MMPluginManager *self, MMPlugin *plugin) { const gchar **tags; guint i; - if (!mm_filter_check_rule_enabled (self->priv->filter, MM_FILTER_RULE_PLUGIN_WHITELIST)) + if (!mm_filter_check_rule_enabled (self->priv->filter, MM_FILTER_RULE_PLUGIN_ALLOWLIST)) return; tags = mm_plugin_get_allowed_udev_tags (plugin); for (i = 0; tags && tags[i]; i++) - mm_filter_register_plugin_whitelist_tag (self->priv->filter, tags[i]); + mm_filter_register_plugin_allowlist_tag (self->priv->filter, tags[i]); } static void -register_plugin_whitelist_vendor_ids (MMPluginManager *self, +register_plugin_allowlist_vendor_ids (MMPluginManager *self, MMPlugin *plugin) { const guint16 *vendor_ids; guint i; - if (!mm_filter_check_rule_enabled (self->priv->filter, MM_FILTER_RULE_PLUGIN_WHITELIST)) + if (!mm_filter_check_rule_enabled (self->priv->filter, MM_FILTER_RULE_PLUGIN_ALLOWLIST)) return; vendor_ids = mm_plugin_get_allowed_vendor_ids (plugin); for (i = 0; vendor_ids && vendor_ids[i]; i++) - mm_filter_register_plugin_whitelist_vendor_id (self->priv->filter, vendor_ids[i]); + mm_filter_register_plugin_allowlist_vendor_id (self->priv->filter, vendor_ids[i]); } static void -register_plugin_whitelist_product_ids (MMPluginManager *self, +register_plugin_allowlist_product_ids (MMPluginManager *self, MMPlugin *plugin) { const mm_uint16_pair *product_ids; guint i; - if (!mm_filter_check_rule_enabled (self->priv->filter, MM_FILTER_RULE_PLUGIN_WHITELIST)) + if (!mm_filter_check_rule_enabled (self->priv->filter, MM_FILTER_RULE_PLUGIN_ALLOWLIST)) return; product_ids = mm_plugin_get_allowed_product_ids (plugin); for (i = 0; product_ids && product_ids[i].l; i++) - mm_filter_register_plugin_whitelist_product_id (self->priv->filter, product_ids[i].l, product_ids[i].r); + mm_filter_register_plugin_allowlist_product_id (self->priv->filter, product_ids[i].l, product_ids[i].r); } static MMPlugin * @@ -1860,10 +1860,10 @@ load_plugins (MMPluginManager *self, g_ptr_array_add (subsystems, g_strdup (plugin_subsystems[i])); } - /* Register plugin whitelist rules in filter, if any */ - register_plugin_whitelist_tags (self, plugin); - register_plugin_whitelist_vendor_ids (self, plugin); - register_plugin_whitelist_product_ids (self, plugin); + /* Register plugin allowlist rules in filter, if any */ + register_plugin_allowlist_tags (self, plugin); + register_plugin_allowlist_vendor_ids (self, plugin); + register_plugin_allowlist_product_ids (self, plugin); } /* Check the generic plugin once all looped */ |