api: router: Resolve chroot paths through chroot_lib
We don't guarantee you can perform your own relative path calculations
for all paths. Let chroot_lib handle that.
BUG=b:265885353
TEST=./run_tests
Change-Id: I447899bc64c6cffdb4d9048a74687775741501cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4327881
Reviewed-by: Cindy Lin <xcl@google.com>
Commit-Queue: Brian Norris <briannorris@chromium.org>
Tested-by: Brian Norris <briannorris@chromium.org>
diff --git a/api/router.py b/api/router.py
index 68a71e8..e6bae4d 100644
--- a/api/router.py
+++ b/api/router.py
@@ -393,11 +393,11 @@
# Build inside-chroot paths for the input, output, and config
# messages.
new_input = os.path.join(tempdir, self.REEXEC_INPUT_FILE)
- chroot_input = "/%s" % os.path.relpath(new_input, chroot.path)
+ chroot_input = chroot.chroot_path(new_input)
new_output = os.path.join(tempdir, self.REEXEC_OUTPUT_FILE)
- chroot_output = "/%s" % os.path.relpath(new_output, chroot.path)
+ chroot_output = chroot.chroot_path(new_output)
new_config = os.path.join(tempdir, self.REEXEC_CONFIG_FILE)
- chroot_config = "/%s" % os.path.relpath(new_config, chroot.path)
+ chroot_config = chroot.chroot_path(new_config)
# Setup the inside-chroot message files.
logging.info("Writing input message to: %s", new_input)