Merge pull request #207 from Duncaen/relative

xbps-uchroot and xbps-uunshare usability improvements
This commit is contained in:
Juan RP 2017-10-25 09:14:40 +02:00 committed by GitHub
commit 9c0d795810
2 changed files with 19 additions and 3 deletions

View File

@ -281,7 +281,7 @@ main(int argc, char **argv)
tmpfs_opts = chrootdir = cmd = NULL;
argv0 = argv[0];
while ((c = getopt_long(argc, argv, "Oto:b:V", longopts, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "+Oto:b:V", longopts, NULL)) != -1) {
switch (c) {
case 'O':
overlayfs = true;
@ -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");

View File

@ -136,7 +136,7 @@ main(int argc, char **argv)
chrootdir = cmd = NULL;
argv0 = argv[0];
while ((c = getopt_long(argc, argv, "b:V", longopts, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "+b:V", longopts, NULL)) != -1) {
switch (c) {
case 'b':
if (optarg == NULL || *optarg == '\0')
@ -157,7 +157,7 @@ main(int argc, char **argv)
if (argc < 2)
usage(argv0);
chrootdir = argv[0];
chrootdir = argv[-1];
cmd = argv[1];
cmdargs = argv + 1;
@ -165,6 +165,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);
}
/*
* Unshare from the current process namespaces and set ours.
*/