From 23e12329648645842a60c0931ee753375452e942 Mon Sep 17 00:00:00 2001 From: Robert Escriva Date: Mon, 1 Aug 2016 11:10:25 -0400 Subject: [PATCH] Compatibility with Ubuntu 14.04 Added some configure checks, lifted some declarations, fixed Cython, and updated the README to reflect the newest instructions. --- README | 5 ++++- bindings/python/macaroons.pyx | 4 ++-- configure.ac | 12 ++++++++++-- macaroon-test-serialization.c | 6 ++++-- test/varint.c | 3 ++- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/README b/README index cddfbef..514500a 100644 --- a/README +++ b/README @@ -81,7 +81,10 @@ This library makes it easy to get started with using macaroons in your service. To use the library you must first install it. You'll need to somehow install libbsd[2]. It's packaged in some Linux distributions, and can be installed from source on most *NIX platforms. Once you have libbsd -installed, installing macaroons is straight forward: +installed, installing macaroons is straight forward. If you're installing +from git you'll need to install autoconf, automake, libtool, and +autoconf-archive and execute the first command. if you're installing from a +release tarball, you should skip the first command and start with configure. $ autoreconf -i # only when installing from Git $ ./configure --enable-python-bindings diff --git a/bindings/python/macaroons.pyx b/bindings/python/macaroons.pyx index 75b26b7..6c09c4b 100644 --- a/bindings/python/macaroons.pyx +++ b/bindings/python/macaroons.pyx @@ -78,10 +78,10 @@ cdef extern from "macaroons.h": MACAROON_V2J cdef macaroon_format MACAROON_LATEST cdef macaroon_format MACAROON_LATEST_JSON - size_t macaroon_serialize_size_hint(const macaroon* M, macaroon_format f); + size_t macaroon_serialize_size_hint(const macaroon* M, macaroon_format f) size_t macaroon_serialize(const macaroon* M, macaroon_format f, char* buf, size_t buf_sz, - macaroon_returncode* err); + macaroon_returncode* err) macaroon* macaroon_deserialize(unsigned char* data, size_t data_sz, macaroon_returncode* err) diff --git a/configure.ac b/configure.ac index c44f2f4..8cfdffb 100644 --- a/configure.ac +++ b/configure.ac @@ -29,10 +29,18 @@ AC_CHECK_FUNC([strlcpy],[BSDLIB=],[BSDLIB=-lbsd]) AC_SUBST([BSDLIBS], [$BSDLIB]) # Checks for header files. -AC_CHECK_HEADER([libutil.h],[AC_DEFINE([HAVE_LIBUTIL_H],[1],[Define to 1 if you have the header file.])],,) +need_libbsd=yes +AC_CHECK_HEADER([libutil.h],[need_libbsd=no; AC_DEFINE([HAVE_LIBUTIL_H],[1],[Define to 1 if you have the header file.])],,) AC_CHECK_HEADER([bsd/stdlib.h],[AC_DEFINE([HAVE_BSD_STDLIB_H],[1],[Define to 1 if you have the header file.])],,) AC_CHECK_HEADER([bsd/libutil.h],[AC_DEFINE([HAVE_BSD_LIBUTIL_H],[1],[Define to 1 if you have the header file.])],,) -AC_CHECK_HEADER([util.h],[AC_DEFINE([HAVE_OSX_LIBUTIL_H],[1],[Define to 1 if you have the header file.])],,) +AC_CHECK_HEADER([util.h],[need_libbsd=no; AC_DEFINE([HAVE_OSX_LIBUTIL_H],[1],[Define to 1 if you have the header file.])],,) + +AS_IF([test "x${need_libbsd}" = xyes], + [AC_CHECK_LIB([bsd],[strlcat],,[AC_MSG_ERROR([ +------------------------------------------------- +libmacaroons relies upon the libbsd library. +Please install libbsd to continue. +-------------------------------------------------])],)],) # Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T diff --git a/macaroon-test-serialization.c b/macaroon-test-serialization.c index e3d8892..74b3e79 100644 --- a/macaroon-test-serialization.c +++ b/macaroon-test-serialization.c @@ -51,6 +51,8 @@ main(int argc, const char* argv[]) size_t line_sz = 0; struct parsed_macaroon* macaroons = NULL; size_t macaroons_sz = 0; + size_t i; + size_t j; while (1) { @@ -143,9 +145,9 @@ main(int argc, const char* argv[]) int ret = EXIT_SUCCESS; - for (size_t i = 0; i < macaroons_sz; ++i) + for (i = 0; i < macaroons_sz; ++i) { - for (size_t j = i + 1; j < macaroons_sz; ++j) + for (j = i + 1; j < macaroons_sz; ++j) { if (macaroon_cmp(macaroons[i].M, macaroons[j].M) != 0) { diff --git a/test/varint.c b/test/varint.c index fb8502b..6620538 100644 --- a/test/varint.c +++ b/test/varint.c @@ -47,11 +47,12 @@ varint_verify(uint64_t value, const char* representation) assert(sz % 2 == 0); unsigned char buf[VARINT_MAX_SIZE]; uint64_t eulav; + unsigned int i; assert(packvarint(value, buf) == buf + sz / 2); assert(unpackvarint(buf, buf + VARINT_MAX_SIZE, &eulav) == buf + sz / 2); assert(value == eulav); - for (unsigned i = 0; i < sz / 2; ++i) + for (i = 0; i < sz / 2; ++i) { char hex[3]; snprintf(hex, 3, "%02x", buf[i] & 0xff);