Commit Graph

31 Commits

Author SHA1 Message Date
Andrew Bettison
11e7874fff Improve get_self_executable_path() on Mac OS 2018-04-30 21:18:15 +09:30
Andrew Bettison
faa0f392c5 Improve Rhizome DB path configuration
Change the default 'rhizome.datastore_path' to "rhizome", ie, a sub-
directory of the instance directory.

Add a new erename() operation to "os.h".

Clean up the code around the fix 39f582cca (two commits ago) for a bug
introduced in 2014: the 'rhizome.db' file was always being created in
the instance directory, regardless of the setting of the
'rhizome.datastore_path' config option.

Whenever the Rhizome database is opened (by the server or by a CLI
invocation), if the database file does not exist but there is a
'rhizome.db' file in the legacy location, then move that file (and any
accompanying "blob" and "hash" sub-directories) to the configured
location.

Update copyright notices.
2018-04-17 12:01:02 +09:30
Andrew Bettison
92fa6c196a Rewrite logging system
Rename the logging primitive functions and utility functions, prefixing
all with 'serval_log', eg: logMessage() -> serval_logf() etc.

Add an XPRINTF xhexdump() function and use it to implement the
serval_log_hexdump() utility, renamed from dump().  Add macros
WHY_dump(), WARN_dump(), HINT_dump() and DEBUG_dump(), and use them
everywhere.

Remove the 'log.console.dump_config' and 'log.file.dump_config'
configuration options; configuration is now dumped in every log prolog.

The logging system now constructs the log prolog by invoking the new
'log_prolog' trigger, so that it no longer depends on the version string
and configuration system.  Any system that wants to present a message in
the log prolog can define its own trigger, which calls standard log
primitives to print the message.

Split the logging system into a front-end (log.c) that provides the
logging primitives and is independent of the configuration system, and a
set of back-end "outputters" (log_output_console.c, log_output_file.c,
log_output_android.c) that may depend on the configuration system and
are decoupled from the front-end using the 'logoutput' link section.

These log outputters are explicitly linked into executables by the
Makefile rules, but could also be linked in using USE_FEATURE().  The
USE_FEATURE() calls have _not_ been added to servald_features.c, so that
different daemon executables can be built with the same feature set but
different log outputs.
2018-03-06 15:16:56 +10:30
Jeremy Lakeman
1e70bcaac6 Clean up some more warnings 2016-11-21 10:34:12 +10:30
Andrew Bettison
1efe6686fc Use config.h instead of -DHAVE_FOO=1
swiftc(1) requires every -D option to be prefixed with -Xcc, which
is not easy to achieve using autoconf.

Now instead of setting configuration macros like HAVE_LSEEK64 on the
command line using -D, they are defined in config.h, which is generated
by ./configure, ignored by Git, and included by all headers and source
files that use any configuration macro.

The dependency on Makefile has been replaced with a dependency on
Makefile.in and config.h, which helps avoid some redundant full
recompiles after running ./configure, because the configure script
does not overwrit config.h if its content does not change.
2016-10-19 16:27:20 +10:30
Jeremy Lakeman
bd47a8eb60 Use libsodium for retrieving random bytes 2016-05-09 10:32:04 +09:30
Jeremy Lakeman
bc87f8c7c0 Add timestamps to meshms messages and acks 2014-07-14 13:43:37 +09:30
Andrew Bettison
21f51965c1 Overhaul Makefile and header files
Make .o files in separate subdirectories for servald and library
Factor struct __sourceloc and __WHENCE__ from "log.h" into "whence.h"
Factor sid_t etc from "serval.h" into "serval_types.h"
Factor rhizome_bid_t etc from "rhizome.h" into "rhizome_types.h"
Do not include "serval.h" in library sources
Add log_stderr.c and logMessage.c for stand-alone executables
2014-05-26 15:36:26 +09:30
Andrew Bettison
c9e2ed3038 time_ms_to_timeval() 2014-05-13 08:55:57 +09:30
Andrew Bettison
936db7bca3 Rename TIME_NEVER... to TIME_MS_NEVER... 2014-05-13 08:55:57 +09:30
Andrew Bettison
18c89b4b98 Fix bug in read_symlink(), improve logging 2014-05-05 18:12:25 +09:30
Andrew Bettison
f606daebc6 Move get_self_executable_path() into "os.h"/os.c 2014-05-05 18:12:01 +09:30
Andrew Bettison
684735b11c Fix config file timestamp bug
Ensure that timestamp always advances by at least one second every time
the config file is modified, add test case

Refactor test defs: detecting started HTTPD is not specific to Rhizome

Refactor struct file_meta and associated functions into "io.h" and io.c

Add various strbuf helper functions for formatting struct timespec
and struct file_meta to assist debug logging
2014-04-29 15:04:20 +09:30
Andrew Bettison
c222727a46 Add malloc_read_whole_file()
Use to implement read_whole_file()
2014-04-29 12:36:58 +09:30
Andrew Bettison
53c1b1c04c Filesystem Heirarchy Standard (FHS) paths
If no instance directory specified, then use paths like
/etc/serval/serval.conf
/var/cache/serval
/var/log/serval
/var/run/serval
etc. for files, instead of all in a single directory.

Log all directory creation as INFO messages.

Interpretation of log.file.directory_path has changed slightly.

Updated servald configuration tech doc.
2014-03-26 15:35:43 +10:30
Andrew Bettison
0bef066949 Store Rhizome external blob files in "blob" subdirectory
This will make issue #50 a bit easier to tackle
2014-03-07 16:55:38 +10:30
gardners
660180fec8 fix compile errors introduced in off_t/off64_t fix. 2014-02-18 14:04:08 +10:30
Andrew Bettison
c4944e4334 Deal with missing lseek64(2) sys call
On OSX, off_t is 64 bits, so can use lseek(2) instead
2014-02-17 14:33:32 +10:30
Andrew Bettison
21328e2888 Improve read_whole_file()
Move into os.c, declare and document in os.h
2013-12-19 19:14:52 +10:30
Jeremy Lakeman
68b8f94b01 Add time constants representing +/- infinity, don't schedule an alarm that will never run 2013-12-09 11:22:44 +10:30
Andrew Bettison
5226e47ef6 Uniform #ifdef __SERVAL_DNA__... for headers 2013-12-04 17:15:36 +10:30
Andrew Bettison
4aea05f445 Fix prototype of bcopy()
Add const to void * src argument
2013-11-06 23:56:33 +10:30
Andrew Bettison
bacba19dc1 Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.

Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key.  These maintained by the setter functions.

Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.

More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c.  More uniform use of
size_t to dimension memory buffers.  Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems.  Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.

Replace some 'int' loop variables with 'unsigned' where appropriate.

Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.

Instrument the first MeshMS test case to aid debugging.

New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.

Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-11-04 19:17:49 +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
630c7cd57d Fix bug in new bcmp() function
Was revealed by ndk-build, ie, on a system with HAVE_BCMP false
2013-05-21 12:45:33 +09:30
Andrew Bettison
f8386d5aed Define bcmp() using memcmp() on systems lacking native bcmp()
See 1e61e7a02f for equivalent changes
for bzero() and bcopy()
2013-05-17 13:59:42 +09:30
Andrew Bettison
65f6e88e67 Add emkdirs() and emkdirsn() 2013-04-04 17:37:49 +10:30
Andrew Bettison
5518859b66 Refactor: move read_symlink() from log.c to os.c 2013-02-25 15:25:53 +10:30
Andrew Bettison
1e61e7a02f Fix bcopy()/bzero() #define hack
Replace #define bcopy(...) memset(...) with inline functions only if
bcopy() is unavailable, as checked by configure script

Ditto bzero()
2013-02-25 15:23:03 +10:30
Andrew Bettison
d3c2205d44 Add os.c and "os.h", replacing mkdirs.c
The new header "os.h" defines a supplemental API around existing basic
operating system services (system calls and standard library functions).

Moved some function prototypes from serval.h and net.h into os.h.

This allows non-servald executables to take advantage of this API without
having to include serval.h and bringing in all the other servald link-time
baggage.
2012-12-04 10:12:35 +10:30