This was tested with NDK release r8e on ARM (on a real device) and x86 (compile only). Signed-off-by: Kevin Cernekee <cernekee at gmail.com> --- android/0001-Remove-call-to-mlockall.patch | 33 +++++++++++++ android/Makefile | 69 +++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 android/0001-Remove-call-to-mlockall.patch diff --git a/android/0001-Remove-call-to-mlockall.patch b/android/0001-Remove-call-to-mlockall.patch new file mode 100644 index 0000000..c09afb6 --- /dev/null +++ b/android/0001-Remove-call-to-mlockall.patch @@ -0,0 +1,33 @@ +From aecf4b5e1bb335a41ea00c99c771dfa889ce314b Mon Sep 17 00:00:00 2001 +From: Kevin Cernekee <cernekee at gmail.com> +Date: Sun, 11 Aug 2013 13:26:39 -0700 +Subject: [PATCH] Remove call to mlockall() + +This patch against v0.2 allows for building stoken on Android, without +rerunning autotools. + +Signed-off-by: Kevin Cernekee <cernekee at gmail.com> +--- + src/common.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/src/common.c b/src/common.c +index d2d22f1..4711696 100644 +--- a/src/common.c ++++ b/src/common.c +@@ -331,12 +331,6 @@ int common_init(char *cmd) + struct securid_token *t; + int is_import = !strcmp(cmd, "import"); + +- /* +- * we don't actually scrub memory, but at least try to keep the seeds +- * from being swapped out to disk +- */ +- mlockall(MCL_CURRENT | MCL_FUTURE); +- + cfg = xzalloc(sizeof(*cfg)); + if (__stoken_read_rcfile(opt_rcfile, cfg, &warn) != ERR_NONE) + __stoken_zap_rcfile_data(cfg); +-- +1.7.9.5 + diff --git a/android/Makefile b/android/Makefile index ba013ab..bdf04db 100644 --- a/android/Makefile +++ b/android/Makefile @@ -242,6 +242,73 @@ gnutls: $(GNUTLS_DEPS) ##################################################################### # +# Build libtomcrypt +# +TOMCRYPT_VER := 1.17 +TOMCRYPT_DIR := $(TRIPLET)/libtomcrypt-$(TOMCRYPT_VER) + +crypt-$(TOMCRYPT_VER).tar.bz2: + curl http://libtom.org/files/crypt-$(TOMCRYPT_VER).tar.bz2 -o $@.tmp && mv $@.tmp $@ + +$(TOMCRYPT_DIR)/makefile: crypt-$(TOMCRYPT_VER).tar.bz2 + mkdir -p $(TRIPLET) + tar xfj $< -C $(TRIPLET) + touch $@ + +$(TOMCRYPT_DIR)/libtomcrypt.a: $(TOMCRYPT_DIR)/makefile + $(MAKE) -C $(TOMCRYPT_DIR) \ + CC="$(TRIPLET)-gcc --sysroot=$(NDK_SYSROOT)" \ + AR="$(TRIPLET)-ar" \ + RANLIB="$(TRIPLET)-ranlib" + +$(OC_SYSROOT)/lib/libtomcrypt.a: $(TOMCRYPT_DIR)/libtomcrypt.a + $(MAKE) -C $(TOMCRYPT_DIR) \ + DESTDIR=$(OC_SYSROOT) \ + LIBPATH=/lib INCPATH=/include \ + INSTALL_USER=$(shell id -u) \ + INSTALL_GROUP=$(shell id -g) \ + NODOCS=1 install + +TOMCRYPT_DEPS := $(OC_SYSROOT)/lib/libtomcrypt.a + +tomcrypt: $(TOMCRYPT_DEPS) + + +##################################################################### +# +# Build libstoken +# +STOKEN_VER := 0.2 +STOKEN_SRC := sources/stoken-$(STOKEN_VER) +STOKEN_BUILD := $(TRIPLET)/stoken + +stoken-$(STOKEN_VER).tar.gz: + curl -L http://sourceforge.net/projects/stoken/files/stoken-$(STOKEN_VER).tar.gz/download -o $@.tmp && mv $@.tmp $@ + +$(STOKEN_SRC)/configure: stoken-$(STOKEN_VER).tar.gz + mkdir -p sources + tar xfz $< -C sources + cd $(STOKEN_SRC) && patch -p1 < ../../0001-Remove-call-to-mlockall.patch + touch $@ + +$(STOKEN_BUILD)/Makefile: $(STOKEN_SRC)/configure $(TOMCRYPT_DEPS) + mkdir -p $(STOKEN_BUILD) + cd $(STOKEN_BUILD) && ../../$(STOKEN_SRC)/configure $(CONFIGURE_ARGS) \ + --without-gtk + +$(STOKEN_BUILD)/libstoken.la: $(STOKEN_BUILD)/Makefile + $(MAKE) -C $(STOKEN_BUILD) + +$(OC_SYSROOT)/lib/libstoken.la: $(STOKEN_BUILD)/libstoken.la + $(MAKEINSTALL) -C $(STOKEN_BUILD) install + +STOKEN_DEPS := $(OC_SYSROOT)/lib/libstoken.la + +stoken: $(STOKEN_DEPS) + + +##################################################################### +# # Build OpenConnect for Android # OPENCONNECT_SRC := .. @@ -250,7 +317,7 @@ OPENCONNECT_BUILD := $(TRIPLET)/openconnect $(OPENCONNECT_SRC)/configure: cd $(OPENCONNECT_SRC) && ./autogen.sh -$(OPENCONNECT_BUILD)/Makefile: $(GNUTLS_DEPS) $(LIBXML_DEPS) $(OPENCONNECT_SRC)/configure +$(OPENCONNECT_BUILD)/Makefile: $(GNUTLS_DEPS) $(LIBXML_DEPS) $(STOKEN_DEPS) $(OPENCONNECT_SRC)/configure mkdir -p $(OPENCONNECT_BUILD) cd $(OPENCONNECT_BUILD) && ../../../configure $(CONFIGURE_ARGS) \ CFLAGS="--sysroot=$(NDK_SYSROOT) -DNO_BROKEN_DTLS_CHECK" \ -- 1.7.9.5