Commit Graph

32 Commits

Author SHA1 Message Date
Jeremy Lakeman
0c5a84c305 Fallback to streaming bytes when rename() fails due to crossing filesystems 2018-05-22 16:05:27 +09:30
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
bd47a8eb60 Use libsodium for retrieving random bytes 2016-05-09 10:32:04 +09:30
Jeremy Lakeman
d0da910b19 Avoid undefined behaviour as highlighted by clang 2016-01-27 16:27:47 +10:30
Jeremy Lakeman
00a2ea2913 Ignore potential race condition between setting up instance path and first log message 2015-08-24 16:38:55 +09:30
gardners
db5daa20ee fix OSX build errors. 2014-10-01 15:52:14 +09:30
Andrew Bettison
7e1fbe8c76 Refactor to fix some OS-X compile warnings
Fixes two minor bugs that escaped notice until now
2014-08-14 17:39:44 +09:30
Jeremy Lakeman
bc87f8c7c0 Add timestamps to meshms messages and acks 2014-07-14 13:43:37 +09:30
Jeremy Lakeman
66f266a0c0 Fix OSX specific issues 2014-06-05 14:57:53 +09:30
Andrew Bettison
c9e2ed3038 time_ms_to_timeval() 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
60201d78c9 Fix Android compile failure: st_mtim, UTIME_OMIT
Use utimes(2) instead of utimensat(2), use struct timeval instead of
struct timespec

Add strbuf helper functions for struct timeval and time_ms_t
2014-05-02 15:47:51 +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
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
Andrew Bettison
4428a76379 Use ssize_t for read(2) and write(2) return value
Test for errors using == -1 not < 0, and cast to (size_t) subsequently

Fixes some -Wsign-compare warnings
2013-12-10 17:21:35 +10:30
Andrew Bettison
5226e47ef6 Uniform #ifdef __SERVAL_DNA__... for headers 2013-12-04 17:15:36 +10:30
Andrew Bettison
1c8e01af9d urandombytes() size_t instead of unsigned long long 2013-10-07 04:47:23 +10:30
Jeremy Lakeman
8fea1523b1 More consistent use of sleep_ms 2013-08-27 15:14:17 +09:30
gardners
8bd05b6f6d fix type cast warning on OSX. 2013-07-19 20:04:15 +09:30
gardners
dc49671583 take sleep() out of urandomdev(), since it just causes problems, and
read() should block if there aren't bytes available yet.
2013-05-07 14:42:47 +09:30
gardners
243a26707e reset urandomfd if it delivers an EBADF (seeing this on Mesh Extenders) 2013-05-07 13:52:19 +09:30
Andrew Bettison
65f6e88e67 Add emkdirs() and emkdirsn() 2013-04-04 17:37:49 +10:30
Andrew Bettison
5430b70640 Fix Android build with latest bcopy/bzero changes 2013-02-26 11:34:41 +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