aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2011-06-27 17:05:18 +0000
committerRob Austein <sra@hactrn.net>2011-06-27 17:05:18 +0000
commit04c317b34175df6599eb9cdd1fab07ce1ed33224 (patch)
tree1e69cde3d7af270ec965f3c91e35b685a82f725d
parent2dbd6e22cea18427dfe9da826e2e0b05f786a9c9 (diff)
Construct file:// URI to name local trust anchors
svn path=/rcynic-ng/rcynic.c; revision=3901
-rw-r--r--rcynic-ng/rcynic.c37
-rw-r--r--rcynic/rcynic.c13
2 files changed, 49 insertions, 1 deletions
diff --git a/rcynic-ng/rcynic.c b/rcynic-ng/rcynic.c
index a3a1f176..4b466823 100644
--- a/rcynic-ng/rcynic.c
+++ b/rcynic-ng/rcynic.c
@@ -1156,6 +1156,29 @@ static int rm_rf(const path_t *name)
/**
+ * Test whether a pair of URIs "conflict", that is, whether attempting
+ * to rsync both of them at the same time in parallel might cause
+ * unpredictable behavior. Might need a better name for this test.
+ *
+ * Returns non-zero iff the two URIs "conflict".
+ */
+static int conflicting_uris(const uri_t *a, const uri_t *b)
+{
+ size_t len_a, len_b;
+
+ assert(a && is_rsync(a->s) && b && is_rsync(b->s));
+
+ len_a = strlen(a->s);
+ len_b = strlen(b->s);
+
+ assert(len_a < sizeof(a->s) && len_b < sizeof(b->s));
+
+ return !strncmp(a->s, b->s, len_a < len_b ? len_a : len_b);
+}
+
+
+
+/**
* Read non-directory filenames from a directory, so we can check to
* see what's missing from a manifest.
*/
@@ -3977,7 +4000,19 @@ int main(int argc, char *argv[])
logmsg(&rc, log_sys_err, "Couldn't find a free name for trust anchor %s", path1.s);
goto done;
}
- uri.s[0] = '\0';
+ assert(sizeof("file://") < sizeof(uri.s));
+ strcpy(uri.s, "file://");
+ if (path1.s[0] != '/') {
+ if (getcwd(uri.s + strlen(uri.s), sizeof(uri.s) - strlen(uri.s)) == NULL ||
+ (!endswith(uri.s, "/") && strlen(uri.s) >= sizeof(uri.s) - 1))
+ uri.s[0] = '\0';
+ else
+ strcat(uri.s, "/");
+ }
+ if (uri.s[0] != '\0' && strlen(uri.s) + strlen(path1.s) < sizeof(uri.s))
+ strcat(uri.s, path1.s);
+ else
+ uri.s[0] = '\0';
}
if (!name_cmp(val->name, "trust-anchor-locator")) {
diff --git a/rcynic/rcynic.c b/rcynic/rcynic.c
index 76de5717..6dfaee83 100644
--- a/rcynic/rcynic.c
+++ b/rcynic/rcynic.c
@@ -3489,6 +3489,19 @@ int main(int argc, char *argv[])
logmsg(&rc, log_sys_err, "Couldn't find a free name for trust anchor %s", path1);
goto done;
}
+ assert(sizeof("file://") < sizeof(uri));
+ strcpy(uri, "file://");
+ if (path1[0] != '/') {
+ if (getcwd(uri + strlen(uri), sizeof(uri) - strlen(uri)) == NULL ||
+ (!endswith(uri, "/") && strlen(uri) >= sizeof(uri) - 1))
+ uri[0] = '\0';
+ else
+ strcat(uri, "/");
+ }
+ if (uri[0] != '\0' && strlen(uri) + strlen(path1) < sizeof(uri))
+ strcat(uri, path1);
+ else
+ uri[0] = '\0';
}
if (!name_cmp(val->name, "trust-anchor-uri-with-key") ||