-
Notifications
You must be signed in to change notification settings - Fork 2.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
"sudo logname" should return my username instead of "root" #32185
Comments
|
Actually, I just worry if this will affect other programs behavior |
The man page is pretty clear about not relying on |
POSIX says that "The login name shall be the string that would be returned by the getlogin() function", so that's it. One could argue that musl implements getlogin incorrectly - "a string containing the user name associated by the login activity with the controlling terminal of the current process" looks to me like they don't care if you ran sudo or equivalent, but rather only what you logged in as; I hope to be wrong here, because if I'm running anything as root I'd expect getlogin & friends to say I'm root. That being said, I'm not a POSIX lawyer, so...
|
@loreb arguably it's more on |
@ericonr til that If I understand correctly:
so either musl resorts to strange hacks to handle the situation or until the musl guys do something like https://skarnet.org/software/utmps/ (unlikely) it looks to me like the current behavior is the least-worst option. |
Thank you guys for replying! @loreb Is
@ericonr
In @ALL |
But the possibility of musl complicating the implementation of a trash function by hardcoding knowledge of the currently most used capability raising programs is really quite low. |
I don't see any reason for the current behaviour in musl to change based on the POSIX standard outlined earlier. If anything should change, this should be raised with sudo and doas, but IMO I don't see much of an issue with that anyway. I haven't ever seen evidence of a bad |
@rivanfebrian123 sorry for the late reply! TLDR: properly implementing logname requires something called getlogin; properly implementing getlogin requires the utmpx functions (see https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/getlogin.c;hb=HEAD), and the musl developers think the utmpx functions were designed by monkeys and it's better not to have them. https://skarnet.org/software/utmps/ is trying a different approach - to have a daemon deal with the utmp file and rewrite all the utmp functions to make them talk to the daemon, which should work, but
Sorry for the mouthful and sorry again for being so late. |
Actually, I'm okay with that as the current POSIX spec doesn't require returning output of getlogin, as far as I know. But again, I'm just worrying about shell programmers who didn't know about this. Maybe their shell programs don't run as they intended or something like that. But yeah, software testing is definitely their responsibility :) |
Anyone using |
Maybe you right. But we can't solely blame them tho: https://www.ibm.com/docs/en/zos/2.2.0?topic=descriptions-logname-return-users-login-name. Well, I think it's okay to close this issue now |
That page makes it clear it uses env vars and can't really be trusted. Should be fine. I will close this, then. I forgot to mention, I pushed 56a567d after my investigation into this issue. It's probably minor, but just a note. |
Thanks for bringing this up, anyway! |
System
xuname:
package:
Expected behavior
Returns my username just like any other distro
Actual behavior
Returns "root"
Steps to reproduce the behavior
Run
sudo logname
The text was updated successfully, but these errors were encountered: