tar-out: Add optional numericowner flag (RHBZ#847880).

This is equivalent to the tar option --numeric-owner.
This commit is contained in:
Richard W.M. Jones
2012-08-14 09:54:31 +01:00
parent 864ef706a8
commit 4dbae7cc06
2 changed files with 22 additions and 7 deletions

View File

@@ -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);
}

View File

@@ -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<compress>, C<gzip>, C<bzip2>, C<xz>, C<lzop>.
(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<numericowner>
If set to true, the output tar file will contain UID/GID numbers
instead of user/group names.
=back" };
{ defaults with
name = "tgz_in";