arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1505492-nscd_stat.patch

147e83
commit 1e9522c61c7a544d59db32cb7fbbd42e6793d848
147e83
Author: Florian Weimer <fweimer@redhat.com>
147e83
Date:   Thu Oct 5 18:14:27 2017 +0200
147e83
147e83
    nscd: Eliminate compilation time dependency in the build output
147e83
    
147e83
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
147e83
147e83
diff --git a/nscd/nscd_stat.c b/nscd/nscd_stat.c
147e83
index d7d351c663fa6fe6..27b914aa712e7b8d 100644
147e83
--- a/nscd/nscd_stat.c
147e83
+++ b/nscd/nscd_stat.c
147e83
@@ -35,9 +35,23 @@
147e83
 # include <selinux/avc.h>
147e83
 #endif /* HAVE_SELINUX */
147e83
 
147e83
+/* We use this to make sure the receiver is the same.  The lower 16
147e83
+   bits are reserved for flags indicating compilation variants.  This
147e83
+   version needs to be updated if the definition of struct statdata
147e83
+   changes.  */
147e83
+#define STATDATA_VERSION  0x01020000U
147e83
 
147e83
-/* We use this to make sure the receiver is the same.  */
147e83
-static const char compilation[21] = __DATE__ " " __TIME__;
147e83
+#ifdef HAVE_SELINUX
147e83
+# define STATDATA_VERSION_SELINUX_FLAG 0x0001U
147e83
+#else
147e83
+# define STATDATA_VERSION_SELINUX_FLAG 0x0000U
147e83
+#endif
147e83
+
147e83
+/* All flags affecting the struct statdata layout.  */
147e83
+#define STATDATA_VERSION_FLAGS STATDATA_VERSION_SELINUX_FLAG
147e83
+
147e83
+/* The full version number for struct statdata.  */
147e83
+#define STATDATA_VERSION_FULL (STATDATA_VERSION | STATDATA_VERSION_FLAGS)
147e83
 
147e83
 /* Statistic data for one database.  */
147e83
 struct dbstat
147e83
@@ -68,10 +82,11 @@ struct dbstat
147e83
   uintmax_t addfailed;
147e83
 };
147e83
 
147e83
-/* Record for transmitting statistics.  */
147e83
+/* Record for transmitting statistics.  If this definition changes,
147e83
+   update STATDATA_VERSION above.  */
147e83
 struct statdata
147e83
 {
147e83
-  char version[sizeof (compilation)];
147e83
+  unsigned int version;		/* Must be STATDATA_VERSION_FULL.  */
147e83
   int debug_level;
147e83
   time_t runtime;
147e83
   unsigned long int client_queued;
147e83
@@ -96,7 +111,7 @@ send_stats (int fd, struct database_dyn dbs[lastdb])
147e83
 
147e83
   memset (&data, 0, sizeof (data));
147e83
 
147e83
-  memcpy (data.version, compilation, sizeof (compilation));
147e83
+  data.version = STATDATA_VERSION_FULL;
147e83
   data.debug_level = debug_level;
147e83
   data.runtime = time (NULL) - start_time;
147e83
   data.client_queued = client_queued;
147e83
@@ -196,7 +211,7 @@ receive_print_stats (void)
147e83
 
147e83
   /* Read as much data as we expect.  */
147e83
   if (TEMP_FAILURE_RETRY (read (fd, &data, sizeof (data))) != sizeof (data)
147e83
-      || (memcmp (data.version, compilation, sizeof (compilation)) != 0
147e83
+      || (data.version != STATDATA_VERSION_FULL
147e83
 	  /* Yes, this is an assignment!  */
147e83
 	  && (errno = EINVAL)))
147e83
     {