|
|
147e83 |
This file contains the reworked/backported sections from these two
|
|
|
147e83 |
upstream commits:
|
|
|
147e83 |
|
|
|
147e83 |
commit ae5c498d93d049d9574d3f8f18e62cac64cbdf5c
|
|
|
147e83 |
Author: DJ Delorie <dj@delorie.com>
|
|
|
147e83 |
Date: Mon Jul 17 15:50:43 2017 -0400
|
|
|
147e83 |
|
|
|
147e83 |
Extend NSS test suite
|
|
|
147e83 |
|
|
|
147e83 |
commit a3fe6a20bf81ef6a97a761dac9050517e7fd7a1f
|
|
|
147e83 |
Author: DJ Delorie <dj@redhat.com>
|
|
|
147e83 |
Date: Thu Aug 17 17:58:25 2017 -0400
|
|
|
147e83 |
|
|
|
147e83 |
Update nss tests to new skeleton
|
|
|
147e83 |
|
|
|
147e83 |
diff -Nrup a/nss/Makefile b/nss/Makefile
|
|
|
147e83 |
--- a/nss/Makefile 2019-07-29 22:25:16.482170120 -0400
|
|
|
147e83 |
+++ b/nss/Makefile 2019-07-29 22:37:05.675342258 -0400
|
|
|
147e83 |
@@ -38,8 +38,14 @@ install-bin := getent makedb
|
|
|
147e83 |
makedb-modules = xmalloc hash-string
|
|
|
147e83 |
extra-objs += $(makedb-modules:=.o)
|
|
|
147e83 |
|
|
|
147e83 |
-tests = test-netdb tst-nss-test1 bug17079 tst-nss-getpwent \
|
|
|
147e83 |
- test-digits-dots tst-nss-files-hosts-erange
|
|
|
147e83 |
+tests = test-netdb test-digits-dots tst-nss-getpwent bug17079 \
|
|
|
147e83 |
+ tst-nss-files-hosts-erange \
|
|
|
147e83 |
+ tst-nss-test1 \
|
|
|
147e83 |
+ tst-nss-test2 \
|
|
|
147e83 |
+ tst-nss-test3 \
|
|
|
147e83 |
+ tst-nss-test4 \
|
|
|
147e83 |
+ tst-nss-test5
|
|
|
147e83 |
+
|
|
|
147e83 |
xtests = bug-erange
|
|
|
147e83 |
|
|
|
147e83 |
include ../Makeconfig
|
|
|
147e83 |
@@ -80,6 +86,8 @@ tests-static = tst-nss-static
|
|
|
147e83 |
tests += $(tests-static)
|
|
|
147e83 |
endif
|
|
|
147e83 |
|
|
|
147e83 |
+extra-test-objs += nss_test1.os nss_test2.os
|
|
|
147e83 |
+
|
|
|
147e83 |
include ../Rules
|
|
|
147e83 |
|
|
|
147e83 |
ifeq (yes,$(have-selinux))
|
|
|
147e83 |
@@ -107,13 +115,28 @@ $(objpfx)makedb: $(makedb-modules:%=$(ob
|
|
|
147e83 |
$(inst_vardbdir)/Makefile: db-Makefile $(+force)
|
|
|
147e83 |
$(do-install)
|
|
|
147e83 |
|
|
|
147e83 |
+libnss_test1.so-no-z-defs = 1
|
|
|
147e83 |
+libnss_test2.so-no-z-defs = 1
|
|
|
147e83 |
+
|
|
|
147e83 |
+rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver
|
|
|
147e83 |
+
|
|
|
147e83 |
libof-nss_test1 = extramodules
|
|
|
147e83 |
+libof-nss_test2 = extramodules
|
|
|
147e83 |
$(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
|
|
|
147e83 |
$(build-module)
|
|
|
147e83 |
+$(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps)
|
|
|
147e83 |
+ $(build-module)
|
|
|
147e83 |
+$(objpfx)nss_test2.os : nss_test1.c
|
|
|
147e83 |
ifdef libnss_test1.so-version
|
|
|
147e83 |
$(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
|
|
|
147e83 |
$(make-link)
|
|
|
147e83 |
endif
|
|
|
147e83 |
-$(objpfx)tst-nss-test1.out: $(objpfx)/libnss_test1.so$(libnss_test1.so-version)
|
|
|
147e83 |
+ifdef libnss_test2.so-version
|
|
|
147e83 |
+$(objpfx)/libnss_test2.so$(libnss_test2.so-version): $(objpfx)/libnss_test2.so
|
|
|
147e83 |
+ $(make-link)
|
|
|
147e83 |
+endif
|
|
|
147e83 |
+$(patsubst %,$(objpfx)%.out,$(tests)) : \
|
|
|
147e83 |
+ $(objpfx)/libnss_test1.so$(libnss_test1.so-version) \
|
|
|
147e83 |
+ $(objpfx)/libnss_test2.so$(libnss_test2.so-version)
|
|
|
147e83 |
|
|
|
147e83 |
$(objpfx)tst-nss-files-hosts-erange: $(libdl)
|
|
|
147e83 |
diff -Nrup a/nss/tst-nss-getpwent.c b/nss/tst-nss-getpwent.c
|
|
|
147e83 |
--- a/nss/tst-nss-getpwent.c 2019-07-29 16:44:37.670904243 -0400
|
|
|
147e83 |
+++ b/nss/tst-nss-getpwent.c 2019-07-29 16:49:58.538313946 -0400
|
|
|
147e83 |
@@ -21,6 +21,8 @@
|
|
|
147e83 |
#include <stdlib.h>
|
|
|
147e83 |
#include <string.h>
|
|
|
147e83 |
|
|
|
147e83 |
+#include <support/support.h>
|
|
|
147e83 |
+
|
|
|
147e83 |
int
|
|
|
147e83 |
do_test (void)
|
|
|
147e83 |
{
|
|
|
147e83 |
@@ -37,22 +39,12 @@ do_test (void)
|
|
|
147e83 |
{
|
|
|
147e83 |
if (first_name == NULL)
|
|
|
147e83 |
{
|
|
|
147e83 |
- first_name = strdup (pw->pw_name);
|
|
|
147e83 |
- if (first_name == NULL)
|
|
|
147e83 |
- {
|
|
|
147e83 |
- printf ("strdup: %m\n");
|
|
|
147e83 |
- return 1;
|
|
|
147e83 |
- }
|
|
|
147e83 |
+ first_name = xstrdup (pw->pw_name);
|
|
|
147e83 |
first_uid = pw->pw_uid;
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
free (last_name);
|
|
|
147e83 |
- last_name = strdup (pw->pw_name);
|
|
|
147e83 |
- if (last_name == NULL)
|
|
|
147e83 |
- {
|
|
|
147e83 |
- printf ("strdup: %m\n");
|
|
|
147e83 |
- return 1;
|
|
|
147e83 |
- }
|
|
|
147e83 |
+ last_name = xstrdup (pw->pw_name);
|
|
|
147e83 |
last_uid = pw->pw_uid;
|
|
|
147e83 |
++count;
|
|
|
147e83 |
}
|
|
|
147e83 |
@@ -112,5 +104,4 @@ do_test (void)
|
|
|
147e83 |
return 0;
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
-#define TEST_FUNCTION do_test ()
|
|
|
147e83 |
-#include "../test-skeleton.c"
|
|
|
147e83 |
+#include <support/test-driver.c>
|
|
|
147e83 |
diff -Nrup a/shlib-versions b/shlib-versions
|
|
|
147e83 |
--- a/shlib-versions 2019-07-29 16:50:46.222077613 -0400
|
|
|
147e83 |
+++ b/shlib-versions 2019-07-29 16:53:04.745391058 -0400
|
|
|
147e83 |
@@ -87,6 +87,7 @@ sh.*-.*-linux.* ld=ld-linux.so.2 GLIBC_
|
|
|
147e83 |
# Tests for NSS. They must have the same NSS_SHLIB_REVISION number as
|
|
|
147e83 |
# the rest.
|
|
|
147e83 |
.*-.*-.* libnss_test1=2
|
|
|
147e83 |
+.*-.*-.* libnss_test2=2
|
|
|
147e83 |
|
|
|
147e83 |
# Version for libnsl with YP and NIS+ functions.
|
|
|
147e83 |
.*-.*-.* libnsl=1
|
|
|
147e83 |
diff -Nrup a/nss/tst-nss-test1.c b/nss/tst-nss-test1.c
|
|
|
147e83 |
--- a/nss/tst-nss-test1.c 2019-07-29 16:54:05.824241220 -0400
|
|
|
147e83 |
+++ b/nss/tst-nss-test1.c 2019-07-29 17:13:55.696765720 -0400
|
|
|
147e83 |
@@ -1,9 +1,51 @@
|
|
|
147e83 |
+/* Basic test of passwd database handling.
|
|
|
147e83 |
+ Copyright (C) 2017 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
#include <nss.h>
|
|
|
147e83 |
#include <pwd.h>
|
|
|
147e83 |
#include <stdio.h>
|
|
|
147e83 |
#include <stdlib.h>
|
|
|
147e83 |
#include <string.h>
|
|
|
147e83 |
|
|
|
147e83 |
+#include <support/support.h>
|
|
|
147e83 |
+
|
|
|
147e83 |
+#include "nss_test.h"
|
|
|
147e83 |
+
|
|
|
147e83 |
+static int hook_called = 0;
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* Note: the values chosen here are arbitrary; they need only be
|
|
|
147e83 |
+ unique within the table. However, they do need to match the
|
|
|
147e83 |
+ "pwdids" array further down. */
|
|
|
147e83 |
+static struct passwd pwd_table[] = {
|
|
|
147e83 |
+ PWD (100),
|
|
|
147e83 |
+ PWD (30),
|
|
|
147e83 |
+ PWD (200),
|
|
|
147e83 |
+ PWD (60),
|
|
|
147e83 |
+ PWD (20000),
|
|
|
147e83 |
+ PWD_LAST ()
|
|
|
147e83 |
+ };
|
|
|
147e83 |
+
|
|
|
147e83 |
+void
|
|
|
147e83 |
+_nss_test1_init_hook(test_tables *t)
|
|
|
147e83 |
+{
|
|
|
147e83 |
+ hook_called = 1;
|
|
|
147e83 |
+ t->pwd_table = pwd_table;
|
|
|
147e83 |
+}
|
|
|
147e83 |
|
|
|
147e83 |
static int
|
|
|
147e83 |
do_test (void)
|
|
|
147e83 |
@@ -12,20 +54,26 @@ do_test (void)
|
|
|
147e83 |
|
|
|
147e83 |
__nss_configure_lookup ("passwd", "test1");
|
|
|
147e83 |
|
|
|
147e83 |
+ /* This must match the pwd_table above. */
|
|
|
147e83 |
static const unsigned int pwdids[] = { 100, 30, 200, 60, 20000 };
|
|
|
147e83 |
#define npwdids (sizeof (pwdids) / sizeof (pwdids[0]))
|
|
|
147e83 |
+
|
|
|
147e83 |
setpwent ();
|
|
|
147e83 |
|
|
|
147e83 |
const unsigned int *np = pwdids;
|
|
|
147e83 |
for (struct passwd *p = getpwent (); p != NULL; ++np, p = getpwent ())
|
|
|
147e83 |
- if (p->pw_uid != *np || strncmp (p->pw_name, "name", 4) != 0
|
|
|
147e83 |
- || atol (p->pw_name + 4) != *np)
|
|
|
147e83 |
- {
|
|
|
147e83 |
- printf ("passwd entry %td wrong (%s, %u)\n",
|
|
|
147e83 |
- np - pwdids, p->pw_name, p->pw_uid);
|
|
|
147e83 |
- retval = 1;
|
|
|
147e83 |
- break;
|
|
|
147e83 |
- }
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ retval += compare_passwds (np-pwdids, p, & pwd_table[np-pwdids]);
|
|
|
147e83 |
+
|
|
|
147e83 |
+ if (p->pw_uid != *np || strncmp (p->pw_name, "name", 4) != 0
|
|
|
147e83 |
+ || atol (p->pw_name + 4) != *np)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ printf ("FAIL: passwd entry %td wrong (%s, %u)\n",
|
|
|
147e83 |
+ np - pwdids, p->pw_name, p->pw_uid);
|
|
|
147e83 |
+ retval = 1;
|
|
|
147e83 |
+ break;
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+ }
|
|
|
147e83 |
|
|
|
147e83 |
endpwent ();
|
|
|
147e83 |
|
|
|
147e83 |
@@ -37,14 +85,14 @@ do_test (void)
|
|
|
147e83 |
struct passwd *p = getpwnam (buf);
|
|
|
147e83 |
if (p == NULL || p->pw_uid != pwdids[i] || strcmp (buf, p->pw_name) != 0)
|
|
|
147e83 |
{
|
|
|
147e83 |
- printf ("passwd entry \"%s\" wrong\n", buf);
|
|
|
147e83 |
+ printf ("FAIL: passwd entry \"%s\" wrong\n", buf);
|
|
|
147e83 |
retval = 1;
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
p = getpwuid (pwdids[i]);
|
|
|
147e83 |
if (p == NULL || p->pw_uid != pwdids[i] || strcmp (buf, p->pw_name) != 0)
|
|
|
147e83 |
{
|
|
|
147e83 |
- printf ("passwd entry %u wrong\n", pwdids[i]);
|
|
|
147e83 |
+ printf ("FAIL: passwd entry %u wrong\n", pwdids[i]);
|
|
|
147e83 |
retval = 1;
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
@@ -53,20 +101,25 @@ do_test (void)
|
|
|
147e83 |
p = getpwnam (buf);
|
|
|
147e83 |
if (p != NULL)
|
|
|
147e83 |
{
|
|
|
147e83 |
- printf ("passwd entry \"%s\" wrong\n", buf);
|
|
|
147e83 |
+ printf ("FAIL: passwd entry \"%s\" wrong\n", buf);
|
|
|
147e83 |
retval = 1;
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
p = getpwuid (pwdids[i] + 1);
|
|
|
147e83 |
if (p != NULL)
|
|
|
147e83 |
{
|
|
|
147e83 |
- printf ("passwd entry %u wrong\n", pwdids[i] + 1);
|
|
|
147e83 |
+ printf ("FAIL: passwd entry %u wrong\n", pwdids[i] + 1);
|
|
|
147e83 |
retval = 1;
|
|
|
147e83 |
}
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
+ if (!hook_called)
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ retval = 1;
|
|
|
147e83 |
+ printf("FAIL: init hook never called\n");
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+
|
|
|
147e83 |
return retval;
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
-#define TEST_FUNCTION do_test ()
|
|
|
147e83 |
-#include "../test-skeleton.c"
|
|
|
147e83 |
+#include <support/test-driver.c>
|
|
|
147e83 |
diff -Nrup a/nss/test-netdb.c b/nss/test-netdb.c
|
|
|
147e83 |
--- a/nss/test-netdb.c 2019-07-30 15:31:30.468602060 -0400
|
|
|
147e83 |
+++ b/nss/test-netdb.c 2019-07-30 15:37:29.116601115 -0400
|
|
|
147e83 |
@@ -42,6 +42,8 @@
|
|
|
147e83 |
#include <errno.h>
|
|
|
147e83 |
#include "nss.h"
|
|
|
147e83 |
|
|
|
147e83 |
+#include <support/support.h>
|
|
|
147e83 |
+
|
|
|
147e83 |
/*
|
|
|
147e83 |
The following define is necessary for glibc 2.0.6
|
|
|
147e83 |
*/
|
|
|
147e83 |
@@ -179,7 +181,7 @@ test_hosts (void)
|
|
|
147e83 |
while (gethostname (name, namelen) < 0 && errno == ENAMETOOLONG)
|
|
|
147e83 |
{
|
|
|
147e83 |
namelen += 2; /* tiny increments to test a lot */
|
|
|
147e83 |
- name = realloc (name, namelen);
|
|
|
147e83 |
+ name = xrealloc (name, namelen);
|
|
|
147e83 |
}
|
|
|
147e83 |
if (gethostname (name, namelen) == 0)
|
|
|
147e83 |
{
|
|
|
147e83 |
@@ -377,5 +379,4 @@ do_test (void)
|
|
|
147e83 |
return (error_count != 0);
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
-#define TEST_FUNCTION do_test ()
|
|
|
147e83 |
-#include "../test-skeleton.c"
|
|
|
147e83 |
+#include <support/test-driver.c>
|