summaryrefslogtreecommitdiffstats
path: root/configure.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-01-12 16:39:01 +0000
committerRoy Marples <roy@marples.name>2009-01-12 16:39:01 +0000
commite467f4b21724ad4c3c9f7a3ee9af91c4385a8a88 (patch)
tree8337a6a5ba3d2bb2a4db5f23a2831fe32de2b0e4 /configure.c
parente0c05611c032b8a1e75a11aa8bdbfecf34acf785 (diff)
downloaddhcpcd-e467f4b21724ad4c3c9f7a3ee9af91c4385a8a88.tar.xz
Remove the limit for the number of connections to the control socket.
Send the dhcpcd-run-hooks enviornment to listeners on the control socket.
Diffstat (limited to 'configure.c')
-rw-r--r--configure.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/configure.c b/configure.c
index 917bd181..24bec760 100644
--- a/configure.c
+++ b/configure.c
@@ -26,6 +26,7 @@
*/
#include <sys/stat.h>
+#include <sys/uio.h>
#include <sys/wait.h>
#include <netinet/in.h>
@@ -135,17 +136,41 @@ append_config(char ***env, ssize_t *len,
*env = ne;
}
+static size_t
+arraytostr(const char *const *argv, char **s)
+{
+ const char *const *ap;
+ char *p;
+ size_t len, l;
+
+ len = 0;
+ ap = argv;
+ while (*ap)
+ len += strlen(*ap++) + 1;
+ *s = p = xmalloc(len);
+ ap = argv;
+ while (*ap) {
+ l = strlen(*ap) + 1;
+ memcpy(p, *ap, l);
+ p += l;
+ ap++;
+ }
+ return len;
+}
+
int
run_script(const struct interface *iface, const char *reason)
{
char *const argv[2] = { UNCONST(iface->state->options->script), NULL };
char **env = NULL, **ep;
- char *path, *p;
+ char *path, *p, *bigenv;
ssize_t e, elen, l;
pid_t pid;
int status = 0;
const struct if_options *ifo = iface->state->options;
const struct interface *ifp;
+ const struct fd_list *fd;
+ struct iovec iov[2];
syslog(LOG_DEBUG, "%s: executing `%s', reason %s",
iface->name, argv[0], reason);
@@ -236,6 +261,23 @@ run_script(const struct interface *iface, const char *reason)
}
}
+ /* Send to our listeners */
+ bigenv = NULL;
+ for (fd = fds; fd != NULL; fd = fd->next) {
+ if (fd->listener) {
+ if (bigenv == NULL) {
+ elen = arraytostr((const char *const *)env,
+ &bigenv);
+ iov[0].iov_base = &elen;
+ iov[0].iov_len = sizeof(size_t);
+ iov[1].iov_base = bigenv;
+ iov[1].iov_len = elen;
+ }
+ writev(fd->fd, iov, 2);
+ }
+ }
+ free(bigenv);
+
/* Cleanup */
ep = env;
while (*ep)