if (m/^!FINAL \{\s*$/) {
die unless $kw;
die if @next_kw;
- $co .= inst("FIN_$kwid")."\\n { BEGIN(0); c->lno++; }\n";
+ $co .= inst("FIN_$kwid")."\\n { BEGIN(0); c->loc.line++; }\n";
$co .= inst("$in_s")."{L}/\\n {\n";
$co .= "\tBEGIN(FIN_$kwid);\n";
$co .= lineno(1,1);
S [ \t]+
BASE91S []-~!#-&(-[]+
%x SKIPNL
+%x SYNTAXERR
%option yylineno
%option noyywrap
struct pubkeyset_context {
/* filled in during setup: */
+ struct cloc loc; /* line is runtime */
struct log_if *log;
struct buffer_if *data_buf;
struct peer_keyset *building;
/* runtime: */
bool_t had_serial;
- int lno;
bool_t fallback_skip;
const struct sigscheme_info *scheme;
uint8_t grpid[GRPIDSZ];
break; \
})
#define DOSKIP(m) ({ \
- slilog(LI,M_INFO,"l.%d: " m, c->lno); \
+ slilog(LI,M_INFO,"%s:%d: " m, c->loc.file, c->loc.line); \
DOSKIPQ; \
})
#define FAIL(m) do{ \
- slilog(LI,M_ERR,"l.%d: " m, c->lno); \
+ slilog(LI,M_ERR,"%s:%d: " m, c->loc.file, c->loc.line); \
return -1; \
}while(0)
if (c->building->nkeys >= MAX_SIG_KEYS) DOSKIP("too many public keys");
struct sigpubkey_if *pubkey;
bool_t ok=c->scheme->loadpub(c->scheme,c->data_buf,
- &pubkey,c->log);
+ &pubkey,c->log,c->loc);
if (!ok) break;
memcpy(c->building->keys[c->building->nkeys].id.b,
c->grpid,
BEGIN(SKIPNL);
}
{L}\n {
- c->lno++;
+ c->loc.line++;
}
<SKIPNL>.*\n {
- c->lno++;
+ c->loc.line++;
BEGIN(0);
}
<INITIAL><<EOF>> { return 0; }
-<*>. { FAIL("syntax error"); }
+<*>. {
+ yymore();
+ BEGIN(SYNTAXERR);
+}
+<SYNTAXERR>.* {
+ slilog(LI,M_DEBUG,"pubkeys syntax error at `%s'", yytext);
+ FAIL("syntax error");
+}
<*>\n { FAIL("syntax error - unexpected newline"); }
<<EOF>> { FAIL("syntax error - unexpected eof"); }
struct log_if *log, int logcl_enoent) {
assert(!c->building);
c->log=log;
+ c->loc.file=path;
pkyyin = fopen(path, "r");
if (!pkyyin) {
slilog(LI,
errno==ENOENT ? logcl_enoent : M_ERR,
- "could not open keyset file %s: %s",
+ "%scould not open keyset file %s: %s",
+ logcl_enoent==M_DEBUG && errno==ENOENT ? "expectedly " : "",
path,strerror(errno));
goto err;
}
c->building->refcount=1;
c->fallback_skip=0;
c->had_serial=0;
- c->lno=1;
+ c->loc.line=1;
FILLZERO(c->grpid);
FILLZERO(c->serial);
int r=pkyylex();
if (r) goto err_bad;
- if (!c->had_serial) {
- slilog(LI,M_ERR,"missing serial number in %s",path);
- goto err_bad;
- }
if (!c->building->nkeys) {
slilog(LI,M_ERR,"no useable keys in %s",path);
goto err_bad;