From: pcarana Date: Wed, 12 Jun 2019 22:23:31 +0000 (-0500) Subject: Fix #7, use --dirs by default and update 'strict' mode behavior. X-Git-Tag: v0.0.2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=865c168609ddb43ce9516ee63fcc5b468c63093a;p=thirdparty%2FFORT-validator.git Fix #7, use --dirs by default and update 'strict' mode behavior. If the mode is 'strict', download rsync URI if it hasn't been explicitly visited before. --- diff --git a/docs/doc/usage.md b/docs/doc/usage.md index ddf05ee0..02d9164c 100644 --- a/docs/doc/usage.md +++ b/docs/doc/usage.md @@ -397,6 +397,7 @@ The configuration options are mostly the same as the ones from the `argv` interf ], "arguments-flat": [ "--times", + "--dirs", "$REMOTE", "$LOCAL" ] @@ -474,7 +475,7 @@ Fort will replace `"$REMOTE"` with the remote URL it needs to download, and `"$L - **Type:** String array - **Availability:** JSON only -- **Default:** `[ "--times", "--contimeout=20", "$REMOTE", "$LOCAL" ]` +- **Default:** `[ "--times", "--contimeout=20", "--dirs", "$REMOTE", "$LOCAL" ]` Arguments needed by [`rsync.program`](#rsyncprogram) to perform a single-file rsync. diff --git a/man/fort.8 b/man/fort.8 index 42f8748e..2cd36475 100644 --- a/man/fort.8 +++ b/man/fort.8 @@ -94,7 +94,7 @@ Arguments needed by .B rsync.program to perform a single-file rsync. The arguments are specified as a JSON string array; its default value is: -[ "--times", "--contimeout=20", "$REMOTE", "$LOCAL" ] +[ "--times", "--contimeout=20", "--dirs", "$REMOTE", "$LOCAL" ] .P FORT will replace "$REMOTE" with the remote URL it needs to download, and "$LOCAL" with the target local directory where the file is supposed to be @@ -478,6 +478,7 @@ to a specific value: "arguments-flat": [ "--times", "--contimeout=20", + "--dirs", "$REMOTE", "$LOCAL" ] @@ -552,6 +553,8 @@ assertions: .RS 4 .IR getaddrinfo(3) ", " services(5) ", " listen(2) ", " rsync(1) .RE +.P + .B FORTs official documentation .RS 4 More documentation about FORT validator can be consulted at github repository diff --git a/src/config.c b/src/config.c index 8b64b099..fe253e11 100644 --- a/src/config.c +++ b/src/config.c @@ -437,7 +437,7 @@ print_config(void) static int set_default_values(void) { - static char const *default_rsync_args[] = { + static char const *recursive_rsync_args[] = { "--recursive", "--delete", "--times", @@ -446,6 +446,14 @@ set_default_values(void) "$LOCAL", }; + static char const *flat_rsync_args[] = { + "--times", + "--contimeout=20", + "--dirs", + "$REMOTE", + "$LOCAL", + }; + int error; /* @@ -482,12 +490,12 @@ set_default_values(void) } error = string_array_init(&rpki_config.rsync.args.recursive, - default_rsync_args, ARRAY_LEN(default_rsync_args)); + recursive_rsync_args, ARRAY_LEN(recursive_rsync_args)); if (error) goto revert_rsync_program; /* Simply remove --recursive and --delete. */ error = string_array_init(&rpki_config.rsync.args.flat, - default_rsync_args + 2, ARRAY_LEN(default_rsync_args) - 2); + flat_rsync_args, ARRAY_LEN(flat_rsync_args)); if (error) goto revert_recursive_array; diff --git a/src/rsync/rsync.c b/src/rsync/rsync.c index fc1afe6b..8fa38a0c 100644 --- a/src/rsync/rsync.c +++ b/src/rsync/rsync.c @@ -58,6 +58,10 @@ is_descendant(struct rpki_uri *ancestor, struct rpki_uri *descendant) string_tokenizer_init(&descendant_tokenizer, uri_get_global(descendant), uri_get_global_len(descendant), '/'); + if (config_get_sync_strategy() == SYNC_STRICT) + return strcmp(uri_get_global(ancestor), + uri_get_global(descendant)) == 0; + do { if (!string_tokenizer_next(&ancestor_tokenizer)) return true;