Commit Graph

2567 Commits

Author SHA1 Message Date
Andrew Bettison
f3f39faf84 Improve test defs: setup_jq()
For test fixtures that need the jq(1) JSON filter utility
2013-10-14 16:50:02 +10:30
Andrew Bettison
70af3289f6 Refactor setup for 'rhizomeops' test script 2013-10-14 16:49:06 +10:30
Andrew Bettison
eb46cc99b3 Improve test defs: setup_curl()
Replace setup_curl_7() function in separate test scripts with a single,
general setup_curl() function in testdefs.sh which takes the minimum
version number as its argument.
2013-10-14 16:48:20 +10:30
Andrew Bettison
ef2cc1404c Improve test framework: tfw_cmp_version()
Also add unit tests for test framework itself
2013-10-14 16:45:56 +10:30
Andrew Bettison
0437e4adbb Add writev_all() function
Use it in rhizome_write_manifest_file() instead of two separate write(2)
system calls or buffered stdio.
2013-10-12 03:54:18 +10:30
Andrew Bettison
97cbebc91e Issue #11: improve types in file i/o functions
Use open(2)/read(2)/write(2) instead of fopen(3)/fread(3)/fwrite(3) in
several places to avoid unnecessary buffering

Fix a bug in Rhizome HTTP add's handling of unconfigured manifest
template file

Improve some debug and error logging for file i/o
2013-10-11 16:24:51 +10:30
Andrew Bettison
49729cc768 Remove default service=file for new manifests 2013-10-11 15:39:10 +10:30
Andrew Bettison
974c7a56a0 Issue #11: Use rhizome_filehash_t everywhere 2013-10-11 15:35:27 +10:30
Andrew Bettison
c97bd4a69a Rewrite two major SQL queries using new bind syntax
Extend bind varargs syntax to handle optionally-NULL parameters.
2013-10-10 17:17:03 +10:30
Andrew Bettison
147eec4315 Fix compiler warning on Linux ix86 2013-10-10 17:17:03 +10:30
Jeremy Lakeman
0c1c767af0 Wait until sid from local keyring is unreachable before claiming ownership 2013-10-10 15:59:44 +10:30
Jeremy Lakeman
ef7351bddc Unload identities from a running daemon 2013-10-10 14:27:00 +10:30
Andrew Bettison
221fc4a4fc mdp_port_t 2013-10-09 19:22:51 +10:30
Andrew Bettison
a95ef79139 Use sid_t everywhere
Remove stowSid() at last

Change API of tohex() and strbuf_tohex(), to pass string length instead of
binary byte count.  This allows odd numbers of hex digits to be produced.

Remove alloca_tohex_sid(); replace with alloca_tohex_sid_t()

New alloca_tohex_sid_t_trunc() macro
2013-10-09 18:54:21 +10:30
Jeremy Lakeman
ae7e120ed5 Pass keyring entry pin to running daemon and unlock identities 2013-10-09 15:34:41 +10:30
Jeremy Lakeman
60e3f5a3fc Fix printf formats for 64bit compilation 2013-10-09 10:31:52 +10:30
Andrew Bettison
c9f9025581 Fix intermittent 'routing' test failures
Caused by tests running so slowly that nodes become unreachable due to
timeout before the assertion of reachability is made.  The timeout was
hard coded at five times the tick interval (2.5 seconds).

Introduced new config options: mdp.iftype.*.reachable_timeout_ms and
interface.*.mdp.reachable_timeout_ms to allow the timeout to be
configured.  Configure the timeout to 60 seconds in 'routing' tests.

Changed the config schema to move options interfaces.*.mdp_tick_ms and
interfaces.*.packet_interval into interfaces.*.mdp.tick_ms and
interfaces.*.mdp.packet_interval (introduced new sub-struct 'mdp').
2013-10-08 16:36:07 +10:30
Andrew Bettison
2119433bb0 Issue #11: fix printf "%zd" ssize_t warnings on Android
Also use ssize_t instead of 'int' in a few suitable places
2013-10-08 15:39:29 +10:30
Andrew Bettison
9ba08e465f Issue #11: use socklen_t instead of int where appropriate
Also check for valid recvaddrlen before processing a received MDP packet.
2013-10-08 14:11:00 +10:30
Andrew Bettison
1c96164b62 Issue #11: uint16_t instead of unsigned short for URI port number 2013-10-08 09:56:54 +10:30
Andrew Bettison
7a8d750a0e Issue #11: uint16_t instead of short for TCP port number 2013-10-07 23:37:37 +10:30
Andrew Bettison
ffafae86b1 Issue #11: replace long long with int64_t 2013-10-07 05:54:46 +10:30
Andrew Bettison
1c8e01af9d urandombytes() size_t instead of unsigned long long 2013-10-07 04:47:23 +10:30
Andrew Bettison
5d7ea6e6f5 Improve logic and logging in server_pid() 2013-10-07 04:47:23 +10:30
Andrew Bettison
55edc74482 Fix intermittent 'rhizomeops' test failure 2013-10-07 04:47:14 +10:30
Andrew Bettison
8970c4ece7 Improved debug to help diagnose MDP failures on Android 2013-10-07 04:47:13 +10:30
Andrew Bettison
6fadb73f1f Improve version_string.sh: detect changes in submodules 2013-10-07 04:47:13 +10:30
Andrew Bettison
3758b038ab Merge branch 'sqlbind' into 'development'
Issue #69: Fixed SQL injection vulnerabilities (for good?) by replacing
sprintf(3)-style SQL statement composition with a varargs parameter
binding syntax.

Introduced rhizome_bid_t type and used it everywhere instead of unsigned
char [RHIZOME_MANIFEST_ID_BYTES].  Bundle IDs are now stored and passed
around internally almost entirely in binary form.
2013-10-04 11:59:03 +09:30
Andrew Bettison
7b427d48ee A few more uses of rhizome_bid_t
Now the TEXT_TOUPPER SQL bind action is only used for filehash hex
strings; all Bundle ID parameters are bound using RHIZOME_BID_T.
2013-10-04 04:50:37 +09:30
Andrew Bettison
e3f64516d5 Add config option 'debug.rhizome_bind' 2013-10-04 03:46:52 +09:30
Andrew Bettison
f5e7db089c Fix bugs revealed by test failures
Introduced by the recent change to rhizome_bid_t everywhere
2013-10-04 03:12:52 +09:30
Andrew Bettison
c3a4ab1f25 Fix two Rhizome Direct test cases 2013-10-04 03:11:54 +09:30
Jeremy Lakeman
0861dfdd94 Fix rhizome sync with larger numbers of existing bundles 2013-10-03 18:24:39 +02:00
Andrew Bettison
ab31420faf rhizome_bid_t
Consistent type for internal binary representation of Rhizome Bundle ID
(aka Manifest ID)
2013-10-03 23:16:45 +09:30
Andrew Bettison
d18e48868d Issue #69: transient text SQL binding 2013-10-03 23:16:02 +09:30
Andrew Bettison
41e18e587d Issue #69: replace sqlite3_bind_xxx() calls
Use the new sqlite_bind() and sqlite_prepare_bind() calls instead.

Add cmp_sid_t() function, use it instead of memcmp().

Use alloca_tohex_sid_t() in preference to alloca_tohex_sid() when the
argument is a sid_t.
2013-10-03 16:44:06 +09:30
Andrew Bettison
7e3a552011 Issue #69: refactor all Rhizome SQL queries to use binding
Remove all uses of sprintf(3) and its ilk to form SQL query commands.
Use the new sqlite_bind() and sqlite_prepare_bind() functions instead.
2013-10-03 15:15:30 +09:30
Andrew Bettison
41c862ea30 Fix 'rhizomeops' test case
Was broken by 919455608f
2013-10-03 15:13:28 +09:30
Andrew Bettison
8f7d600216 Issue #69: continue work on multi-bind varargs
Revise sqlite_prepare() macro et al and underlying functions to use bind
varargs instead of sprintf(3)-style varargs.

Convert all SQL function calls in rhizome_database.c
2013-10-03 01:16:10 +09:30
Andrew Bettison
772e1bf9d6 Issue #69: start writing SQLite multi-bind function 2013-10-02 18:19:20 +09:30
Andrew Bettison
06d7620314 Add "rhizome add file" --force-new option
Overrides the default behaviour of de-duplicating added manifests

New 'rhizomeops' test case: AddForceDuplicate
2013-09-30 16:48:18 +09:30
Andrew Bettison
2868cf0adf Improve Rhizome test functions
Options to allow manifest name to be given explicitly to override the
conventional "<filename>.manifest"
2013-09-30 16:39:58 +09:30
Andrew Bettison
919455608f Rename 'rhizomeops' test case
AddDuplicate -> AddDeDuplicate
2013-09-30 16:34:17 +09:30
Andrew Bettison
162108dd18 Fix duplicate payload logic
rhizome_finish_write() was treating a duplicate file hash as an error,
instead of dealing with it sensibly
2013-09-30 16:32:08 +09:30
Andrew Bettison
01216f06c2 Refactor rhizome_cleanup()
Compute time horizons once only, not once per query

Factor query that deletes orphan FILEBLOBS rows into its own function
2013-09-30 16:20:50 +09:30
Andrew Bettison
99a0d36812 Improve Rhizome debugging
Log the integer result of an int64 query
2013-09-30 16:16:44 +09:30
Andrew Bettison
c91ea7f8ac Make some Rhizome db functions static 2013-09-30 16:15:59 +09:30
Andrew Bettison
a04fc263f9 Improve comments on Rhizome db functions 2013-09-30 16:15:01 +09:30
Andrew Bettison
394870502d Fix "rhizome hash file" command for nil files
Now returns an empty result for zero-length file or zero-length file name

Test framework only invokes on non-zero-length files
2013-09-30 16:11:35 +09:30
Andrew Bettison
ae5ae2d394 Cosmetic changes to whitespace
Make it easier to edit in Vim
2013-09-30 16:06:23 +09:30