aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2011-03-23 14:42:07 -0700
committerDmitry Shmidt <dimitrysh@google.com>2011-03-23 14:44:04 -0700
commit98564e9e7ad91339b5d4fe85b6ecff6e58a25751 (patch)
treedecc575c39c65b0371c2e8d7d3c773ecfe048bfc
parentcaa3ae59116c4d03fccc2996fed935bf297a15ec (diff)
downloadexternal_dhcpcd-98564e9e7ad91339b5d4fe85b6ecff6e58a25751.zip
external_dhcpcd-98564e9e7ad91339b5d4fe85b6ecff6e58a25751.tar.gz
external_dhcpcd-98564e9e7ad91339b5d4fe85b6ecff6e58a25751.tar.bz2
Fix dhcp.{iface_name}.pid property setting
Change-Id: I57b3da6eec12d34ae9f13db4220e454a3c570171 Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
-rw-r--r--dhcpcd.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index e984ceb..c229baf 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1898,9 +1898,14 @@ main(int argc, char **argv)
char pidpropname[PROPERTY_KEY_MAX];
char pidpropval[PROPERTY_VALUE_MAX];
+ if (optind != argc - 1) {
+ syslog(LOG_ERR, "Android requires an interface");
+ exit(EXIT_FAILURE);
+ }
+
if (snprintf(pidpropname,
sizeof(pidpropname),
- "dhcp.%s.pid", iface->name) >= PROPERTY_KEY_MAX)
+ "dhcp.%s.pid", argv[optind]) >= PROPERTY_KEY_MAX)
exit(EXIT_FAILURE);
property_get(pidpropname, pidpropval, NULL);
if (strlen(pidpropval) == 0)
@@ -1978,9 +1983,14 @@ main(int argc, char **argv)
if (set_cloexec(pidfd) == -1)
exit(EXIT_FAILURE);
#ifdef ANDROID
+ if (optind != argc - 1) {
+ syslog(LOG_ERR, "Android requires an interface");
+ exit(EXIT_FAILURE);
+ }
+
if (snprintf(pidpropname,
sizeof(pidpropname),
- "dhcp.%s.pid", iface->name) >= PROPERTY_KEY_MAX)
+ "dhcp.%s.pid", argv[optind]) >= PROPERTY_KEY_MAX)
exit(EXIT_FAILURE);
if (snprintf(pidpropval, sizeof(pidpropval), "%d", getpid()) >= PROPERTY_VALUE_MAX)
exit(EXIT_FAILURE);