From c5784e9cc3c2256a16b9cf86c4e98722781b5cd4 Mon Sep 17 00:00:00 2001 From: Duncaen Date: Sun, 25 Sep 2016 22:22:27 +0200 Subject: [PATCH] bin/xbps-uchroot: allow relative chroot directory --- bin/xbps-uchroot/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/xbps-uchroot/main.c b/bin/xbps-uchroot/main.c index d2008ba4..75da04c7 100644 --- a/bin/xbps-uchroot/main.c +++ b/bin/xbps-uchroot/main.c @@ -319,6 +319,14 @@ main(int argc, char **argv) if (strcmp(chrootdir, "/") == 0) die("/ is not allowed to be used as chrootdir"); + /* Make chrootdir absolute */ + if (chrootdir[0] != '/') { + char cwd[PATH_MAX-1]; + if (getcwd(cwd, sizeof(cwd)) == NULL) + die("getcwd"); + chrootdir = xbps_xasprintf("%s/%s", cwd, chrootdir); + } + if (getresgid(&rgid, &egid, &sgid) == -1) die("getresgid");