bsdtar.c (342360) | bsdtar.c (348607) |
---|---|
1/*- 2 * Copyright (c) 2003-2008 Tim Kientzle 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 10 unchanged lines hidden (view full) --- 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "bsdtar_platform.h" | 1/*- 2 * Copyright (c) 2003-2008 Tim Kientzle 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 10 unchanged lines hidden (view full) --- 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "bsdtar_platform.h" |
27__FBSDID("$FreeBSD: stable/11/contrib/libarchive/tar/bsdtar.c 342360 2018-12-21 23:33:05Z mm $"); | 27__FBSDID("$FreeBSD: stable/11/contrib/libarchive/tar/bsdtar.c 348607 2019-06-04 10:35:54Z mm $"); |
28 29#ifdef HAVE_SYS_PARAM_H 30#include <sys/param.h> 31#endif 32#ifdef HAVE_SYS_STAT_H 33#include <sys/stat.h> 34#endif 35#ifdef HAVE_COPYFILE_H --- 88 unchanged lines hidden (view full) --- 124static void set_mode(struct bsdtar *, char opt); 125static void version(void) __LA_DEAD; 126 127/* A basic set of security flags to request from libarchive. */ 128#define SECURITY \ 129 (ARCHIVE_EXTRACT_SECURE_SYMLINKS \ 130 | ARCHIVE_EXTRACT_SECURE_NODOTDOT) 131 | 28 29#ifdef HAVE_SYS_PARAM_H 30#include <sys/param.h> 31#endif 32#ifdef HAVE_SYS_STAT_H 33#include <sys/stat.h> 34#endif 35#ifdef HAVE_COPYFILE_H --- 88 unchanged lines hidden (view full) --- 124static void set_mode(struct bsdtar *, char opt); 125static void version(void) __LA_DEAD; 126 127/* A basic set of security flags to request from libarchive. */ 128#define SECURITY \ 129 (ARCHIVE_EXTRACT_SECURE_SYMLINKS \ 130 | ARCHIVE_EXTRACT_SECURE_NODOTDOT) 131 |
132static char const * const vcs_files[] = { 133 /* CVS */ 134 "CVS", ".cvsignore", 135 /* RCS */ 136 "RCS", 137 /* SCCS */ 138 "SCCS", 139 /* SVN */ 140 ".svn", 141 /* git */ 142 ".git", ".gitignore", ".gitattributes", ".gitmodules", 143 /* Arch */ 144 ".arch-ids", "{arch}", "=RELEASE-ID", "=meta-update", "=update", 145 /* Bazaar */ 146 ".bzr", ".bzrignore", ".bzrtags", 147 /* Mercurial */ 148 ".hg", ".hgignore", ".hgtags", 149 /* darcs */ 150 "_darcs", 151 NULL 152}; 153 |
|
132int 133main(int argc, char **argv) 134{ 135 struct bsdtar *bsdtar, bsdtar_storage; 136 int opt, t; 137 char compression, compression2; 138 const char *compression_name, *compression2_name; 139 const char *compress_program; --- 173 unchanged lines hidden (view full) --- 313 ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS; 314 break; 315 case OPTION_EXCLUDE: /* GNU tar */ 316 if (archive_match_exclude_pattern( 317 bsdtar->matching, bsdtar->argument) != ARCHIVE_OK) 318 lafe_errc(1, 0, 319 "Couldn't exclude %s\n", bsdtar->argument); 320 break; | 154int 155main(int argc, char **argv) 156{ 157 struct bsdtar *bsdtar, bsdtar_storage; 158 int opt, t; 159 char compression, compression2; 160 const char *compression_name, *compression2_name; 161 const char *compress_program; --- 173 unchanged lines hidden (view full) --- 335 ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS; 336 break; 337 case OPTION_EXCLUDE: /* GNU tar */ 338 if (archive_match_exclude_pattern( 339 bsdtar->matching, bsdtar->argument) != ARCHIVE_OK) 340 lafe_errc(1, 0, 341 "Couldn't exclude %s\n", bsdtar->argument); 342 break; |
343 case OPTION_EXCLUDE_VCS: /* GNU tar */ 344 for(t=0; vcs_files[t]; t++) { 345 if (archive_match_exclude_pattern( 346 bsdtar->matching, 347 vcs_files[t]) != ARCHIVE_OK) 348 lafe_errc(1, 0, "Couldn't " 349 "exclude %s\n", vcs_files[t]); 350 } 351 break; |
|
321 case OPTION_FFLAGS: 322 bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS; 323 bsdtar->readdisk_flags &= ~ARCHIVE_READDISK_NO_FFLAGS; 324 bsdtar->flags |= OPTFLAG_FFLAGS; 325 break; 326 case OPTION_FORMAT: /* GNU tar, others */ 327 cset_set_format(bsdtar->cset, bsdtar->argument); 328 break; --- 474 unchanged lines hidden (view full) --- 803 bsdtar->flags |= OPTFLAG_NO_OWNER; 804 bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_OWNER; 805 break; 806 default: 807 only_mode(bsdtar, "-o", "xc"); 808 break; 809 } 810 } | 352 case OPTION_FFLAGS: 353 bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS; 354 bsdtar->readdisk_flags &= ~ARCHIVE_READDISK_NO_FFLAGS; 355 bsdtar->flags |= OPTFLAG_FFLAGS; 356 break; 357 case OPTION_FORMAT: /* GNU tar, others */ 358 cset_set_format(bsdtar->cset, bsdtar->argument); 359 break; --- 474 unchanged lines hidden (view full) --- 834 bsdtar->flags |= OPTFLAG_NO_OWNER; 835 bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_OWNER; 836 break; 837 default: 838 only_mode(bsdtar, "-o", "xc"); 839 break; 840 } 841 } |
811 if (bsdtar->flags & OPTFLAG_NO_SUBDIRS) 812 only_mode(bsdtar, "-n", "cru"); | |
813 if (bsdtar->flags & OPTFLAG_STDOUT) 814 only_mode(bsdtar, "-O", "xt"); 815 if (bsdtar->flags & OPTFLAG_UNLINK_FIRST) 816 only_mode(bsdtar, "-U", "x"); 817 if (bsdtar->flags & OPTFLAG_WARN_LINKS) 818 only_mode(bsdtar, "--check-links", "cr"); 819 820 if ((bsdtar->flags & OPTFLAG_AUTO_COMPRESS) && --- 33 unchanged lines hidden (view full) --- 854 if (cset_get_format(bsdtar->cset) != NULL) 855 only_mode(bsdtar, "--format", "cru"); 856 if (bsdtar->symlink_mode != '\0') { 857 strcpy(buff, "-?"); 858 buff[1] = bsdtar->symlink_mode; 859 only_mode(bsdtar, buff, "cru"); 860 } 861 | 842 if (bsdtar->flags & OPTFLAG_STDOUT) 843 only_mode(bsdtar, "-O", "xt"); 844 if (bsdtar->flags & OPTFLAG_UNLINK_FIRST) 845 only_mode(bsdtar, "-U", "x"); 846 if (bsdtar->flags & OPTFLAG_WARN_LINKS) 847 only_mode(bsdtar, "--check-links", "cr"); 848 849 if ((bsdtar->flags & OPTFLAG_AUTO_COMPRESS) && --- 33 unchanged lines hidden (view full) --- 883 if (cset_get_format(bsdtar->cset) != NULL) 884 only_mode(bsdtar, "--format", "cru"); 885 if (bsdtar->symlink_mode != '\0') { 886 strcpy(buff, "-?"); 887 buff[1] = bsdtar->symlink_mode; 888 only_mode(bsdtar, buff, "cru"); 889 } 890 |
891 /* 892 * When creating an archive from a directory tree, the directory 893 * walking code will already avoid entering directories when 894 * recursive inclusion of directory content is disabled, therefore 895 * changing the matching behavior has no effect for creation modes. 896 * It is relevant for extraction or listing. 897 */ 898 archive_match_set_inclusion_recursion(bsdtar->matching, 899 !(bsdtar->flags & OPTFLAG_NO_SUBDIRS)); 900 |
|
862 /* Filename "-" implies stdio. */ 863 if (strcmp(bsdtar->filename, "-") == 0) 864 bsdtar->filename = NULL; 865 866 switch(bsdtar->mode) { 867 case 'c': 868 tar_mode_c(bsdtar); 869 break; --- 133 unchanged lines hidden --- | 901 /* Filename "-" implies stdio. */ 902 if (strcmp(bsdtar->filename, "-") == 0) 903 bsdtar->filename = NULL; 904 905 switch(bsdtar->mode) { 906 case 'c': 907 tar_mode_c(bsdtar); 908 break; --- 133 unchanged lines hidden --- |