shill: add ability to blacklist devices
BUG=chromium-os:16787
TEST=ebuild + manual
manual testing: set up mac80211_hwsim and hostapd on a device.
run shill, observe that it core dumps. run shill again, with
"--black-list=mon.wlan1", observe that it does not core dump.
Change-Id: Id43ed8badc2d8ac414c8a2ceb7487ecb85dc851c
Reviewed-on: http://gerrit.chromium.org/gerrit/4414
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Tested-by: mukesh agrawal <quiche@chromium.org>
diff --git a/shill_main.cc b/shill_main.cc
index c3153a1..07dde74 100644
--- a/shill_main.cc
+++ b/shill_main.cc
@@ -4,12 +4,14 @@
#include <time.h>
#include <string>
+#include <vector>
#include <base/at_exit.h>
#include <base/command_line.h>
#include <base/file_path.h>
#include <base/logging.h>
#include <base/string_number_conversions.h>
+#include <base/string_split.h>
#include <chromeos/syslog_logging.h>
#include "shill/dbus_control.h"
@@ -20,6 +22,7 @@
#include "shill/shill_daemon.h"
using std::string;
+using std::vector;
namespace switches {
@@ -29,6 +32,8 @@
static const char kConfigDir[] = "config-dir";
// Directory to read default configuration settings (Read Only).
static const char kDefaultConfigDir[] = "default-config-dir";
+// Don't attempt to manage these devices.
+static const char kDeviceBlackList[] = "device-black-list";
// Flag that causes shill to show the help message and exit.
static const char kHelp[] = "help";
// LOG() level. 0 = INFO, 1 = WARNING, 2 = ERROR.
@@ -39,10 +44,12 @@
"Available Switches: \n"
" --foreground\n"
" Don\'t daemon()ize; run in foreground.\n"
- " --config_dir\n"
+ " --config-dir\n"
" Directory to read confguration settings.\n"
- " --default_config_dir\n"
- " Directory to read default configuration settings (Read Only)."
+ " --default-config-dir\n"
+ " Directory to read default configuration settings (Read Only).\n"
+ " --device-black-list=device1,device2\n"
+ " Do not manage devices named device1 or device2\n"
" --log-level=N\n"
" LOG() level. 0 = INFO, 1 = WARNING, 2 = ERROR.\n"
" --v=N\n"
@@ -108,6 +115,17 @@
shill::DHCPProvider::GetInstance()->Init(&glib);
shill::Daemon daemon(&config, dbus_control.get(), &glib);
+
+ if (cl->HasSwitch(switches::kDeviceBlackList)) {
+ vector<string> device_list;
+ base::SplitString(cl->GetSwitchValueASCII(switches::kDeviceBlackList),
+ ',', &device_list);
+
+ vector<string>::iterator i;
+ for (i = device_list.begin(); i != device_list.end(); ++i) {
+ daemon.AddDeviceToBlackList(*i);
+ }
+ }
daemon.Run();
return 0;