|
Packit Service |
3c59f5 |
/* Test for endgrent changing errno for BZ #24696
|
|
Packit Service |
3c59f5 |
Copyright (C) 2019 Free Software Foundation, Inc.
|
|
Packit Service |
3c59f5 |
This file is part of the GNU C Library.
|
|
Packit Service |
3c59f5 |
|
|
Packit Service |
3c59f5 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
3c59f5 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
3c59f5 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
3c59f5 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
3c59f5 |
|
|
Packit Service |
3c59f5 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
3c59f5 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
3c59f5 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
3c59f5 |
Lesser General Public License for more details.
|
|
Packit Service |
3c59f5 |
|
|
Packit Service |
3c59f5 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
3c59f5 |
License along with the GNU C Library; if not, see
|
|
Packit Service |
3c59f5 |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
3c59f5 |
|
|
Packit Service |
3c59f5 |
#include <stdlib.h>
|
|
Packit Service |
3c59f5 |
#include <sys/types.h>
|
|
Packit Service |
3c59f5 |
#include <grp.h>
|
|
Packit Service |
3c59f5 |
#include <unistd.h>
|
|
Packit Service |
3c59f5 |
#include <errno.h>
|
|
Packit Service |
3c59f5 |
|
|
Packit Service |
3c59f5 |
#include <support/check.h>
|
|
Packit Service |
3c59f5 |
#include <support/support.h>
|
|
Packit Service |
3c59f5 |
|
|
Packit Service |
3c59f5 |
/* The following test verifies that if the db NSS Service is initialized
|
|
Packit Service |
3c59f5 |
with no database (getgrent), that a subsequent closure (endgrent) does
|
|
Packit Service |
3c59f5 |
not set errno. In the case of the db service it is not an error to close
|
|
Packit Service |
3c59f5 |
the service and so it should not set errno. */
|
|
Packit Service |
3c59f5 |
|
|
Packit Service |
3c59f5 |
static int
|
|
Packit Service |
3c59f5 |
do_test (void)
|
|
Packit Service |
3c59f5 |
{
|
|
Packit Service |
3c59f5 |
/* Just make sure it's not there, although usually it won't be. */
|
|
Packit Service |
3c59f5 |
unlink ("/var/db/group.db");
|
|
Packit Service |
3c59f5 |
|
|
Packit Service |
3c59f5 |
/* This, in conjunction with the testroot's nsswitch.conf, causes
|
|
Packit Service |
3c59f5 |
the nss_db module to be "connected" and initialized - but the
|
|
Packit Service |
3c59f5 |
testroot has no group.db, so no mapping will be created. */
|
|
Packit Service |
3c59f5 |
getgrent ();
|
|
Packit Service |
3c59f5 |
|
|
Packit Service |
3c59f5 |
errno = 0;
|
|
Packit Service |
3c59f5 |
|
|
Packit Service |
3c59f5 |
/* Before the fix, this would call munmap (NULL) and set errno. */
|
|
Packit Service |
3c59f5 |
endgrent ();
|
|
Packit Service |
3c59f5 |
|
|
Packit Service |
3c59f5 |
if (errno != 0)
|
|
Packit Service |
3c59f5 |
FAIL_EXIT1 ("endgrent set errno to %d\n", errno);
|
|
Packit Service |
3c59f5 |
|
|
Packit Service |
3c59f5 |
return 0;
|
|
Packit Service |
3c59f5 |
}
|
|
Packit Service |
3c59f5 |
#include <support/test-driver.c>
|