-
Notifications
You must be signed in to change notification settings - Fork 257
useradd: Correctly set subuid/subgid when using -F #1511
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?
Conversation
0066ad0 to
4ecf680
Compare
The -F flag should bypass the UID check and always add entries to the sub[ud]id while the -r flag should still be used in addition with the UID check. Closes: <shadow-maint#1255> Signed-off-by: ndostert <crawax@cwxlab.fr>
4ecf680 to
1185c23
Compare
| subuid_count > 0 && sub_uid_file_present () && | ||
| (!rflg || Fflg) && | ||
| (!user_id || (user_id <= uid_max && user_id >= uid_min)); | ||
| (!rflg && (!user_id || (user_id <= uid_max && user_id >= uid_min))) || Fflg; |
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 seems brittle. It is affected by the fact that && has more precedence than ||, which is something not well known.
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.
Sorry I'm more a Python person, I can mostly read C code but not really write it.
Doesn't the parenthesis group the tests so there is not && and || in the same test ?
(
!rflg && (
!user_id || (
user_id <= uid_max && user_id >= uid_min
)
)
) || Fflg;
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.
Yes, but you have the full expression (see lines 2513 and above) as
a && b && && c && (...) || eThose && and || don't necessarily interact as you'd expect.
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.
Yes, but you have the full expression (see lines 2513 and above) as
a && b && && c && (...) || eThose && and || don't necessarily interact as you'd expect.
Ah yes I see, well I'm out of my depth on that.
I will see if I can either "prove" this work or fix it.
And also, thanks for your help !
Fixes #1255
I was not able to run the tests as described in doc/contributions/tests.md at the moment but I was able to build and test that
useradd -Fwork as intended.