struct config *config, *new_config;
+char *cf_text; /* Actual position from parser */
+
static struct config *old_config; /* Old configuration */
static struct config *future_config; /* New config held here if recon requested during recon */
static int old_cftype; /* Type of transition old_config -> config (RECONFIG_SOFT/HARD) */
strcpy(buf, "<bug: error message too long>");
va_end(args);
new_config->err_msg = cfg_strdup(buf);
+ new_config->err_token = cfg_strdup(cf_text);
new_config->err_lino = ifs->lino;
new_config->err_file_name = ifs->file_name;
cf_lex_unwind();
int err_lino; /* Line containing error */
char *err_file_name; /* File name containing error */
char *file_name; /* Name of main configuration file */
+ char *err_token; /* Token where parser fell down */
int file_fd; /* File descriptor of main configuration file */
HASH(struct symbol) sym_hash; /* Lexer: symbol hash table */
struct config *fallback; /* Link to regular config for CLI parsing */
lp_flush(c->parser_pool);
res = cli_parse(&f);
if (!res)
- cli_printf(c, 9001, f.err_msg);
+ cli_printf(c, 9001, "Bad command (nearby '%s'): %s", f.err_token, f.err_msg);
config_free(&f);
}
if (!unix_read_config(&conf, config_name))
{
if (conf->err_msg)
- die("%s, line %d: %s", conf->err_file_name, conf->err_lino, conf->err_msg);
+ die("%s, line %d (nearby '%s'): %s", conf->err_file_name, conf->err_lino, conf->err_token, conf->err_msg);
else
die("Unable to open configuration file %s: %m", config_name);
}
if (!unix_read_config(&conf, config_name))
{
if (conf->err_msg)
- log(L_ERR "%s, line %d: %s", conf->err_file_name, conf->err_lino, conf->err_msg);
+ log(L_ERR "%s, line %d (nearby '%s'): %s", conf->err_file_name, conf->err_lino, conf->err_token, conf->err_msg);
else
log(L_ERR "Unable to open configuration file %s: %m", config_name);
config_free(conf);
if (!unix_read_config(&conf, name))
{
if (conf->err_msg)
- cli_msg(8002, "%s, line %d: %s", conf->err_file_name, conf->err_lino, conf->err_msg);
+ cli_msg(8002, "%s, line %d (nearby '%s'): %s", conf->err_file_name, conf->err_lino, conf->err_token, conf->err_msg);
else
cli_msg(8002, "%s: %m", name);
config_free(conf);