1 | /* Initialization in nss_files module. |
2 | Copyright (C) 2011-2020 Free Software Foundation, Inc. |
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 | #ifdef USE_NSCD |
20 | |
21 | #include <string.h> |
22 | #include <nscd/nscd.h> |
23 | #include <nss.h> |
24 | |
25 | NSS_DECLARE_MODULE_FUNCTIONS (files) |
26 | |
27 | #define PWD_FILENAME "/etc/passwd" |
28 | define_traced_file (pwd, PWD_FILENAME); |
29 | |
30 | #define GRP_FILENAME "/etc/group" |
31 | define_traced_file (grp, GRP_FILENAME); |
32 | |
33 | #define HST_FILENAME "/etc/hosts" |
34 | define_traced_file (hst, HST_FILENAME); |
35 | |
36 | #define RESOLV_FILENAME "/etc/resolv.conf" |
37 | define_traced_file (resolv, RESOLV_FILENAME); |
38 | |
39 | #define SERV_FILENAME "/etc/services" |
40 | define_traced_file (serv, SERV_FILENAME); |
41 | |
42 | #define NETGR_FILENAME "/etc/netgroup" |
43 | define_traced_file (netgr, NETGR_FILENAME); |
44 | |
45 | void |
46 | _nss_files_init (void (*cb) (size_t, struct traced_file *)) |
47 | { |
48 | init_traced_file (&pwd_traced_file.file, PWD_FILENAME, 0); |
49 | cb (pwddb, &pwd_traced_file.file); |
50 | |
51 | init_traced_file (&grp_traced_file.file, GRP_FILENAME, 0); |
52 | cb (grpdb, &grp_traced_file.file); |
53 | |
54 | init_traced_file (&hst_traced_file.file, HST_FILENAME, 0); |
55 | cb (hstdb, &hst_traced_file.file); |
56 | |
57 | init_traced_file (&resolv_traced_file.file, RESOLV_FILENAME, 1); |
58 | cb (hstdb, &resolv_traced_file.file); |
59 | |
60 | init_traced_file (&serv_traced_file.file, SERV_FILENAME, 0); |
61 | cb (servdb, &serv_traced_file.file); |
62 | |
63 | init_traced_file (&netgr_traced_file.file, NETGR_FILENAME, 0); |
64 | cb (netgrdb, &netgr_traced_file.file); |
65 | } |
66 | |
67 | #endif |
68 | |