nss_db: fix endent wrt NULL mappings [BZ #24695] [BZ #24696]
commit99135114ba23c3110b7e4e650fabdc5e639746b7
authorDJ Delorie <dj@redhat.com>
Fri, 28 Jun 2019 23:30:00 +0000 (28 18:30 -0500)
committerDJ Delorie <dj@redhat.com>
Wed, 10 Jul 2019 18:51:18 +0000 (10 14:51 -0400)
tree09e4349308db59321eddff440eadaa630f60575b
parent30ba0375464f34e4bf8129f3d3dc14d0c09add17
nss_db: fix endent wrt NULL mappings [BZ #24695] [BZ #24696]

nss_db allows for getpwent et al to be called without a set*ent,
but it only works once.  After the last get*ent a set*ent is
required to restart, because the end*ent did not properly reset
the module.  Resetting it to NULL allows for a proper restart.

If the database doesn't exist, however, end*ent erroniously called
munmap which set errno.

The test case runs "makedb" inside the testroot, so needs selinux
DSOs installed.
ChangeLog
nss/Makefile
nss/nss_db/db-open.c
nss/tst-nss-db-endgrent.c [new file with mode: 0644]
nss/tst-nss-db-endgrent.root/etc/nsswitch.conf [new file with mode: 0644]
nss/tst-nss-db-endpwent.c [new file with mode: 0644]
nss/tst-nss-db-endpwent.root/etc/nsswitch.conf [new file with mode: 0644]
nss/tst-nss-db-endpwent.root/var/db/passwd.in [new file with mode: 0644]
support/Makefile
support/links-dso-program-c.c
support/links-dso-program.cc