From 0fb533dd0befea1db90222f98c6f464a52a8ede4 Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Fri, 14 Nov 2014 16:57:53 -0500 Subject: [PATCH] fix byte ordering in check_sysid Several uuid fields as well as the ip addreses in the sysid file are in network byte order. Fix the check_sysid utility to decode these fields properly. In addition, print the server uuid in the common string format used to display uuids, instead of by individual uuid fields. Reviewed-on: http://gerrit.openafs.org/11603 Tested-by: BuildBot Reviewed-by: Daria Brashear (cherry picked from commit 52b8073a6c1ef11f1a47fb26d77efd87425be556) Note: Although this fix is marked as a "cherry-pick", this patch was rewritten for the 1.6 branch since the opr uuid handling functions are not available in the 1.6 branch. Change-Id: I52e74fc28b30f06a8180ff65a8006c9281162fe9 Reviewed-on: http://gerrit.openafs.org/12090 Tested-by: BuildBot Reviewed-by: Mark Vitale Reviewed-by: Stephan Wiesand --- src/viced/check_sysid.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/viced/check_sysid.c b/src/viced/check_sysid.c index 7c89a6218..c76ecfbd5 100644 --- a/src/viced/check_sysid.c +++ b/src/viced/check_sysid.c @@ -24,8 +24,8 @@ #define SYSIDVERSION 1 struct versionStamp { /* Stolen from */ - int magic; - int version; + int magic; /* stored in host byte order */ + int version; /* stored in host byte order */ }; int @@ -69,6 +69,19 @@ main(int argc, char **argv) errno); exit(3); } + + /* These uuid fields are in network byte order */ + uuid.time_low = ntohl(uuid.time_low); + uuid.time_mid = ntohs(uuid.time_mid); + uuid.time_hi_and_version = ntohs(uuid.time_hi_and_version); + + printf("UUID = %08x-%04x-%04x-%02x-%02x-%02x%02x%02x%02x%02x%02x\n", + uuid.time_low, uuid.time_mid, uuid.time_hi_and_version, + (unsigned char)uuid.clock_seq_hi_and_reserved, + (unsigned char)uuid.clock_seq_low, (unsigned char)uuid.node[0], + (unsigned char)uuid.node[1], (unsigned char)uuid.node[2], + (unsigned char)uuid.node[3], (unsigned char)uuid.node[4], + (unsigned char)uuid.node[5]); printf("UUID.time(hi.mid.low)= 0x%03x.%04x.%08x\n", uuid.time_hi_and_version & 0x0fff, uuid.time_mid & 0xffff, uuid.time_low); @@ -101,6 +114,7 @@ main(int argc, char **argv) i + 1, size, errno); exit(5); } + addr = ntohl(addr); printf("Address = %d.%d.%d.%d (0x%x)\n", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, (addr) & 0xff, addr); -- 2.39.5