]>
Commit | Line | Data |
---|---|---|
9b456c5d | 1 | /* Test error checking for group entries. |
6d7e8eda | 2 | Copyright (C) 2021-2023 Free Software Foundation, Inc. |
9b456c5d DD |
3 | This file is part of the GNU C Library. |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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/>. */ | |
18 | ||
19 | #include <nss.h> | |
20 | #include <stdio.h> | |
21 | #include <stdlib.h> | |
22 | #include <string.h> | |
23 | ||
24 | #include <shadow.h> | |
25 | ||
26 | #include <support/support.h> | |
27 | #include <support/check.h> | |
28 | ||
29 | #include "nss_test.h" | |
30 | ||
31 | static struct passwd pwd_table[] = { | |
32 | PWD (100), | |
33 | PWD (30), | |
34 | PWD_LAST () | |
35 | }; | |
36 | ||
37 | static struct spwd spwd_table[] = { | |
38 | SPWD (100), | |
39 | SPWD (30), | |
40 | SPWD_LAST () | |
41 | }; | |
42 | ||
43 | void | |
44 | _nss_test1_init_hook(test_tables *t) | |
45 | { | |
46 | t->pwd_table = pwd_table; | |
47 | t->spwd_table = spwd_table; | |
48 | } | |
49 | ||
50 | static int | |
51 | do_test (void) | |
52 | { | |
53 | struct passwd *p = NULL; | |
54 | struct spwd *s = NULL; | |
55 | struct group *g = NULL; | |
56 | ||
57 | /* Test that compat-to-test works. */ | |
58 | p = getpwuid (100); | |
59 | if (p == NULL) | |
60 | FAIL_EXIT1("getpwuid-compat-test1 p"); | |
61 | else if (strcmp (p->pw_name, "name100") != 0) | |
62 | FAIL_EXIT1("getpwuid-compat-test1 name100"); | |
63 | ||
64 | /* Shadow compat should use passwd via the alternate name. */ | |
65 | s = getspnam ("name30"); | |
66 | if (s == NULL) | |
67 | FAIL_EXIT1("getspnam-compat-test1 s"); | |
68 | else if (strcmp (s->sp_namp, "name30") != 0) | |
69 | FAIL_EXIT1("getpwuid-compat-test1 name30"); | |
70 | ||
71 | /* Test that internal defconfig works. */ | |
72 | g = getgrgid (100); | |
73 | if (g == NULL) | |
74 | FAIL_EXIT1("getgrgid-compat-null"); | |
75 | if (strcmp (g->gr_name, "wilma") != 0) | |
76 | FAIL_EXIT1("getgrgid-compat-name"); | |
77 | ||
78 | return 0; | |
79 | } | |
80 | ||
81 | #include <support/test-driver.c> |