Launch dhcpcd using Minijail.

dhcpcd runs as root and listens on the network. Launch it using Minijail
so that we can run it as a regular user, mitigating the risk of an eventual
compromise.

Add a mock Minijail wrapper for unittesting.

BUG=chromium-os:28336
TEST=dhcp_config_unittest
TEST=network_netperf2
TEST=Manual connection to ethernet, GoogleGuest, Google-A.
CQ-DEPEND=I243e02c82f70c6a3469ca712e539ec9fb6e3e4d4

Change-Id: I14c4e843eba478ed39b10fa4fcb0e25eb3186c1a
Reviewed-on: https://gerrit.chromium.org/gerrit/20414
Commit-Ready: Jorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Tested-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
diff --git a/device_unittest.cc b/device_unittest.cc
index fb24466..cb769ad 100644
--- a/device_unittest.cc
+++ b/device_unittest.cc
@@ -25,6 +25,8 @@
 #include "shill/mock_connection.h"
 #include "shill/mock_device.h"
 #include "shill/mock_device_info.h"
+#include "shill/mock_dhcp_config.h"
+#include "shill/mock_dhcp_provider.h"
 #include "shill/mock_glib.h"
 #include "shill/mock_ipconfig.h"
 #include "shill/mock_manager.h"
@@ -190,12 +192,20 @@
 
 TEST_F(DeviceTest, AcquireIPConfig) {
   device_->ipconfig_ = new IPConfig(control_interface(), "randomname");
-  EXPECT_CALL(*glib(), SpawnAsync(_, _, _, _, _, _, _, _))
+  scoped_ptr<MockDHCPProvider> dhcp_provider(new MockDHCPProvider());
+  device_->dhcp_provider_ = dhcp_provider.get();
+  scoped_refptr<MockDHCPConfig> dhcp_config(new MockDHCPConfig(
+                                                    control_interface(),
+                                                    kDeviceName));
+  EXPECT_CALL(*dhcp_provider, CreateConfig(_, _, _, _))
+      .WillOnce(Return(dhcp_config));
+  EXPECT_CALL(*dhcp_config, RequestIP())
       .WillOnce(Return(false));
   EXPECT_FALSE(device_->AcquireIPConfig());
   ASSERT_TRUE(device_->ipconfig_.get());
   EXPECT_EQ(kDeviceName, device_->ipconfig_->device_name());
   EXPECT_FALSE(device_->ipconfig_->update_callback_.is_null());
+  device_->dhcp_provider_ = NULL;
 }
 
 TEST_F(DeviceTest, Load) {