1 /* Check handling of missing end-of-line at end of /etc/aliases (bug 24059).
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 <gnu/lib-names.h>
23 #include <support/check.h>
24 #include <support/namespace.h>
25 #include <support/test-driver.h>
26 #include <support/xdlfcn.h>
27 #include <support/xunistd.h>
30 in_chroot (void *closure
)
32 struct support_chroot
*chroot_env
= closure
;
33 xchroot (chroot_env
->path_chroot
);
35 struct aliasent
*e
= getaliasbyname ("user1");
36 TEST_VERIFY_EXIT (e
!= NULL
);
37 TEST_COMPARE_STRING (e
->alias_name
, "user1");
38 TEST_COMPARE (e
->alias_members_len
, 1);
39 TEST_VERIFY_EXIT (e
->alias_members
!= NULL
);
40 TEST_COMPARE_STRING (e
->alias_members
[0], "alias1");
41 TEST_VERIFY (e
->alias_local
);
47 /* Make sure we don't try to load the module in the chroot. */
48 xdlopen (LIBNSS_FILES_SO
, RTLD_NOW
);
50 __nss_configure_lookup ("aliases", "files");
52 support_become_root ();
53 if (!support_can_chroot ())
54 return EXIT_UNSUPPORTED
;
56 struct support_chroot
*chroot_env
= support_chroot_create
57 ((struct support_chroot_configuration
)
59 .aliases
= "user1: alias1,\n"
60 " " /* Continuation line, but no \n. */
63 support_isolate_in_subprocess (in_chroot
, chroot_env
);
65 support_chroot_free (chroot_env
);
69 #include <support/test-driver.c>