aboutsummaryrefslogtreecommitdiff
path: root/mod/mod-build-result.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-09-05 21:23:41 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-09-08 17:44:57 +0300
commit70c1cdfd8f34472761fe5ec97f0713990c1b4f5b (patch)
treef2e631c10563bcc0cde07e4359c11b800a188d86 /mod/mod-build-result.cxx
parent3be834183ae36c321e4b560dce9a63cee846e63d (diff)
Add multi-tenancy support
Diffstat (limited to 'mod/mod-build-result.cxx')
-rw-r--r--mod/mod-build-result.cxx23
1 files changed, 16 insertions, 7 deletions
diff --git a/mod/mod-build-result.cxx b/mod/mod-build-result.cxx
index 65e8425..1ba1bec 100644
--- a/mod/mod-build-result.cxx
+++ b/mod/mod-build-result.cxx
@@ -106,8 +106,8 @@ handle (request& rq, response&)
}
// Parse the task response session to obtain the build configuration name and
- // the timestamp, and to make sure the session matches the result manifest's
- // package name and version.
+ // the timestamp, and to make sure the session matches tenant and the result
+ // manifest's package name, and version.
//
build_id id;
timestamp session_timestamp;
@@ -116,9 +116,18 @@ handle (request& rq, response&)
{
const string& s (rqm.session);
- size_t p (s.find ('/')); // End of package name.
+ size_t p (s.find ('/')); // End of tenant.
- if (p == 0)
+ if (p == string::npos)
+ throw invalid_argument ("no package name");
+
+ if (tenant.compare (0, tenant.size (), s, 0, p) != 0)
+ throw invalid_argument ("tenant mismatch");
+
+ size_t b (p + 1); // Start of package name.
+ p = s.find ('/', b); // End of package name.
+
+ if (p == b)
throw invalid_argument ("empty package name");
if (p == string::npos)
@@ -127,11 +136,11 @@ handle (request& rq, response&)
package_name& name (rqm.result.name);
{
const string& n (name.string ());
- if (n.compare (0, n.size (), s, 0, p) != 0)
+ if (n.compare (0, n.size (), s, b, p - b) != 0)
throw invalid_argument ("package name mismatch");
}
- size_t b (p + 1); // Start of version.
+ b = p + 1; // Start of version.
p = s.find ('/', b); // End of version.
if (p == string::npos)
@@ -172,7 +181,7 @@ handle (request& rq, response&)
version toolchain_version (parse_version ("toolchain version"));
- id = build_id (package_id (move (name), package_version),
+ id = build_id (package_id (move (tenant), move (name), package_version),
move (config),
toolchain_version);