diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-17 04:43:14 +0400 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-17 04:43:14 +0400 |
commit | d57d62686dac254e83fbc18f851c773ec16013d8 (patch) | |
tree | 3e22476c6f2d74208568d5d56a629a81e11589ea /archival/tar.c | |
parent | 1166d7b1360285659aa7585e5c5bd4e1321aeeaf (diff) |
tar: fix --numeric-owner, --no-same-owner, --no-same-permissions bits
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/tar.c')
-rw-r--r-- | archival/tar.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/archival/tar.c b/archival/tar.c index 9b7a42a18..bd8e5dc99 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -735,10 +735,10 @@ enum { IF_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,) IF_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,) IF_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,) - IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) - OPTBIT_NOPRESERVE_OWN, - OPTBIT_NOPRESERVE_PERM, + IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) /* 15th bit */ OPTBIT_NUMERIC_OWNER, + OPTBIT_NOPRESERVE_OWNER, + OPTBIT_NOPRESERVE_PERM, OPT_TEST = 1 << 0, // t OPT_EXTRACT = 1 << 1, // x OPT_BASEDIR = 1 << 2, // C @@ -755,9 +755,9 @@ enum { OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z - OPT_NOPRESERVE_OWN = 1 << OPTBIT_NOPRESERVE_OWN , // no-same-owner - OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions OPT_NUMERIC_OWNER = 1 << OPTBIT_NUMERIC_OWNER, + OPT_NOPRESERVE_OWNER = 1 << OPTBIT_NOPRESERVE_OWNER , // no-same-owner + OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions }; #if ENABLE_FEATURE_TAR_LONG_OPTIONS static const char tar_longopts[] ALIGN1 = @@ -789,12 +789,15 @@ static const char tar_longopts[] ALIGN1 = # if ENABLE_FEATURE_SEAMLESS_Z "compress\0" No_argument "Z" # endif + /* use numeric uid/gid from tar header, not textual */ "numeric-owner\0" No_argument "\xfc" + /* do not restore owner */ "no-same-owner\0" No_argument "\xfd" + /* do not restore mode */ "no-same-permissions\0" No_argument "\xfe" /* --exclude takes next bit position in option mask, */ /* therefore we have to either put it _after_ --no-same-perm */ - /* or add OPT[BIT]_EXCLUDE before OPT[BIT]_NOPRESERVE_OWN */ + /* or add OPT[BIT]_EXCLUDE before OPT[BIT]_NOPRESERVE_OWNER */ # if ENABLE_FEATURE_TAR_FROM "exclude\0" Required_argument "\xff" # endif @@ -817,12 +820,12 @@ int tar_main(int argc UNUSED_PARAM, char **argv) /* Initialise default values */ tar_handle = init_handle(); tar_handle->ah_flags = ARCHIVE_CREATE_LEADING_DIRS - | ARCHIVE_PRESERVE_DATE - | ARCHIVE_EXTRACT_UNCONDITIONAL; + | ARCHIVE_RESTORE_DATE + | ARCHIVE_UNLINK_OLD; /* Apparently only root's tar preserves perms (see bug 3844) */ if (getuid() != 0) - tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_PERM; + tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_PERM; /* Prepend '-' to the first argument if required */ opt_complementary = "--:" // first arg is options @@ -856,6 +859,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv) , &verboseFlag // combined count for -t and -v , &verboseFlag // combined count for -t and -v ); + //bb_error_msg("opt:%08x", opt); argv += optind; if (verboseFlag) tar_handle->action_header = header_verbose_list; @@ -868,17 +872,17 @@ int tar_main(int argc UNUSED_PARAM, char **argv) tar_handle->action_data = data_extract_to_stdout; if (opt & OPT_KEEP_OLD) - tar_handle->ah_flags &= ~ARCHIVE_EXTRACT_UNCONDITIONAL; - - if (opt & OPT_NOPRESERVE_OWN) - tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_OWN; - - if (opt & OPT_NOPRESERVE_PERM) - tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_PERM; + tar_handle->ah_flags &= ~ARCHIVE_UNLINK_OLD; if (opt & OPT_NUMERIC_OWNER) tar_handle->ah_flags |= ARCHIVE_NUMERIC_OWNER; + if (opt & OPT_NOPRESERVE_OWNER) + tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_OWNER; + + if (opt & OPT_NOPRESERVE_PERM) + tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_PERM; + if (opt & OPT_GZIP) get_header_ptr = get_header_tar_gz; |