diff --git a/daemon/tar.c b/daemon/tar.c index 8d78283e6..f46733dfb 100644 --- a/daemon/tar.c +++ b/daemon/tar.c @@ -240,7 +240,7 @@ do_txz_in (const char *dir) /* Has one FileOut parameter. */ /* Takes optional arguments, consult optargs_bitmask. */ int -do_tar_out (const char *dir, const char *compress) +do_tar_out (const char *dir, const char *compress, int numericowner) { const char *filter; int r; @@ -266,9 +266,13 @@ do_tar_out (const char *dir, const char *compress) } else filter = ""; + if (!(optargs_bitmask & GUESTFS_TAR_OUT_NUMERICOWNER_BITMASK)) + numericowner = 0; + /* "tar -C /sysroot%s -cf - ." but we have to quote the dir. */ - if (asprintf_nowarn (&cmd, "tar -C %R%s -cf - .", - dir, filter) == -1) { + if (asprintf_nowarn (&cmd, "tar -C %R%s%s -cf - .", + dir, filter, + numericowner ? " --numeric-owner" : "") == -1) { reply_with_perror ("asprintf"); return -1; } @@ -321,7 +325,7 @@ int do_tgz_out (const char *dir) { optargs_bitmask = GUESTFS_TAR_OUT_COMPRESS_BITMASK; - return do_tar_out (dir, "gzip"); + return do_tar_out (dir, "gzip", 0); } /* Has one FileOut parameter. */ @@ -329,5 +333,5 @@ int do_txz_out (const char *dir) { optargs_bitmask = GUESTFS_TAR_OUT_COMPRESS_BITMASK; - return do_tar_out (dir, "bzip2"); + return do_tar_out (dir, "bzip2", 0); } diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index a29a68559..0771b6225 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -3433,7 +3433,7 @@ compression types)." }; { defaults with name = "tar_out"; - style = RErr, [String "directory"; FileOut "tarfile"], [OString "compress"]; + style = RErr, [String "directory"; FileOut "tarfile"], [OString "compress"; OBool "numericowner"]; proc_nr = Some 70; once_had_no_optargs = true; cancellable = true; @@ -3447,7 +3447,18 @@ then the output will be an uncompressed tar file. Otherwise one of the following strings may be given to select the compression type of the output file: C, C, C, C, C. (Note that not all builds of libguestfs will support all of these -compression types)." }; +compression types). + +The other optional arguments are: + +=over 4 + +=item C + +If set to true, the output tar file will contain UID/GID numbers +instead of user/group names. + +=back" }; { defaults with name = "tgz_in";