aboutsummaryrefslogtreecommitdiffstats
path: root/dhcp.c
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2011-01-24 16:42:36 -0800
committerDmitry Shmidt <dimitrysh@google.com>2011-01-25 11:26:43 -0800
commit0545fad98723550607287a86bfee3807c7d26e91 (patch)
tree929f297d0827ea7caec97da72100f02a91095295 /dhcp.c
parente86eee143ed21592f88a46623a81f71002430459 (diff)
downloadexternal_dhcpcd-0545fad98723550607287a86bfee3807c7d26e91.zip
external_dhcpcd-0545fad98723550607287a86bfee3807c7d26e91.tar.gz
external_dhcpcd-0545fad98723550607287a86bfee3807c7d26e91.tar.bz2
dhcpcd: Add Android patches
Change-Id: Ia232992f6e18a1494ad12e38c95fd0d2a7520e8e Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'dhcp.c')
-rw-r--r--dhcp.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/dhcp.c b/dhcp.c
index bd6c719..0642ba1 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -839,7 +839,6 @@ make_message(struct dhcp_message **message,
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 @@ write_lease(const struct interface *iface, const struct dhcp_message *dhcp)
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;