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
Adding new switch -rG to usermod #421
Conversation
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.
From the code review perspective I've only seen a little error.
I still would like to test the change though, to see that everything works as expected. By the way, have you considered automating the tests?
src/usermod.c
Outdated
@@ -424,6 +425,9 @@ static /*@noreturn@*/void usage (int status) | |||
(void) fputs (_(" -a, --append append the user to the supplemental GROUPS\n" | |||
" mentioned by the -G option without removing\n" | |||
" the user from other groups\n"), usageout); | |||
(void) fputs (_(" -r, --remove remove the user from only the supplemental GROUPS\n" | |||
" mentioned by the -G option without removing\n" | |||
" the user from theother groups\n"), usageout); |
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.
To be consistent with -a
option you should remove 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.
Hi @ikerexxe I fixed the grammatical error.
In regards to writing tests. Would need to look at how the tests are setup. Never looked at it before so. might have a few questions. Are the tests cases a hard requirement for this PR?
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.
From my point of view no, it's not necessary, but the last word is up to the maintainers.
That reminds me that I haven't tested this PR. I'll try to do that today.
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.
Hi @ikerexxe I fixed the grammatical error.
In regards to writing tests. Would need to look at how the tests are setup. Never looked at it before so. might have a few questions. Are the tests cases a hard requirement for this PR?
I do worry that if you don't write them now, they'll never get written :) So if you have time in the next week, that would be great. They'd go under tests/usertools/, one test per directory.
Unfortunately I haven't yet ported the github repo from travis to github actions, so currently the tests aren't being run.
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 will try write the tests at a later time and in another commit.
I've been able to test the changes with satisfactory results. Thanks for the changes! Initial state:
Testing
Testing
Testing the new
|
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.
Might be a nice thing to fix.
No, I didn't have time to test the latest update. I may have time this week but I can't promise. |
I've been able to find some minutes to test it and everything looks good from my side. |
Ok, I rebased from and collapsed the commits into a single commit. |
Adding a new switch -rG, which provides a similar feature set to -aG, allowing a person to list exactly what groups to remove a user from. shadow-maint#337
Thanks. |
Adding a new switch -rG, which provides a similar feature set to -aG, allowing a person to list exactly what groups to remove a user from.
As we can see user tester is part of test[1..4]
[a@localhost src]$ tail /etc/group ; sudo tail /etc/gshadow
tester1:x:1003:
test1:x:1004:tester1
test2:x:1005:tester1
test3:x:1006:tester1
test4:x:1007:tester1
tester1:!::
test1:!::tester1
test2:!::tester1
test3:!::tester1
test4:!::tester1
Running with -rG, we can now see that we have removed user tester1 from the named groups, while leaving the unnamed groups untouched
[a@localhost src]$ sudo ./usermod -rG test1,test2 tester1
[a@localhost src]$ tail /etc/group ; sudo tail /etc/gshadow
tester1:x:1003:
test1:x:1004:
test2:x:1005:
test3:x:1006:tester1
test4:x:1007:tester1
tester1:!::
test1:!::
test2:!::
test3:!::tester1
test4:!::tester1
Testing -G flag to see if we broke anything,
[a@localhost src]$ sudo ./usermod -G test1,test2 tester1
[a@localhost src]$ tail /etc/group ; sudo tail /etc/gshadow
tester1:x:1003:
test1:x:1004:tester1
test2:x:1005:tester1
test3:x:1006:
test4:x:1007:
tester1:!::
test1:!::tester1
test2:!::tester1
test3:!::
test4:!::
Works as expected, lets test -aG see if we broke that
[a@localhost src]$ sudo ./usermod -aG test3,test4 tester1
[a@localhost src]$ tail /etc/group ; sudo tail /etc/gshadow
tester1:x:1003:
test1:x:1004:tester1
test2:x:1005:tester1
test3:x:1006:tester1
test4:x:1007:tester1
tester1:!::
test1:!::tester1
test2:!::tester1
test3:!::tester1
test4:!::tester1
Closes #337