[PATCH] Tests: fixed warning on win32 in auth_basic.t
Maxim Dounin
mdounin at mdounin.ru
Fri Jun 16 00:51:01 UTC 2023
Hello!
On Thu, Jun 15, 2023 at 04:53:07PM +0400, Sergey Kandaurov wrote:
>
> > On 15 Jun 2023, at 04:22, Maxim Dounin <mdounin at mdounin.ru> wrote:
> >
> > # HG changeset patch
> > # User Maxim Dounin <mdounin at mdounin.ru>
> > # Date 1686748038 -10800
> > # Wed Jun 14 16:07:18 2023 +0300
> > # Node ID 032ccd3118cbd5a4cc170a12667cc31ddd279c1f
> > # Parent f61d1b4ac638e756c7540dff4d2d69a82d7274fb
> > Tests: fixed warning on win32 in auth_basic.t.
> >
> > diff -r f61d1b4ac638 -r 032ccd3118cb auth_basic.t
> > --- a/auth_basic.t Wed Jun 14 16:57:01 2023 +0400
> > +++ b/auth_basic.t Wed Jun 14 16:07:18 2023 +0300
> > @@ -64,8 +64,8 @@ EOF
> >
> > $t->write_file(
> > 'htpasswd',
> > - 'crypt:' . crypt('password', 'salt') . "\n" .
> > - 'crypt1:' . crypt('password', '$1$salt$') . "\n" .
> > + 'crypt:' . (crypt('password', 'salt') || '') . "\n" .
> > + 'crypt1:' . (crypt('password', '$1$salt$') || '') . "\n" .
> > 'crypt2:' . '$1$' . "\n" .
> > 'apr1:' . '$apr1$salt$Xxd1irWT9ycqoYxGFn4cb.' . "\n" .
> > 'apr12:' . '$apr1$' . "\n" .
>
> No objections, including that it may not be available per perlport.
> I assume crypt returns undef due to missing functionality?
>
> Just for the record: on what Perl version such warnings observed?
> None seen on two different native Perl versions and one from msys.
I'm seeing the warning with Perl 5.32.1 as provided by Strawberry
Perl: crypt(..., '$1$salt$') returns undef.
>From the des_fcrypt() function I would expect this to happen on
all modern native win32 builds
(https://github.com/Perl/perl5/blob/b263f63493f4649c2ac69e2dd054bc5b1ed87f6e/win32/fcrypt.c#L488):
if (!good_for_salt(salt[0]) || !good_for_salt(salt[1])) {
errno = EINVAL;
return NULL;
}
Where good_for_salt() only permits [./0-9A-Za-z], and therefore
does not like attempts to use modular crypt(). This was
introduced in perl 5.25.7 in 2016
(https://github.com/Perl/perl5/commit/d691474c4cf3d3119367a72ebb28a990d039baf3).
Given the perlport clause that crypt() might not be available on
win32 at all and the fact that crypt() passwords are not checked
on win32 anyway, I've added "|| ''" for both calls.
Pushed to http://mdounin.ru/hg/nginx-tests, thanks for the review.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx-devel
mailing list