test-journal-verify.c revision 507f22bd0172bff5e5d98145b1419bd472a2c57f
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2012 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include "util.h"
#include "log.h"
#include "journal-file.h"
#include "journal-verify.h"
#include "journal-authenticate.h"
#define N_ENTRIES 6000
#define RANDOM_RANGE 77
uint8_t b;
ssize_t r;
int fd;
assert(r == 1);
b ^= 1 << (p % 8);
assert(r == 1);
}
JournalFile *f;
int r;
if (r < 0)
return r;
return r;
}
char t[] = "/tmp/journal-XXXXXX";
unsigned n;
JournalFile *f;
char a[FORMAT_TIMESTAMP_MAX];
char b[FORMAT_TIMESTAMP_MAX];
char c[FORMAT_TIMESPAN_MAX];
uint64_t p;
log_info("Generating...");
assert_se(journal_file_open("test.journal", O_RDWR|O_CREAT, 0666, true, !!verification_key, NULL, NULL, NULL, &f) == 0);
for (n = 0; n < N_ENTRIES; n++) {
struct dual_timestamp ts;
char *test;
}
log_info("Verifying...");
assert_se(journal_file_open("test.journal", O_RDONLY, 0666, true, !!verification_key, NULL, NULL, NULL, &f) == 0);
/* journal_file_print_header(f); */
log_info("=> Validated from %s to %s, %s missing",
format_timestamp(a, sizeof(a), from),
format_timestamp(b, sizeof(b), to),
}
if (verification_key) {
log_info("Toggling bits...");
bit_toggle("test.journal", p);
log_notice(ANSI_HIGHLIGHT_RED_ON ">>>> %"PRIu64" (bit %"PRIu64") can be toggled without detection." ANSI_HIGHLIGHT_OFF, p / 8, p % 8);
bit_toggle("test.journal", p);
}
}
log_info("Exiting...");
assert_se(rm_rf_dangerous(t, false, true, false) >= 0);
return 0;
}