-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
who: Add who command #25943
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
base: master
Are you sure you want to change the base?
who: Add who command #25943
Conversation
1aca307
to
72d8ca1
Compare
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.
In need of C-ism removal, but functionality is good :^)
{ | ||
TRY(Core::System::pledge("stdio rpath")); | ||
TRY(Core::System::unveil("/var/run/utmp", "r")); | ||
TRY(Core::System::unveil("/etc", "r")); |
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.
It seems like the program only ever needs to read /etc/passwd here, please be more specific with your unveil then.
auto time = static_cast<time_t>(login_at); | ||
auto* tm = localtime(&time); | ||
char timebuf[32]; | ||
strftime(timebuf, sizeof(timebuf), "%b %d %H:%M", tm); |
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.
Even though it’s a bad interface and I have a branch somewhere that fixes it, please rather use Core::LocalTime. We’re not C.
json.as_object().for_each_member([&](auto& key, auto& value) { | ||
auto const& obj = value.as_object(); | ||
auto uid = obj.get_i32("uid"sv).value(); | ||
auto* passwd = getpwuid(uid); |
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 am pretty sure Core::Account can do this with better error handling.
Uh oh!
There was an error while loading. Please reload this page.