summaryrefslogtreecommitdiffstats
path: root/cfg.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-12-29 21:28:32 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-12-29 21:28:32 +0000
commit230e39ec3558142c94858efae53c36ab0efbcf59 (patch)
treee1d6b2799fcb4736dbebafffbd7ee8d0d4e0e5ae /cfg.c
parentefa8c93664f6cf7a7b70a5f4b915d8fb135a0744 (diff)
Allow the config file parser and source-file to return "don't exit" to
the client to let attach work from configuration files.
Diffstat (limited to 'cfg.c')
-rw-r--r--cfg.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/cfg.c b/cfg.c
index 406cf219..75e0414f 100644
--- a/cfg.c
+++ b/cfg.c
@@ -80,6 +80,7 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
size_t len;
struct cmd_list *cmdlist;
struct cmd_ctx ctx;
+ int retval;
if ((f = fopen(path, "rb")) == NULL) {
cfg_add_cause(causes, "%s: %s", path, strerror(errno));
@@ -88,6 +89,7 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
n = 0;
line = NULL;
+ retval = 0;
while ((buf = fgetln(f, &len))) {
if (buf[len - 1] == '\n')
buf[len - 1] = '\0';
@@ -125,19 +127,17 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
ctx.info = cfg_print;
cfg_cause = NULL;
- cmd_list_exec(cmdlist, &ctx);
+ if (cmd_list_exec(cmdlist, &ctx) == 1)
+ retval = 1;
cmd_list_free(cmdlist);
if (cfg_cause != NULL) {
cfg_add_cause(causes, "%s: %d: %s", path, n, cfg_cause);
xfree(cfg_cause);
- continue;
}
}
if (line != NULL)
xfree(line);
fclose(f);
- if (ARRAY_LENGTH(causes) != 0)
- return (-1);
- return (0);
+ return (retval);
}