diff mbox series

nss_db: reset mapping after last get*ent

Message ID xntvcoc88x.fsf@greed.delorie.com
State New
Headers show
Series nss_db: reset mapping after last get*ent | expand

Commit Message

DJ Delorie June 17, 2019, 7:38 p.m. UTC
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.

	* nss/nss_db/db-open.c (internal_endent): Reset mapping to NULL.

Comments

Florian Weimer June 17, 2019, 8:10 p.m. UTC | #1
* DJ Delorie:

> 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.
>
> 	* nss/nss_db/db-open.c (internal_endent): Reset mapping to NULL.
>
> diff --git a/nss/nss_db/db-open.c b/nss/nss_db/db-open.c
> index 8a83d6b930..f7c53b4486 100644
> --- a/nss/nss_db/db-open.c
> +++ b/nss/nss_db/db-open.c
> @@ -64,4 +64,5 @@ void
>  internal_endent (struct nss_db_map *mapping)
>  {
>    munmap (mapping->header, mapping->len);
> +  mapping->header = NULL;
>  }

This needs a bug in Bugzilla and, ideally, a test case.
Andreas Schwab June 18, 2019, 8:03 a.m. UTC | #2
On Jun 17 2019, DJ Delorie <dj@redhat.com> wrote:

> diff --git a/support/links-dso-program-c.c b/support/links-dso-program-c.c
> index d28a28a0d0..6043b8652b 100644
> --- a/support/links-dso-program-c.c
> +++ b/support/links-dso-program-c.c
> @@ -1,9 +1,18 @@
>  #include <stdio.h>
>  
> +/* makedb needs selinux dso's.  */
> +#ifdef HAVE_SELINUX
> +# include <selinux/selinux.h>
> +int sel;

Where is this variable used?

Andreas.
diff mbox series

Patch

diff --git a/nss/nss_db/db-open.c b/nss/nss_db/db-open.c
index 8a83d6b930..f7c53b4486 100644
--- a/nss/nss_db/db-open.c
+++ b/nss/nss_db/db-open.c
@@ -64,4 +64,5 @@  void
 internal_endent (struct nss_db_map *mapping)
 {
   munmap (mapping->header, mapping->len);
+  mapping->header = NULL;
 }