1 /* Test for endgrent changing errno for BZ #24696
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
20 #include <sys/types.h>
25 #include <support/check.h>
26 #include <support/support.h>
28 /* The following test verifies that if the db NSS Service is initialized
29 with no database (getgrent), that a subsequent closure (endgrent) does
30 not set errno. In the case of the db service it is not an error to close
31 the service and so it should not set errno. */
36 /* Just make sure it's not there, although usually it won't be. */
37 unlink ("/var/db/group.db");
39 /* This, in conjunction with the testroot's nsswitch.conf, causes
40 the nss_db module to be "connected" and initialized - but the
41 testroot has no group.db, so no mapping will be created. */
46 /* Before the fix, this would call munmap (NULL) and set errno. */
50 FAIL_EXIT1 ("endgrent set errno to %d\n", errno
);
54 #include <support/test-driver.c>