diff options
| author | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-06-22 02:55:16 +0000 |
|---|---|---|
| committer | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-06-22 02:55:16 +0000 |
| commit | 092a3ecf33f431fb5267390ea0b6b5c17514fb5b (patch) | |
| tree | f45b55655c61d952c869b6ba0cd85655aead8bff /libbb | |
| parent | fc2d376a018fa6621ee2cbb38d46eb5a971e32b2 (diff) | |
| download | busybox-w32-092a3ecf33f431fb5267390ea0b6b5c17514fb5b.tar.gz busybox-w32-092a3ecf33f431fb5267390ea0b6b5c17514fb5b.tar.bz2 busybox-w32-092a3ecf33f431fb5267390ea0b6b5c17514fb5b.zip | |
Dont change date or chmod on symlinks, lchown on symlinks if lchown available
git-svn-id: svn://busybox.net/trunk/busybox@2880 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
| -rw-r--r-- | libbb/unarchive.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/libbb/unarchive.c b/libbb/unarchive.c index e4150bda2..199123ec4 100644 --- a/libbb/unarchive.c +++ b/libbb/unarchive.c | |||
| @@ -162,13 +162,23 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f | |||
| 162 | } | 162 | } |
| 163 | break; | 163 | break; |
| 164 | } | 164 | } |
| 165 | if (function & extract_preserve_date) { | 165 | |
| 166 | t.actime = file_entry->mtime; | 166 | /* Changing a symlink's properties normally changes the properties of the |
| 167 | t.modtime = file_entry->mtime; | 167 | * file pointed to, so dont try and change the date or mode, lchown does |
| 168 | utime(full_name, &t); | 168 | * does the right thing, but isnt available in older versions of libc */ |
| 169 | if (S_ISLNK(file_entry->mode)) { | ||
| 170 | #if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) | ||
| 171 | lchown(full_name, file_entry->uid, file_entry->gid); | ||
| 172 | #endif | ||
| 173 | } else { | ||
| 174 | if (function & extract_preserve_date) { | ||
| 175 | t.actime = file_entry->mtime; | ||
| 176 | t.modtime = file_entry->mtime; | ||
| 177 | utime(full_name, &t); | ||
| 178 | } | ||
| 179 | chmod(full_name, file_entry->mode); | ||
| 180 | chown(full_name, file_entry->uid, file_entry->gid); | ||
| 169 | } | 181 | } |
| 170 | chmod(full_name, file_entry->mode); | ||
| 171 | lchown(full_name, file_entry->uid, file_entry->gid); | ||
| 172 | } else { | 182 | } else { |
| 173 | /* If we arent extracting data we have to skip it, | 183 | /* If we arent extracting data we have to skip it, |
| 174 | * if data size is 0 then then just do it anyway | 184 | * if data size is 0 then then just do it anyway |
