public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] nscd: Move declarations used in the library out of <nscd.h>
@ 2023-07-03 12:43 Florian Weimer
  2023-07-13  8:06 ` Hiroaki.Fuse
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2023-07-03 12:43 UTC (permalink / raw)
  To: libc-alpha; +Cc: Hiroaki.Fuse, libc-stable

Installed the shared header as include/nscd.h.  Rename the remaining
header with the nscd-internal declarations from nscd/nscd.h to
nscd/nscdP.h.

This makes it clear that the library does not depend on
include/programs/xmalloc.h.

Tested on i686-linux-gnu and x86_64-linux-gnu.  Built with
build-many-glibcs.py.

---
 include/nscd.h                              | 99 +++++++++++++++++++++++++++++
 nscd/aicache.c                              |  2 +-
 nscd/cache.c                                |  2 +-
 nscd/cachedumper.c                          |  2 +-
 nscd/connections.c                          |  2 +-
 nscd/dbg_log.c                              |  2 +-
 nscd/grpcache.c                             |  2 +-
 nscd/hstcache.c                             |  2 +-
 nscd/initgrcache.c                          |  2 +-
 nscd/mem.c                                  |  2 +-
 nscd/netgroupcache.c                        |  2 +-
 nscd/nscd-client.h                          |  2 +-
 nscd/{nscd.h => nscdP.h}                    | 83 ++----------------------
 nscd/nscd_conf.c                            |  2 +-
 nscd/nscd_setup_thread.c                    |  2 +-
 nscd/pwdcache.c                             |  2 +-
 nscd/selinux.h                              |  2 +-
 nscd/servicescache.c                        |  2 +-
 nss/nss_db/db-init.c                        |  2 +-
 nss/nss_files/files-init.c                  |  2 +-
 nss/nss_module.c                            |  2 +-
 sysdeps/unix/sysv/linux/nscd_setup_thread.c |  2 +-
 22 files changed, 124 insertions(+), 98 deletions(-)

diff --git a/include/nscd.h b/include/nscd.h
new file mode 100644
index 0000000000..109e3ab800
--- /dev/null
+++ b/include/nscd.h
@@ -0,0 +1,99 @@
+/* Private interface between sncd and NSS service modules.
+   Copyright (c) 2011-2023 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
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   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, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef NSCD_H
+#define NSCD_H
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+/* Handle databases.  */
+typedef enum
+{
+  pwddb,
+  grpdb,
+  hstdb,
+  servdb,
+  netgrdb,
+  lastdb
+} dbtype;
+
+/* Records the file registered per database that when changed
+   or modified requires invalidating the database.  */
+struct traced_file
+{
+  /* Tracks the last modified time of the traced file.  */
+  __time64_t mtime;
+  /* Support multiple registered files per database.  */
+  struct traced_file *next;
+  int call_res_init;
+  /* Requires Inotify support to do anything useful.  */
+#define TRACED_FILE     0
+#define TRACED_DIR      1
+  int inotify_descr[2];
+# ifndef PATH_MAX
+#  define PATH_MAX 1024
+# endif
+  /* The parent directory is used to scan for creation/deletion.  */
+  char dname[PATH_MAX];
+  /* Just the name of the file with no directory component.  */
+  char *sfname;
+  /* The full-path name of the registered file.  */
+  char fname[];
+};
+
+/* Initialize a `struct traced_file`.  As input we need the name
+   of the file, and if invalidation requires calling res_init.
+   If CRINIT is 1 then res_init will be called after invalidation
+   or if the traced file is changed in any way, otherwise it will
+   not.  */
+static inline void
+init_traced_file(struct traced_file *file, const char *fname, int crinit)
+{
+   char *dname;
+   file->mtime = 0;
+   file->inotify_descr[TRACED_FILE] = -1;
+   file->inotify_descr[TRACED_DIR] = -1;
+   strcpy (file->fname, fname);
+   /* Compute the parent directory name and store a copy.  The copy makes
+      it much faster to add/remove watches while nscd is running instead
+      of computing this over and over again in a temp buffer.  */
+   file->dname[0] = '\0';
+   dname = strrchr (fname, '/');
+   if (dname != NULL)
+     {
+       size_t len = (size_t)(dname - fname);
+       if (len > sizeof (file->dname))
+         abort ();
+       memcpy (file->dname, file->fname, len);
+       file->dname[len] = '\0';
+     }
+   /* The basename is the name just after the last forward slash.  */
+   file->sfname = &dname[1];
+   file->call_res_init = crinit;
+}
+
+#define define_traced_file(id, filename)                        \
+static union                                                    \
+{                                                               \
+  struct traced_file file;                                      \
+  char buf[sizeof (struct traced_file) + sizeof (filename)];    \
+} id##_traced_file;
+
+#endif /* NSCD_H */
diff --git a/nscd/aicache.c b/nscd/aicache.c
index 96f699c216..1967402a90 100644
--- a/nscd/aicache.c
+++ b/nscd/aicache.c
@@ -29,7 +29,7 @@
 #include <scratch_buffer.h>
 
 #include "dbg_log.h"
-#include "nscd.h"
+#include "nscdP.h"
 
 
 static const ai_response_header notfound =
diff --git a/nscd/cache.c b/nscd/cache.c
index b4b54d82bb..7071855774 100644
--- a/nscd/cache.c
+++ b/nscd/cache.c
@@ -30,7 +30,7 @@
 #include <sys/uio.h>
 #include <nss.h>
 
-#include "nscd.h"
+#include "nscdP.h"
 #include "dbg_log.h"
 
 
diff --git a/nscd/cachedumper.c b/nscd/cachedumper.c
index a197c081ef..68f9af49f7 100644
--- a/nscd/cachedumper.c
+++ b/nscd/cachedumper.c
@@ -28,7 +28,7 @@
 #include <getopt.h>
 #include <sys/param.h>
 
-#include "nscd.h"
+#include "nscdP.h"
 #include "dbg_log.h"
 
 static void *the_cache;
diff --git a/nscd/connections.c b/nscd/connections.c
index a405a44a9b..92b29e5148 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -49,7 +49,7 @@
 #include <sys/stat.h>
 #include <sys/un.h>
 
-#include "nscd.h"
+#include "nscdP.h"
 #include "dbg_log.h"
 #include "selinux.h"
 #include <resolv/resolv.h>
diff --git a/nscd/dbg_log.c b/nscd/dbg_log.c
index d31e79ceb3..d1e2523356 100644
--- a/nscd/dbg_log.c
+++ b/nscd/dbg_log.c
@@ -20,7 +20,7 @@
 #include <syslog.h>
 #include <unistd.h>
 #include "dbg_log.h"
-#include "nscd.h"
+#include "nscdP.h"
 
 /* if in debug mode and we have a debug file, we write the messages to it,
    if in debug mode and no debug file, we write the messages to stderr,
diff --git a/nscd/grpcache.c b/nscd/grpcache.c
index cdd1071970..93a9c9e7a0 100644
--- a/nscd/grpcache.c
+++ b/nscd/grpcache.c
@@ -32,7 +32,7 @@
 #include <stackinfo.h>
 #include <scratch_buffer.h>
 
-#include "nscd.h"
+#include "nscdP.h"
 #include "dbg_log.h"
 
 /* This is the standard reply in case the service is disabled.  */
diff --git a/nscd/hstcache.c b/nscd/hstcache.c
index bd289b4628..a979cff983 100644
--- a/nscd/hstcache.c
+++ b/nscd/hstcache.c
@@ -35,7 +35,7 @@
 #include <stackinfo.h>
 #include <scratch_buffer.h>
 
-#include "nscd.h"
+#include "nscdP.h"
 #include "dbg_log.h"
 
 
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c
index be44951bd6..1b9bee5711 100644
--- a/nscd/initgrcache.c
+++ b/nscd/initgrcache.c
@@ -27,7 +27,7 @@
 #include <config.h>
 
 #include "dbg_log.h"
-#include "nscd.h"
+#include "nscdP.h"
 
 #include "../nss/nsswitch.h"
 
diff --git a/nscd/mem.c b/nscd/mem.c
index 50f8162609..07ffcb542d 100644
--- a/nscd/mem.c
+++ b/nscd/mem.c
@@ -30,7 +30,7 @@
 #include <sys/param.h>
 
 #include "dbg_log.h"
-#include "nscd.h"
+#include "nscdP.h"
 
 
 static int
diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
index 06b7d7b6ca..9b317a38cd 100644
--- a/nscd/netgroupcache.c
+++ b/nscd/netgroupcache.c
@@ -25,7 +25,7 @@
 #include <sys/mman.h>
 
 #include "../inet/netgroup.h"
-#include "nscd.h"
+#include "nscdP.h"
 #include "dbg_log.h"
 
 #include <kernel-features.h>
diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h
index 5588ade982..9126fc83c2 100644
--- a/nscd/nscd-client.h
+++ b/nscd/nscd-client.h
@@ -450,4 +450,4 @@ extern ssize_t writeall (int fd, const void *buf, size_t len)
 extern uint32_t __nscd_get_nl_timestamp (void)
   attribute_hidden;
 
-#endif /* nscd.h */
+#endif /* nscd-client.h */
diff --git a/nscd/nscd.h b/nscd/nscdP.h
similarity index 82%
rename from nscd/nscd.h
rename to nscd/nscdP.h
index 04f82fc0b0..7d5f6e2011 100644
--- a/nscd/nscd.h
+++ b/nscd/nscdP.h
@@ -15,32 +15,21 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#ifndef _NSCD_H
-#define _NSCD_H	1
+#ifndef _NSCDP_H
+#define _NSCDP_H	1
 
 #include <pthread.h>
 #include <stdbool.h>
 #include <time.h>
 #include <sys/uio.h>
 
+#include <nscd.h>
+
 /* The declarations for the request and response types are in the file
    "nscd-client.h", which should contain everything needed by client
    functions.  */
 #include "nscd-client.h"
 
-
-/* Handle databases.  */
-typedef enum
-{
-  pwddb,
-  grpdb,
-  hstdb,
-  servdb,
-  netgrdb,
-  lastdb
-} dbtype;
-
-
 /* Default limit on the number of times a value gets reloaded without
    being used in the meantime.  NSCD does not throw a value out as
    soon as it times out.  It tries to reload the value from the
@@ -60,68 +49,6 @@ typedef enum
    80% of the thread stack size.  */
 #define MAX_STACK_USE ((8 * NSCD_THREAD_STACKSIZE) / 10)
 
-/* Records the file registered per database that when changed
-   or modified requires invalidating the database.  */
-struct traced_file
-{
-  /* Tracks the last modified time of the traced file.  */
-  __time64_t mtime;
-  /* Support multiple registered files per database.  */
-  struct traced_file *next;
-  int call_res_init;
-  /* Requires Inotify support to do anything useful.  */
-#define TRACED_FILE	0
-#define TRACED_DIR	1
-  int inotify_descr[2];
-# ifndef PATH_MAX
-#  define PATH_MAX 1024
-# endif
-  /* The parent directory is used to scan for creation/deletion.  */
-  char dname[PATH_MAX];
-  /* Just the name of the file with no directory component.  */
-  char *sfname;
-  /* The full-path name of the registered file.  */
-  char fname[];
-};
-
-/* Initialize a `struct traced_file`.  As input we need the name
-   of the file, and if invalidation requires calling res_init.
-   If CRINIT is 1 then res_init will be called after invalidation
-   or if the traced file is changed in any way, otherwise it will
-   not.  */
-static inline void
-init_traced_file(struct traced_file *file, const char *fname, int crinit)
-{
-   char *dname;
-   file->mtime = 0;
-   file->inotify_descr[TRACED_FILE] = -1;
-   file->inotify_descr[TRACED_DIR] = -1;
-   strcpy (file->fname, fname);
-   /* Compute the parent directory name and store a copy.  The copy makes
-      it much faster to add/remove watches while nscd is running instead
-      of computing this over and over again in a temp buffer.  */
-   file->dname[0] = '\0';
-   dname = strrchr (fname, '/');
-   if (dname != NULL)
-     {
-       size_t len = (size_t)(dname - fname);
-       if (len > sizeof (file->dname))
-	 abort ();
-       memcpy (file->dname, file->fname, len);
-       file->dname[len] = '\0';
-     }
-   /* The basename is the name just after the last forward slash.  */
-   file->sfname = &dname[1];
-   file->call_res_init = crinit;
-}
-
-#define define_traced_file(id, filename) 			\
-static union							\
-{								\
-  struct traced_file file;					\
-  char buf[sizeof (struct traced_file) + sizeof (filename)];	\
-} id##_traced_file;
-
 /* Structure describing dynamic part of one database.  */
 struct database_dyn
 {
@@ -375,4 +302,4 @@ extern void nscd_print_cache (const char *name);
        while (__result == EINTR);					      \
        __result; }))
 
-#endif /* nscd.h */
+#endif /* nscdP.h */
diff --git a/nscd/nscd_conf.c b/nscd/nscd_conf.c
index ead13e99b8..717ad8b425 100644
--- a/nscd/nscd_conf.c
+++ b/nscd/nscd_conf.c
@@ -29,7 +29,7 @@
 #include <sys/types.h>
 
 #include "dbg_log.h"
-#include "nscd.h"
+#include "nscdP.h"
 
 
 /* Names of the databases.  */
diff --git a/nscd/nscd_setup_thread.c b/nscd/nscd_setup_thread.c
index 5d6eff7a59..d33cd1069f 100644
--- a/nscd/nscd_setup_thread.c
+++ b/nscd/nscd_setup_thread.c
@@ -15,7 +15,7 @@
    You should have received a copy of the GNU General Public License
    along with this program; if not, see <https://www.gnu.org/licenses/>.  */
 
-#include <nscd.h>
+#include <nscdP.h>
 
 
 int
diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c
index e1b579de6b..e89b93fb07 100644
--- a/nscd/pwdcache.c
+++ b/nscd/pwdcache.c
@@ -32,7 +32,7 @@
 #include <stackinfo.h>
 #include <scratch_buffer.h>
 
-#include "nscd.h"
+#include "nscdP.h"
 #include "dbg_log.h"
 
 /* This is the standard reply in case the service is disabled.  */
diff --git a/nscd/selinux.h b/nscd/selinux.h
index 3f075b5533..b505654f7f 100644
--- a/nscd/selinux.h
+++ b/nscd/selinux.h
@@ -19,7 +19,7 @@
 #ifndef _SELINUX_H
 #define _SELINUX_H 1
 
-#include "nscd.h"
+#include "nscdP.h"
 #ifdef HAVE_LIBCAP
 # include <sys/capability.h>
 #endif
diff --git a/nscd/servicescache.c b/nscd/servicescache.c
index 2202679500..68663bb1af 100644
--- a/nscd/servicescache.c
+++ b/nscd/servicescache.c
@@ -25,7 +25,7 @@
 #include <kernel-features.h>
 #include <scratch_buffer.h>
 
-#include "nscd.h"
+#include "nscdP.h"
 #include "dbg_log.h"
 
 
diff --git a/nss/nss_db/db-init.c b/nss/nss_db/db-init.c
index bd79826cab..850e8c5fb4 100644
--- a/nss/nss_db/db-init.c
+++ b/nss/nss_db/db-init.c
@@ -19,7 +19,7 @@
 #ifdef USE_NSCD
 
 #include <paths.h>
-#include <nscd/nscd.h>
+#include <nscd.h>
 #include <string.h>
 
 #include "nss_db.h"
diff --git a/nss/nss_files/files-init.c b/nss/nss_files/files-init.c
index d5c2795b30..541ad65ffe 100644
--- a/nss/nss_files/files-init.c
+++ b/nss/nss_files/files-init.c
@@ -19,7 +19,7 @@
 #ifdef USE_NSCD
 
 #include <string.h>
-#include <nscd/nscd.h>
+#include <nscd.h>
 #include <nss.h>
 #include <nss_files.h>
 
diff --git a/nss/nss_module.c b/nss/nss_module.c
index 0104f88974..934ff4a968 100644
--- a/nss/nss_module.c
+++ b/nss/nss_module.c
@@ -17,7 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <nsswitch.h>
-#include <nscd/nscd.h>
+#include <nscd.h>
 #include <nscd/nscd_proto.h>
 
 #include <array_length.h>
diff --git a/sysdeps/unix/sysv/linux/nscd_setup_thread.c b/sysdeps/unix/sysv/linux/nscd_setup_thread.c
index cf1a56e005..76d9fad10f 100644
--- a/sysdeps/unix/sysv/linux/nscd_setup_thread.c
+++ b/sysdeps/unix/sysv/linux/nscd_setup_thread.c
@@ -17,7 +17,7 @@
 
 #include <string.h>
 #include <unistd.h>
-#include <nscd.h>
+#include <nscdP.h>
 #include <sysdep.h>
 
 

base-commit: e18c293af0ece38921ad71fbd76ff8049c3b2d67


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] nscd: Move declarations used in the library out of <nscd.h>
  2023-07-03 12:43 [PATCH] nscd: Move declarations used in the library out of <nscd.h> Florian Weimer
@ 2023-07-13  8:06 ` Hiroaki.Fuse
  2023-07-13  8:27   ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: Hiroaki.Fuse @ 2023-07-13  8:06 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha; +Cc: libc-stable

Dear Florian Weimer,

Thank you for your quick update.
My understanding is that we can conclude the license of glibc as LGPLv2.1
after applying your patch. Is it correct?

I hope community's consensus to apply this fix to the mainline.

Regards,

> -----Original Message-----
> From: Florian Weimer <fweimer@redhat.com>
> Sent: Monday, July 3, 2023 9:44 PM
> To: libc-alpha@sourceware.org
> Cc: Fuse, Hiroaki (SGC) <Hiroaki.Fuse@sony.com>;
> libc-stable@sourceware.org
> Subject: [PATCH] nscd: Move declarations used in the library out of <nscd.h>
> 
> Installed the shared header as include/nscd.h.  Rename the remaining header
> with the nscd-internal declarations from nscd/nscd.h to nscd/nscdP.h.
> 
> This makes it clear that the library does not depend on
> include/programs/xmalloc.h.
> 
> Tested on i686-linux-gnu and x86_64-linux-gnu.  Built with
> build-many-glibcs.py.
> 
> ---
>  include/nscd.h                              | 99
> +++++++++++++++++++++++++++++
>  nscd/aicache.c                              |  2 +-
>  nscd/cache.c                                |  2 +-
>  nscd/cachedumper.c                          |  2 +-
>  nscd/connections.c                          |  2 +-
>  nscd/dbg_log.c                              |  2 +-
>  nscd/grpcache.c                             |  2 +-
>  nscd/hstcache.c                             |  2 +-
>  nscd/initgrcache.c                          |  2 +-
>  nscd/mem.c                                  |  2 +-
>  nscd/netgroupcache.c                        |  2 +-
>  nscd/nscd-client.h                          |  2 +-
>  nscd/{nscd.h => nscdP.h}                    | 83 ++----------------------
>  nscd/nscd_conf.c                            |  2 +-
>  nscd/nscd_setup_thread.c                    |  2 +-
>  nscd/pwdcache.c                             |  2 +-
>  nscd/selinux.h                              |  2 +-
>  nscd/servicescache.c                        |  2 +-
>  nss/nss_db/db-init.c                        |  2 +-
>  nss/nss_files/files-init.c                  |  2 +-
>  nss/nss_module.c                            |  2 +-
>  sysdeps/unix/sysv/linux/nscd_setup_thread.c |  2 +-
>  22 files changed, 124 insertions(+), 98 deletions(-)
> 
> diff --git a/include/nscd.h b/include/nscd.h new file mode 100644 index
> 0000000000..109e3ab800
> --- /dev/null
> +++ b/include/nscd.h
> @@ -0,0 +1,99 @@
> +/* Private interface between sncd and NSS service modules.
> +   Copyright (c) 2011-2023 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
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> the GNU
> +   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, see
> +
> + <https://www.gnu.org/licenses/
> +
> Bv3RvKRSx!8TizXXLSPkv5T-YMcMlLIUXmJnM6OEBMlb5lozd03KZ_JUJWVOAI
> dSXAD1Vx
> + msno4bLOCvcCncBMBxal$ [gnu[.]org]>.  */
> +
> +#ifndef NSCD_H
> +#define NSCD_H
> +
> +#include <stdlib.h>
> +#include <string.h>
> +#include <time.h>
> +
> +/* Handle databases.  */
> +typedef enum
> +{
> +  pwddb,
> +  grpdb,
> +  hstdb,
> +  servdb,
> +  netgrdb,
> +  lastdb
> +} dbtype;
> +
> +/* Records the file registered per database that when changed
> +   or modified requires invalidating the database.  */ struct
> +traced_file {
> +  /* Tracks the last modified time of the traced file.  */
> +  __time64_t mtime;
> +  /* Support multiple registered files per database.  */
> +  struct traced_file *next;
> +  int call_res_init;
> +  /* Requires Inotify support to do anything useful.  */
> +#define TRACED_FILE     0
> +#define TRACED_DIR      1
> +  int inotify_descr[2];
> +# ifndef PATH_MAX
> +#  define PATH_MAX 1024
> +# endif
> +  /* The parent directory is used to scan for creation/deletion.  */
> +  char dname[PATH_MAX];
> +  /* Just the name of the file with no directory component.  */
> +  char *sfname;
> +  /* The full-path name of the registered file.  */
> +  char fname[];
> +};
> +
> +/* Initialize a `struct traced_file`.  As input we need the name
> +   of the file, and if invalidation requires calling res_init.
> +   If CRINIT is 1 then res_init will be called after invalidation
> +   or if the traced file is changed in any way, otherwise it will
> +   not.  */
> +static inline void
> +init_traced_file(struct traced_file *file, const char *fname, int
> +crinit) {
> +   char *dname;
> +   file->mtime = 0;
> +   file->inotify_descr[TRACED_FILE] = -1;
> +   file->inotify_descr[TRACED_DIR] = -1;
> +   strcpy (file->fname, fname);
> +   /* Compute the parent directory name and store a copy.  The copy makes
> +      it much faster to add/remove watches while nscd is running instead
> +      of computing this over and over again in a temp buffer.  */
> +   file->dname[0] = '\0';
> +   dname = strrchr (fname, '/');
> +   if (dname != NULL)
> +     {
> +       size_t len = (size_t)(dname - fname);
> +       if (len > sizeof (file->dname))
> +         abort ();
> +       memcpy (file->dname, file->fname, len);
> +       file->dname[len] = '\0';
> +     }
> +   /* The basename is the name just after the last forward slash.  */
> +   file->sfname = &dname[1];
> +   file->call_res_init = crinit;
> +}
> +
> +#define define_traced_file(id, filename)                        \
> +static union                                                    \
> +{                                                               \
> +  struct traced_file file;                                      \
> +  char buf[sizeof (struct traced_file) + sizeof (filename)];    \
> +} id##_traced_file;
> +
> +#endif /* NSCD_H */
> diff --git a/nscd/aicache.c b/nscd/aicache.c index 96f699c216..1967402a90
> 100644
> --- a/nscd/aicache.c
> +++ b/nscd/aicache.c
> @@ -29,7 +29,7 @@
>  #include <scratch_buffer.h>
> 
>  #include "dbg_log.h"
> -#include "nscd.h"
> +#include "nscdP.h"
> 
> 
>  static const ai_response_header notfound = diff --git a/nscd/cache.c
> b/nscd/cache.c index b4b54d82bb..7071855774 100644
> --- a/nscd/cache.c
> +++ b/nscd/cache.c
> @@ -30,7 +30,7 @@
>  #include <sys/uio.h>
>  #include <nss.h>
> 
> -#include "nscd.h"
> +#include "nscdP.h"
>  #include "dbg_log.h"
> 
> 
> diff --git a/nscd/cachedumper.c b/nscd/cachedumper.c index
> a197c081ef..68f9af49f7 100644
> --- a/nscd/cachedumper.c
> +++ b/nscd/cachedumper.c
> @@ -28,7 +28,7 @@
>  #include <getopt.h>
>  #include <sys/param.h>
> 
> -#include "nscd.h"
> +#include "nscdP.h"
>  #include "dbg_log.h"
> 
>  static void *the_cache;
> diff --git a/nscd/connections.c b/nscd/connections.c index
> a405a44a9b..92b29e5148 100644
> --- a/nscd/connections.c
> +++ b/nscd/connections.c
> @@ -49,7 +49,7 @@
>  #include <sys/stat.h>
>  #include <sys/un.h>
> 
> -#include "nscd.h"
> +#include "nscdP.h"
>  #include "dbg_log.h"
>  #include "selinux.h"
>  #include <resolv/resolv.h>
> diff --git a/nscd/dbg_log.c b/nscd/dbg_log.c index d31e79ceb3..d1e2523356
> 100644
> --- a/nscd/dbg_log.c
> +++ b/nscd/dbg_log.c
> @@ -20,7 +20,7 @@
>  #include <syslog.h>
>  #include <unistd.h>
>  #include "dbg_log.h"
> -#include "nscd.h"
> +#include "nscdP.h"
> 
>  /* if in debug mode and we have a debug file, we write the messages to it,
>     if in debug mode and no debug file, we write the messages to stderr, diff
> --git a/nscd/grpcache.c b/nscd/grpcache.c index cdd1071970..93a9c9e7a0
> 100644
> --- a/nscd/grpcache.c
> +++ b/nscd/grpcache.c
> @@ -32,7 +32,7 @@
>  #include <stackinfo.h>
>  #include <scratch_buffer.h>
> 
> -#include "nscd.h"
> +#include "nscdP.h"
>  #include "dbg_log.h"
> 
>  /* This is the standard reply in case the service is disabled.  */ diff --git
> a/nscd/hstcache.c b/nscd/hstcache.c index bd289b4628..a979cff983 100644
> --- a/nscd/hstcache.c
> +++ b/nscd/hstcache.c
> @@ -35,7 +35,7 @@
>  #include <stackinfo.h>
>  #include <scratch_buffer.h>
> 
> -#include "nscd.h"
> +#include "nscdP.h"
>  #include "dbg_log.h"
> 
> 
> diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c index
> be44951bd6..1b9bee5711 100644
> --- a/nscd/initgrcache.c
> +++ b/nscd/initgrcache.c
> @@ -27,7 +27,7 @@
>  #include <config.h>
> 
>  #include "dbg_log.h"
> -#include "nscd.h"
> +#include "nscdP.h"
> 
>  #include "../nss/nsswitch.h"
> 
> diff --git a/nscd/mem.c b/nscd/mem.c
> index 50f8162609..07ffcb542d 100644
> --- a/nscd/mem.c
> +++ b/nscd/mem.c
> @@ -30,7 +30,7 @@
>  #include <sys/param.h>
> 
>  #include "dbg_log.h"
> -#include "nscd.h"
> +#include "nscdP.h"
> 
> 
>  static int
> diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c index
> 06b7d7b6ca..9b317a38cd 100644
> --- a/nscd/netgroupcache.c
> +++ b/nscd/netgroupcache.c
> @@ -25,7 +25,7 @@
>  #include <sys/mman.h>
> 
>  #include "../inet/netgroup.h"
> -#include "nscd.h"
> +#include "nscdP.h"
>  #include "dbg_log.h"
> 
>  #include <kernel-features.h>
> diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h index
> 5588ade982..9126fc83c2 100644
> --- a/nscd/nscd-client.h
> +++ b/nscd/nscd-client.h
> @@ -450,4 +450,4 @@ extern ssize_t writeall (int fd, const void *buf, size_t len)
> extern uint32_t __nscd_get_nl_timestamp (void)
>    attribute_hidden;
> 
> -#endif /* nscd.h */
> +#endif /* nscd-client.h */
> diff --git a/nscd/nscd.h b/nscd/nscdP.h
> similarity index 82%
> rename from nscd/nscd.h
> rename to nscd/nscdP.h
> index 04f82fc0b0..7d5f6e2011 100644
> --- a/nscd/nscd.h
> +++ b/nscd/nscdP.h
> @@ -15,32 +15,21 @@
>     License along with the GNU C Library; if not, see
> 
> <https://www.gnu.org/licenses/
> 3RvKRSx!8TizXXLSPkv5T-YMcMlLIUXmJnM6OEBMlb5lozd03KZ_JUJWVOAIdS
> XAD1Vxmsno4bLOCvcCncBMBxal$ [gnu[.]org]>.  */
> 
> -#ifndef _NSCD_H
> -#define _NSCD_H	1
> +#ifndef _NSCDP_H
> +#define _NSCDP_H	1
> 
>  #include <pthread.h>
>  #include <stdbool.h>
>  #include <time.h>
>  #include <sys/uio.h>
> 
> +#include <nscd.h>
> +
>  /* The declarations for the request and response types are in the file
>     "nscd-client.h", which should contain everything needed by client
>     functions.  */
>  #include "nscd-client.h"
> 
> -
> -/* Handle databases.  */
> -typedef enum
> -{
> -  pwddb,
> -  grpdb,
> -  hstdb,
> -  servdb,
> -  netgrdb,
> -  lastdb
> -} dbtype;
> -
> -
>  /* Default limit on the number of times a value gets reloaded without
>     being used in the meantime.  NSCD does not throw a value out as
>     soon as it times out.  It tries to reload the value from the @@ -60,68 +49,6
> @@ typedef enum
>     80% of the thread stack size.  */
>  #define MAX_STACK_USE ((8 * NSCD_THREAD_STACKSIZE) / 10)
> 
> -/* Records the file registered per database that when changed
> -   or modified requires invalidating the database.  */
> -struct traced_file
> -{
> -  /* Tracks the last modified time of the traced file.  */
> -  __time64_t mtime;
> -  /* Support multiple registered files per database.  */
> -  struct traced_file *next;
> -  int call_res_init;
> -  /* Requires Inotify support to do anything useful.  */
> -#define TRACED_FILE	0
> -#define TRACED_DIR	1
> -  int inotify_descr[2];
> -# ifndef PATH_MAX
> -#  define PATH_MAX 1024
> -# endif
> -  /* The parent directory is used to scan for creation/deletion.  */
> -  char dname[PATH_MAX];
> -  /* Just the name of the file with no directory component.  */
> -  char *sfname;
> -  /* The full-path name of the registered file.  */
> -  char fname[];
> -};
> -
> -/* Initialize a `struct traced_file`.  As input we need the name
> -   of the file, and if invalidation requires calling res_init.
> -   If CRINIT is 1 then res_init will be called after invalidation
> -   or if the traced file is changed in any way, otherwise it will
> -   not.  */
> -static inline void
> -init_traced_file(struct traced_file *file, const char *fname, int crinit) -{
> -   char *dname;
> -   file->mtime = 0;
> -   file->inotify_descr[TRACED_FILE] = -1;
> -   file->inotify_descr[TRACED_DIR] = -1;
> -   strcpy (file->fname, fname);
> -   /* Compute the parent directory name and store a copy.  The copy makes
> -      it much faster to add/remove watches while nscd is running instead
> -      of computing this over and over again in a temp buffer.  */
> -   file->dname[0] = '\0';
> -   dname = strrchr (fname, '/');
> -   if (dname != NULL)
> -     {
> -       size_t len = (size_t)(dname - fname);
> -       if (len > sizeof (file->dname))
> -	 abort ();
> -       memcpy (file->dname, file->fname, len);
> -       file->dname[len] = '\0';
> -     }
> -   /* The basename is the name just after the last forward slash.  */
> -   file->sfname = &dname[1];
> -   file->call_res_init = crinit;
> -}
> -
> -#define define_traced_file(id, filename) 			\
> -static union							\
> -{								\
> -  struct traced_file file;					\
> -  char buf[sizeof (struct traced_file) + sizeof (filename)];	\
> -} id##_traced_file;
> -
>  /* Structure describing dynamic part of one database.  */  struct
> database_dyn  { @@ -375,4 +302,4 @@ extern void nscd_print_cache (const
> char *name);
>         while (__result == EINTR);
> \
>         __result; }))
> 
> -#endif /* nscd.h */
> +#endif /* nscdP.h */
> diff --git a/nscd/nscd_conf.c b/nscd/nscd_conf.c index
> ead13e99b8..717ad8b425 100644
> --- a/nscd/nscd_conf.c
> +++ b/nscd/nscd_conf.c
> @@ -29,7 +29,7 @@
>  #include <sys/types.h>
> 
>  #include "dbg_log.h"
> -#include "nscd.h"
> +#include "nscdP.h"
> 
> 
>  /* Names of the databases.  */
> diff --git a/nscd/nscd_setup_thread.c b/nscd/nscd_setup_thread.c index
> 5d6eff7a59..d33cd1069f 100644
> --- a/nscd/nscd_setup_thread.c
> +++ b/nscd/nscd_setup_thread.c
> @@ -15,7 +15,7 @@
>     You should have received a copy of the GNU General Public License
>     along with this program; if not, see
> <https://www.gnu.org/licenses/
> 3RvKRSx!8TizXXLSPkv5T-YMcMlLIUXmJnM6OEBMlb5lozd03KZ_JUJWVOAIdS
> XAD1Vxmsno4bLOCvcCncBMBxal$ [gnu[.]org]>.  */
> 
> -#include <nscd.h>
> +#include <nscdP.h>
> 
> 
>  int
> diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c index
> e1b579de6b..e89b93fb07 100644
> --- a/nscd/pwdcache.c
> +++ b/nscd/pwdcache.c
> @@ -32,7 +32,7 @@
>  #include <stackinfo.h>
>  #include <scratch_buffer.h>
> 
> -#include "nscd.h"
> +#include "nscdP.h"
>  #include "dbg_log.h"
> 
>  /* This is the standard reply in case the service is disabled.  */ diff --git
> a/nscd/selinux.h b/nscd/selinux.h index 3f075b5533..b505654f7f 100644
> --- a/nscd/selinux.h
> +++ b/nscd/selinux.h
> @@ -19,7 +19,7 @@
>  #ifndef _SELINUX_H
>  #define _SELINUX_H 1
> 
> -#include "nscd.h"
> +#include "nscdP.h"
>  #ifdef HAVE_LIBCAP
>  # include <sys/capability.h>
>  #endif
> diff --git a/nscd/servicescache.c b/nscd/servicescache.c index
> 2202679500..68663bb1af 100644
> --- a/nscd/servicescache.c
> +++ b/nscd/servicescache.c
> @@ -25,7 +25,7 @@
>  #include <kernel-features.h>
>  #include <scratch_buffer.h>
> 
> -#include "nscd.h"
> +#include "nscdP.h"
>  #include "dbg_log.h"
> 
> 
> diff --git a/nss/nss_db/db-init.c b/nss/nss_db/db-init.c index
> bd79826cab..850e8c5fb4 100644
> --- a/nss/nss_db/db-init.c
> +++ b/nss/nss_db/db-init.c
> @@ -19,7 +19,7 @@
>  #ifdef USE_NSCD
> 
>  #include <paths.h>
> -#include <nscd/nscd.h>
> +#include <nscd.h>
>  #include <string.h>
> 
>  #include "nss_db.h"
> diff --git a/nss/nss_files/files-init.c b/nss/nss_files/files-init.c index
> d5c2795b30..541ad65ffe 100644
> --- a/nss/nss_files/files-init.c
> +++ b/nss/nss_files/files-init.c
> @@ -19,7 +19,7 @@
>  #ifdef USE_NSCD
> 
>  #include <string.h>
> -#include <nscd/nscd.h>
> +#include <nscd.h>
>  #include <nss.h>
>  #include <nss_files.h>
> 
> diff --git a/nss/nss_module.c b/nss/nss_module.c index
> 0104f88974..934ff4a968 100644
> --- a/nss/nss_module.c
> +++ b/nss/nss_module.c
> @@ -17,7 +17,7 @@
> 
> <https://www.gnu.org/licenses/
> 3RvKRSx!8TizXXLSPkv5T-YMcMlLIUXmJnM6OEBMlb5lozd03KZ_JUJWVOAIdS
> XAD1Vxmsno4bLOCvcCncBMBxal$ [gnu[.]org]>.  */
> 
>  #include <nsswitch.h>
> -#include <nscd/nscd.h>
> +#include <nscd.h>
>  #include <nscd/nscd_proto.h>
> 
>  #include <array_length.h>
> diff --git a/sysdeps/unix/sysv/linux/nscd_setup_thread.c
> b/sysdeps/unix/sysv/linux/nscd_setup_thread.c
> index cf1a56e005..76d9fad10f 100644
> --- a/sysdeps/unix/sysv/linux/nscd_setup_thread.c
> +++ b/sysdeps/unix/sysv/linux/nscd_setup_thread.c
> @@ -17,7 +17,7 @@
> 
>  #include <string.h>
>  #include <unistd.h>
> -#include <nscd.h>
> +#include <nscdP.h>
>  #include <sysdep.h>
> 
> 
> 
> base-commit: e18c293af0ece38921ad71fbd76ff8049c3b2d67


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nscd: Move declarations used in the library out of <nscd.h>
  2023-07-13  8:06 ` Hiroaki.Fuse
@ 2023-07-13  8:27   ` Florian Weimer
  0 siblings, 0 replies; 3+ messages in thread
From: Florian Weimer @ 2023-07-13  8:27 UTC (permalink / raw)
  To: Hiroaki.Fuse; +Cc: libc-alpha, libc-stable

* Hiroaki:

> Dear Florian Weimer,
>
> Thank you for your quick update.
> My understanding is that we can conclude the license of glibc as LGPLv2.1
> after applying your patch. Is it correct?

You need to perform your own license analysis.  There are some resources
that could help you, like the LICENSES file in the source tree.  I'm not
sure everyone would agree that “LGPLv2.1” is an accurate summary.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-13  8:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-03 12:43 [PATCH] nscd: Move declarations used in the library out of <nscd.h> Florian Weimer
2023-07-13  8:06 ` Hiroaki.Fuse
2023-07-13  8:27   ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).