]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nss/nss_files/files-init.c
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / nss / nss_files / files-init.c
index cc6822d305e50b64a2f45bc1f655a22832c700f5..346395c6ff692966fcad84a3a77cf53ba81248a5 100644 (file)
@@ -1,5 +1,5 @@
 /* Initialization in nss_files module.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
-#include <nscd/nscd.h>
+#ifdef USE_NSCD
 
+#include <string.h>
+#include <nscd/nscd.h>
 
-static union
-{
-  struct traced_file file;
-  char buf[sizeof (struct traced_file) + sizeof ("/etc/passwd")];
-} pwd_traced_file;
 
-static union
-{
-  struct traced_file file;
-  char buf[sizeof (struct traced_file) + sizeof ("/etc/group")];
-} grp_traced_file;
+#define TF(id, filename, ...)                                  \
+static union                                                   \
+{                                                              \
+  struct traced_file file;                                     \
+  char buf[sizeof (struct traced_file) + sizeof (filename)];   \
+} id##_traced_file =                                           \
+  {                                                            \
+    .file =                                                    \
+    {                                                          \
+      __VA_ARGS__                                              \
+    }                                                          \
+  }
 
-static union
-{
-  struct traced_file file;
-  char buf[sizeof (struct traced_file) + sizeof ("/etc/hosts")];
-} hst_traced_file;
-
-static union
-{
-  struct traced_file file;
-  char buf[sizeof (struct traced_file) + sizeof ("/etc/resolv.conf")];
-} resolv_traced_file;
-
-static union
-{
-  struct traced_file file;
-  char buf[sizeof (struct traced_file) + sizeof ("/etc/services")];
-} serv_traced_file;
+TF (pwd, "/etc/passwd");
+TF (grp, "/etc/group");
+TF (hst, "/etc/hosts");
+TF (resolv, "/etc/resolv.conf", .call_res_init = 1);
+TF (serv, "/etc/services");
+TF (netgr, "/etc/netgroup");
 
 
 void
@@ -63,10 +55,14 @@ _nss_files_init (void (*cb) (size_t, struct traced_file *))
   strcpy (hst_traced_file.file.fname, "/etc/hosts");
   cb (hstdb, &hst_traced_file.file);
 
-  resolv_traced_file.file.call_res_init = 1;
   strcpy (resolv_traced_file.file.fname, "/etc/resolv.conf");
   cb (hstdb, &resolv_traced_file.file);
 
   strcpy (serv_traced_file.file.fname, "/etc/services");
   cb (servdb, &serv_traced_file.file);
+
+  strcpy (netgr_traced_file.file.fname, "/etc/netgroup");
+  cb (netgrdb, &netgr_traced_file.file);
 }
+
+#endif