-
Notifications
You must be signed in to change notification settings - Fork 67
libpam: Add a patch to allow null passwords #1068
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
Draft
erickshepherdNI
wants to merge
1
commit into
ni:nilrt/master/next
Choose a base branch
from
erickshepherdNI:ershephe/blank-password-patch-next
base: nilrt/master/next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
recipes-extended/pam/libpam/0001-pam_unix_passwd-allow-blank-passwords.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| From f285df521f3a63515615d6e7ad39a3cd5e18d88f Mon Sep 17 00:00:00 2001 | ||
| From: Erick Shepherd <erick.shepherd@ni.com> | ||
| Date: Mon, 17 Aug 2026 11:36:50 -0500 | ||
| Subject: [PATCH] pam_unix_passwd: Allow empty password to be set | ||
|
|
||
| Upstream-Status: Inappropriate [NI specific] | ||
|
|
||
| Allow users to set a blank password using linux-pam by no longer | ||
| setting blank passwords to NULL and making their shadow file entry | ||
| blank. This is toggled by the nullok option. | ||
|
|
||
| Signed-off-by: Erick Shepherd <erick.shepherd@ni.com> | ||
| --- | ||
| modules/pam_unix/pam_unix.8.xml | 4 ++-- | ||
| modules/pam_unix/pam_unix_passwd.c | 10 ++++++++-- | ||
| 2 files changed, 10 insertions(+), 4 deletions(-) | ||
|
|
||
| diff --git a/modules/pam_unix/pam_unix.8.xml b/modules/pam_unix/pam_unix.8.xml | ||
| index d2cd198f..7f95beeb 100644 | ||
| --- a/modules/pam_unix/pam_unix.8.xml | ||
| +++ b/modules/pam_unix/pam_unix.8.xml | ||
| @@ -155,8 +155,8 @@ | ||
| <listitem> | ||
| <para> | ||
| The default action of this module is to not permit the | ||
| - user access to a service if their official password is blank. | ||
| - The <option>nullok</option> argument overrides this default. | ||
| + user access to a service if their official password is blank | ||
| + or allow blank passwords to be set during password changes. | ||
| </para> | ||
| </listitem> | ||
| </varlistentry> | ||
| diff --git a/modules/pam_unix/pam_unix_passwd.c b/modules/pam_unix/pam_unix_passwd.c | ||
| index c01fd56b..b8ac9688 100644 | ||
| --- a/modules/pam_unix/pam_unix_passwd.c | ||
| +++ b/modules/pam_unix/pam_unix_passwd.c | ||
| @@ -593,6 +593,7 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char **argv) | ||
| int remember = -1; | ||
| int rounds = 0; | ||
| int pass_min_len = 0; | ||
| + int nullok_enabled = 0; | ||
|
erickshepherdNI marked this conversation as resolved.
|
||
| struct passwd *pwd; | ||
|
|
||
| /* <DO NOT free() THESE> */ | ||
| @@ -605,6 +606,7 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char **argv) | ||
|
|
||
| ctrl = _set_ctrl(pamh, flags, &remember, &rounds, &pass_min_len, | ||
| argc, argv); | ||
| + nullok_enabled = off(UNIX__NONULL, ctrl); | ||
|
erickshepherdNI marked this conversation as resolved.
|
||
|
|
||
| /* | ||
| * First get the name of a user | ||
| @@ -772,7 +774,7 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char **argv) | ||
| * password is acceptable. | ||
| */ | ||
|
|
||
| - if (*pass_new == '\0') { /* "\0" password = NULL */ | ||
| + if (!nullok_enabled && pass_new != NULL && *pass_new == '\0') { | ||
| pass_new = NULL; | ||
| } | ||
| retval = _pam_unix_approve_pass(pamh, ctrl, pass_old, | ||
| @@ -828,7 +830,11 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char **argv) | ||
| * First we encrypt the new password. | ||
| */ | ||
|
|
||
| - tpass = create_password_hash(pamh, pass_new, ctrl, rounds); | ||
| + if (pass_new != NULL && *pass_new == '\0') { | ||
| + tpass = strdup(""); | ||
| + } else { | ||
| + tpass = create_password_hash(pamh, pass_new, ctrl, rounds); | ||
| + } | ||
| if (tpass == NULL) { | ||
| pam_syslog(pamh, LOG_CRIT, | ||
| "crypt() failure or out of memory for password"); | ||
| -- | ||
| 2.51.0 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.