X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=pubkeys.fl.pl;h=da1e4d40ce396e255ff685c181710b531c23f8b8;hb=49b56eafcd147185c28848a7c04e31a32c49a82e;hp=b8cac624317de3307f7d61efd9e8903597740f2d;hpb=69087acd398f20f881689ecb077de9fd20363bb9;p=secnet.git diff --git a/pubkeys.fl.pl b/pubkeys.fl.pl index b8cac62..da1e4d4 100755 --- a/pubkeys.fl.pl +++ b/pubkeys.fl.pl @@ -109,7 +109,7 @@ while () { 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); @@ -134,6 +134,7 @@ L [ \t]* S [ \t]+ BASE91S []-~!#-&(-[]+ %x SKIPNL +%x SYNTAXERR %option yylineno %option noyywrap @@ -158,13 +159,12 @@ BASE91S []-~!#-&(-[]+ struct pubkeyset_context { /* filled in during setup: */ - const char *path; + 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]; @@ -186,11 +186,11 @@ static struct pubkeyset_context c[1]; break; \ }) #define DOSKIP(m) ({ \ - slilog(LI,M_INFO,"%s:%d: " m, c->path, c->lno); \ + slilog(LI,M_INFO,"%s:%d: " m, c->loc.file, c->loc.line); \ DOSKIPQ; \ }) #define FAIL(m) do{ \ - slilog(LI,M_ERR,"%s:%d: " m, c->path, c->lno); \ + slilog(LI,M_ERR,"%s:%d: " m, c->loc.file, c->loc.line); \ return -1; \ }while(0) @@ -227,16 +227,16 @@ static struct pubkeyset_context c[1]; !FINAL { if (c->building->nkeys >= MAX_SIG_KEYS) DOSKIP("too many public keys"); struct sigpubkey_if *pubkey; + closure_t *cl; bool_t ok=c->scheme->loadpub(c->scheme,c->data_buf, - &pubkey,c->log); + &pubkey,&cl,c->log,c->loc); if (!ok) break; - memcpy(c->building->keys[c->building->nkeys].id.b, - c->grpid, - GRPIDSZ); + struct peer_pubkey *fill=&c->building->keys[c->building->nkeys]; + memcpy(fill->id.b,c->grpid,GRPIDSZ); assert(ALGIDSZ==1); /* otherwise need htons or htonl or something */ - c->building->keys[c->building->nkeys].id.b[GRPIDSZ]= - c->scheme->algid; - c->building->keys[c->building->nkeys++].pubkey=pubkey; + fill->id.b[GRPIDSZ]=c->scheme->algid; + fill->pubkey=pubkey; + c->building->nkeys++; !} !KEYWORD serial @@ -258,17 +258,24 @@ static struct pubkeyset_context c[1]; BEGIN(SKIPNL); } {L}\n { - c->lno++; + c->loc.line++; } .*\n { - c->lno++; + c->loc.line++; BEGIN(0); } <> { return 0; } -<*>. { FAIL("syntax error"); } +<*>. { + yymore(); + BEGIN(SYNTAXERR); +} +.* { + slilog(LI,M_DEBUG,"pubkeys syntax error at `%s'", yytext); + FAIL("syntax error"); +} <*>\n { FAIL("syntax error - unexpected newline"); } <> { FAIL("syntax error - unexpected eof"); } @@ -279,12 +286,13 @@ keyset_load(const char *path, struct buffer_if *data_buf, struct log_if *log, int logcl_enoent) { assert(!c->building); c->log=log; - c->path=path; + 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; } @@ -297,16 +305,12 @@ keyset_load(const char *path, struct buffer_if *data_buf, 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;