dhcpcd: Add Android patches
Change-Id: Ia232992f6e18a1494ad12e38c95fd0d2a7520e8e
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/dhcp.c b/dhcp.c
index bd6c719..0642ba1 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -839,7 +839,6 @@
const struct if_options *ifo = iface->state->options;
const struct dhcp_lease *lease = &iface->state->lease;
- printf("%s: Start\n", __func__);
dhcp = xzalloc(sizeof (*dhcp));
m = (uint8_t *)dhcp;
p = dhcp->options;
@@ -1056,6 +1055,13 @@
iface->name, iface->leasefile);
fd = open(iface->leasefile, O_WRONLY | O_CREAT | O_TRUNC, 0444);
+#ifdef ANDROID
+ if (fd == -1 && errno == EACCES) {
+ /* the lease file might have been created when dhcpcd was running as root */
+ unlink(iface->leasefile);
+ fd = open(iface->leasefile, O_WRONLY | O_CREAT | O_TRUNC, 0444);
+ }
+#endif
if (fd == -1) {
syslog(LOG_ERR, "%s: open: %m", iface->name);
return -1;