From 8670bd3a035b753e0b38b4f79a3e79ed407f067e Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sun, 4 May 2008 16:12:56 -0400 Subject: [PATCH] Basic implementation of --numeric-owner. Submitted by: Jaakko Heinonen SVN-Revision: 22 --- tar/bsdtar.1 | 4 ++++ tar/bsdtar.c | 5 +++++ tar/bsdtar.h | 1 + tar/read.c | 5 +++++ 4 files changed, 15 insertions(+) diff --git a/tar/bsdtar.1 b/tar/bsdtar.1 index ca7117593..ed8df3481 100644 --- a/tar/bsdtar.1 +++ b/tar/bsdtar.1 @@ -274,6 +274,10 @@ This is often used to read filenames output by the .Fl print0 option to .Xr find 1 . +.It Fl -numeric-owner +(x mode only) +Ignore symbolic user and group names when restoring archives to disk, +only numeric uid and gid values will be obeyed. .It Fl O (x, t modes only) In extract (-x) mode, files will be written to standard out rather than diff --git a/tar/bsdtar.c b/tar/bsdtar.c index b10c428a2..43881cf3f 100644 --- a/tar/bsdtar.c +++ b/tar/bsdtar.c @@ -150,6 +150,7 @@ enum { OPTION_NO_SAME_OWNER, OPTION_NO_SAME_PERMISSIONS, OPTION_NULL, + OPTION_NUMERIC_OWNER, OPTION_ONE_FILE_SYSTEM, OPTION_POSIX, OPTION_STRIP_COMPONENTS, @@ -205,6 +206,7 @@ static const struct option tar_longopts[] = { { "no-same-owner", no_argument, NULL, OPTION_NO_SAME_OWNER }, { "no-same-permissions",no_argument, NULL, OPTION_NO_SAME_PERMISSIONS }, { "null", no_argument, NULL, OPTION_NULL }, + { "numeric-owner", no_argument, NULL, OPTION_NUMERIC_OWNER }, { "one-file-system", no_argument, NULL, OPTION_ONE_FILE_SYSTEM }, { "posix", no_argument, NULL, OPTION_POSIX }, { "preserve-permissions", no_argument, NULL, 'p' }, @@ -455,6 +457,9 @@ main(int argc, char **argv) case OPTION_NULL: /* GNU tar */ bsdtar->option_null++; break; + case OPTION_NUMERIC_OWNER: /* GNU tar */ + bsdtar->option_numeric_owner++; + break; case 'O': /* GNU tar */ bsdtar->option_stdout = 1; break; diff --git a/tar/bsdtar.h b/tar/bsdtar.h index 167b55235..726e29eb9 100644 --- a/tar/bsdtar.h +++ b/tar/bsdtar.h @@ -65,6 +65,7 @@ struct bsdtar { char option_no_owner; /* -o */ char option_no_subdirs; /* -n */ char option_null; /* --null */ + char option_numeric_owner; /* --numeric-owner */ char option_stdout; /* -O */ char option_totals; /* --totals */ char option_unlink_first; /* -U */ diff --git a/tar/read.c b/tar/read.c index 279a10549..0795c7941 100644 --- a/tar/read.c +++ b/tar/read.c @@ -150,6 +150,11 @@ read_archive(struct bsdtar *bsdtar, char mode) if (r == ARCHIVE_FATAL) break; + if (bsdtar->option_numeric_owner) { + archive_entry_set_uname(entry, NULL); + archive_entry_set_gname(entry, NULL); + } + /* * Exclude entries that are too old. */ -- 2.47.3