--numeric-owner now affects private headers too
Problem reported by Daniel Peebles in: http://lists.gnu.org/archive/html/bug-tar/2017-04/msg00004.html * NEWS: Document this. * src/create.c (write_gnu_long_link): If --numeric-owner, leave the user and group empty in a private header. Cache the names for 0.
This commit is contained in:
5
NEWS
5
NEWS
@@ -1,4 +1,4 @@
|
||||
GNU tar NEWS - User visible changes. 2016-10-29
|
||||
GNU tar NEWS - User visible changes. 2017-04-06
|
||||
Please send GNU tar bug reports to <bug-tar@gnu.org>
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ issued the following error message
|
||||
tar: --exclude '*.o' has no effect
|
||||
tar: Exiting with failure status due to previous errors
|
||||
|
||||
* --numeric-owner now affects private headers too.
|
||||
This helps the output of 'tar' to be more deterministic.
|
||||
|
||||
|
||||
version 1.29 - Sergey Poznyakoff, 2016-05-16
|
||||
|
||||
|
||||
22
src/create.c
22
src/create.c
@@ -202,8 +202,8 @@ to_base256 (int negative, uintmax_t value, char *where, size_t size)
|
||||
#define MODE_TO_CHARS(val, where) mode_to_chars (val, where, sizeof (where))
|
||||
#define UID_TO_CHARS(val, where) uid_to_chars (val, where, sizeof (where))
|
||||
|
||||
#define UNAME_TO_CHARS(name,buf) string_to_chars (name, buf, sizeof(buf))
|
||||
#define GNAME_TO_CHARS(name,buf) string_to_chars (name, buf, sizeof(buf))
|
||||
#define UNAME_TO_CHARS(name, buf) string_to_chars (name, buf, sizeof (buf))
|
||||
#define GNAME_TO_CHARS(name, buf) string_to_chars (name, buf, sizeof (buf))
|
||||
|
||||
static bool
|
||||
to_chars (int negative, uintmax_t value, size_t valsize,
|
||||
@@ -542,15 +542,19 @@ write_gnu_long_link (struct tar_stat_info *st, const char *p, char type)
|
||||
size_t size = strlen (p) + 1;
|
||||
size_t bufsize;
|
||||
union block *header;
|
||||
char *tmpname;
|
||||
|
||||
header = start_private_header ("././@LongLink", size, 0);
|
||||
uid_to_uname (0, &tmpname);
|
||||
UNAME_TO_CHARS (tmpname, header->header.uname);
|
||||
free (tmpname);
|
||||
gid_to_gname (0, &tmpname);
|
||||
GNAME_TO_CHARS (tmpname, header->header.gname);
|
||||
free (tmpname);
|
||||
if (! numeric_owner_option)
|
||||
{
|
||||
static char *uname, *gname;
|
||||
if (!uname)
|
||||
{
|
||||
uid_to_uname (0, &uname);
|
||||
gid_to_gname (0, &gname);
|
||||
}
|
||||
UNAME_TO_CHARS (uname, header->header.uname);
|
||||
GNAME_TO_CHARS (gname, header->header.gname);
|
||||
}
|
||||
|
||||
strcpy (header->buffer + offsetof (struct posix_header, magic),
|
||||
OLDGNU_MAGIC);
|
||||
|
||||
Reference in New Issue
Block a user