[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] [PATCH] Possible fix for --update mode and some other problems
From: |
Pavel Raiskup |
Subject: |
[Bug-tar] [PATCH] Possible fix for --update mode and some other problems. |
Date: |
Thu, 16 Aug 2012 15:47:43 +0200 |
Hi, I'd like consult some defects in tar --update feature. There are
several problems I have found in --update mode until now:
* cooperation with -C option. I have mentioned it some time before:
http://lists.gnu.org/archive/html/bug-tar/2012-02/msg00007.html
(my *previous* mail client deformed the second patch MIME, it is also
plain text patch so don't worry to open the proposed fix)
* problem with --wildcards option #1. Mentioned here:
https://bugzilla.redhat.com/show_bug.cgi?id=848230
and yet before here:
http://forums.fedoraforum.org/showthread.php?p=1597330#post1597330
Proposed test/fix is in attachment. I'm not sure that it is proper
solution so I'm writing here. The problem is that regular file name
stored in archive is interpreted later on like fnmatch pattern -- and
if the stored file name contains special characters like '*', '[' and
others, it causes problems. The proposed fix just disables fnmatch()
for added file. Second possibility would be to escape all special
characters in filenames but it requires some hacks later on.
* Problem with default behavior of --update when --wildcards is turned
'on' for some files. See the following:
1) prepare
$ mkdir zzz
$ touch zzz/aaa
$ mkdir zz
$ touch zz/oh
$ tar -cvf test.tar zzz
zzz/
zzz/aaa
2a)
$ touch zzz/aaa
$ tar -uvf test.tar --wildcards 'zz*'
zzz/aaa
** BUT **
2b)
$ tar -uvf test.tar --wildcards 'zz'
zz/
zz/oh
-> note that tar is adding directory 'zz' even if it does not exist
in archive. If it is correct way than the 'zz' directory should be
added into archive even if the 'zz*' wildcard is passed.
(sorry --> commands may contain typos -> I'm C&P them)
* another problem is maybe here:
| @@ -146,15 +146,16 @@ update_archive (void)
| && (name = name_scan (current_stat_info.file_name)) != NULL)
| {
| struct stat s;
| + const char *target_name = current_stat_info.file_name;
| _
| chdir_do (name->change_dir);
| - if (deref_stat (current_stat_info.file_name, &s) == 0)
| + if (deref_stat (target_name, &s) == 0)
| {
| if (S_ISDIR (s.st_mode))
| {
| char *p, *dirp;
| DIR *stream = NULL;
| - int fd = openat (chdir_fd, name->name,
| + int fd = openat (chdir_fd, target_name,
| open_read_flags | O_DIRECTORY);
| if (fd < 0)
| open_error (name->name);
| @@ -163,7 +164,7 @@ update_archive (void)
| savedir_error (name->name);
| else
| {
| - namebuf_t nbuf = namebuf_create (name->name);
| + namebuf_t nbuf = namebuf_create (target_name);
|
| for (p = dirp; *p; p += strlen (p) + 1)
| /* we are adding new file name based on actual
... the deref_stat () may be done on different string than following
openat() call.
* my last problem is when:
$ mkdir zzz
$ touch zzz/aaa
$ touch zzzfile
$ tar -cvf test.tar zzz zzzfile
zzz/
zzz/aaa
zzzfile
$ touch zzzfile
$ tar -uvf test.tar --wildcards zzz
$ # prints nothing ^^^ ! but the 'zzzfile' was touched.
The problem here is the 'rmname()' call even for wildcard patterns.
It would like to ask you whether it would be possible to add another list
with "whitelisted" files that are going to be updated aside the
'namelist'. The 'namelist' is noticeably unusable for --update purposes.
Are there any other possibilities?
Would it be possible to add some notes about mentioned circumstances into
info documentation?
Thanks for your help,
Pavel
0001-Test-for-bad-cooperation-of-wildcard-and-update-opti.patch
Description: Text Data
0002-Fix-for-bad-cooperation-of-wildcard-and-update.patch
Description: Text Data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-tar] [PATCH] Possible fix for --update mode and some other problems.,
Pavel Raiskup <=