-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
users: Fix truncated "From" in account logs #21418
Conversation
This silences this unsightly warning during build: > src/session/session.c:912:10: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result' [-Wunused-result] Just ignore the result -- there is absolutely nothing that we can do at this point to recover: we are in a signal handler and about to exit.
In TestLogin.testLogging, validate that the "last login from" string contains a correct and complete IPv6 address and session type. We can do this because the IP is predictable in our CI, and this test does not run in tmt. This ensures that cockpit-project#21383 does not affect the Overview page.
It gets stringified along the way, but this is untidy and a type violation.
Call `last` with `--fullnames` to avoid truncating values (like IPv6 addresses). We don't rely on a "nicely" (argh) formatted ASCII table with fixed column widths, but parse the structure. Flesh out TestAccounts.testAccountLogs to actually test some values on the page. It was almost empty before. Like in the previous commit, we can afford to hardcode the expected IPv6 "from" address. Fixes cockpit-project#21383
self.assertIn(year, started) | ||
self.assertIn(year, ended) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This of course assumes that this test doesn't run at precisely mightnight on new year. But if you send a PR around that time, shame on you 😁 I tried to parse the shown date with date
, but it's a custom format which date -d
doesn't understand, so I gave up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this comment it feels like "challenge accepted". But maybe more for dependabot :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -31,7 +31,7 @@ const _ = cockpit.gettext; | |||
export function AccountLogs({ name }) { | |||
const [logins, setLogins] = useState([]); | |||
useInit(() => { | |||
cockpit.spawn(["last", "--time-format", "iso", "-n", 25, name], { environ: ["LC_ALL=C"] }) | |||
cockpit.spawn(["last", "--time-format", "iso", "-n25", "--fullnames", name], { environ: ["LC_ALL=C"] }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was confused for a bit, why isn't this -w
, but that's the same thing :) I guess for historical raisins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer long options in code for better readability. But -w
is the same thing indeed.
self.assertIn(year, started) | ||
self.assertIn(year, ended) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this comment it feels like "challenge accepted". But maybe more for dependabot :)
Call
last
with--fullnames
to avoid truncating values (like IPv6addresses). We don't rely on a "nicely" (argh) formatted ASCII table
with fixed column widths, but parse the structure.
Flesh out TestAccounts.testAccountLogs to actually test some values on
the page. It was almost empty before. Like in the previous commit, we
can afford to hardcode the expected IPv6 "from" address.
Fixes #21383