summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2011-05-26 14:38:03 +0000
committerreyk <reyk@openbsd.org>2011-05-26 14:38:03 +0000
commit82b2e7eb59df64850ab6367359989618f445c529 (patch)
tree326268151fe5c9cbfd287390b1a0471bec38c5d1
parentremove hack to test and create /usr/lib/pkgconfig/ if needed, it's been six (diff)
downloadwireguard-openbsd-82b2e7eb59df64850ab6367359989618f445c529.tar.xz
wireguard-openbsd-82b2e7eb59df64850ab6367359989618f445c529.zip
fix "check script" by sending all required information to the parent.
-rw-r--r--usr.sbin/relayd/check_script.c24
-rw-r--r--usr.sbin/relayd/relayd.h5
2 files changed, 18 insertions, 11 deletions
diff --git a/usr.sbin/relayd/check_script.c b/usr.sbin/relayd/check_script.c
index 5dff88d0113..6e5270d979e 100644
--- a/usr.sbin/relayd/check_script.c
+++ b/usr.sbin/relayd/check_script.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: check_script.c,v 1.12 2011/05/09 12:08:47 reyk Exp $ */
+/* $OpenBSD: check_script.c,v 1.13 2011/05/26 14:38:03 reyk Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -45,11 +45,19 @@ void
check_script(struct relayd *env, struct host *host)
{
struct ctl_script scr;
+ struct table *table;
+
+ if ((table = table_find(env, host->conf.tableid)) == NULL)
+ fatalx("check_script: invalid table id");
host->last_up = host->up;
host->flags &= ~(F_CHECK_SENT|F_CHECK_DONE);
scr.host = host->conf.id;
+ strlcpy(scr.name, host->conf.name, sizeof(host->conf.name));
+ strlcpy(scr.path, table->conf.path, sizeof(table->conf.path));
+ memcpy(&scr.timeout, &table->conf.timeout, sizeof(scr.timeout));
+
proc_compose_imsg(env->sc_ps, PROC_PARENT, 0, IMSG_SCRIPT,
-1, &scr, sizeof(scr));
}
@@ -92,18 +100,14 @@ script_exec(struct relayd *env, struct ctl_script *scr)
struct itimerval it;
struct timeval *tv;
const char *file, *arg;
- struct host *host;
- struct table *table;
struct passwd *pw;
- if ((host = host_find(env, scr->host)) == NULL)
- fatalx("script_exec: invalid host id");
- if ((table = table_find(env, host->conf.tableid)) == NULL)
- fatalx("script_exec: invalid table id");
+ DPRINTF("%s: running script %s, host %s",
+ __func__, scr->path, scr->name);
- arg = host->conf.name;
- file = table->conf.path;
- tv = &table->conf.timeout;
+ arg = scr->name;
+ file = scr->path;
+ tv = &scr->timeout;
save_quit = signal(SIGQUIT, SIG_IGN);
save_int = signal(SIGINT, SIG_IGN);
diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h
index 5a649b83ae1..f535b6778fd 100644
--- a/usr.sbin/relayd/relayd.h
+++ b/usr.sbin/relayd/relayd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.h,v 1.148 2011/05/20 09:43:53 reyk Exp $ */
+/* $OpenBSD: relayd.h,v 1.149 2011/05/26 14:38:03 reyk Exp $ */
/*
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -101,6 +101,9 @@ struct ctl_id {
struct ctl_script {
objid_t host;
int retval;
+ struct timeval timeout;
+ char name[MAXHOSTNAMELEN];
+ char path[MAXPATHLEN];
};
struct ctl_demote {