summaryrefslogtreecommitdiff
path: root/common/print.c
diff options
context:
space:
mode:
authorDavid Hankins <dhankins@isc.org>2006-07-31 22:19:51 +0000
committerDavid Hankins <dhankins@isc.org>2006-07-31 22:19:51 +0000
commitb543fea9d425b507066d6d82e89a7787a0354eb1 (patch)
tree7e7e5184bb8466750ddaa9eec43d6b2ce42e9a57 /common/print.c
parentd5341d9b5f08f17d05dd00350a51d1c49f6393ff (diff)
downloadisc-dhcp-b543fea9d425b507066d6d82e89a7787a0354eb1.tar.gz
- A new common configuration executable statement, execute(), has been
added. This permits dhcpd or dhclient to execute a named external program with command line arguments specified from other configuration language. Thanks to a patch written by Mattias Ronnblom, gotten to us via Robin Breathe. [ISC-Bugs #13728]
Diffstat (limited to 'common/print.c')
-rw-r--r--common/print.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/common/print.c b/common/print.c
index a1c748ad..4438fbe5 100644
--- a/common/print.c
+++ b/common/print.c
@@ -34,7 +34,7 @@
#ifndef lint
static char copyright[] =
-"$Id: print.c,v 1.60 2006/06/06 16:35:18 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
+"$Id: print.c,v 1.61 2006/07/31 22:19:51 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -461,7 +461,8 @@ static unsigned print_subexpression (expr, buf, len)
{
unsigned rv, left;
const char *s;
-
+ struct expression *next_arg;
+
switch (expr -> op) {
case expr_none:
if (len > 3) {
@@ -1046,10 +1047,46 @@ static unsigned print_subexpression (expr, buf, len)
rv += strlen (foo -> string);
}
}
- buf [rv] = ')';
- buf [rv++] = 0;
+ buf [rv++] = ')';
+ buf [rv] = 0;
+ return rv;
+ }
+ case expr_execute:
+#ifdef ENABLE_EXECUTE
+ rv = 11 + strlen(expr->data.execute.command);
+ if (len > rv + 2) {
+ sprintf(buf, "(execute \"%s\"",
+ expr->data.execute.command);
+ for(next_arg = expr->data.execute.arglist;
+ next_arg;
+ next_arg = next_arg->data.arg.next) {
+ if (len <= rv + 3)
+ return 0;
+
+ buf[rv++] = ' ';
+ rv += print_subexpression(next_arg->
+ data.arg.val,
+ buf + rv,
+ len - rv - 2);
+ }
+
+ if (len <= rv + 2)
+ return 0;
+
+ buf[rv++] = ')';
+ buf[rv] = 0;
return rv;
}
+#else
+ log_fatal("Impossible case at %s:%d (ENABLE_EXECUTE is not "
+ "defined.", MDL);
+#endif
+ break;
+
+ default:
+ log_fatal("Impossible case at %s:%d (undefined expression "
+ "%d).", MDL, expr->op);
+ break;
}
return 0;
}