From: Sergey Poznyakoff Date: Tue, 11 Apr 2006 11:59:40 +0000 (+0000) Subject: (extract_dir): Fix toggling existing directory X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=8300c820d552b6608d1d1abd37b4ff4aef5a8a05;p=chaz%2Ftar (extract_dir): Fix toggling existing directory permissions. Use parts of patch provided by Ian Jackson . --- diff --git a/src/extract.c b/src/extract.c index a630bb7..4082083 100644 --- a/src/extract.c +++ b/src/extract.c @@ -428,7 +428,7 @@ make_directories (char *file_name) invert_permissions is zero, because repair_delayed_set_stat may need to update the struct. */ delay_set_stat (file_name, - ¤t_stat_info /* ignored */, + ¤t_stat_info, invert_permissions, INTERDIR_PERMSTATUS); print_for_mkdir (file_name, cursor - file_name, mode); @@ -647,7 +647,7 @@ extract_dir (char *file_name, int typeflag) } if (S_ISDIR (st.st_mode)) { - mode = st.st_mode & ~ current_umask; + mode = st.st_mode; break; } } @@ -668,12 +668,16 @@ extract_dir (char *file_name, int typeflag) if (status == 0 || old_files_option == DEFAULT_OLD_FILES || old_files_option == OVERWRITE_OLD_FILES) - delay_set_stat (file_name, ¤t_stat_info, - MODE_RWX & (mode ^ current_stat_info.stat.st_mode), - (status == 0 - ? ARCHIVED_PERMSTATUS - : UNKNOWN_PERMSTATUS)); - + { + if (status == 0) + delay_set_stat (file_name, ¤t_stat_info, + MODE_RWX & (mode ^ current_stat_info.stat.st_mode), + ARCHIVED_PERMSTATUS); + else /* For an already existing directory, invert_perms must be 0 */ + delay_set_stat (file_name, ¤t_stat_info, + 0, + UNKNOWN_PERMSTATUS); + } return status; }