summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am6
-rw-r--r--tools/logsigner.c54
2 files changed, 26 insertions, 34 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 9d9bd352..712443c0 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -58,6 +58,12 @@ logctl_SOURCES = logctl.c
logctl_CPPFLAGS = $(LIBMONGO_CLIENT_CFLAGS)
logctl_LDADD = $(LIBMONGO_CLIENT_LIBS)
endif
+if ENABLE_GUARDTIME
+bin_PROGRAMS += logsigner
+logsigner = logsigner.c
+logsigner_CPPFLAGS = $(RSRT_CFLAGS) $(GUARDTIME_CFLAGS)
+logsigner_LDADD = ../runtime/librsgt.la $(GUARDTIME_LIBS)
+endif
endif
EXTRA_DIST = $(man_MANS) \
diff --git a/tools/logsigner.c b/tools/logsigner.c
index 2aeb2162..51803be2 100644
--- a/tools/logsigner.c
+++ b/tools/logsigner.c
@@ -26,15 +26,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
-
#include <gt_base.h>
#include <gt_http.h>
+#include "librsgt.h"
+
+#if 0
void
outputhash(GTDataHash *hash)
{
@@ -45,33 +50,6 @@ outputhash(GTDataHash *hash)
}
void
-gtInit()
-{
- int r = GT_OK;
-
- r = GT_init();
- if(r != GT_OK) {
- fprintf(stderr, "GT_init() failed: %d (%s)\n",
- r, GT_getErrorString(r));
- goto done;
- }
- r = GTHTTP_init("rsyslog logsigner", 1);
- if(r != GT_OK) {
- fprintf(stderr, "GTHTTP_init() failed: %d (%s)\n",
- r, GTHTTP_getErrorString(r));
- goto done;
- }
-done: return;
-}
-
-void
-gtExit()
-{
- GTHTTP_finalize();
- GT_finalize();
-}
-
-void
timestampIt(GTDataHash *hash)
{
int r = GT_OK;
@@ -116,7 +94,7 @@ done:
void
-sign(const char *buf, size_t len)
+sign(const char *buf, const size_t len)
{
int r;
GTDataHash *hash = NULL;
@@ -132,6 +110,7 @@ sign(const char *buf, size_t len)
timestampIt(hash); /* of course, this needs to be moved to once at end ;) */
done: GTDataHash_free(hash);
}
+#endif
void
processFile(char *name)
@@ -139,7 +118,10 @@ processFile(char *name)
FILE *fp;
size_t len;
char line[64*1024+1];
+ gtctx ctx = NULL;
+ ctx = rsgtCtxNew();
+ sigblkInit(ctx);
if(!strcmp(name, "-"))
fp = stdin;
else
@@ -147,7 +129,8 @@ processFile(char *name)
while(1) {
if(fgets(line, sizeof(line), fp) == NULL) {
- perror(name);
+ if(!feof(fp))
+ perror(name);
break;
}
len = strlen(line);
@@ -155,19 +138,22 @@ processFile(char *name)
--len;
line[len] = '\0';
}
- sign(line, len);
+ //sign(line, len);
+ sigblkAddRecord(ctx, line, len);
}
- if(fp != stdout)
+ if(fp != stdin)
fclose(fp);
+ sigblkFinish(ctx);
+ rsgtCtxDel(ctx);
}
int
main(int argc, char *argv[])
{
- gtInit();
+ rsgtInit("rsyslog logsigner " VERSION);
processFile("-");
- gtExit();
+ rsgtExit();
return 0;
}