Android - Sync arbitrary files with a server
You may have found something you are happy with now but I have compiled a binary of unison that works on android - it is possible using the hand-waving instructions you are talking about - I used them to cross-compile the linux source within ubuntu 12.10 using the android NDK and with a few alterations to the code it is now working. Follow the instructions at https://sites.google.com/site/keigoattic/ocaml-on-android and then you will need to do a few things. There is a file called pty.c in the unison source - find the following section:
// openpty
#if defined(__linux)
#include <pty.h>
/*#define HAS_OPENPTY 1*/
#endif
and comment out define HAS_OPENPTY 1
as shown. You also need to open ubase/util.ml and edit:
let homeDir () =
System.fspathFromString "/Your path here"
Comment out from here:
(if (osType = `Unix) || isCygwin then
safeGetenv "HOME"
else if osType = `Win32 then
(*We don't want the behavior of Unison to depends on whether it is run
from a Cygwin shell (where HOME is set) or in any other way (where
HOME is usually not set)
try System.getenv "HOME" (* Windows 9x with Cygwin HOME set *)
with Not_found ->
*)
try System.getenv "USERPROFILE" (* Windows NT/2K standard *)
with Not_found ->
try System.getenv "UNISON" (* Use UNISON dir if it is set *)
with Not_found ->
"c:/" (* Default *)
else
assert false (* osType can't be anything else *))
...To here!
Then you'll also have to edit Makefile.Ocaml
CWD=$(shell pwd)
EXEC_EXT=
WINOBJS=
SYSTEM=generic
# openpty is in the libutil library
ifneq ($(OSARCH),solaris)
ifneq ($(OSARCH),osx)
# CLIBS+=-cclib -lutil
endif
endif
buildexecutable::
@echo Building for Unix
endif
endif
And comment out # CLIBS+=-cclib -lutil
as shown.
And as far as I can remember that all worked. The other step once compiled is to mount your android system partition as writable and copy unison to the /system folder where all the rest of the shell commands are.
Hope that is helpful to someone...I lost a lot of sleep getting it compiled.
You might want to consider another option here, if you want to use this for KeePass password database. This won't work for other sensitive material, but since you asked specifically for KeePass, here's what I do:
- Protect the database with the password (I assume you have, already), and a key. This will give you a two-factor authentication ("something you know" -- your password, and "something you have" -- your key). The password database can only be unlocked when both pieces are in place.
- Copy the key to the local storage of all your devices, and give it some inconspicuous name. Preferably put it in a crowded directory where it would seem like some configuration file or some random noise file created by a program.
Upload your database to a third-party storage service (I use Dropbox, but other options would work just as well). It goes without saying that the service should have an Android client if you want to use it on your device.
DO NOT upload your key there -- use another method to copy it to the devices you need. Dropbox in particular keeps a copy of the files you upload and then delete at least for a week for backup purposes (quite convenient, I must admit), but if your key is on the server already, it's not more secure than a normal password-protected database.
- Configure your KeePass clients not to remember the location of the key (remembering the location of the database is fine).
In this way, you can upload your database to a random website, and even if your password gets compromised for some reason (i.e. keyboard loggers), you can only use the database from devices that have the key AND now which file is actually the key.
For convenience, you might want to have key-only authentication on a mobile device (secure passwords are tedious to type on a mobile device, and you obviously don't want to use anything short and easy here). But I would recommend against this, as in this case the security is even lower than a password-protected database -- instead of a password you have in your head, you use a "password" (the key file) that is on your device.
KeePass doesn't give any hints whether it requires key, password or both -- which works to your advantage.
I do exactly what you ask with FolderSync. It's a very nice piece of software, with plenty of options and features. I use it as a personal dropbox alternative using SFTP over SSH with keyfile for authentication. You can even set it up to automatically detect changes on the local replicas and trigger an immediate upload. On my phone i use it to upload pics on my server as soon as i take them, and it works just perfect.