Skip to content
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

Passwd length #953

Merged
merged 2 commits into from
Feb 16, 2024
Merged

Passwd length #953

merged 2 commits into from
Feb 16, 2024

Conversation

thalman
Copy link
Contributor

@thalman thalman commented Feb 16, 2024

This PR addresses two issues:

  • The passwd utility has limit 200 characters. Some admins wants uses longer passwords for technical accounts
  • The passwd utility cuts the provided password silently

First commit unifies the password length limit between agetpass.c and passwd.c.

The second one introduces checking the length of provided password.

@thalman thalman force-pushed the passwd_length branch 2 times, most recently from 7aaeb55 to 6a0c380 Compare February 16, 2024 09:38
The passwd utility had hardcoded limit for password lenght set
to 200 characters. In the agetpass.c is used PASS_MAX for
this purpose.

This patch moves the PASS_MAX definition to common place
and uses it in both places.

Signed-off-by: Tomas Halman <tomas@halman.net>
The passwd silently truncated the password length to PASS_MAX.
This patch introduces check that prints an error message
and exits the call.

Signed-off-by: Tomas Halman <tomas@halman.net>
@alejandro-colomar
Copy link
Collaborator

Thanks for doing this!

I see we have several macros that seem very related:

$ grep -rho 'PASS[A-Z_]*MAX[A-Z_]*' src/ lib* | sort | uniq | grep -v PASS_MAX_DAYS
PASSWD_ENTRY_MAX_LENGTH
PASS_MAX
PASS_MAX_LEN

Do any of those mean the same thing? I suspect we have different maximum lengths in different places, and we should unify them.

@alejandro-colomar
Copy link
Collaborator

1a36ac7 ("src/passwd.c: inconsistent password length limit ")

Reviewed-by: Alejandro Colomar <alx@kernel.org>

@alejandro-colomar
Copy link
Collaborator

6a0c380 ("src/passwd.c: check password length upper limit")

Reviewed-by: Alejandro Colomar <alx@kernel.org>

@alejandro-colomar
Copy link
Collaborator

Thanks for doing this!

I see we have several macros that seem very related:

$ grep -rho 'PASS[A-Z_]*MAX[A-Z_]*' src/ lib* | sort | uniq | grep -v PASS_MAX_DAYS
PASSWD_ENTRY_MAX_LENGTH
PASS_MAX
PASS_MAX_LEN

Do any of those mean the same thing? I suspect we have different maximum lengths in different places, and we should unify them.

Let's keep this for a different PR. I think this one is good as is.

@thalman
Copy link
Contributor Author

thalman commented Feb 16, 2024

Thanks for doing this!
I see we have several macros that seem very related:

$ grep -rho 'PASS[A-Z_]*MAX[A-Z_]*' src/ lib* | sort | uniq | grep -v PASS_MAX_DAYS
PASSWD_ENTRY_MAX_LENGTH
PASS_MAX
PASS_MAX_LEN

Do any of those mean the same thing? I suspect we have different maximum lengths in different places, and we should unify them.

Let's keep this for a different PR. I think this one is good as is.

I think that they have different meaning. If I understand correctly PASSWD_ENTRY_MAX_LENGTH is the whole record from /etc/passwd. PASS_MAX_LEN is from system configuration and PASS_MAX is our internal limit. But I might be wrong.

Copy link
Collaborator

@alejandro-colomar alejandro-colomar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@hallyn hallyn merged commit e15aa5a into shadow-maint:master Feb 16, 2024
9 checks passed
alejandro-colomar pushed a commit that referenced this pull request Feb 16, 2024
The passwd utility had hardcoded limit for password lenght set
to 200 characters. In the agetpass.c is used PASS_MAX for
this purpose.

This patch moves the PASS_MAX definition to common place
and uses it in both places.

Signed-off-by: Tomas Halman <tomas@halman.net>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: f024002b3d66 ("src/passwd.c: inconsistent password length limit")
Cc: Serge Hallyn <serge@hallyn.com>
Link: <#953>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
alejandro-colomar pushed a commit that referenced this pull request Feb 16, 2024
The passwd silently truncated the password length to PASS_MAX.
This patch introduces check that prints an error message
and exits the call.

Signed-off-by: Tomas Halman <tomas@halman.net>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: f024002b3d66 ("src/passwd.c: inconsistent password length limit")
Cc: Serge Hallyn <serge@hallyn.com>
Link: <#953>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants