-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
id: The --real
flag should only affect -u
, -g
, and -G
#7796
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: main
Are you sure you want to change the base?
Conversation
GNU testsuite comparison:
|
How should we test the situation where UID != EUID or GID != EGID? I had the idea of mocking the State struct, but the id_print function is hard to test as it only prints to stdout. Also, it uses the |
Could you please add a test to make sure we don't regress in the future? |
Yes, I can. I will probably try to mock the |
i don't think you need to do that, you should do that in |
I still don't understand how to run the command so that the UID != EUID or GID != EGID without somehow mocking them. |
@sylvestre Did you have any ideas on how this could be tested? |
--real
flag should only affect -u
, -g
, and -U
--real
flag should only affect -u
, -g
, and -G
I added a test for different UID and EUID. I didn't figure out a better way than to overwrite the |
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.
At the risk of having too many opinions in this thread, maybe we can test it in ways more similar to the original issue? If not then I think we just shouldn't have a test for this. The test you came up with is very clever, but depending on gcc
is not great.
@tertsdiepraam The original issue requires elevated privileges and assumes that a system has In my opinion, creating a test that requires elevated privileges as a precondition is not a good idea if there are no other tests that do so, except those that use the |
The current test also does not break if a system does not have the |
I'm open to any decision you make. |
GNU testsuite comparison:
|
@tertsdiepraam The test doesn't work on CI/CD, so I guess it should be removed. What would you like me to do? Should I remove the test, or also try to do a test that requires elevated privileges as a precondition? |
I'm ok with no test, but I'll defer to @sul. Maybe he has some ideas |
GNU testsuite comparison:
|
Feel free to merge as is. Please let me know if you have any ideas on how the testing could be performed. |
This PR fixes the logic for retrieving the actual UID and GID of the calling process when the
id
command is invoked without any users as arguments. The--real
flag should only affect what IDs to report about a user with-u
,-g
, or-U
flags set. Previously, it affected the command whenever no users were specified as an argument.fixes #7749