diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-03-23 18:39:03 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-03-23 18:39:03 +0100 |
commit | 199630a5ef8f0c919fbbbd9e122415d1d72886a3 (patch) | |
tree | 0d3739d114a65b04207f4e109ec2c32524d2b53b /tools/rsgtutil.c | |
parent | 0b77585a10062117d1904c8c08db1fc4520ab16d (diff) | |
download | rsyslog-199630a5ef8f0c919fbbbd9e122415d1d72886a3.tar.gz rsyslog-199630a5ef8f0c919fbbbd9e122415d1d72886a3.tar.bz2 rsyslog-199630a5ef8f0c919fbbbd9e122415d1d72886a3.zip |
rsgtutil/milestone: basic 'extend' mode implementation
... done up until the point where I need to wait for the
timestamps to become extendible. So doing a milestone commit
to make sure the work is inside the archive. Actual writing of the
extended timestamp is missing.
Diffstat (limited to 'tools/rsgtutil.c')
-rw-r--r-- | tools/rsgtutil.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/tools/rsgtutil.c b/tools/rsgtutil.c index f65c46fd..1f475527 100644 --- a/tools/rsgtutil.c +++ b/tools/rsgtutil.c @@ -148,13 +148,14 @@ err: fprintf(stderr, "error %d processing file %s\n", r, name); } static inline int -doVerifyRec(FILE *logfp, FILE *sigfp, block_sig_t *bs, gtfile gf, gterrctx_t *ectx, uint8_t bInBlock) +doVerifyRec(FILE *logfp, FILE *sigfp, FILE *nsigfp, + block_sig_t *bs, gtfile gf, gterrctx_t *ectx, uint8_t bInBlock) { int r; size_t lenRec; - char rec[128*1024]; + char line[128*1024]; - if(fgets(rec, sizeof(rec), logfp) == NULL) { + if(fgets(line, sizeof(line), logfp) == NULL) { if(feof(logfp)) { r = RSGTE_EOF; } else { @@ -163,20 +164,20 @@ doVerifyRec(FILE *logfp, FILE *sigfp, block_sig_t *bs, gtfile gf, gterrctx_t *ec } goto done; } - lenRec = strlen(rec); - if(rec[lenRec-1] == '\n') { - rec[lenRec-1] = '\0'; + lenRec = strlen(line); + if(line[lenRec-1] == '\n') { + line[lenRec-1] = '\0'; --lenRec; - rsgt_errctxSetErrRec(ectx, rec); + rsgt_errctxSetErrRec(ectx, line); } - /* we need to preserve the first record of each block for + /* we need to preserve the first line (record) of each block for * error-reporting purposes (bInBlock==0 meanst start of block) */ if(bInBlock == 0) - rsgt_errctxFrstRecInBlk(ectx, rec); + rsgt_errctxFrstRecInBlk(ectx, line); - r = rsgt_vrfy_nextRec(bs, gf, sigfp, (unsigned char*)rec, lenRec, ectx); + r = rsgt_vrfy_nextRec(bs, gf, sigfp, nsigfp, (unsigned char*)line, lenRec, ectx); done: return r; } @@ -231,7 +232,13 @@ verify(char *name) ectx.filename = strdup(sigfname); if((r = rsgt_chkFileHdr(sigfp, "LOGSIG10")) != 0) goto err; - + if(mode == MD_EXTEND) { + if(fwrite("LOGSIG10", 8, 1, nsigfp) != 1) { + perror(nsigfname); + r = RSGTE_IO; + goto err; + } + } gf = rsgt_vrfyConstruct_gf(); if(gf == NULL) { fprintf(stderr, "error initializing signature file structure\n"); @@ -254,10 +261,11 @@ verify(char *name) ++ectx.blkNum; } ++ectx.recNum, ++ectx.recNumInFile; - if((r = doVerifyRec(logfp, sigfp, bs, gf, &ectx, bInBlock)) != 0) + if((r = doVerifyRec(logfp, sigfp, nsigfp, bs, gf, &ectx, bInBlock)) != 0) goto err; if(ectx.recNum == bs->recCount) { - verifyBLOCK_SIG(bs, gf, sigfp, &ectx); + verifyBLOCK_SIG(bs, gf, sigfp, nsigfp, + (mode == MD_EXTEND) ? 1 : 0, &ectx); bInBlock = 0; } else bInBlock = 1; } |