From: Kern Sibbald Date: Wed, 27 Apr 2005 20:52:59 +0000 (+0000) Subject: - Update Web header to include google search in the search X-Git-Tag: Release-7.0.0~8860 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=835846f2d76dc5f46f2be140e4565ceacfe060c5;p=bacula%2Fbacula - Update Web header to include google search in the search box -- thanks to input from Michel Meyers. - Fix md5sum so that it builds with the new openssl stuff. - Take some enhancements to the md5sum test program proposed by a user. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1965 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/lib/Makefile.in b/bacula/src/lib/Makefile.in index a64d0d872e..5ca5fa0bd5 100644 --- a/bacula/src/lib/Makefile.in +++ b/bacula/src/lib/Makefile.in @@ -14,6 +14,8 @@ topdir = ../.. # this dir relative to top dir thisdir = src/lib +OPENSSL_LIBS = @OPENSSL_LIBS@ +OPENSSL_INC = @OPENSSL_INC@ DEBUG=@DEBUG@ @@ -53,10 +55,10 @@ EXTRAOBJS = @OBJLIST@ # inference rules .c.o: - $(CXX) $(DEFS) $(DEBUG) -c $(WCFLAGS) $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $< + $(CXX) $(DEFS) $(DEBUG) -c $(WCFLAGS) $(CPPFLAGS) $(OPENSSL_INC) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $< .cc.o: - $(CXX) $(DEFS) $(DEBUG) -c $(WCFLAGS) $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $< + $(CXX) $(DEFS) $(DEBUG) -c $(WCFLAGS) $(CPPFLAGS) $(OPENSSL_INC) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $< #------------------------------------------------------------------------- all: Makefile libbac.a @@ -82,18 +84,18 @@ rwlock_test: rm -f rwlock.o $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) rwlock.c -md5sum: +md5sum: md5.o rm -f md5.o $(CXX) -DMD5_SUM $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) md5.c - $(CXX) $(LDFLAGS) -L. -o $@ md5.o $(LIBS) $(DLIB) -lbac -lm + $(CXX) $(LDFLAGS) -L. -o $@ md5.o $(LIBS) $(DLIB) -lbac $(OPENSSL_LIBS) -lm rm -f md5.o $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) md5.c -sha1sum: +sha1sum: sha1.o rm -f sha1.o $(CXX) -DSHA1_SUM $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) sha1.c - $(CXX) $(LDFLAGS) -L. -o $@ sha1.o $(LIBS) $(DLIB) -lbac -lm + $(CXX) $(LDFLAGS) -L. -o $@ sha1.o $(LIBS) $(DLIB) -lbac $(OPENSSL_LIBS) -lm rm -f sha1.o $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) md5.c diff --git a/bacula/src/lib/md5.c b/bacula/src/lib/md5.c index 9b788e8d7e..0f52e9908b 100644 --- a/bacula/src/lib/md5.c +++ b/bacula/src/lib/md5.c @@ -1,6 +1,6 @@ /* * This code implements the MD5 message-digest algorithm. - * The algorithm is due to Ron Rivest. This code was + * The algorithm is due to Ron Rivest. This code was * written by Colin Plumb in 1993, no copyright is claimed. * This code is in the public domain; do with it what you wish. * @@ -24,7 +24,7 @@ #include "bacula.h" #ifndef HAVE_BIGENDIAN -#define byteReverse(buf, len) /* Nothing */ +#define byteReverse(buf, len) /* Nothing */ #else /* * Note: this code is harmless on little-endian machines. @@ -33,10 +33,10 @@ void byteReverse(unsigned char *buf, unsigned longs) { uint32_t t; do { - t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - *(uint32_t *) buf = t; - buf += 4; + t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | + ((unsigned) buf[1] << 8 | buf[0]); + *(uint32_t *) buf = t; + buf += 4; } while (--longs); } #endif @@ -68,35 +68,35 @@ void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned len) t = ctx->bits[0]; if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ + ctx->bits[1]++; /* Carry from low to high */ ctx->bits[1] += len >> 29; - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ + t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ /* Handle any leading odd-sized chunks */ if (t) { - unsigned char *p = (unsigned char *) ctx->in + t; - - t = 64 - t; - if (len < t) { - memcpy(p, buf, len); - return; - } - memcpy(p, buf, t); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32_t *) ctx->in); - buf += t; - len -= t; + unsigned char *p = (unsigned char *) ctx->in + t; + + t = 64 - t; + if (len < t) { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32_t *) ctx->in); + buf += t; + len -= t; } /* Process data in 64-byte chunks */ while (len >= 64) { - memcpy(ctx->in, buf, 64); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32_t *) ctx->in); - buf += 64; - len -= 64; + memcpy(ctx->in, buf, 64); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32_t *) ctx->in); + buf += 64; + len -= 64; } /* Handle any remaining bytes of data. */ @@ -105,7 +105,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned len) } /* - * Final wrapup - pad to 64-byte boundary with the bit pattern + * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) @@ -126,16 +126,16 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) /* Pad out to 56 mod 64 */ if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32_t *) ctx->in); + /* Two lots of padding: Pad the first block to 64 bytes */ + memset(p, 0, count); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32_t *) ctx->in); - /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); + /* Now fill the next block with 56 bytes */ + memset(ctx->in, 0, 56); } else { - /* Pad block to 56 bytes */ - memset(p, 0, count - 8); + /* Pad block to 56 bytes */ + memset(p, 0, count - 8); } byteReverse(ctx->in, 14); @@ -160,7 +160,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) /* This is the central step in the MD5 algorithm. */ #define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) + ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) /* * The core of the MD5 algorithm, this alters an existing MD5 hash to @@ -251,11 +251,12 @@ void MD5Transform(uint32_t buf[4], uint32_t in[16]) } #ifdef MD5_SUM +#define OUTPUT_BASE64 1 /* * Reads a single ASCII file and prints the HEX md5 sum. */ #include -int main(int argc, char *argv[]) +int main(int argc, char *argv[]) { FILE *fd; MD5Context ctx; @@ -277,8 +278,14 @@ int main(int argc, char *argv[]) } MD5Final((unsigned char *)signature, &ctx); for (int i=0; i < 16; i++) { - printf("%02x", signature[i]& 0xFF); + printf("%02x", signature[i]& 0xFF); } +#ifdef OUTPUT_BASE64 + char MD5buf[40]; /* 24 should do */ + memset(MD5buf, 0, 40); + bin_to_base64(MD5buf, (char *)signature, 16); /* encode 16 bytes */ + printf(" %s", MD5buf); +#endif printf(" %s\n", argv[1]); } #endif