summaryrefslogtreecommitdiff
path: root/nscd/nscd_stat.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-12-27 16:39:27 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-12-27 16:39:27 +0000
commit52629237a522c7c146d788ddaaf69946fd2729f9 (patch)
tree552402b085cff37bc251fc0f45ed9255b53cdd57 /nscd/nscd_stat.c
parent3896c5809b49e72fbadc57da2189ff42aa2a5d02 (diff)
parent064374be911f72dfaec8a75f06da1f9fc1827712 (diff)
Merge commit 'refs/top-bases/t/hurdsig-boot-fix' into t/hurdsig-boot-fix
Diffstat (limited to 'nscd/nscd_stat.c')
-rw-r--r--nscd/nscd_stat.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/nscd/nscd_stat.c b/nscd/nscd_stat.c
index f34c3526cb..8428322c35 100644
--- a/nscd/nscd_stat.c
+++ b/nscd/nscd_stat.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998-2016 Free Software Foundation, Inc.
+/* Copyright (c) 1998-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998.
@@ -35,9 +35,23 @@
# include <selinux/avc.h>
#endif /* HAVE_SELINUX */
+/* We use this to make sure the receiver is the same. The lower 16
+ bits are reserved for flags indicating compilation variants. This
+ version needs to be updated if the definition of struct statdata
+ changes. */
+#define STATDATA_VERSION 0x01020000U
-/* We use this to make sure the receiver is the same. */
-static const char compilation[21] = __DATE__ " " __TIME__;
+#ifdef HAVE_SELINUX
+# define STATDATA_VERSION_SELINUX_FLAG 0x0001U
+#else
+# define STATDATA_VERSION_SELINUX_FLAG 0x0000U
+#endif
+
+/* All flags affecting the struct statdata layout. */
+#define STATDATA_VERSION_FLAGS STATDATA_VERSION_SELINUX_FLAG
+
+/* The full version number for struct statdata. */
+#define STATDATA_VERSION_FULL (STATDATA_VERSION | STATDATA_VERSION_FLAGS)
/* Statistic data for one database. */
struct dbstat
@@ -68,10 +82,11 @@ struct dbstat
uintmax_t addfailed;
};
-/* Record for transmitting statistics. */
+/* Record for transmitting statistics. If this definition changes,
+ update STATDATA_VERSION above. */
struct statdata
{
- char version[sizeof (compilation)];
+ unsigned int version; /* Must be STATDATA_VERSION_FULL. */
int debug_level;
time_t runtime;
unsigned long int client_queued;
@@ -96,7 +111,7 @@ send_stats (int fd, struct database_dyn dbs[lastdb])
memset (&data, 0, sizeof (data));
- memcpy (data.version, compilation, sizeof (compilation));
+ data.version = STATDATA_VERSION_FULL;
data.debug_level = debug_level;
data.runtime = time (NULL) - start_time;
data.client_queued = client_queued;
@@ -196,7 +211,7 @@ receive_print_stats (void)
/* Read as much data as we expect. */
if (TEMP_FAILURE_RETRY (read (fd, &data, sizeof (data))) != sizeof (data)
- || (memcmp (data.version, compilation, sizeof (compilation)) != 0
+ || (data.version != STATDATA_VERSION_FULL
/* Yes, this is an assignment! */
&& (errno = EINVAL)))
{