]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Fix #7, use --dirs by default and update 'strict' mode behavior.
authorpcarana <pc.moreno2099@gmail.com>
Wed, 12 Jun 2019 22:23:31 +0000 (17:23 -0500)
committerpcarana <pc.moreno2099@gmail.com>
Wed, 12 Jun 2019 22:23:31 +0000 (17:23 -0500)
If the mode is 'strict', download rsync URI if it hasn't been explicitly visited before.

docs/doc/usage.md
man/fort.8
src/config.c
src/rsync/rsync.c

index ddf05ee006915c88f8245e2333fbe115a990ef78..02d9164c6870d136698e06df2cfda25ae15b3aa6 100644 (file)
@@ -397,6 +397,7 @@ The configuration options are mostly the same as the ones from the `argv` interf
                ],
                "<a href="#rsyncarguments-flat">arguments-flat</a>": [
                        "--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.
 
index 42f8748eae0501029a81fd09334bd5edd50ce152..2cd36475377160a50b062b366b4253497a5e7503 100644 (file)
@@ -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
index 8b64b099707c07eeae377a14fc36ecaca9f24113..fe253e116e1cff7b5f8897c82b4df19ad91b3b30 100644 (file)
@@ -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;
 
index fc1afe6bafa822eb8b67b827273fdbe345fb2943..8fa38a0c3b52daca7f66343889d7b408f38d10cb 100644 (file)
@@ -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;