Re: [PATCH] policycoreutils/run_init: handle NULL from crypt() in non-PAM build

Stephen Smalley <[email protected]> Tue, 21 Jul 2026 08:49:03 -0400
Newsgroups org.kernel.vger.selinux
Message-ID <CAEjxPJ4VVMffTYyg3+u4PQg3OTXe08YcC4yYH=2NSnY3gMBM4A@mail.gmail.com>
On Thu, Jul 16, 2026 at 8:58 AM Stephen Smalley
<[email protected]> wrote:
>
> crypt() returns NULL on error, so check for NULL and treat as if
> authentication failed in that case.
>
> Signed-off-by: Stephen Smalley <[email protected]>

Merged.

> ---
>  policycoreutils/run_init/run_init.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/policycoreutils/run_init/run_init.c b/policycoreutils/run_init/run_init.c
> index bb9593ad..89921b23 100644
> --- a/policycoreutils/run_init/run_init.c
> +++ b/policycoreutils/run_init/run_init.c
> @@ -213,6 +213,8 @@ static int authenticate_via_shadow_passwd(const struct passwd *p_passwd_line)
>         encrypted_password_s =
>                 crypt(unencrypted_password_s, p_shadow_line->sp_pwdp);
>         memset(unencrypted_password_s, 0, strlen(unencrypted_password_s));
> +       if (!encrypted_password_s)
> +               return 0;
>
>         /* Return 1 (authenticated) iff the encrypted version of the user's *
>          * input password matches the encrypted password stored in the      *
> --
> 2.55.0
>