From b1db6527cf9d4801e48dfe6e9fe8124532269159 Mon Sep 17 00:00:00 2001 From: Loic Poulain Date: Wed, 16 Dec 2020 14:01:53 +0100 Subject: filter: Add wwan port devices Allow WWAN control ports. Signed-off-by: Loic Poulain --- src/mm-filter.c | 8 ++++++++ src/mm-filter.h | 13 +++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/mm-filter.c b/src/mm-filter.c index 3bc84e17..cdfc5448 100644 --- a/src/mm-filter.c +++ b/src/mm-filter.c @@ -215,6 +215,13 @@ mm_filter_port (MMFilter *self, return TRUE; } + /* If this is a wwan port/device, we always allow it */ + if ((self->priv->enabled_rules & MM_FILTER_RULE_WWAN) && + (g_strcmp0 (subsystem, "wwan") == 0)) { + mm_obj_dbg (self, "(%s/%s) port allowed: wwan device", subsystem, name); + return TRUE; + } + /* If this is a tty device, we may allow it */ if ((self->priv->enabled_rules & MM_FILTER_RULE_TTY) && (g_strcmp0 (subsystem, "tty") == 0)) { @@ -467,6 +474,7 @@ mm_filter_new (MMFilterRule enabled_rules, mm_obj_dbg (self, " net devices allowed: %s", RULE_ENABLED_STR (MM_FILTER_RULE_NET)); mm_obj_dbg (self, " usbmisc devices allowed: %s", RULE_ENABLED_STR (MM_FILTER_RULE_USBMISC)); mm_obj_dbg (self, " rpmsg devices allowed: %s", RULE_ENABLED_STR (MM_FILTER_RULE_RPMSG)); + mm_obj_dbg (self, " wwan devices allowed: %s", RULE_ENABLED_STR (MM_FILTER_RULE_WWAN)); if (self->priv->enabled_rules & MM_FILTER_RULE_TTY) { mm_obj_dbg (self, " tty devices:"); mm_obj_dbg (self, " blacklist applied: %s", RULE_ENABLED_STR (MM_FILTER_RULE_TTY_BLACKLIST)); diff --git a/src/mm-filter.h b/src/mm-filter.h index a7fa7c93..de035e18 100644 --- a/src/mm-filter.h +++ b/src/mm-filter.h @@ -64,6 +64,7 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/ MM_FILTER_RULE_TTY_ACM_INTERFACE = 1 << 14, MM_FILTER_RULE_TTY_WITH_NET = 1 << 15, MM_FILTER_RULE_TTY_DEFAULT_FORBIDDEN = 1 << 16, + MM_FILTER_RULE_WWAN = 1 << 17, } MMFilterRule; #define MM_FILTER_RULE_ALL \ @@ -83,7 +84,8 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/ MM_FILTER_RULE_TTY_DRIVER | \ MM_FILTER_RULE_TTY_ACM_INTERFACE | \ MM_FILTER_RULE_TTY_WITH_NET | \ - MM_FILTER_RULE_TTY_DEFAULT_FORBIDDEN) + MM_FILTER_RULE_TTY_DEFAULT_FORBIDDEN | \ + MM_FILTER_RULE_WWAN) /* This is the legacy ModemManager policy that tries to automatically probe * device ports unless they're blacklisted in some way or another. */ @@ -98,7 +100,8 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/ MM_FILTER_RULE_TTY_BLACKLIST | \ MM_FILTER_RULE_TTY_MANUAL_SCAN_ONLY | \ MM_FILTER_RULE_TTY_PLATFORM_DRIVER | \ - MM_FILTER_RULE_TTY_DEFAULT_ALLOWED) + MM_FILTER_RULE_TTY_DEFAULT_ALLOWED | \ + MM_FILTER_RULE_WWAN) /* This is a stricter policy which will only automatically probe device ports * if they are allowed by any of the automatic whitelist rules. */ @@ -116,7 +119,8 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/ MM_FILTER_RULE_TTY_DRIVER | \ MM_FILTER_RULE_TTY_ACM_INTERFACE | \ MM_FILTER_RULE_TTY_WITH_NET | \ - MM_FILTER_RULE_TTY_DEFAULT_FORBIDDEN) + MM_FILTER_RULE_TTY_DEFAULT_FORBIDDEN | \ + MM_FILTER_RULE_WWAN) /* This is equivalent to the strict policy, but also applying the device * blacklists explicitly */ @@ -136,7 +140,8 @@ typedef enum { /*< underscore_name=mm_filter_rule >*/ MM_FILTER_RULE_TTY_DRIVER | \ MM_FILTER_RULE_TTY_ACM_INTERFACE | \ MM_FILTER_RULE_TTY_WITH_NET | \ - MM_FILTER_RULE_TTY_DEFAULT_FORBIDDEN) + MM_FILTER_RULE_TTY_DEFAULT_FORBIDDEN | \ + MM_FILTER_RULE_WWAN) /* This policy only allows using device ports explicitly whitelisted via * udev rules. i.e. ModemManager won't do any kind of automatic probing. */ -- cgit v1.2.3