Merge pull request #207 from Duncaen/relative
xbps-uchroot and xbps-uunshare usability improvements
This commit is contained in:
commit
9c0d795810
@ -281,7 +281,7 @@ main(int argc, char **argv)
|
|||||||
tmpfs_opts = chrootdir = cmd = NULL;
|
tmpfs_opts = chrootdir = cmd = NULL;
|
||||||
argv0 = argv[0];
|
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) {
|
switch (c) {
|
||||||
case 'O':
|
case 'O':
|
||||||
overlayfs = true;
|
overlayfs = true;
|
||||||
@ -319,6 +319,14 @@ main(int argc, char **argv)
|
|||||||
if (strcmp(chrootdir, "/") == 0)
|
if (strcmp(chrootdir, "/") == 0)
|
||||||
die("/ is not allowed to be used as chrootdir");
|
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)
|
if (getresgid(&rgid, &egid, &sgid) == -1)
|
||||||
die("getresgid");
|
die("getresgid");
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ main(int argc, char **argv)
|
|||||||
chrootdir = cmd = NULL;
|
chrootdir = cmd = NULL;
|
||||||
argv0 = argv[0];
|
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) {
|
switch (c) {
|
||||||
case 'b':
|
case 'b':
|
||||||
if (optarg == NULL || *optarg == '\0')
|
if (optarg == NULL || *optarg == '\0')
|
||||||
@ -157,7 +157,7 @@ main(int argc, char **argv)
|
|||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
usage(argv0);
|
usage(argv0);
|
||||||
|
|
||||||
chrootdir = argv[0];
|
chrootdir = argv[-1];
|
||||||
cmd = argv[1];
|
cmd = argv[1];
|
||||||
cmdargs = argv + 1;
|
cmdargs = argv + 1;
|
||||||
|
|
||||||
@ -165,6 +165,14 @@ main(int argc, char **argv)
|
|||||||
if (strcmp(chrootdir, "/") == 0)
|
if (strcmp(chrootdir, "/") == 0)
|
||||||
die("/ is not allowed to be used as chrootdir");
|
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.
|
* Unshare from the current process namespaces and set ours.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user