diff options
Diffstat (limited to 'main/busybox/bb-tar-numeric-owner.patch')
-rw-r--r-- | main/busybox/bb-tar-numeric-owner.patch | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/main/busybox/bb-tar-numeric-owner.patch b/main/busybox/bb-tar-numeric-owner.patch new file mode 100644 index 000000000..ad6481ffe --- /dev/null +++ b/main/busybox/bb-tar-numeric-owner.patch @@ -0,0 +1,92 @@ +Index: archival/tar.c +=================================================================== +--- a/archival/tar.c (revision 26114) ++++ b/archival/tar.c (working copy) +@@ -738,6 +738,7 @@ + USE_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) + OPTBIT_NOPRESERVE_OWN, + OPTBIT_NOPRESERVE_PERM, ++ OPTBIT_NUMERIC_OWNER, + OPT_TEST = 1 << 0, // t + OPT_EXTRACT = 1 << 1, // x + OPT_BASEDIR = 1 << 2, // C +@@ -754,6 +755,7 @@ + OPT_EXCLUDE_FROM = USE_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X + OPT_GZIP = USE_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z + OPT_COMPRESS = USE_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z ++ OPT_NUMERIC_OWNER = 1 << OPTBIT_NUMERIC_OWNER, + OPT_NOPRESERVE_OWN = 1 << OPTBIT_NOPRESERVE_OWN , // no-same-owner + OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions + }; +@@ -787,6 +789,7 @@ + # if ENABLE_FEATURE_SEAMLESS_Z + "compress\0" No_argument "Z" + # endif ++ "numeric-owner\0" No_argument "\xfc" + "no-same-owner\0" No_argument "\xfd" + "no-same-permissions\0" No_argument "\xfe" + /* --exclude takes next bit position in option mask, */ +@@ -873,6 +876,9 @@ + if (opt & OPT_NOPRESERVE_PERM) + tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_PERM; + ++ if (opt & OPT_NUMERIC_OWNER) ++ tar_handle->ah_flags |= ARCHIVE_NUMERIC_OWNER; ++ + if (opt & OPT_GZIP) + get_header_ptr = get_header_tar_gz; + +Index: archival/libunarchive/data_extract_all.c +=================================================================== +--- a/archival/libunarchive/data_extract_all.c (revision 26114) ++++ b/archival/libunarchive/data_extract_all.c (working copy) +@@ -114,22 +114,23 @@ + } + + if (!(archive_handle->ah_flags & ARCHIVE_NOPRESERVE_OWN)) { +-#if ENABLE_FEATURE_TAR_UNAME_GNAME +- uid_t uid = file_header->uid; +- gid_t gid = file_header->gid; ++ if (ENABLE_FEATURE_TAR_UNAME_GNAME && ++ !(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)) { ++ uid_t uid = file_header->uid; ++ gid_t gid = file_header->gid; + +- if (file_header->uname) { +- struct passwd *pwd = getpwnam(file_header->uname); +- if (pwd) uid = pwd->pw_uid; ++ if (file_header->uname) { ++ struct passwd *pwd = getpwnam(file_header->uname); ++ if (pwd) uid = pwd->pw_uid; ++ } ++ if (file_header->gname) { ++ struct group *grp = getgrnam(file_header->gname); ++ if (grp) gid = grp->gr_gid; ++ } ++ lchown(file_header->name, uid, gid); ++ } else { ++ lchown(file_header->name, file_header->uid, file_header->gid); + } +- if (file_header->gname) { +- struct group *grp = getgrnam(file_header->gname); +- if (grp) gid = grp->gr_gid; +- } +- lchown(file_header->name, uid, gid); +-#else +- lchown(file_header->name, file_header->uid, file_header->gid); +-#endif + } + if ((file_header->mode & S_IFMT) != S_IFLNK) { + /* uclibc has no lchmod, glibc is even stranger - +Index: include/unarchive.h +=================================================================== +--- a/include/unarchive.h (revision 26114) ++++ b/include/unarchive.h (working copy) +@@ -11,6 +11,7 @@ + #define ARCHIVE_EXTRACT_NEWER 16 + #define ARCHIVE_NOPRESERVE_OWN 32 + #define ARCHIVE_NOPRESERVE_PERM 64 ++#define ARCHIVE_NUMERIC_OWNER 128 + + typedef struct file_header_t { + char *name; |