filter: allow selection of filter policy on startup
Added a new '--filter-policy=[POLICY]' option in the daemon, which allows selecting between the supported filter policies. For now, only two policies are defined: * default: the default policy used by ModemManager, where it tries to probe and detect as many modem ports as possible. * whitelist-only: only devices explicitly tagged via udev (with the ID_MM_DEVICE_PROCESS tag) will be probed and used.
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <mm-gdbus-test.h>
|
||||
|
||||
#include "mm-base-manager.h"
|
||||
#include "mm-daemon-enums-types.h"
|
||||
#include "mm-device.h"
|
||||
#include "mm-plugin-manager.h"
|
||||
#include "mm-auth.h"
|
||||
@@ -52,6 +53,7 @@ enum {
|
||||
PROP_0,
|
||||
PROP_CONNECTION,
|
||||
PROP_AUTO_SCAN,
|
||||
PROP_FILTER_POLICY,
|
||||
PROP_ENABLE_TEST,
|
||||
PROP_PLUGIN_DIR,
|
||||
PROP_INITIAL_KERNEL_EVENTS,
|
||||
@@ -63,6 +65,8 @@ struct _MMBaseManagerPrivate {
|
||||
GDBusConnection *connection;
|
||||
/* Whether auto-scanning is enabled */
|
||||
gboolean auto_scan;
|
||||
/* Filter policy (mask of enabled rules) */
|
||||
MMFilterRule filter_policy;
|
||||
/* Whether the test interface is enabled */
|
||||
gboolean enable_test;
|
||||
/* Path to look for plugins */
|
||||
@@ -962,23 +966,25 @@ out:
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBaseManager *
|
||||
mm_base_manager_new (GDBusConnection *connection,
|
||||
const gchar *plugin_dir,
|
||||
gboolean auto_scan,
|
||||
const gchar *initial_kernel_events,
|
||||
gboolean enable_test,
|
||||
GError **error)
|
||||
mm_base_manager_new (GDBusConnection *connection,
|
||||
const gchar *plugin_dir,
|
||||
gboolean auto_scan,
|
||||
MMFilterRule filter_policy,
|
||||
const gchar *initial_kernel_events,
|
||||
gboolean enable_test,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
|
||||
|
||||
return g_initable_new (MM_TYPE_BASE_MANAGER,
|
||||
NULL, /* cancellable */
|
||||
error,
|
||||
MM_BASE_MANAGER_CONNECTION, connection,
|
||||
MM_BASE_MANAGER_PLUGIN_DIR, plugin_dir,
|
||||
MM_BASE_MANAGER_AUTO_SCAN, auto_scan,
|
||||
MM_BASE_MANAGER_CONNECTION, connection,
|
||||
MM_BASE_MANAGER_PLUGIN_DIR, plugin_dir,
|
||||
MM_BASE_MANAGER_AUTO_SCAN, auto_scan,
|
||||
MM_BASE_MANAGER_FILTER_POLICY, filter_policy,
|
||||
MM_BASE_MANAGER_INITIAL_KERNEL_EVENTS, initial_kernel_events,
|
||||
MM_BASE_MANAGER_ENABLE_TEST, enable_test,
|
||||
MM_BASE_MANAGER_ENABLE_TEST, enable_test,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -1016,6 +1022,9 @@ set_property (GObject *object,
|
||||
case PROP_AUTO_SCAN:
|
||||
priv->auto_scan = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_FILTER_POLICY:
|
||||
priv->filter_policy = g_value_get_flags (value);
|
||||
break;
|
||||
case PROP_ENABLE_TEST:
|
||||
priv->enable_test = g_value_get_boolean (value);
|
||||
break;
|
||||
@@ -1048,6 +1057,9 @@ get_property (GObject *object,
|
||||
case PROP_AUTO_SCAN:
|
||||
g_value_set_boolean (value, priv->auto_scan);
|
||||
break;
|
||||
case PROP_FILTER_POLICY:
|
||||
g_value_set_flags (value, priv->filter_policy);
|
||||
break;
|
||||
case PROP_ENABLE_TEST:
|
||||
g_value_set_boolean (value, priv->enable_test);
|
||||
break;
|
||||
@@ -1127,7 +1139,7 @@ initable_init (GInitable *initable,
|
||||
#endif
|
||||
|
||||
/* Create filter */
|
||||
priv->filter = mm_filter_new (MM_FILTER_RULE_ALL);
|
||||
priv->filter = mm_filter_new (priv->filter_policy);
|
||||
|
||||
/* Create plugin manager */
|
||||
priv->plugin_manager = mm_plugin_manager_new (priv->plugin_dir, error);
|
||||
@@ -1238,6 +1250,15 @@ mm_base_manager_class_init (MMBaseManagerClass *manager_class)
|
||||
TRUE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (
|
||||
object_class, PROP_FILTER_POLICY,
|
||||
g_param_spec_flags (MM_BASE_MANAGER_FILTER_POLICY,
|
||||
"Filter policy",
|
||||
"Mask of rules enabled in the filter",
|
||||
MM_TYPE_FILTER_RULE,
|
||||
MM_FILTER_RULE_NONE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ENABLE_TEST,
|
||||
g_param_spec_boolean (MM_BASE_MANAGER_ENABLE_TEST,
|
||||
|
Reference in New Issue
Block a user