diff options
author | Peter Qiu <zqiu@google.com> | 2015-09-29 09:48:03 -0700 |
---|---|---|
committer | Peter Qiu <zqiu@google.com> | 2015-09-29 20:17:15 +0000 |
commit | 784aa32ee151a52eea942f3f08f0773529228763 (patch) | |
tree | 2a9daf4d6de0bf7767754441e5fcc32adf155077 | |
parent | 2a9f348075be89217b7efdc1e2255992ba4f99d7 (diff) | |
download | apmanager-784aa32ee151a52eea942f3f08f0773529228763.tar.gz |
Overwrite dnsmasq pid file path for Android
dnsmasq normally creates a pid file in /var/run/dnsmasq.pid, which
doesn't exist on Android. So specify the pid file to a valid file
path on Android.
Bug: 22828115
TEST=Manual test on dragonboard
Change-Id: Ibd1db2d4df71d2693204307ad6886132da4187b7
-rw-r--r-- | dhcp_server.cc | 8 | ||||
-rw-r--r-- | dhcp_server.h | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/dhcp_server.cc b/dhcp_server.cc index de54bdf..5531f0d 100644 --- a/dhcp_server.cc +++ b/dhcp_server.cc @@ -40,6 +40,8 @@ const char DHCPServer::kDnsmasqConfigFilePathFormat[] = "/data/misc/apmanager/dnsmasq/dhcpd-%d.conf"; const char DHCPServer::kDHCPLeasesFilePathFormat[] = "/data/misc/apmanager/dnsmasq/dhcpd-%d.leases"; +const char DHCPServer::kDnsmasqPidFilePath[] = + "/data/misc/apmanager/dnsmasq/dnsmasq.pid"; #endif // __ANDROID__ const char DHCPServer::kServerAddressFormat[] = "192.168.%d.254"; @@ -100,6 +102,12 @@ bool DHCPServer::Start() { dnsmasq_process_->AddArg(kDnsmasqPath); dnsmasq_process_->AddArg(base::StringPrintf("--conf-file=%s", file_name.c_str())); +#if defined(__ANDROID__) + // dnsmasq normally creates a pid file in /var/run/dnsmasq.pid. Overwrite + // this file path for Android. + dnsmasq_process_->AddArg( + base::StringPrintf("--pid-file=%s", kDnsmasqPidFilePath)); +#endif // __ANDROID__ if (!dnsmasq_process_->Start()) { rtnl_handler_->RemoveInterfaceAddress(interface_index, server_address_); dnsmasq_process_.reset(); diff --git a/dhcp_server.h b/dhcp_server.h index 5a2320f..881edbb 100644 --- a/dhcp_server.h +++ b/dhcp_server.h @@ -50,6 +50,9 @@ class DHCPServer { static const char kAddressRangeHighFormat[]; static const int kServerAddressPrefix; static const int kTerminationTimeoutSeconds; +#if defined(__ANDROID__) + static const char kDnsmasqPidFilePath[]; +#endif // __ANDROID__ uint16_t server_address_index_; std::string interface_name_; |