mirror of
https://github.com/systemd/systemd
synced 2025-10-06 12:14:46 +02:00
Compare commits
No commits in common. "8013beb4a2221680b2c741bac6b3a33fe66406e1" and "6e6c3b8d21dad714be760006fc36b7693fedc3a8" have entirely different histories.
8013beb4a2
...
6e6c3b8d21
@ -29,7 +29,6 @@ typedef struct Context {
|
|||||||
bool has_cursor;
|
bool has_cursor;
|
||||||
bool need_seek;
|
bool need_seek;
|
||||||
bool since_seeked;
|
bool since_seeked;
|
||||||
bool until_safe;
|
|
||||||
bool ellipsized;
|
bool ellipsized;
|
||||||
bool previous_boot_id_valid;
|
bool previous_boot_id_valid;
|
||||||
sd_id128_t previous_boot_id;
|
sd_id128_t previous_boot_id;
|
||||||
@ -118,15 +117,10 @@ static int seek_journal(Context *c) {
|
|||||||
return log_error_errno(r, "Failed to seek to tail: %m");
|
return log_error_errno(r, "Failed to seek to tail: %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_reverse) {
|
if (arg_reverse)
|
||||||
r = sd_journal_previous(j);
|
r = sd_journal_previous(j);
|
||||||
c->until_safe = true; /* can't possibly go beyond --until= if --reverse */
|
else /* arg_lines_needs_seek_end */
|
||||||
|
|
||||||
} else { /* arg_lines_needs_seek_end() */
|
|
||||||
r = sd_journal_previous_skip(j, arg_lines);
|
r = sd_journal_previous_skip(j, arg_lines);
|
||||||
c->until_safe = r >= arg_lines; /* We have enough lines to output before --until= is hit.
|
|
||||||
No need to check timestamp of each journal entry */
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (arg_since_set) {
|
} else if (arg_since_set) {
|
||||||
/* This is placed after arg_reverse and arg_lines. If --since is used without
|
/* This is placed after arg_reverse and arg_lines. If --since is used without
|
||||||
@ -180,10 +174,11 @@ static int show(Context *c) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_until_set && !c->until_safe) {
|
if (arg_until_set && !arg_reverse && (arg_lines < 0 || arg_since_set || c->has_cursor)) {
|
||||||
/* If --lines= is set, we usually rely on the n_shown to tell us when to stop.
|
/* If --lines= is set, we usually rely on the n_shown to tell us when to stop.
|
||||||
* However, in the case where we may have less than --lines= to output let's check
|
* However, if --since= or one of the cursor argument is set too, we may end up
|
||||||
* whether the individual entries are in range. */
|
* having less than --lines= to output. In this case let's also check if the entry
|
||||||
|
* is in range. */
|
||||||
|
|
||||||
usec_t usec;
|
usec_t usec;
|
||||||
|
|
||||||
@ -212,11 +207,6 @@ static int show(Context *c) {
|
|||||||
return log_error_errno(r, "Failed to seek to date: %m");
|
return log_error_errno(r, "Failed to seek to date: %m");
|
||||||
c->since_seeked = true;
|
c->since_seeked = true;
|
||||||
|
|
||||||
/* We just jumped forward, meaning there might suddenly be less than
|
|
||||||
* --lines= to show within the --until= range, hence keep a close eye on
|
|
||||||
* timestamps from now on. */
|
|
||||||
c->until_safe = false;
|
|
||||||
|
|
||||||
c->need_seek = true;
|
c->need_seek = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -245,12 +235,6 @@ static int show(Context *c) {
|
|||||||
r = sd_journal_get_data(j, "MESSAGE", &message, &len);
|
r = sd_journal_get_data(j, "MESSAGE", &message, &len);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
if (r == -ENOENT) {
|
if (r == -ENOENT) {
|
||||||
/* We will skip some entries forward, meaning there might suddenly
|
|
||||||
* be less than --lines= to show within the --until= range, hence
|
|
||||||
* keep a close eye on timestamps from now on. */
|
|
||||||
if (!arg_reverse)
|
|
||||||
c->until_safe = false;
|
|
||||||
|
|
||||||
c->need_seek = true;
|
c->need_seek = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -265,12 +249,6 @@ static int show(Context *c) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
/* We will skip some entries forward, meaning there might suddenly
|
|
||||||
* be less than --lines= to show within the --until= range, hence
|
|
||||||
* keep a close eye on timestamps from now on. */
|
|
||||||
if (!arg_reverse)
|
|
||||||
c->until_safe = false;
|
|
||||||
|
|
||||||
c->need_seek = true;
|
c->need_seek = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1422,7 +1422,18 @@ testcase_unpriv_dir() {
|
|||||||
# Use an image owned by the foreign UID range first via direct mapping, and than via the managed uid logic
|
# Use an image owned by the foreign UID range first via direct mapping, and than via the managed uid logic
|
||||||
systemd-dissect --shift "$root" foreign
|
systemd-dissect --shift "$root" foreign
|
||||||
assert_eq "$(systemd-nspawn --pipe --register=no -D "$root" --private-users=pick --private-users-ownership=foreign bash -c 'echo foobar')" "foobar"
|
assert_eq "$(systemd-nspawn --pipe --register=no -D "$root" --private-users=pick --private-users-ownership=foreign bash -c 'echo foobar')" "foobar"
|
||||||
assert_eq "$(systemd-nspawn --pipe --register=no -D "$root" --private-users=managed --private-network bash -c 'echo foobar')" "foobar"
|
# FIXME:
|
||||||
|
# Since 90fa161b5ba29d58953e9f08ddca49121b51efe6, --bind= or Bind= settings for coverage directory does
|
||||||
|
# not work with managed mode:
|
||||||
|
# ========
|
||||||
|
# [ 158.105361] systemd-nspawn[3718]: Failed to open tree and set mount attributes: Operation not permitted
|
||||||
|
# [ 158.105364] systemd-nspawn[3718]: Failed to clone /coverage: Operation not permitted
|
||||||
|
# [ 158.118655] systemd-nspawn[3707]: (sd-namespace) failed with exit status 1.
|
||||||
|
# ========
|
||||||
|
# Let's tentatively skip the test case when running on coverage.
|
||||||
|
if [[ -z "${COVERAGE_BUILD_DIR:-}" ]]; then
|
||||||
|
assert_eq "$(systemd-nspawn --pipe --register=no -D "$root" --private-users=managed --private-network bash -c 'echo foobar')" "foobar"
|
||||||
|
fi
|
||||||
|
|
||||||
# Test unprivileged operation
|
# Test unprivileged operation
|
||||||
chown testuser:testuser "$root/.."
|
chown testuser:testuser "$root/.."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user