Blame SOURCES/glibc-rh1505492-nscd_stat.patch

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