Skip to content

Commit 618a5fd

Browse files
author
Rik
committed
Modify BIST tests for password functions to pass on all platforms (bug #67379)
On OpenBSD using endpwent() does not reset file pointer on password database to first entry. Instead, use setpwent() which reliably works on all OS to set the file pointer to first entry. * system.tst: Add HAVE_GETPWENT, HAVE_SETPWENT, and HAVE_ENDPWENT as necessary to %!testif header so that BIST tests are guaranteed to have the functions they need to run. Replace use of endpwent() to position password file pointer with setpwent().
1 parent ba5ee16 commit 618a5fd

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/system.tst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@
350350

351351
%!assert (ischar (pwd ()))
352352

353-
%!testif HAVE_GETPWENT
354-
%! endpwent ();
353+
%!testif HAVE_GETPWENT, HAVE_SETPWENT, HAVE_ENDPWENT
354+
%! setpwent ();
355355
%! s = getpwent ();
356356
%! endpwent ();
357357
%! assert (isstruct (s)
@@ -365,18 +365,19 @@
365365

366366
%!error <Invalid call to getpwent> getpwent (1)
367367

368-
%!testif HAVE_GETPWUID
369-
%! endpwent ();
368+
%!testif HAVE_GETPWUID, HAVE_GETPWENT, HAVE_SETPWENT, HAVE_ENDPWENT
369+
%! setpwent ();
370370
%! x = getpwent ();
371+
%! setpwent ();
371372
%! y = getpwuid (x.uid);
372373
%! endpwent ();
373374
%! assert (strcmp (x.name, y.name) && x.uid == y.uid && x.gid == y.gid);
374375

375376
%!error <Invalid call to getpwuid> getpwuid ()
376377
%!error <Invalid call to getpwuid> getpwuid (1, 2)
377378

378-
%!testif HAVE_GETPWNAM
379-
%! endpwent ();
379+
%!testif HAVE_GETPWNAM, HAVE_SETPWENT, HAVE_GETPWENT
380+
%! setpwent ();
380381
%! x = getpwent ();
381382
%! y = getpwnam (x.name);
382383
%! endpwent ();
@@ -385,8 +386,8 @@
385386
%!error <Invalid call to getpwnam> getpwnam ()
386387
%!error <Invalid call to getpwnam> getpwnam ("foo", 1)
387388

388-
%!testif HAVE_SETPWENT
389-
%! endpwent ();
389+
%!testif HAVE_SETPWENT, HAVE_GETPWENT, HAVE_ENDPWENT
390+
%! setpwent ();
390391
%! x = getpwent ();
391392
%! setpwent ();
392393
%! y = getpwent ();

0 commit comments

Comments
 (0)