search for: chroot_in

Displaying 20 results from an estimated 92 matches for "chroot_in".

Did you mean: chroot_dir
2009 Aug 18
1
CHROOT_IN and CHROOT_OUT
...--r--r-- 1 root root 0 Aug 18 10:37 /sysroot/../proc/modules ><fs> cat /../proc/modules libguestfs: error: open: /../proc/modules: No such file or directory The underlying reason for this seems to be that ll uses sysroot_path to establish a path before operating on it, whereas cat uses CHROOT_IN and CHROOT_OUT to open() inside a chroot. It seems to me that wherever a path is used directly by a command, there should never be a reason to use chroot because the real path can always be worked out. The only place I see for using a chroot is in command and sh. Is it worth making a bulk CHRO...
2014 Jan 10
4
Re: RFC: copy-attributes command
...> > return buf.st_size; > > > > } > > > > + > > +int > > +do_copy_attributes (const char *src, const char *dest, int > > permissions, int xattributes) +{ > > + int r; > > + struct stat srcstat, deststat; > > + > > + CHROOT_IN; > > + r = stat (src, &srcstat); > > + CHROOT_OUT; > > + > > + if (r == -1) { > > + reply_with_perror ("stat: %s", src); > > + return -1; > > + } > > + > > + CHROOT_IN; > > + r = stat (dest, &deststat); > &...
2020 Mar 12
0
[PATCH libguestfs 1/3] daemon: xattr: Refactor code which splits attr names from the kernel.
...s_int_xattr_list_val = calloc (r->guestfs_int_xattr_list_len, sizeof (guestfs_int_xattr)); @@ -134,34 +163,34 @@ getxattrs (const char *path, goto error; } - for (i = 0, j = 0; i < (size_t) len; i += strlen (&buf[i]) + 1, ++j) { + for (i = 0; names[i] != NULL; ++i) { CHROOT_IN; - vlen = getxattr (path, &buf[i], NULL, 0); + vlen = getxattr (path, names[i], NULL, 0); CHROOT_OUT; if (vlen == -1) { - reply_with_perror ("getxattr"); + reply_with_perror ("%s: getxattr", names[i]); goto error; } if (vlen >...
2020 Mar 16
0
[PATCH libguestfs v2 1/3] daemon: xattr: Refactor code which splits attr names from the kernel.
...s_int_xattr_list_val = calloc (r->guestfs_int_xattr_list_len, sizeof (guestfs_int_xattr)); @@ -134,34 +160,34 @@ getxattrs (const char *path, goto error; } - for (i = 0, j = 0; i < (size_t) len; i += strlen (&buf[i]) + 1, ++j) { + for (i = 0; names[i] != NULL; ++i) { CHROOT_IN; - vlen = getxattr (path, &buf[i], NULL, 0); + vlen = getxattr (path, names[i], NULL, 0); CHROOT_OUT; if (vlen == -1) { - reply_with_perror ("getxattr"); + reply_with_perror ("getxattr: %s", names[i]); goto error; } if (vlen >...
2014 Jan 07
8
RFC: copy-attributes command
Hi, attached there is a prototype of patch for adding a new copy-attributes command. Such command would allow copy the attributes of a "file" to another, so for example in guestfish: copy-attributes foo bar permissions:true xattributes:false would only copy the permissions of foo to bar, not copying its extended attributes too. Just few notes: - my first daemon command, so
2014 Jan 07
0
Re: RFC: copy-attributes command
...at, zcat); > @@ -584,3 +585,46 @@ do_filesize (const char *path) > > return buf.st_size; > } > + > +int > +do_copy_attributes (const char *src, const char *dest, int permissions, int xattributes) > +{ > + int r; > + struct stat srcstat, deststat; > + > + CHROOT_IN; > + r = stat (src, &srcstat); > + CHROOT_OUT; > + > + if (r == -1) { > + reply_with_perror ("stat: %s", src); > + return -1; > + } > + > + CHROOT_IN; > + r = stat (dest, &deststat); > + CHROOT_OUT; > + > + if (r == -1) { > +...
2015 Dec 01
2
Re: [PATCH] daemon: always provide stdin when running chroot commands (RHBZ#1280029)
On Tue, Dec 01, 2015 at 03:59:56PM +0100, Mateusz Guzik wrote: > CHROOT_IN/OUT around commandvf are definitely problematic. chroot should be > done in the child, which also removes the need to chroot out in the > parent. The CHROOT_IN/OUT business does need to be rewritten. Every instance where we currently do something like: CHROOT_IN; r = stat (fd, &sta...
2015 Nov 19
5
[PATCH] daemon: always provide stdin when running chroot commands (RHBZ#1280029)
...+ reply_with_perror ("/dev/null"); + return NULL; + } + if (bind_mount (&bind_state) == -1) return NULL; if (enable_network) { @@ -266,8 +279,10 @@ do_command (char *const *argv) return NULL; } + flags = COMMAND_FLAG_CHROOT_COPY_FILE_TO_STDIN | fd; + CHROOT_IN; - r = commandv (&out, &err, (const char * const *) argv); + r = commandvf (&out, &err, flags, (const char * const *) argv); CHROOT_OUT; free_bind_state (&bind_state); -- 2.1.0
2014 Jan 10
0
[PATCH] daemon: xattr: move the listxattrs code in an own function
...); +static char *_listxattrs (const char *path, ssize_t (*listxattr) (const char *path, char *list, size_t size), ssize_t *size); guestfs_int_xattr_list * do_getxattrs (const char *path) @@ -111,27 +112,10 @@ getxattrs (const char *path, size_t i, j; guestfs_int_xattr_list *r = NULL; - CHROOT_IN; - len = listxattr (path, NULL, 0); - CHROOT_OUT; - if (len == -1) { - reply_with_perror ("listxattr: %s", path); + buf = _listxattrs (path, listxattr, &len); + if (buf == NULL) + /* _listxattrs issues reply_with_perror already. */ goto error; - } - - buf = malloc (l...
2014 Jan 13
0
[PATCH] New API: copy-attributes.
...if (!(optargs_bitmask & GUESTFS_COPY_ATTRIBUTES_MODE_BITMASK)) + mode = 1; + if (!(optargs_bitmask & GUESTFS_COPY_ATTRIBUTES_XATTRIBUTES_BITMASK)) + xattributes = 1; + if (!(optargs_bitmask & GUESTFS_COPY_ATTRIBUTES_OWNERSHIP_BITMASK)) + ownership = 1; + } + + CHROOT_IN; + r = stat (src, &srcstat); + CHROOT_OUT; + + if (r == -1) { + reply_with_perror ("stat: %s", src); + return -1; + } + + CHROOT_IN; + r = stat (dest, &deststat); + CHROOT_OUT; + + if (r == -1) { + reply_with_perror ("stat: %s", dest); + return -1; +...
2016 Jan 15
1
[PATCH] daemon: resolve paths for ll and llz
...is command is not meant for - * serious use anyway, just for quick interactive sessions. - */ - char * do_ll (const char *path) { int r; char *out; CLEANUP_FREE char *err = NULL; + CLEANUP_FREE char *rpath = NULL; CLEANUP_FREE char *spath = NULL; - spath = sysroot_path (path); + CHROOT_IN; + rpath = realpath (path, NULL); + CHROOT_OUT; + if (rpath == NULL) { + reply_with_perror ("%s", path); + return NULL; + } + + spath = sysroot_path (rpath); if (!spath) { reply_with_perror ("malloc"); return NULL; @@ -131,9 +134,18 @@ do_llz (const char...
2009 Aug 12
23
[PATCH 0/23] factor and const-correctness
This started as a simple warning-elimination change. I'll get back to that series shortly ;-) It turned into a factorization and constification exercise during which I got a taste of ocaml. Thanks to Rich Jones for help with a few snippets in generator.ml. The overall result is that many previously-manually-maintained bits from daemon/*.c functions are now hoisted into the automatically-
2014 Apr 30
2
[PATCH] daemon: xattr: factorize do_getxattr and do_lgetxattr
...size_t size), + size_t *size_r) +{ ssize_t r; char *buf; size_t len; @@ -496,49 +506,7 @@ do_getxattr (const char *path, const char *name, size_t *size_r) char * do_lgetxattr (const char *path, const char *name, size_t *size_r) { - ssize_t r; - char *buf; - size_t len; - - CHROOT_IN; - r = lgetxattr (path, name, NULL, 0); - CHROOT_OUT; - if (r == -1) { - reply_with_perror ("lgetxattr"); - return NULL; - } - - len = r; - - if (len > XATTR_SIZE_MAX) { - reply_with_error ("extended attribute is too large"); - return NULL; - } - - buf = m...
2020 Mar 16
6
[PATCH libguestfs v2 0/3] daemon: Fix various commands which break on NTFS-3g compressed files.
v1 here: https://www.redhat.com/archives/libguestfs/2020-March/msg00099.html This one fixes most of the points picked up in review, and does not strdup the strings which should keep down memory usage if that is a concern. Rich.
2015 Dec 01
0
Re: [PATCH] daemon: always provide stdin when running chroot commands (RHBZ#1280029)
On Tue, Dec 01, 2015 at 04:58:11PM +0000, Richard W.M. Jones wrote: > On Tue, Dec 01, 2015 at 03:59:56PM +0100, Mateusz Guzik wrote: > > CHROOT_IN/OUT around commandvf are definitely problematic. chroot should be > > done in the child, which also removes the need to chroot out in the > > parent. > > The CHROOT_IN/OUT business does need to be rewritten. Every > instance where we currently do something like: > >...
2015 Dec 02
3
[PATCH] daemon: improve internal commandrvf
- add a flag to request chroot for the process, which is done only as very last (before chdir) operation before exec'ing the process in the child: this avoids using CHROOT_IN & CHROOT_OUT around command* invocations, and reduces the code spent in chroot mode - add failure checks for dup2 and open done in child, not proceeding to executing the process if they fail - open /dev/null without O_CLOEXEC, so it stays available for the exec'ed process, and thus we...
2017 Jul 19
2
Re: [PATCH 03/27] daemon: Reimplement ‘file’ API in OCaml.
...t ?name () = Chroot.create (Sysroot.sysroot ()) ?name this way it can be used like: let chroot = create_chroot ~name:(sprintf "file: %s" path) in > + > + let statbuf = Chroot.f chroot lstat path in Hm is chroot needed for this? The current C implementation does not use CHROOT_IN/OUT, and it does not even resolve symlinks, so it should be safe. -- Pino Toscano
2020 Mar 12
8
[PATCH libguestfs 0/3] daemon: Fix various commands which break on NTFS-3g compressed files.
https://bugzilla.redhat.com/show_bug.cgi?id=1811539 Commands including virt-diff which read extended attributes will sometimes fail on NTFS filesystems that are using system compressed. The reason is complex, see comment 5 of the bug linked above. This patch filters out the troublesome xattr. For justification, see the comment I added in patch 3. Patch 1 & 2 are refactoring. I was on the
2015 Dec 01
1
Re: [PATCH] daemon: always provide stdin when running chroot commands (RHBZ#1280029)
...return NULL; nit: this leaks the fd on error, but it may not matter much. > if (enable_network) { > @@ -266,8 +279,10 @@ do_command (char *const *argv) > return NULL; > } > nit: same. > + flags = COMMAND_FLAG_CHROOT_COPY_FILE_TO_STDIN | fd; > + > CHROOT_IN; > - r = commandv (&out, &err, (const char * const *) argv); > + r = commandvf (&out, &err, flags, (const char * const *) argv); > CHROOT_OUT; > > free_bind_state (&bind_state); According to the analysis in https://bugzilla.redhat.com/show_bug.cgi?id=12...
2009 Aug 11
1
[PATCH libguestfs] generator.ml: constify do_mkdtemp
...const char *path) } char * -do_mkdtemp (char *template) +do_mkdtemp (const char *template) { - char *r; - - NEED_ROOT (return NULL); - ABS_PATH (template, return NULL); + char *r = strdup (template); + if (r == NULL) { + reply_with_perror ("strdup"); + return NULL; + } CHROOT_IN; - r = mkdtemp (template); + r = mkdtemp (r); CHROOT_OUT; - if (r == NULL) { + if (r == NULL) reply_with_perror ("mkdtemp: %s", template); - return NULL; - } - /* The caller will free template AND try to free the return value, - * so we must make a copy here. - */ -...