aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-06-02 15:42:58 +0200
committerAleksander Morgado <aleksander@aleksander.es>2020-06-04 11:34:43 +0200
commita5c060ef879c804ee21aa6c68784ccdac7171ee7 (patch)
tree00e1e6e1bc23651113d9305770ea0873f5c9688f /src
parentbbeca601138ff51b817bb1ef84b53a70572d0c19 (diff)
filter: setup automatic per-vid checks in the plugin whitelist
Until now, the plugin whitelist rule in the filter would only handle those plugins that require specific udev tags, and those that had explicit full vid:pid pairs. This update makes a new implicit automatic whitelist for all devices that match any of the vids managed by the different plugins. Looking at the current list of devices in the blacklist and greylist maintained by ModemManager, there are no devices falling under the list of supported plugin vids that would need to be blacklisted; except for u-blox GPS modules: huawei -> 0x12d1 -> None in blacklist/greylist thuraya -> 0x1a26 -> None in blacklist/greylist telit -> 0x1bc7 -> None in blacklist/greylist dLink -> 0x2001 -> None in blacklist/greylist wavecom -> 0x114f -> None in blacklist/greylist x22x -> 0x1bbb,0x0b3c -> None in blacklist/greylist anydata -> 0x16d5 -> None in blacklist/greylist quectel -> 0x2c7c -> None in blacklist/greylist haier -> 0x201e -> None in blacklist/greylist novatel -> 0x1410 -> None in blacklist/greylist dell -> 0x413c -> None in blacklist/greylist option -> 0x0af0,0x1931 -> None in blacklist/greylist nokia -> 0x0421 -> None in blacklist/greylist cinterion -> 0x1e2d,0x0681 -> None in blacklist/greylist simtech -> 0x1e0e -> None in blacklist/greylist iridium -> 0x1edd -> None in blacklist/greylist pantech -> 0x106c -> None in blacklist/greylist longcheer -> 0x1c9e,0x1bbb -> None in blacklist/greylist linktop -> 0x230d -> None in blacklist/greylist sierra -> 0x1199 -> None in blacklist/greylist ublox -> 0x1546 -------------> GPS chips blacklisted !!!!! foxconn -> 0x0489 -> None in blacklist/greylist broadmobi -> 0x2020 -> None in blacklist/greylist fibocom -> 0x2cb7 -> None in blacklist/greylist tplink -> 0x2357 -> None in blacklist/greylist zte -> 0x19d2 -> None in blacklist/greylist The rules used to blacklist the u-blox GPS chips have already been moved to the u-blox plugin itself, and now they use the broader ID_MM_DEVICE_IGNORE tag that applies in all filter modes.
Diffstat (limited to 'src')
-rw-r--r--src/mm-filter.c37
-rw-r--r--src/mm-filter.h2
-rw-r--r--src/mm-plugin-manager.c18
-rw-r--r--src/mm-plugin.c6
-rw-r--r--src/mm-plugin.h1
5 files changed, 63 insertions, 1 deletions
diff --git a/src/mm-filter.c b/src/mm-filter.c
index cfa620b4..18ea08f6 100644
--- a/src/mm-filter.c
+++ b/src/mm-filter.c
@@ -39,6 +39,7 @@ enum {
struct _MMFilterPrivate {
MMFilterRule enabled_rules;
GList *plugin_whitelist_tags;
+ GArray *plugin_whitelist_vendor_ids;
GArray *plugin_whitelist_product_ids;
};
@@ -55,6 +56,27 @@ mm_filter_register_plugin_whitelist_tag (MMFilter *self,
}
void
+mm_filter_register_plugin_whitelist_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);
+
+ for (i = 0; i < self->priv->plugin_whitelist_vendor_ids->len; i++) {
+ guint16 item;
+
+ item = g_array_index (self->priv->plugin_whitelist_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);
+}
+
+void
mm_filter_register_plugin_whitelist_product_id (MMFilter *self,
guint16 vid,
guint16 pid)
@@ -140,6 +162,20 @@ mm_filter_port (MMFilter *self,
}
}
}
+
+ if (vid && self->priv->plugin_whitelist_vendor_ids) {
+ guint i;
+
+ for (i = 0; i < self->priv->plugin_whitelist_vendor_ids->len; i++) {
+ guint16 item;
+
+ item = g_array_index (self->priv->plugin_whitelist_vendor_ids, guint16, i);
+ if (item == vid) {
+ mm_obj_dbg (self, "(%s/%s) port allowed: device is whitelisted by plugin (vid)", subsystem, name);
+ return TRUE;
+ }
+ }
+ }
}
/* If this is a virtual device, don't allow it */
@@ -483,6 +519,7 @@ 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);
diff --git a/src/mm-filter.h b/src/mm-filter.h
index b567edb1..c3579979 100644
--- a/src/mm-filter.h
+++ b/src/mm-filter.h
@@ -145,6 +145,8 @@ gboolean mm_filter_device_and_port (MMFilter *self,
void mm_filter_register_plugin_whitelist_tag (MMFilter *self,
const gchar *tag);
+void mm_filter_register_plugin_whitelist_vendor_id (MMFilter *self,
+ guint16 vid);
void mm_filter_register_plugin_whitelist_product_id (MMFilter *self,
guint16 vid,
guint16 pid);
diff --git a/src/mm-plugin-manager.c b/src/mm-plugin-manager.c
index 9ee4edae..e76c9a82 100644
--- a/src/mm-plugin-manager.c
+++ b/src/mm-plugin-manager.c
@@ -1617,6 +1617,21 @@ register_plugin_whitelist_tags (MMPluginManager *self,
}
static void
+register_plugin_whitelist_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))
+ 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]);
+}
+
+static void
register_plugin_whitelist_product_ids (MMPluginManager *self,
MMPlugin *plugin)
{
@@ -1812,7 +1827,8 @@ load_plugins (MMPluginManager *self,
self->priv->plugins = g_list_append (self->priv->plugins, plugin);
/* Register plugin whitelist rules in filter, if any */
- register_plugin_whitelist_tags (self, plugin);
+ register_plugin_whitelist_tags (self, plugin);
+ register_plugin_whitelist_vendor_ids (self, plugin);
register_plugin_whitelist_product_ids (self, plugin);
}
diff --git a/src/mm-plugin.c b/src/mm-plugin.c
index 4f3ec18d..adfe4bf2 100644
--- a/src/mm-plugin.c
+++ b/src/mm-plugin.c
@@ -152,6 +152,12 @@ mm_plugin_get_allowed_udev_tags (MMPlugin *self)
return (const gchar **) self->priv->udev_tags;
}
+const guint16 *
+mm_plugin_get_allowed_vendor_ids (MMPlugin *self)
+{
+ return self->priv->vendor_ids;
+}
+
const mm_uint16_pair *
mm_plugin_get_allowed_product_ids (MMPlugin *self)
{
diff --git a/src/mm-plugin.h b/src/mm-plugin.h
index fe0469c1..f5863522 100644
--- a/src/mm-plugin.h
+++ b/src/mm-plugin.h
@@ -126,6 +126,7 @@ GType mm_plugin_get_type (void);
const gchar *mm_plugin_get_name (MMPlugin *self);
const gchar **mm_plugin_get_allowed_udev_tags (MMPlugin *self);
+const guint16 *mm_plugin_get_allowed_vendor_ids (MMPlugin *self);
const mm_uint16_pair *mm_plugin_get_allowed_product_ids (MMPlugin *self);
gboolean mm_plugin_is_generic (MMPlugin *self);