[systemd-commits] 4 commits - src/journal
Zbigniew Jędrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Mon Mar 9 19:08:33 PDT 2015
src/journal/journal-file.c | 25 ++++++++++++-------------
src/journal/journalctl.c | 19 ++++++++-----------
2 files changed, 20 insertions(+), 24 deletions(-)
New commits:
commit faf9da01ad93bd48523f0966646bbd3ca85a2951
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Mar 9 18:58:47 2015 -0400
journalctl: unlink without checking with access first
It is more elegant to do this in one step.
Coverity complains about the TOCTOU difference, but it is not an
actual problem (CID #1237777).
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 2b0e00e..f0f03b0 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1316,19 +1316,16 @@ static int setup_keys(void) {
SD_ID128_FORMAT_VAL(machine)) < 0)
return log_oom();
- if (access(p, F_OK) >= 0) {
- if (arg_force) {
- r = unlink(p);
- if (r < 0) {
- log_error_errno(errno, "unlink(\"%s\") failed: %m", p);
- r = -errno;
- goto finish;
- }
- } else {
- log_error("Sealing key file %s exists already. (--force to recreate)", p);
- r = -EEXIST;
+ if (arg_force) {
+ r = unlink(p);
+ if (r < 0 && errno != ENOENT) {
+ r = log_error_errno(errno, "unlink(\"%s\") failed: %m", p);
goto finish;
}
+ } else if (access(p, F_OK) >= 0) {
+ log_error("Sealing key file %s exists already. Use --force to recreate.", p);
+ r = -EEXIST;
+ goto finish;
}
if (asprintf(&k, "/var/log/journal/" SD_ID128_FORMAT_STR "/fss.tmp.XXXXXX",
commit 977eaa1eae53af7f418d87fcb42f4a4d34aad739
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Mar 9 17:46:30 2015 -0400
journal: fix return code
Introduced in fa6ac76083b8ff.
Might be related to CID #1261724, but I don't know if coverity can
recurse this deep.
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index f857a6a..8e76427 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2651,10 +2651,8 @@ int journal_file_open(
}
r = mmap_cache_get(f->mmap, f->fd, f->prot, CONTEXT_HEADER, true, 0, PAGE_ALIGN(sizeof(Header)), &f->last_stat, &h);
- if (r < 0) {
- r = -errno;
+ if (r < 0)
goto fail;
- }
f->header = h;
commit d587eca5104b212793b310d8590db480f1004d3a
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Mar 9 17:22:50 2015 -0400
journal-file: update format string to remove cast
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 1e861d1..f857a6a 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2818,9 +2818,9 @@ int journal_file_open_reliably(
/* The file is corrupted. Rotate it away and try it again (but only once) */
l = strlen(fname);
- if (asprintf(&p, "%.*s@%016llx-%016" PRIx64 ".journal~",
+ if (asprintf(&p, "%.*s@%016"PRIx64 "-%016"PRIx64 ".journal~",
(int) l - 8, fname,
- (unsigned long long) now(CLOCK_REALTIME),
+ now(CLOCK_REALTIME),
random_u64()) < 0)
return -ENOMEM;
commit 288359dba1417703c7eaf008f153339c6c321412
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Mar 9 17:10:33 2015 -0400
journal: align comments to make them more legible
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 0e33a0f..1e861d1 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2795,14 +2795,15 @@ int journal_file_open_reliably(
r = journal_file_open(fname, flags, mode, compress, seal,
metrics, mmap_cache, template, ret);
- if (r != -EBADMSG && /* corrupted */
- r != -ENODATA && /* truncated */
- r != -EHOSTDOWN && /* other machine */
- r != -EPROTONOSUPPORT && /* incompatible feature */
- r != -EBUSY && /* unclean shutdown */
- r != -ESHUTDOWN && /* already archived */
- r != -EIO && /* IO error, including SIGBUS on mmap */
- r != -EIDRM /* File has been deleted */)
+ if (!IN_SET(r,
+ -EBADMSG, /* corrupted */
+ -ENODATA, /* truncated */
+ -EHOSTDOWN, /* other machine */
+ -EPROTONOSUPPORT, /* incompatible feature */
+ -EBUSY, /* unclean shutdown */
+ -ESHUTDOWN, /* already archived */
+ -EIO, /* IO error, including SIGBUS on mmap */
+ -EIDRM /* File has been deleted */))
return r;
if ((flags & O_ACCMODE) == O_RDONLY)
More information about the systemd-commits
mailing list