mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-19 16:35:20 +01:00
Qt/QML edition
This commit is contained in:
commit
d7b361ba44
2168 changed files with 721948 additions and 0 deletions
50
dependencies/libarchive-3.4.2/tar/CMakeLists.txt
vendored
Normal file
50
dependencies/libarchive-3.4.2/tar/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
############################################
|
||||
#
|
||||
# How to build bsdtar
|
||||
#
|
||||
############################################
|
||||
IF(ENABLE_TAR)
|
||||
|
||||
SET(bsdtar_SOURCES
|
||||
bsdtar.c
|
||||
bsdtar.h
|
||||
bsdtar_platform.h
|
||||
cmdline.c
|
||||
creation_set.c
|
||||
read.c
|
||||
subst.c
|
||||
util.c
|
||||
write.c
|
||||
../libarchive_fe/err.c
|
||||
../libarchive_fe/err.h
|
||||
../libarchive_fe/lafe_platform.h
|
||||
../libarchive_fe/line_reader.c
|
||||
../libarchive_fe/line_reader.h
|
||||
../libarchive_fe/passphrase.c
|
||||
../libarchive_fe/passphrase.h
|
||||
)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libarchive_fe)
|
||||
IF(WIN32 AND NOT CYGWIN)
|
||||
LIST(APPEND bsdtar_SOURCES bsdtar_windows.c)
|
||||
LIST(APPEND bsdtar_SOURCES bsdtar_windows.h)
|
||||
ENDIF(WIN32 AND NOT CYGWIN)
|
||||
|
||||
# bsdtar documentation
|
||||
SET(bsdtar_MANS bsdtar.1)
|
||||
|
||||
# How to build bsdtar
|
||||
ADD_EXECUTABLE(bsdtar ${bsdtar_SOURCES})
|
||||
IF(ENABLE_TAR_SHARED)
|
||||
TARGET_LINK_LIBRARIES(bsdtar archive ${ADDITIONAL_LIBS})
|
||||
ELSE(ENABLE_TAR_SHARED)
|
||||
TARGET_LINK_LIBRARIES(bsdtar archive_static ${ADDITIONAL_LIBS})
|
||||
SET_TARGET_PROPERTIES(bsdtar PROPERTIES COMPILE_DEFINITIONS
|
||||
LIBARCHIVE_STATIC)
|
||||
ENDIF(ENABLE_TAR_SHARED)
|
||||
|
||||
# Installation rules
|
||||
INSTALL(TARGETS bsdtar RUNTIME DESTINATION bin)
|
||||
INSTALL_MAN(${bsdtar_MANS})
|
||||
ENDIF(ENABLE_TAR)
|
||||
|
||||
add_subdirectory(test)
|
1320
dependencies/libarchive-3.4.2/tar/bsdtar.1
vendored
Normal file
1320
dependencies/libarchive-3.4.2/tar/bsdtar.1
vendored
Normal file
File diff suppressed because it is too large
Load diff
1047
dependencies/libarchive-3.4.2/tar/bsdtar.c
vendored
Normal file
1047
dependencies/libarchive-3.4.2/tar/bsdtar.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
233
dependencies/libarchive-3.4.2/tar/bsdtar.h
vendored
Normal file
233
dependencies/libarchive-3.4.2/tar/bsdtar.h
vendored
Normal file
|
@ -0,0 +1,233 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD: src/usr.bin/tar/bsdtar.h,v 1.37 2008/12/06 07:37:14 kientzle Exp $
|
||||
*/
|
||||
|
||||
#ifndef BSDTAR_H_INCLUDED
|
||||
#define BSDTAR_H_INCLUDED
|
||||
|
||||
#include "bsdtar_platform.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define DEFAULT_BYTES_PER_BLOCK (20*512)
|
||||
#define ENV_READER_OPTIONS "TAR_READER_OPTIONS"
|
||||
#define ENV_WRITER_OPTIONS "TAR_WRITER_OPTIONS"
|
||||
#define IGNORE_WRONG_MODULE_NAME "__ignore_wrong_module_name__,"
|
||||
|
||||
struct creation_set;
|
||||
/*
|
||||
* The internal state for the "bsdtar" program.
|
||||
*
|
||||
* Keeping all of the state in a structure like this simplifies memory
|
||||
* leak testing (at exit, anything left on the heap is suspect). A
|
||||
* pointer to this structure is passed to most bsdtar internal
|
||||
* functions.
|
||||
*/
|
||||
struct bsdtar {
|
||||
/* Options */
|
||||
const char *filename; /* -f filename */
|
||||
char *pending_chdir; /* -C dir */
|
||||
const char *names_from_file; /* -T file */
|
||||
int bytes_per_block; /* -b block_size */
|
||||
int bytes_in_last_block; /* See -b handling. */
|
||||
int verbose; /* -v */
|
||||
unsigned int flags; /* Bitfield of boolean options */
|
||||
int extract_flags; /* Flags for extract operation */
|
||||
int readdisk_flags; /* Flags for read disk operation */
|
||||
int strip_components; /* Remove this many leading dirs */
|
||||
int gid; /* --gid */
|
||||
const char *gname; /* --gname */
|
||||
int uid; /* --uid */
|
||||
const char *uname; /* --uname */
|
||||
const char *passphrase; /* --passphrase */
|
||||
char mode; /* Program mode: 'c', 't', 'r', 'u', 'x' */
|
||||
char symlink_mode; /* H or L, per BSD conventions */
|
||||
const char *option_options; /* --options */
|
||||
char day_first; /* show day before month in -tv output */
|
||||
struct creation_set *cset;
|
||||
|
||||
/* Option parser state */
|
||||
int getopt_state;
|
||||
char *getopt_word;
|
||||
|
||||
/* If >= 0, then close this when done. */
|
||||
int fd;
|
||||
|
||||
/* Miscellaneous state information */
|
||||
int argc;
|
||||
char **argv;
|
||||
const char *argument;
|
||||
size_t gs_width; /* For 'list_item' in read.c */
|
||||
size_t u_width; /* for 'list_item' in read.c */
|
||||
uid_t user_uid; /* UID running this program */
|
||||
int return_value; /* Value returned by main() */
|
||||
char warned_lead_slash; /* Already displayed warning */
|
||||
char next_line_is_dir; /* Used for -C parsing in -cT */
|
||||
|
||||
/*
|
||||
* Data for various subsystems. Full definitions are located in
|
||||
* the file where they are used.
|
||||
*/
|
||||
struct archive *diskreader; /* for write.c */
|
||||
struct archive_entry_linkresolver *resolver; /* for write.c */
|
||||
struct archive_dir *archive_dir; /* for write.c */
|
||||
struct name_cache *gname_cache; /* for write.c */
|
||||
char *buff; /* for write.c */
|
||||
size_t buff_size; /* for write.c */
|
||||
int first_fs; /* for write.c */
|
||||
struct archive *matching; /* for matching.c */
|
||||
struct security *security; /* for read.c */
|
||||
struct name_cache *uname_cache; /* for write.c */
|
||||
struct siginfo_data *siginfo; /* for siginfo.c */
|
||||
struct substitution *substitution; /* for subst.c */
|
||||
char *ppbuff; /* for util.c */
|
||||
};
|
||||
|
||||
/* Options for flags bitfield */
|
||||
#define OPTFLAG_AUTO_COMPRESS (0x00000001) /* -a */
|
||||
#define OPTFLAG_ABSOLUTE_PATHS (0x00000002) /* -P */
|
||||
#define OPTFLAG_CHROOT (0x00000004) /* --chroot */
|
||||
#define OPTFLAG_FAST_READ (0x00000008) /* --fast-read */
|
||||
#define OPTFLAG_IGNORE_ZEROS (0x00000010) /* --ignore-zeros */
|
||||
#define OPTFLAG_INTERACTIVE (0x00000020) /* -w */
|
||||
#define OPTFLAG_NO_OWNER (0x00000040) /* -o */
|
||||
#define OPTFLAG_NO_SUBDIRS (0x00000080) /* -n */
|
||||
#define OPTFLAG_NULL (0x00000100) /* --null */
|
||||
#define OPTFLAG_NUMERIC_OWNER (0x00000200) /* --numeric-owner */
|
||||
#define OPTFLAG_O (0x00000400) /* -o */
|
||||
#define OPTFLAG_STDOUT (0x00000800) /* -O */
|
||||
#define OPTFLAG_TOTALS (0x00001000) /* --totals */
|
||||
#define OPTFLAG_UNLINK_FIRST (0x00002000) /* -U */
|
||||
#define OPTFLAG_WARN_LINKS (0x00004000) /* --check-links */
|
||||
#define OPTFLAG_NO_XATTRS (0x00008000) /* --no-xattrs */
|
||||
#define OPTFLAG_XATTRS (0x00010000) /* --xattrs */
|
||||
#define OPTFLAG_NO_ACLS (0x00020000) /* --no-acls */
|
||||
#define OPTFLAG_ACLS (0x00040000) /* --acls */
|
||||
#define OPTFLAG_NO_FFLAGS (0x00080000) /* --no-fflags */
|
||||
#define OPTFLAG_FFLAGS (0x00100000) /* --fflags */
|
||||
#define OPTFLAG_NO_MAC_METADATA (0x00200000) /* --no-mac-metadata */
|
||||
#define OPTFLAG_MAC_METADATA (0x00400000) /* --mac-metadata */
|
||||
|
||||
/* Fake short equivalents for long options that otherwise lack them. */
|
||||
enum {
|
||||
OPTION_ACLS = 1,
|
||||
OPTION_B64ENCODE,
|
||||
OPTION_CHECK_LINKS,
|
||||
OPTION_CHROOT,
|
||||
OPTION_CLEAR_NOCHANGE_FFLAGS,
|
||||
OPTION_EXCLUDE,
|
||||
OPTION_EXCLUDE_VCS,
|
||||
OPTION_FFLAGS,
|
||||
OPTION_FORMAT,
|
||||
OPTION_GID,
|
||||
OPTION_GNAME,
|
||||
OPTION_GRZIP,
|
||||
OPTION_HELP,
|
||||
OPTION_HFS_COMPRESSION,
|
||||
OPTION_IGNORE_ZEROS,
|
||||
OPTION_INCLUDE,
|
||||
OPTION_KEEP_NEWER_FILES,
|
||||
OPTION_LRZIP,
|
||||
OPTION_LZ4,
|
||||
OPTION_LZIP,
|
||||
OPTION_LZMA,
|
||||
OPTION_LZOP,
|
||||
OPTION_MAC_METADATA,
|
||||
OPTION_NEWER_CTIME,
|
||||
OPTION_NEWER_CTIME_THAN,
|
||||
OPTION_NEWER_MTIME,
|
||||
OPTION_NEWER_MTIME_THAN,
|
||||
OPTION_NODUMP,
|
||||
OPTION_NOPRESERVE_HFS_COMPRESSION,
|
||||
OPTION_NO_ACLS,
|
||||
OPTION_NO_FFLAGS,
|
||||
OPTION_NO_MAC_METADATA,
|
||||
OPTION_NO_SAFE_WRITES,
|
||||
OPTION_NO_SAME_OWNER,
|
||||
OPTION_NO_SAME_PERMISSIONS,
|
||||
OPTION_NO_XATTRS,
|
||||
OPTION_NULL,
|
||||
OPTION_NUMERIC_OWNER,
|
||||
OPTION_OLDER_CTIME,
|
||||
OPTION_OLDER_CTIME_THAN,
|
||||
OPTION_OLDER_MTIME,
|
||||
OPTION_OLDER_MTIME_THAN,
|
||||
OPTION_ONE_FILE_SYSTEM,
|
||||
OPTION_OPTIONS,
|
||||
OPTION_PASSPHRASE,
|
||||
OPTION_POSIX,
|
||||
OPTION_SAFE_WRITES,
|
||||
OPTION_SAME_OWNER,
|
||||
OPTION_STRIP_COMPONENTS,
|
||||
OPTION_TOTALS,
|
||||
OPTION_UID,
|
||||
OPTION_UNAME,
|
||||
OPTION_USE_COMPRESS_PROGRAM,
|
||||
OPTION_UUENCODE,
|
||||
OPTION_VERSION,
|
||||
OPTION_XATTRS,
|
||||
OPTION_ZSTD,
|
||||
};
|
||||
|
||||
int bsdtar_getopt(struct bsdtar *);
|
||||
void do_chdir(struct bsdtar *);
|
||||
int edit_pathname(struct bsdtar *, struct archive_entry *);
|
||||
int need_report(void);
|
||||
int pathcmp(const char *a, const char *b);
|
||||
void safe_fprintf(FILE *, const char *fmt, ...) __LA_PRINTF(2, 3);
|
||||
void set_chdir(struct bsdtar *, const char *newdir);
|
||||
const char *tar_i64toa(int64_t);
|
||||
void tar_mode_c(struct bsdtar *bsdtar);
|
||||
void tar_mode_r(struct bsdtar *bsdtar);
|
||||
void tar_mode_t(struct bsdtar *bsdtar);
|
||||
void tar_mode_u(struct bsdtar *bsdtar);
|
||||
void tar_mode_x(struct bsdtar *bsdtar);
|
||||
void usage(void) __LA_DEAD;
|
||||
int yes(const char *fmt, ...) __LA_PRINTF(1, 2);
|
||||
|
||||
#if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H)
|
||||
void add_substitution(struct bsdtar *, const char *);
|
||||
int apply_substitution(struct bsdtar *, const char *, char **, int, int);
|
||||
void cleanup_substitution(struct bsdtar *);
|
||||
#endif
|
||||
|
||||
void cset_add_filter(struct creation_set *, const char *);
|
||||
void cset_add_filter_program(struct creation_set *, const char *);
|
||||
int cset_auto_compress(struct creation_set *, const char *);
|
||||
void cset_free(struct creation_set *);
|
||||
const char * cset_get_format(struct creation_set *);
|
||||
struct creation_set *cset_new(void);
|
||||
int cset_read_support_filter_program(struct creation_set *,
|
||||
struct archive *);
|
||||
void cset_set_format(struct creation_set *, const char *);
|
||||
int cset_write_add_filters(struct creation_set *,
|
||||
struct archive *, const void **);
|
||||
|
||||
const char * passphrase_callback(struct archive *, void *);
|
||||
void passphrase_free(char *);
|
||||
void list_item_verbose(struct bsdtar *, FILE *,
|
||||
struct archive_entry *);
|
||||
|
||||
#endif
|
132
dependencies/libarchive-3.4.2/tar/bsdtar_platform.h
vendored
Normal file
132
dependencies/libarchive-3.4.2/tar/bsdtar_platform.h
vendored
Normal file
|
@ -0,0 +1,132 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD: src/usr.bin/tar/bsdtar_platform.h,v 1.26 2008/12/06 07:37:14 kientzle Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* This header is the first thing included in any of the bsdtar
|
||||
* source files. As far as possible, platform-specific issues should
|
||||
* be dealt with here and not within individual source files.
|
||||
*/
|
||||
|
||||
#ifndef BSDTAR_PLATFORM_H_INCLUDED
|
||||
#define BSDTAR_PLATFORM_H_INCLUDED
|
||||
|
||||
#if defined(PLATFORM_CONFIG_H)
|
||||
/* Use hand-built config.h in environments that need it. */
|
||||
#include PLATFORM_CONFIG_H
|
||||
#else
|
||||
/* Not having a config.h of some sort is a serious problem. */
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include "bsdtar_windows.h"
|
||||
#endif
|
||||
|
||||
/* Get a real definition for __FBSDID if we can */
|
||||
#if HAVE_SYS_CDEFS_H
|
||||
#include <sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
/* If not, define it so as to avoid dangling semicolons. */
|
||||
#ifndef __FBSDID
|
||||
#define __FBSDID(a) struct _undefined_hack
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBARCHIVE
|
||||
/* If we're using the platform libarchive, include system headers. */
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
#else
|
||||
/* Otherwise, include user headers. */
|
||||
#include "archive.h"
|
||||
#include "archive_entry.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBACL
|
||||
#include <acl/libacl.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Include "dirent.h" (or its equivalent on several different platforms).
|
||||
*
|
||||
* This is slightly modified from the GNU autoconf recipe.
|
||||
* In particular, FreeBSD includes d_namlen in its dirent structure,
|
||||
* so my configure script includes an explicit test for the d_namlen
|
||||
* field.
|
||||
*/
|
||||
#if HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
# if HAVE_DIRENT_D_NAMLEN
|
||||
# define DIRENT_NAMLEN(dirent) (dirent)->d_namlen
|
||||
# else
|
||||
# define DIRENT_NAMLEN(dirent) strlen((dirent)->d_name)
|
||||
# endif
|
||||
#else
|
||||
# define dirent direct
|
||||
# define DIRENT_NAMLEN(dirent) (dirent)->d_namlen
|
||||
# if HAVE_SYS_NDIR_H
|
||||
# include <sys/ndir.h>
|
||||
# endif
|
||||
# if HAVE_SYS_DIR_H
|
||||
# include <sys/dir.h>
|
||||
# endif
|
||||
# if HAVE_NDIR_H
|
||||
# include <ndir.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
|
||||
#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctimespec.tv_nsec
|
||||
#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtimespec.tv_nsec
|
||||
#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
|
||||
#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctim.tv_nsec
|
||||
#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtim.tv_nsec
|
||||
#elif HAVE_STRUCT_STAT_ST_MTIME_N
|
||||
#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctime_n
|
||||
#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtime_n
|
||||
#elif HAVE_STRUCT_STAT_ST_UMTIME
|
||||
#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_uctime * 1000
|
||||
#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_umtime * 1000
|
||||
#elif HAVE_STRUCT_STAT_ST_MTIME_USEC
|
||||
#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctime_usec * 1000
|
||||
#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtime_usec * 1000
|
||||
#else
|
||||
#define ARCHIVE_STAT_CTIME_NANOS(st) (0)
|
||||
#define ARCHIVE_STAT_MTIME_NANOS(st) (0)
|
||||
#endif
|
||||
|
||||
/* How to mark functions that don't return. */
|
||||
/* This facilitates use of some newer static code analysis tools. */
|
||||
#undef __LA_DEAD
|
||||
#if defined(__GNUC__) && (__GNUC__ > 2 || \
|
||||
(__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
|
||||
#define __LA_DEAD __attribute__((__noreturn__))
|
||||
#else
|
||||
#define __LA_DEAD
|
||||
#endif
|
||||
|
||||
#endif /* !BSDTAR_PLATFORM_H_INCLUDED */
|
298
dependencies/libarchive-3.4.2/tar/bsdtar_windows.c
vendored
Normal file
298
dependencies/libarchive-3.4.2/tar/bsdtar_windows.c
vendored
Normal file
|
@ -0,0 +1,298 @@
|
|||
/*-
|
||||
* Copyright (c) 2009 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
|
||||
#include "bsdtar_platform.h"
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <stddef.h>
|
||||
#ifdef HAVE_SYS_UTIME_H
|
||||
#include <sys/utime.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <process.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <windows.h>
|
||||
#include <sddl.h>
|
||||
|
||||
#include "bsdtar.h"
|
||||
#include "err.h"
|
||||
|
||||
/* This may actually not be needed anymore.
|
||||
* TODO: Review the error handling for chdir() failures and
|
||||
* simply dump this if it's not really needed. */
|
||||
static void __tar_dosmaperr(unsigned long);
|
||||
|
||||
/*
|
||||
* Prepend "\\?\" to the path name and convert it to unicode to permit
|
||||
* an extended-length path for a maximum total path length of 32767
|
||||
* characters.
|
||||
* see also http://msdn.microsoft.com/en-us/library/aa365247.aspx
|
||||
*/
|
||||
static wchar_t *
|
||||
permissive_name(const char *name)
|
||||
{
|
||||
wchar_t *wn, *wnp;
|
||||
wchar_t *ws, *wsp;
|
||||
DWORD l, len, slen, alloclen;
|
||||
int unc;
|
||||
|
||||
len = (DWORD)strlen(name);
|
||||
wn = malloc((len + 1) * sizeof(wchar_t));
|
||||
if (wn == NULL)
|
||||
return (NULL);
|
||||
l = MultiByteToWideChar(CP_ACP, 0, name, len, wn, len);
|
||||
if (l == 0) {
|
||||
free(wn);
|
||||
return (NULL);
|
||||
}
|
||||
wn[l] = L'\0';
|
||||
|
||||
/* Get a full path names */
|
||||
l = GetFullPathNameW(wn, 0, NULL, NULL);
|
||||
if (l == 0) {
|
||||
free(wn);
|
||||
return (NULL);
|
||||
}
|
||||
wnp = malloc(l * sizeof(wchar_t));
|
||||
if (wnp == NULL) {
|
||||
free(wn);
|
||||
return (NULL);
|
||||
}
|
||||
len = GetFullPathNameW(wn, l, wnp, NULL);
|
||||
free(wn);
|
||||
wn = wnp;
|
||||
|
||||
if (wnp[0] == L'\\' && wnp[1] == L'\\' &&
|
||||
wnp[2] == L'?' && wnp[3] == L'\\')
|
||||
/* We have already permissive names. */
|
||||
return (wn);
|
||||
|
||||
if (wnp[0] == L'\\' && wnp[1] == L'\\' &&
|
||||
wnp[2] == L'.' && wnp[3] == L'\\') {
|
||||
/* Device names */
|
||||
if (((wnp[4] >= L'a' && wnp[4] <= L'z') ||
|
||||
(wnp[4] >= L'A' && wnp[4] <= L'Z')) &&
|
||||
wnp[5] == L':' && wnp[6] == L'\\')
|
||||
wnp[2] = L'?';/* Not device names. */
|
||||
return (wn);
|
||||
}
|
||||
|
||||
unc = 0;
|
||||
if (wnp[0] == L'\\' && wnp[1] == L'\\' && wnp[2] != L'\\') {
|
||||
wchar_t *p = &wnp[2];
|
||||
|
||||
/* Skip server-name letters. */
|
||||
while (*p != L'\\' && *p != L'\0')
|
||||
++p;
|
||||
if (*p == L'\\') {
|
||||
wchar_t *rp = ++p;
|
||||
/* Skip share-name letters. */
|
||||
while (*p != L'\\' && *p != L'\0')
|
||||
++p;
|
||||
if (*p == L'\\' && p != rp) {
|
||||
/* Now, match patterns such as
|
||||
* "\\server-name\share-name\" */
|
||||
wnp += 2;
|
||||
len -= 2;
|
||||
unc = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
alloclen = slen = 4 + (unc * 4) + len + 1;
|
||||
ws = wsp = malloc(slen * sizeof(wchar_t));
|
||||
if (ws == NULL) {
|
||||
free(wn);
|
||||
return (NULL);
|
||||
}
|
||||
/* prepend "\\?\" */
|
||||
wcsncpy(wsp, L"\\\\?\\", 4);
|
||||
wsp += 4;
|
||||
slen -= 4;
|
||||
if (unc) {
|
||||
/* append "UNC\" ---> "\\?\UNC\" */
|
||||
wcsncpy(wsp, L"UNC\\", 4);
|
||||
wsp += 4;
|
||||
slen -= 4;
|
||||
}
|
||||
wcsncpy(wsp, wnp, slen);
|
||||
free(wn);
|
||||
ws[alloclen - 1] = L'\0';
|
||||
return (ws);
|
||||
}
|
||||
|
||||
int
|
||||
__tar_chdir(const char *path)
|
||||
{
|
||||
wchar_t *ws;
|
||||
int r;
|
||||
|
||||
r = SetCurrentDirectoryA(path);
|
||||
if (r == 0) {
|
||||
if (GetLastError() != ERROR_FILE_NOT_FOUND) {
|
||||
__tar_dosmaperr(GetLastError());
|
||||
return (-1);
|
||||
}
|
||||
} else
|
||||
return (0);
|
||||
ws = permissive_name(path);
|
||||
if (ws == NULL) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
r = SetCurrentDirectoryW(ws);
|
||||
free(ws);
|
||||
if (r == 0) {
|
||||
__tar_dosmaperr(GetLastError());
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The following function was modified from PostgreSQL sources and is
|
||||
* subject to the copyright below.
|
||||
*/
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* win32error.c
|
||||
* Map win32 error codes to errno values
|
||||
*
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/port/win32error.c,v 1.4 2008/01/01 19:46:00 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
/*
|
||||
PostgreSQL Database Management System
|
||||
(formerly known as Postgres, then as Postgres95)
|
||||
|
||||
Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
|
||||
Portions Copyright (c) 1994, The Regents of the University of California
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose, without fee, and without a written agreement
|
||||
is hereby granted, provided that the above copyright notice and this
|
||||
paragraph and the following two paragraphs appear in all copies.
|
||||
|
||||
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
|
||||
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
||||
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
||||
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
|
||||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*/
|
||||
|
||||
static const struct {
|
||||
DWORD winerr;
|
||||
int doserr;
|
||||
} doserrors[] =
|
||||
{
|
||||
{ ERROR_INVALID_FUNCTION, EINVAL },
|
||||
{ ERROR_FILE_NOT_FOUND, ENOENT },
|
||||
{ ERROR_PATH_NOT_FOUND, ENOENT },
|
||||
{ ERROR_TOO_MANY_OPEN_FILES, EMFILE },
|
||||
{ ERROR_ACCESS_DENIED, EACCES },
|
||||
{ ERROR_INVALID_HANDLE, EBADF },
|
||||
{ ERROR_ARENA_TRASHED, ENOMEM },
|
||||
{ ERROR_NOT_ENOUGH_MEMORY, ENOMEM },
|
||||
{ ERROR_INVALID_BLOCK, ENOMEM },
|
||||
{ ERROR_BAD_ENVIRONMENT, E2BIG },
|
||||
{ ERROR_BAD_FORMAT, ENOEXEC },
|
||||
{ ERROR_INVALID_ACCESS, EINVAL },
|
||||
{ ERROR_INVALID_DATA, EINVAL },
|
||||
{ ERROR_INVALID_DRIVE, ENOENT },
|
||||
{ ERROR_CURRENT_DIRECTORY, EACCES },
|
||||
{ ERROR_NOT_SAME_DEVICE, EXDEV },
|
||||
{ ERROR_NO_MORE_FILES, ENOENT },
|
||||
{ ERROR_LOCK_VIOLATION, EACCES },
|
||||
{ ERROR_SHARING_VIOLATION, EACCES },
|
||||
{ ERROR_BAD_NETPATH, ENOENT },
|
||||
{ ERROR_NETWORK_ACCESS_DENIED, EACCES },
|
||||
{ ERROR_BAD_NET_NAME, ENOENT },
|
||||
{ ERROR_FILE_EXISTS, EEXIST },
|
||||
{ ERROR_CANNOT_MAKE, EACCES },
|
||||
{ ERROR_FAIL_I24, EACCES },
|
||||
{ ERROR_INVALID_PARAMETER, EINVAL },
|
||||
{ ERROR_NO_PROC_SLOTS, EAGAIN },
|
||||
{ ERROR_DRIVE_LOCKED, EACCES },
|
||||
{ ERROR_BROKEN_PIPE, EPIPE },
|
||||
{ ERROR_DISK_FULL, ENOSPC },
|
||||
{ ERROR_INVALID_TARGET_HANDLE, EBADF },
|
||||
{ ERROR_INVALID_HANDLE, EINVAL },
|
||||
{ ERROR_WAIT_NO_CHILDREN, ECHILD },
|
||||
{ ERROR_CHILD_NOT_COMPLETE, ECHILD },
|
||||
{ ERROR_DIRECT_ACCESS_HANDLE, EBADF },
|
||||
{ ERROR_NEGATIVE_SEEK, EINVAL },
|
||||
{ ERROR_SEEK_ON_DEVICE, EACCES },
|
||||
{ ERROR_DIR_NOT_EMPTY, ENOTEMPTY },
|
||||
{ ERROR_NOT_LOCKED, EACCES },
|
||||
{ ERROR_BAD_PATHNAME, ENOENT },
|
||||
{ ERROR_MAX_THRDS_REACHED, EAGAIN },
|
||||
{ ERROR_LOCK_FAILED, EACCES },
|
||||
{ ERROR_ALREADY_EXISTS, EEXIST },
|
||||
{ ERROR_FILENAME_EXCED_RANGE, ENOENT },
|
||||
{ ERROR_NESTING_NOT_ALLOWED, EAGAIN },
|
||||
{ ERROR_NOT_ENOUGH_QUOTA, ENOMEM }
|
||||
};
|
||||
|
||||
static void
|
||||
__tar_dosmaperr(unsigned long e)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (e == 0) {
|
||||
errno = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)sizeof(doserrors); i++) {
|
||||
if (doserrors[i].winerr == e) {
|
||||
errno = doserrors[i].doserr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* fprintf(stderr, "unrecognized win32 error code: %lu", e); */
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
66
dependencies/libarchive-3.4.2/tar/bsdtar_windows.h
vendored
Normal file
66
dependencies/libarchive-3.4.2/tar/bsdtar_windows.h
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
/*-
|
||||
* Copyright (c) 2009 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef BSDTAR_WINDOWS_H
|
||||
#define BSDTAR_WINDOWS_H 1
|
||||
#include <direct.h>
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifndef PRId64
|
||||
#define PRId64 "I64"
|
||||
#endif
|
||||
#define geteuid() 0
|
||||
|
||||
#ifndef __WATCOMC__
|
||||
|
||||
#ifndef S_IFIFO
|
||||
#define S_IFIFO 0010000 /* pipe */
|
||||
#endif
|
||||
|
||||
#include <string.h> /* Must include before redefining 'strdup' */
|
||||
#if !defined(__BORLANDC__)
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
#if !defined(__BORLANDC__)
|
||||
#define getcwd _getcwd
|
||||
#endif
|
||||
|
||||
#define chdir __tar_chdir
|
||||
int __tar_chdir(const char *);
|
||||
|
||||
#ifndef S_ISREG
|
||||
#define S_ISREG(a) (a & _S_IFREG)
|
||||
#endif
|
||||
#ifndef S_ISBLK
|
||||
#define S_ISBLK(a) (0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* BSDTAR_WINDOWS_H */
|
417
dependencies/libarchive-3.4.2/tar/cmdline.c
vendored
Normal file
417
dependencies/libarchive-3.4.2/tar/cmdline.c
vendored
Normal file
|
@ -0,0 +1,417 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2008 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Command line parser for tar.
|
||||
*/
|
||||
|
||||
#include "bsdtar_platform.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "bsdtar.h"
|
||||
#include "err.h"
|
||||
|
||||
/*
|
||||
* Short options for tar. Please keep this sorted.
|
||||
*/
|
||||
static const char *short_options
|
||||
= "aBb:C:cf:HhI:JjkLlmnOoPpqrSs:T:tUuvW:wX:xyZz";
|
||||
|
||||
/*
|
||||
* Long options for tar. Please keep this list sorted.
|
||||
*
|
||||
* The symbolic names for options that lack a short equivalent are
|
||||
* defined in bsdtar.h. Also note that so far I've found no need
|
||||
* to support optional arguments to long options. That would be
|
||||
* a small change to the code below.
|
||||
*/
|
||||
|
||||
static const struct bsdtar_option {
|
||||
const char *name;
|
||||
int required; /* 1 if this option requires an argument. */
|
||||
int equivalent; /* Equivalent short option. */
|
||||
} tar_longopts[] = {
|
||||
{ "absolute-paths", 0, 'P' },
|
||||
{ "append", 0, 'r' },
|
||||
{ "acls", 0, OPTION_ACLS },
|
||||
{ "auto-compress", 0, 'a' },
|
||||
{ "b64encode", 0, OPTION_B64ENCODE },
|
||||
{ "block-size", 1, 'b' },
|
||||
{ "blocking-factor", 1, 'b' },
|
||||
{ "bunzip2", 0, 'j' },
|
||||
{ "bzip", 0, 'j' },
|
||||
{ "bzip2", 0, 'j' },
|
||||
{ "cd", 1, 'C' },
|
||||
{ "check-links", 0, OPTION_CHECK_LINKS },
|
||||
{ "chroot", 0, OPTION_CHROOT },
|
||||
{ "clear-nochange-fflags", 0, OPTION_CLEAR_NOCHANGE_FFLAGS },
|
||||
{ "compress", 0, 'Z' },
|
||||
{ "confirmation", 0, 'w' },
|
||||
{ "create", 0, 'c' },
|
||||
{ "dereference", 0, 'L' },
|
||||
{ "directory", 1, 'C' },
|
||||
{ "disable-copyfile", 0, OPTION_NO_MAC_METADATA },
|
||||
{ "exclude", 1, OPTION_EXCLUDE },
|
||||
{ "exclude-from", 1, 'X' },
|
||||
{ "exclude-vcs", 0, OPTION_EXCLUDE_VCS },
|
||||
{ "extract", 0, 'x' },
|
||||
{ "fast-read", 0, 'q' },
|
||||
{ "fflags", 0, OPTION_FFLAGS },
|
||||
{ "file", 1, 'f' },
|
||||
{ "files-from", 1, 'T' },
|
||||
{ "format", 1, OPTION_FORMAT },
|
||||
{ "gid", 1, OPTION_GID },
|
||||
{ "gname", 1, OPTION_GNAME },
|
||||
{ "grzip", 0, OPTION_GRZIP },
|
||||
{ "gunzip", 0, 'z' },
|
||||
{ "gzip", 0, 'z' },
|
||||
{ "help", 0, OPTION_HELP },
|
||||
{ "hfsCompression", 0, OPTION_HFS_COMPRESSION },
|
||||
{ "ignore-zeros", 0, OPTION_IGNORE_ZEROS },
|
||||
{ "include", 1, OPTION_INCLUDE },
|
||||
{ "insecure", 0, 'P' },
|
||||
{ "interactive", 0, 'w' },
|
||||
{ "keep-newer-files", 0, OPTION_KEEP_NEWER_FILES },
|
||||
{ "keep-old-files", 0, 'k' },
|
||||
{ "list", 0, 't' },
|
||||
{ "lrzip", 0, OPTION_LRZIP },
|
||||
{ "lz4", 0, OPTION_LZ4 },
|
||||
{ "lzip", 0, OPTION_LZIP },
|
||||
{ "lzma", 0, OPTION_LZMA },
|
||||
{ "lzop", 0, OPTION_LZOP },
|
||||
{ "mac-metadata", 0, OPTION_MAC_METADATA },
|
||||
{ "modification-time", 0, 'm' },
|
||||
{ "newer", 1, OPTION_NEWER_CTIME },
|
||||
{ "newer-ctime", 1, OPTION_NEWER_CTIME },
|
||||
{ "newer-ctime-than", 1, OPTION_NEWER_CTIME_THAN },
|
||||
{ "newer-mtime", 1, OPTION_NEWER_MTIME },
|
||||
{ "newer-mtime-than", 1, OPTION_NEWER_MTIME_THAN },
|
||||
{ "newer-than", 1, OPTION_NEWER_CTIME_THAN },
|
||||
{ "no-acls", 0, OPTION_NO_ACLS },
|
||||
{ "no-fflags", 0, OPTION_NO_FFLAGS },
|
||||
{ "no-mac-metadata", 0, OPTION_NO_MAC_METADATA },
|
||||
{ "no-recursion", 0, 'n' },
|
||||
{ "no-safe-writes", 0, OPTION_NO_SAFE_WRITES },
|
||||
{ "no-same-owner", 0, OPTION_NO_SAME_OWNER },
|
||||
{ "no-same-permissions", 0, OPTION_NO_SAME_PERMISSIONS },
|
||||
{ "no-xattr", 0, OPTION_NO_XATTRS },
|
||||
{ "no-xattrs", 0, OPTION_NO_XATTRS },
|
||||
{ "nodump", 0, OPTION_NODUMP },
|
||||
{ "nopreserveHFSCompression",0, OPTION_NOPRESERVE_HFS_COMPRESSION },
|
||||
{ "norecurse", 0, 'n' },
|
||||
{ "null", 0, OPTION_NULL },
|
||||
{ "numeric-owner", 0, OPTION_NUMERIC_OWNER },
|
||||
{ "older", 1, OPTION_OLDER_CTIME },
|
||||
{ "older-ctime", 1, OPTION_OLDER_CTIME },
|
||||
{ "older-ctime-than", 1, OPTION_OLDER_CTIME_THAN },
|
||||
{ "older-mtime", 1, OPTION_OLDER_MTIME },
|
||||
{ "older-mtime-than", 1, OPTION_OLDER_MTIME_THAN },
|
||||
{ "older-than", 1, OPTION_OLDER_CTIME_THAN },
|
||||
{ "one-file-system", 0, OPTION_ONE_FILE_SYSTEM },
|
||||
{ "options", 1, OPTION_OPTIONS },
|
||||
{ "passphrase", 1, OPTION_PASSPHRASE },
|
||||
{ "posix", 0, OPTION_POSIX },
|
||||
{ "preserve-permissions", 0, 'p' },
|
||||
{ "read-full-blocks", 0, 'B' },
|
||||
{ "safe-writes", 0, OPTION_SAFE_WRITES },
|
||||
{ "same-owner", 0, OPTION_SAME_OWNER },
|
||||
{ "same-permissions", 0, 'p' },
|
||||
{ "strip-components", 1, OPTION_STRIP_COMPONENTS },
|
||||
{ "to-stdout", 0, 'O' },
|
||||
{ "totals", 0, OPTION_TOTALS },
|
||||
{ "uid", 1, OPTION_UID },
|
||||
{ "uname", 1, OPTION_UNAME },
|
||||
{ "uncompress", 0, 'Z' },
|
||||
{ "unlink", 0, 'U' },
|
||||
{ "unlink-first", 0, 'U' },
|
||||
{ "update", 0, 'u' },
|
||||
{ "use-compress-program", 1, OPTION_USE_COMPRESS_PROGRAM },
|
||||
{ "uuencode", 0, OPTION_UUENCODE },
|
||||
{ "verbose", 0, 'v' },
|
||||
{ "version", 0, OPTION_VERSION },
|
||||
{ "xattrs", 0, OPTION_XATTRS },
|
||||
{ "xz", 0, 'J' },
|
||||
{ "zstd", 0, OPTION_ZSTD },
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
* This getopt implementation has two key features that common
|
||||
* getopt_long() implementations lack. Apart from those, it's a
|
||||
* straightforward option parser, considerably simplified by not
|
||||
* needing to support the wealth of exotic getopt_long() features. It
|
||||
* has, of course, been shamelessly tailored for bsdtar. (If you're
|
||||
* looking for a generic getopt_long() implementation for your
|
||||
* project, I recommend Gregory Pietsch's public domain getopt_long()
|
||||
* implementation.) The two additional features are:
|
||||
*
|
||||
* Old-style tar arguments: The original tar implementation treated
|
||||
* the first argument word as a list of single-character option
|
||||
* letters. All arguments follow as separate words. For example,
|
||||
* tar xbf 32 /dev/tape
|
||||
* Here, the "xbf" is three option letters, "32" is the argument for
|
||||
* "b" and "/dev/tape" is the argument for "f". We support this usage
|
||||
* if the first command-line argument does not begin with '-'. We
|
||||
* also allow regular short and long options to follow, e.g.,
|
||||
* tar xbf 32 /dev/tape -P --format=pax
|
||||
*
|
||||
* -W long options: There's an obscure GNU convention (only rarely
|
||||
* supported even there) that allows "-W option=argument" as an
|
||||
* alternative way to support long options. This was supported in
|
||||
* early bsdtar as a way to access long options on platforms that did
|
||||
* not support getopt_long() and is preserved here for backwards
|
||||
* compatibility. (Of course, if I'd started with a custom
|
||||
* command-line parser from the beginning, I would have had normal
|
||||
* long option support on every platform so that hack wouldn't have
|
||||
* been necessary. Oh, well. Some mistakes you just have to live
|
||||
* with.)
|
||||
*
|
||||
* TODO: We should be able to use this to pull files and intermingled
|
||||
* options (such as -C) from the command line in write mode. That
|
||||
* will require a little rethinking of the argument handling in
|
||||
* bsdtar.c.
|
||||
*
|
||||
* TODO: If we want to support arbitrary command-line options from -T
|
||||
* input (as GNU tar does), we may need to extend this to handle option
|
||||
* words from sources other than argv/argc. I'm not really sure if I
|
||||
* like that feature of GNU tar, so it's certainly not a priority.
|
||||
*/
|
||||
|
||||
int
|
||||
bsdtar_getopt(struct bsdtar *bsdtar)
|
||||
{
|
||||
enum { state_start = 0, state_old_tar, state_next_word,
|
||||
state_short, state_long };
|
||||
|
||||
const struct bsdtar_option *popt, *match = NULL, *match2 = NULL;
|
||||
const char *p, *long_prefix = "--";
|
||||
size_t optlength;
|
||||
int opt = '?';
|
||||
int required = 0;
|
||||
|
||||
bsdtar->argument = NULL;
|
||||
|
||||
/* First time through, initialize everything. */
|
||||
if (bsdtar->getopt_state == state_start) {
|
||||
/* Skip program name. */
|
||||
++bsdtar->argv;
|
||||
--bsdtar->argc;
|
||||
if (*bsdtar->argv == NULL)
|
||||
return (-1);
|
||||
/* Decide between "new style" and "old style" arguments. */
|
||||
if (bsdtar->argv[0][0] == '-') {
|
||||
bsdtar->getopt_state = state_next_word;
|
||||
} else {
|
||||
bsdtar->getopt_state = state_old_tar;
|
||||
bsdtar->getopt_word = *bsdtar->argv++;
|
||||
--bsdtar->argc;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We're parsing old-style tar arguments
|
||||
*/
|
||||
if (bsdtar->getopt_state == state_old_tar) {
|
||||
/* Get the next option character. */
|
||||
opt = *bsdtar->getopt_word++;
|
||||
if (opt == '\0') {
|
||||
/* New-style args can follow old-style. */
|
||||
bsdtar->getopt_state = state_next_word;
|
||||
} else {
|
||||
/* See if it takes an argument. */
|
||||
p = strchr(short_options, opt);
|
||||
if (p == NULL)
|
||||
return ('?');
|
||||
if (p[1] == ':') {
|
||||
bsdtar->argument = *bsdtar->argv;
|
||||
if (bsdtar->argument == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %c requires an argument",
|
||||
opt);
|
||||
return ('?');
|
||||
}
|
||||
++bsdtar->argv;
|
||||
--bsdtar->argc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We're ready to look at the next word in argv.
|
||||
*/
|
||||
if (bsdtar->getopt_state == state_next_word) {
|
||||
/* No more arguments, so no more options. */
|
||||
if (bsdtar->argv[0] == NULL)
|
||||
return (-1);
|
||||
/* Doesn't start with '-', so no more options. */
|
||||
if (bsdtar->argv[0][0] != '-')
|
||||
return (-1);
|
||||
/* "--" marks end of options; consume it and return. */
|
||||
if (strcmp(bsdtar->argv[0], "--") == 0) {
|
||||
++bsdtar->argv;
|
||||
--bsdtar->argc;
|
||||
return (-1);
|
||||
}
|
||||
/* Get next word for parsing. */
|
||||
bsdtar->getopt_word = *bsdtar->argv++;
|
||||
--bsdtar->argc;
|
||||
if (bsdtar->getopt_word[1] == '-') {
|
||||
/* Set up long option parser. */
|
||||
bsdtar->getopt_state = state_long;
|
||||
bsdtar->getopt_word += 2; /* Skip leading '--' */
|
||||
} else {
|
||||
/* Set up short option parser. */
|
||||
bsdtar->getopt_state = state_short;
|
||||
++bsdtar->getopt_word; /* Skip leading '-' */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We're parsing a group of POSIX-style single-character options.
|
||||
*/
|
||||
if (bsdtar->getopt_state == state_short) {
|
||||
/* Peel next option off of a group of short options. */
|
||||
opt = *bsdtar->getopt_word++;
|
||||
if (opt == '\0') {
|
||||
/* End of this group; recurse to get next option. */
|
||||
bsdtar->getopt_state = state_next_word;
|
||||
return bsdtar_getopt(bsdtar);
|
||||
}
|
||||
|
||||
/* Does this option take an argument? */
|
||||
p = strchr(short_options, opt);
|
||||
if (p == NULL)
|
||||
return ('?');
|
||||
if (p[1] == ':')
|
||||
required = 1;
|
||||
|
||||
/* If it takes an argument, parse that. */
|
||||
if (required) {
|
||||
/* If arg is run-in, bsdtar->getopt_word already points to it. */
|
||||
if (bsdtar->getopt_word[0] == '\0') {
|
||||
/* Otherwise, pick up the next word. */
|
||||
bsdtar->getopt_word = *bsdtar->argv;
|
||||
if (bsdtar->getopt_word == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option -%c requires an argument",
|
||||
opt);
|
||||
return ('?');
|
||||
}
|
||||
++bsdtar->argv;
|
||||
--bsdtar->argc;
|
||||
}
|
||||
if (opt == 'W') {
|
||||
bsdtar->getopt_state = state_long;
|
||||
long_prefix = "-W "; /* For clearer errors. */
|
||||
} else {
|
||||
bsdtar->getopt_state = state_next_word;
|
||||
bsdtar->argument = bsdtar->getopt_word;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We're reading a long option, including -W long=arg convention. */
|
||||
if (bsdtar->getopt_state == state_long) {
|
||||
/* After this long option, we'll be starting a new word. */
|
||||
bsdtar->getopt_state = state_next_word;
|
||||
|
||||
/* Option name ends at '=' if there is one. */
|
||||
p = strchr(bsdtar->getopt_word, '=');
|
||||
if (p != NULL) {
|
||||
optlength = (size_t)(p - bsdtar->getopt_word);
|
||||
bsdtar->argument = (char *)(uintptr_t)(p + 1);
|
||||
} else {
|
||||
optlength = strlen(bsdtar->getopt_word);
|
||||
}
|
||||
|
||||
/* Search the table for an unambiguous match. */
|
||||
for (popt = tar_longopts; popt->name != NULL; popt++) {
|
||||
/* Short-circuit if first chars don't match. */
|
||||
if (popt->name[0] != bsdtar->getopt_word[0])
|
||||
continue;
|
||||
/* If option is a prefix of name in table, record it.*/
|
||||
if (strncmp(bsdtar->getopt_word, popt->name, optlength) == 0) {
|
||||
match2 = match; /* Record up to two matches. */
|
||||
match = popt;
|
||||
/* If it's an exact match, we're done. */
|
||||
if (strlen(popt->name) == optlength) {
|
||||
match2 = NULL; /* Forget the others. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fail if there wasn't a unique match. */
|
||||
if (match == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s is not supported",
|
||||
long_prefix, bsdtar->getopt_word);
|
||||
return ('?');
|
||||
}
|
||||
if (match2 != NULL) {
|
||||
lafe_warnc(0,
|
||||
"Ambiguous option %s%s (matches --%s and --%s)",
|
||||
long_prefix, bsdtar->getopt_word, match->name, match2->name);
|
||||
return ('?');
|
||||
}
|
||||
|
||||
/* We've found a unique match; does it need an argument? */
|
||||
if (match->required) {
|
||||
/* Argument required: get next word if necessary. */
|
||||
if (bsdtar->argument == NULL) {
|
||||
bsdtar->argument = *bsdtar->argv;
|
||||
if (bsdtar->argument == NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s requires an argument",
|
||||
long_prefix, match->name);
|
||||
return ('?');
|
||||
}
|
||||
++bsdtar->argv;
|
||||
--bsdtar->argc;
|
||||
}
|
||||
} else {
|
||||
/* Argument forbidden: fail if there is one. */
|
||||
if (bsdtar->argument != NULL) {
|
||||
lafe_warnc(0,
|
||||
"Option %s%s does not allow an argument",
|
||||
long_prefix, match->name);
|
||||
return ('?');
|
||||
}
|
||||
}
|
||||
return (match->equivalent);
|
||||
}
|
||||
|
||||
return (opt);
|
||||
}
|
84
dependencies/libarchive-3.4.2/tar/config_freebsd.h
vendored
Normal file
84
dependencies/libarchive-3.4.2/tar/config_freebsd.h
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD: src/usr.bin/tar/config_freebsd.h,v 1.8 2008/11/29 20:06:53 kientzle Exp $
|
||||
*/
|
||||
|
||||
/* A default configuration for FreeBSD, used if there is no config.h. */
|
||||
|
||||
#include <sys/param.h> /* __FreeBSD_version */
|
||||
|
||||
#undef HAVE_ATTR_XATTR_H
|
||||
#define HAVE_CHROOT 1
|
||||
#define HAVE_DIRENT_D_NAMLEN 1
|
||||
#define HAVE_DIRENT_H 1
|
||||
#define HAVE_D_MD_ORDER 1
|
||||
#define HAVE_ERRNO_H 1
|
||||
#undef HAVE_EXT2FS_EXT2_FS_H
|
||||
#define HAVE_FCHDIR 1
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_GRP_H 1
|
||||
#define HAVE_LANGINFO_H 1
|
||||
#undef HAVE_LIBACL
|
||||
#define HAVE_LIBARCHIVE 1
|
||||
#define HAVE_LIMITS_H 1
|
||||
#define HAVE_LINK 1
|
||||
#undef HAVE_LINUX_EXT2_FS_H
|
||||
#undef HAVE_LINUX_FS_H
|
||||
#define HAVE_LOCALE_H 1
|
||||
#define HAVE_MBTOWC 1
|
||||
#undef HAVE_NDIR_H
|
||||
#if __FreeBSD_version >= 450002 /* nl_langinfo introduced */
|
||||
#define HAVE_NL_LANGINFO 1
|
||||
#endif
|
||||
#define HAVE_PATHS_H 1
|
||||
#define HAVE_PWD_H 1
|
||||
#define HAVE_READLINK 1
|
||||
#define HAVE_REGEX_H 1
|
||||
#define HAVE_SETLOCALE 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_STRUCT_STAT_ST_FLAGS 1
|
||||
#undef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
|
||||
#undef HAVE_STRUCT_STAT_ST_MTIME_N
|
||||
#undef HAVE_STRUCT_STAT_ST_MTIME_USEC
|
||||
#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
|
||||
#undef HAVE_STRUCT_STAT_ST_UMTIME
|
||||
#define HAVE_SYMLINK 1
|
||||
#define HAVE_SYS_CDEFS_H 1
|
||||
#undef HAVE_SYS_DIR_H
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#define HAVE_TIME_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_UINTMAX_T 1
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_UNSIGNED_LONG_LONG
|
||||
#define HAVE_WCTYPE_H 1
|
||||
#define HAVE_ZLIB_H 1
|
||||
#undef MAJOR_IN_MKDEV
|
318
dependencies/libarchive-3.4.2/tar/creation_set.c
vendored
Normal file
318
dependencies/libarchive-3.4.2/tar/creation_set.c
vendored
Normal file
|
@ -0,0 +1,318 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "bsdtar_platform.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "bsdtar.h"
|
||||
#include "err.h"
|
||||
|
||||
struct creation_set {
|
||||
char *create_format;
|
||||
struct filter_set {
|
||||
int program; /* Set 1 if filter is a program name */
|
||||
char *filter_name;
|
||||
} *filters;
|
||||
int filter_count;
|
||||
};
|
||||
|
||||
struct suffix_code_t {
|
||||
const char *suffix;
|
||||
const char *form;
|
||||
};
|
||||
|
||||
static const char *
|
||||
get_suffix_code(const struct suffix_code_t *tbl, const char *suffix)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (suffix == NULL)
|
||||
return (NULL);
|
||||
for (i = 0; tbl[i].suffix != NULL; i++) {
|
||||
if (strcmp(tbl[i].suffix, suffix) == 0)
|
||||
return (tbl[i].form);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_filter_code(const char *suffix)
|
||||
{
|
||||
/* A pair of suffix and compression/filter. */
|
||||
static const struct suffix_code_t filters[] = {
|
||||
{ ".Z", "compress" },
|
||||
{ ".bz2", "bzip2" },
|
||||
{ ".gz", "gzip" },
|
||||
{ ".grz", "grzip" },
|
||||
{ ".lrz", "lrzip" },
|
||||
{ ".lz", "lzip" },
|
||||
{ ".lz4", "lz4" },
|
||||
{ ".lzo", "lzop" },
|
||||
{ ".lzma", "lzma" },
|
||||
{ ".uu", "uuencode" },
|
||||
{ ".xz", "xz" },
|
||||
{ ".zst", "zstd"},
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
return get_suffix_code(filters, suffix);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_format_code(const char *suffix)
|
||||
{
|
||||
/* A pair of suffix and format. */
|
||||
static const struct suffix_code_t formats[] = {
|
||||
{ ".7z", "7zip" },
|
||||
{ ".ar", "arbsd" },
|
||||
{ ".cpio", "cpio" },
|
||||
{ ".iso", "iso9960" },
|
||||
{ ".mtree", "mtree" },
|
||||
{ ".shar", "shar" },
|
||||
{ ".tar", "paxr" },
|
||||
{ ".warc", "warc" },
|
||||
{ ".xar", "xar" },
|
||||
{ ".zip", "zip" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
return get_suffix_code(formats, suffix);
|
||||
}
|
||||
|
||||
static const char *
|
||||
decompose_alias(const char *suffix)
|
||||
{
|
||||
static const struct suffix_code_t alias[] = {
|
||||
{ ".taz", ".tar.gz" },
|
||||
{ ".tgz", ".tar.gz" },
|
||||
{ ".tbz", ".tar.bz2" },
|
||||
{ ".tbz2", ".tar.bz2" },
|
||||
{ ".tz2", ".tar.bz2" },
|
||||
{ ".tlz", ".tar.lzma" },
|
||||
{ ".txz", ".tar.xz" },
|
||||
{ ".tzo", ".tar.lzo" },
|
||||
{ ".taZ", ".tar.Z" },
|
||||
{ ".tZ", ".tar.Z" },
|
||||
{ ".tzst", ".tar.zst" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
return get_suffix_code(alias, suffix);
|
||||
}
|
||||
|
||||
static void
|
||||
_cset_add_filter(struct creation_set *cset, int program, const char *filter)
|
||||
{
|
||||
struct filter_set *new_ptr;
|
||||
char *new_filter;
|
||||
|
||||
new_ptr = (struct filter_set *)realloc(cset->filters,
|
||||
sizeof(*cset->filters) * (cset->filter_count + 1));
|
||||
if (new_ptr == NULL)
|
||||
lafe_errc(1, 0, "No memory");
|
||||
new_filter = strdup(filter);
|
||||
if (new_filter == NULL)
|
||||
lafe_errc(1, 0, "No memory");
|
||||
cset->filters = new_ptr;
|
||||
cset->filters[cset->filter_count].program = program;
|
||||
cset->filters[cset->filter_count].filter_name = new_filter;
|
||||
cset->filter_count++;
|
||||
}
|
||||
|
||||
void
|
||||
cset_add_filter(struct creation_set *cset, const char *filter)
|
||||
{
|
||||
_cset_add_filter(cset, 0, filter);
|
||||
}
|
||||
|
||||
void
|
||||
cset_add_filter_program(struct creation_set *cset, const char *filter)
|
||||
{
|
||||
_cset_add_filter(cset, 1, filter);
|
||||
}
|
||||
|
||||
int
|
||||
cset_read_support_filter_program(struct creation_set *cset, struct archive *a)
|
||||
{
|
||||
int cnt = 0, i;
|
||||
|
||||
for (i = 0; i < cset->filter_count; i++) {
|
||||
if (cset->filters[i].program) {
|
||||
archive_read_support_filter_program(a,
|
||||
cset->filters[i].filter_name);
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
return (cnt);
|
||||
}
|
||||
|
||||
int
|
||||
cset_write_add_filters(struct creation_set *cset, struct archive *a,
|
||||
const void **filter_name)
|
||||
{
|
||||
int cnt = 0, i, r;
|
||||
|
||||
for (i = 0; i < cset->filter_count; i++) {
|
||||
if (cset->filters[i].program)
|
||||
r = archive_write_add_filter_program(a,
|
||||
cset->filters[i].filter_name);
|
||||
else
|
||||
r = archive_write_add_filter_by_name(a,
|
||||
cset->filters[i].filter_name);
|
||||
if (r < ARCHIVE_WARN) {
|
||||
*filter_name = cset->filters[i].filter_name;
|
||||
return (r);
|
||||
}
|
||||
++cnt;
|
||||
}
|
||||
return (cnt);
|
||||
}
|
||||
|
||||
void
|
||||
cset_set_format(struct creation_set *cset, const char *format)
|
||||
{
|
||||
char *f;
|
||||
|
||||
f = strdup(format);
|
||||
if (f == NULL)
|
||||
lafe_errc(1, 0, "No memory");
|
||||
free(cset->create_format);
|
||||
cset->create_format = f;
|
||||
}
|
||||
|
||||
const char *
|
||||
cset_get_format(struct creation_set *cset)
|
||||
{
|
||||
return (cset->create_format);
|
||||
}
|
||||
|
||||
static void
|
||||
_cleanup_filters(struct filter_set *filters, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
free(filters[i].filter_name);
|
||||
free(filters);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean up a creation set.
|
||||
*/
|
||||
void
|
||||
cset_free(struct creation_set *cset)
|
||||
{
|
||||
_cleanup_filters(cset->filters, cset->filter_count);
|
||||
free(cset->create_format);
|
||||
free(cset);
|
||||
}
|
||||
|
||||
struct creation_set *
|
||||
cset_new(void)
|
||||
{
|
||||
return calloc(1, sizeof(struct creation_set));
|
||||
}
|
||||
|
||||
/*
|
||||
* Build a creation set by a file name suffix.
|
||||
*/
|
||||
int
|
||||
cset_auto_compress(struct creation_set *cset, const char *filename)
|
||||
{
|
||||
struct filter_set *old_filters;
|
||||
char *name, *p;
|
||||
const char *code;
|
||||
int old_filter_count;
|
||||
|
||||
name = strdup(filename);
|
||||
if (name == NULL)
|
||||
lafe_errc(1, 0, "No memory");
|
||||
/* Save previous filters. */
|
||||
old_filters = cset->filters;
|
||||
old_filter_count = cset->filter_count;
|
||||
cset->filters = NULL;
|
||||
cset->filter_count = 0;
|
||||
|
||||
for (;;) {
|
||||
/* Get the suffix. */
|
||||
p = strrchr(name, '.');
|
||||
if (p == NULL)
|
||||
break;
|
||||
/* Suppose it indicates compression/filter type
|
||||
* such as ".gz". */
|
||||
code = get_filter_code(p);
|
||||
if (code != NULL) {
|
||||
cset_add_filter(cset, code);
|
||||
*p = '\0';
|
||||
continue;
|
||||
}
|
||||
/* Suppose it indicates format type such as ".tar". */
|
||||
code = get_format_code(p);
|
||||
if (code != NULL) {
|
||||
cset_set_format(cset, code);
|
||||
break;
|
||||
}
|
||||
/* Suppose it indicates alias such as ".tgz". */
|
||||
code = decompose_alias(p);
|
||||
if (code == NULL)
|
||||
break;
|
||||
/* Replace the suffix. */
|
||||
*p = '\0';
|
||||
name = realloc(name, strlen(name) + strlen(code) + 1);
|
||||
if (name == NULL)
|
||||
lafe_errc(1, 0, "No memory");
|
||||
strcat(name, code);
|
||||
}
|
||||
free(name);
|
||||
if (cset->filters) {
|
||||
struct filter_set *v;
|
||||
int i, r;
|
||||
|
||||
/* Release previous filters. */
|
||||
_cleanup_filters(old_filters, old_filter_count);
|
||||
|
||||
v = malloc(sizeof(*v) * cset->filter_count);
|
||||
if (v == NULL)
|
||||
lafe_errc(1, 0, "No memory");
|
||||
/* Reverse filter sequence. */
|
||||
for (i = 0, r = cset->filter_count; r > 0; )
|
||||
v[i++] = cset->filters[--r];
|
||||
free(cset->filters);
|
||||
cset->filters = v;
|
||||
return (1);
|
||||
} else {
|
||||
/* Put previous filters back. */
|
||||
cset->filters = old_filters;
|
||||
cset->filter_count = old_filter_count;
|
||||
return (0);
|
||||
}
|
||||
}
|
420
dependencies/libarchive-3.4.2/tar/read.c
vendored
Normal file
420
dependencies/libarchive-3.4.2/tar/read.c
vendored
Normal file
|
@ -0,0 +1,420 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "bsdtar_platform.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/read.c,v 1.40 2008/08/21 06:41:14 kientzle Exp $");
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GRP_H
|
||||
#include <grp.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "bsdtar.h"
|
||||
#include "err.h"
|
||||
|
||||
struct progress_data {
|
||||
struct bsdtar *bsdtar;
|
||||
struct archive *archive;
|
||||
struct archive_entry *entry;
|
||||
};
|
||||
|
||||
static void read_archive(struct bsdtar *bsdtar, char mode, struct archive *);
|
||||
static int unmatched_inclusions_warn(struct archive *matching, const char *);
|
||||
|
||||
|
||||
void
|
||||
tar_mode_t(struct bsdtar *bsdtar)
|
||||
{
|
||||
read_archive(bsdtar, 't', NULL);
|
||||
if (unmatched_inclusions_warn(bsdtar->matching,
|
||||
"Not found in archive") != 0)
|
||||
bsdtar->return_value = 1;
|
||||
}
|
||||
|
||||
void
|
||||
tar_mode_x(struct bsdtar *bsdtar)
|
||||
{
|
||||
struct archive *writer;
|
||||
|
||||
writer = archive_write_disk_new();
|
||||
if (writer == NULL)
|
||||
lafe_errc(1, ENOMEM, "Cannot allocate disk writer object");
|
||||
if ((bsdtar->flags & OPTFLAG_NUMERIC_OWNER) == 0)
|
||||
archive_write_disk_set_standard_lookup(writer);
|
||||
archive_write_disk_set_options(writer, bsdtar->extract_flags);
|
||||
|
||||
read_archive(bsdtar, 'x', writer);
|
||||
|
||||
if (unmatched_inclusions_warn(bsdtar->matching,
|
||||
"Not found in archive") != 0)
|
||||
bsdtar->return_value = 1;
|
||||
archive_write_free(writer);
|
||||
}
|
||||
|
||||
static void
|
||||
progress_func(void *cookie)
|
||||
{
|
||||
struct progress_data *progress_data = (struct progress_data *)cookie;
|
||||
struct bsdtar *bsdtar = progress_data->bsdtar;
|
||||
struct archive *a = progress_data->archive;
|
||||
struct archive_entry *entry = progress_data->entry;
|
||||
uint64_t comp, uncomp;
|
||||
int compression;
|
||||
|
||||
if (!need_report())
|
||||
return;
|
||||
|
||||
if (bsdtar->verbose)
|
||||
fprintf(stderr, "\n");
|
||||
if (a != NULL) {
|
||||
comp = archive_filter_bytes(a, -1);
|
||||
uncomp = archive_filter_bytes(a, 0);
|
||||
if (comp > uncomp)
|
||||
compression = 0;
|
||||
else
|
||||
compression = (int)((uncomp - comp) * 100 / uncomp);
|
||||
fprintf(stderr,
|
||||
"In: %s bytes, compression %d%%;",
|
||||
tar_i64toa(comp), compression);
|
||||
fprintf(stderr, " Out: %d files, %s bytes\n",
|
||||
archive_file_count(a), tar_i64toa(uncomp));
|
||||
}
|
||||
if (entry != NULL) {
|
||||
safe_fprintf(stderr, "Current: %s",
|
||||
archive_entry_pathname(entry));
|
||||
fprintf(stderr, " (%s bytes)\n",
|
||||
tar_i64toa(archive_entry_size(entry)));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle 'x' and 't' modes.
|
||||
*/
|
||||
static void
|
||||
read_archive(struct bsdtar *bsdtar, char mode, struct archive *writer)
|
||||
{
|
||||
struct progress_data progress_data;
|
||||
FILE *out;
|
||||
struct archive *a;
|
||||
struct archive_entry *entry;
|
||||
const char *reader_options;
|
||||
int r;
|
||||
|
||||
while (*bsdtar->argv) {
|
||||
if (archive_match_include_pattern(bsdtar->matching,
|
||||
*bsdtar->argv) != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "Error inclusion pattern: %s",
|
||||
archive_error_string(bsdtar->matching));
|
||||
bsdtar->argv++;
|
||||
}
|
||||
|
||||
if (bsdtar->names_from_file != NULL)
|
||||
if (archive_match_include_pattern_from_file(
|
||||
bsdtar->matching, bsdtar->names_from_file,
|
||||
(bsdtar->flags & OPTFLAG_NULL)) != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "Error inclusion pattern: %s",
|
||||
archive_error_string(bsdtar->matching));
|
||||
|
||||
a = archive_read_new();
|
||||
if (cset_read_support_filter_program(bsdtar->cset, a) == 0)
|
||||
archive_read_support_filter_all(a);
|
||||
archive_read_support_format_all(a);
|
||||
|
||||
reader_options = getenv(ENV_READER_OPTIONS);
|
||||
if (reader_options != NULL) {
|
||||
size_t module_len = sizeof(IGNORE_WRONG_MODULE_NAME) - 1;
|
||||
size_t opt_len = strlen(reader_options) + 1;
|
||||
char *p;
|
||||
/* Set default read options. */
|
||||
if ((p = malloc(module_len + opt_len)) == NULL)
|
||||
lafe_errc(1, errno, "Out of memory");
|
||||
/* Prepend magic code to ignore options for
|
||||
* a format or modules which are not added to
|
||||
* the archive read object. */
|
||||
memcpy(p, IGNORE_WRONG_MODULE_NAME, module_len);
|
||||
memcpy(p + module_len, reader_options, opt_len);
|
||||
r = archive_read_set_options(a, p);
|
||||
free(p);
|
||||
if (r == ARCHIVE_FATAL)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(a));
|
||||
else
|
||||
archive_clear_error(a);
|
||||
}
|
||||
if (ARCHIVE_OK != archive_read_set_options(a, bsdtar->option_options))
|
||||
lafe_errc(1, 0, "%s", archive_error_string(a));
|
||||
if (bsdtar->flags & OPTFLAG_IGNORE_ZEROS)
|
||||
if (archive_read_set_options(a,
|
||||
"read_concatenated_archives") != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(a));
|
||||
if (bsdtar->passphrase != NULL)
|
||||
r = archive_read_add_passphrase(a, bsdtar->passphrase);
|
||||
else
|
||||
r = archive_read_set_passphrase_callback(a, bsdtar,
|
||||
&passphrase_callback);
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_errc(1, 0, "%s", archive_error_string(a));
|
||||
if (archive_read_open_filename(a, bsdtar->filename,
|
||||
bsdtar->bytes_per_block))
|
||||
lafe_errc(1, 0, "Error opening archive: %s",
|
||||
archive_error_string(a));
|
||||
|
||||
do_chdir(bsdtar);
|
||||
|
||||
if (mode == 'x') {
|
||||
/* Set an extract callback so that we can handle SIGINFO. */
|
||||
progress_data.bsdtar = bsdtar;
|
||||
progress_data.archive = a;
|
||||
archive_read_extract_set_progress_callback(a, progress_func,
|
||||
&progress_data);
|
||||
}
|
||||
|
||||
if (mode == 'x' && (bsdtar->flags & OPTFLAG_CHROOT)) {
|
||||
#if HAVE_CHROOT
|
||||
if (chroot(".") != 0)
|
||||
lafe_errc(1, errno, "Can't chroot to \".\"");
|
||||
#else
|
||||
lafe_errc(1, 0,
|
||||
"chroot isn't supported on this platform");
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
if (mode == 'x' && (bsdtar->flags & OPTFLAG_STDOUT)) {
|
||||
_setmode(1, _O_BINARY);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
/* Support --fast-read option */
|
||||
const char *p;
|
||||
if ((bsdtar->flags & OPTFLAG_FAST_READ) &&
|
||||
archive_match_path_unmatched_inclusions(bsdtar->matching) == 0)
|
||||
break;
|
||||
|
||||
r = archive_read_next_header(a, &entry);
|
||||
progress_data.entry = entry;
|
||||
if (r == ARCHIVE_EOF)
|
||||
break;
|
||||
if (r < ARCHIVE_OK)
|
||||
lafe_warnc(0, "%s", archive_error_string(a));
|
||||
if (r <= ARCHIVE_WARN)
|
||||
bsdtar->return_value = 1;
|
||||
if (r == ARCHIVE_RETRY) {
|
||||
/* Retryable error: try again */
|
||||
lafe_warnc(0, "Retrying...");
|
||||
continue;
|
||||
}
|
||||
if (r == ARCHIVE_FATAL)
|
||||
break;
|
||||
p = archive_entry_pathname(entry);
|
||||
if (p == NULL || p[0] == '\0') {
|
||||
lafe_warnc(0, "Archive entry has empty or unreadable filename ... skipping.");
|
||||
bsdtar->return_value = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bsdtar->uid >= 0) {
|
||||
archive_entry_set_uid(entry, bsdtar->uid);
|
||||
archive_entry_set_uname(entry, NULL);
|
||||
}
|
||||
if (bsdtar->gid >= 0) {
|
||||
archive_entry_set_gid(entry, bsdtar->gid);
|
||||
archive_entry_set_gname(entry, NULL);
|
||||
}
|
||||
if (bsdtar->uname)
|
||||
archive_entry_set_uname(entry, bsdtar->uname);
|
||||
if (bsdtar->gname)
|
||||
archive_entry_set_gname(entry, bsdtar->gname);
|
||||
|
||||
/*
|
||||
* Note that pattern exclusions are checked before
|
||||
* pathname rewrites are handled. This gives more
|
||||
* control over exclusions, since rewrites always lose
|
||||
* information. (For example, consider a rewrite
|
||||
* s/foo[0-9]/foo/. If we check exclusions after the
|
||||
* rewrite, there would be no way to exclude foo1/bar
|
||||
* while allowing foo2/bar.)
|
||||
*/
|
||||
if (archive_match_excluded(bsdtar->matching, entry))
|
||||
continue; /* Excluded by a pattern test. */
|
||||
|
||||
if (mode == 't') {
|
||||
/* Perversely, gtar uses -O to mean "send to stderr"
|
||||
* when used with -t. */
|
||||
out = (bsdtar->flags & OPTFLAG_STDOUT) ?
|
||||
stderr : stdout;
|
||||
|
||||
/*
|
||||
* TODO: Provide some reasonable way to
|
||||
* preview rewrites. gtar always displays
|
||||
* the unedited path in -t output, which means
|
||||
* you cannot easily preview rewrites.
|
||||
*/
|
||||
if (bsdtar->verbose < 2)
|
||||
safe_fprintf(out, "%s",
|
||||
archive_entry_pathname(entry));
|
||||
else
|
||||
list_item_verbose(bsdtar, out, entry);
|
||||
fflush(out);
|
||||
r = archive_read_data_skip(a);
|
||||
if (r == ARCHIVE_WARN) {
|
||||
fprintf(out, "\n");
|
||||
lafe_warnc(0, "%s",
|
||||
archive_error_string(a));
|
||||
}
|
||||
if (r == ARCHIVE_RETRY) {
|
||||
fprintf(out, "\n");
|
||||
lafe_warnc(0, "%s",
|
||||
archive_error_string(a));
|
||||
}
|
||||
if (r == ARCHIVE_FATAL) {
|
||||
fprintf(out, "\n");
|
||||
lafe_warnc(0, "%s",
|
||||
archive_error_string(a));
|
||||
bsdtar->return_value = 1;
|
||||
break;
|
||||
}
|
||||
fprintf(out, "\n");
|
||||
} else {
|
||||
/* Note: some rewrite failures prevent extraction. */
|
||||
if (edit_pathname(bsdtar, entry))
|
||||
continue; /* Excluded by a rewrite failure. */
|
||||
|
||||
if ((bsdtar->flags & OPTFLAG_INTERACTIVE) &&
|
||||
!yes("extract '%s'", archive_entry_pathname(entry)))
|
||||
continue;
|
||||
|
||||
if (bsdtar->verbose > 1) {
|
||||
/* GNU tar uses -tv format with -xvv */
|
||||
safe_fprintf(stderr, "x ");
|
||||
list_item_verbose(bsdtar, stderr, entry);
|
||||
fflush(stderr);
|
||||
} else if (bsdtar->verbose > 0) {
|
||||
/* Format follows SUSv2, including the
|
||||
* deferred '\n'. */
|
||||
safe_fprintf(stderr, "x %s",
|
||||
archive_entry_pathname(entry));
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
/* TODO siginfo_printinfo(bsdtar, 0); */
|
||||
|
||||
if (bsdtar->flags & OPTFLAG_STDOUT)
|
||||
r = archive_read_data_into_fd(a, 1);
|
||||
else
|
||||
r = archive_read_extract2(a, entry, writer);
|
||||
if (r != ARCHIVE_OK) {
|
||||
if (!bsdtar->verbose)
|
||||
safe_fprintf(stderr, "%s",
|
||||
archive_entry_pathname(entry));
|
||||
safe_fprintf(stderr, ": %s",
|
||||
archive_error_string(a));
|
||||
if (!bsdtar->verbose)
|
||||
fprintf(stderr, "\n");
|
||||
bsdtar->return_value = 1;
|
||||
}
|
||||
if (bsdtar->verbose)
|
||||
fprintf(stderr, "\n");
|
||||
if (r == ARCHIVE_FATAL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
r = archive_read_close(a);
|
||||
if (r != ARCHIVE_OK)
|
||||
lafe_warnc(0, "%s", archive_error_string(a));
|
||||
if (r <= ARCHIVE_WARN)
|
||||
bsdtar->return_value = 1;
|
||||
|
||||
if (bsdtar->verbose > 2)
|
||||
fprintf(stdout, "Archive Format: %s, Compression: %s\n",
|
||||
archive_format_name(a), archive_filter_name(a, 0));
|
||||
|
||||
archive_read_free(a);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
unmatched_inclusions_warn(struct archive *matching, const char *msg)
|
||||
{
|
||||
const char *p;
|
||||
int r;
|
||||
|
||||
if (matching == NULL)
|
||||
return (0);
|
||||
|
||||
while ((r = archive_match_path_unmatched_inclusions_next(
|
||||
matching, &p)) == ARCHIVE_OK)
|
||||
lafe_warnc(0, "%s: %s", p, msg);
|
||||
if (r == ARCHIVE_FATAL)
|
||||
lafe_errc(1, errno, "Out of memory");
|
||||
|
||||
return (archive_match_path_unmatched_inclusions(matching));
|
||||
}
|
327
dependencies/libarchive-3.4.2/tar/subst.c
vendored
Normal file
327
dependencies/libarchive-3.4.2/tar/subst.c
vendored
Normal file
|
@ -0,0 +1,327 @@
|
|||
/*-
|
||||
* Copyright (c) 2008 Joerg Sonnenberger
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "bsdtar_platform.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/subst.c,v 1.4 2008/06/15 10:08:16 kientzle Exp $");
|
||||
|
||||
#if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H)
|
||||
#include "bsdtar.h"
|
||||
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_PCREPOSIX_H
|
||||
#include <pcreposix.h>
|
||||
#else
|
||||
#include <regex.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef REG_BASIC
|
||||
#define REG_BASIC 0
|
||||
#endif
|
||||
|
||||
#include "err.h"
|
||||
|
||||
struct subst_rule {
|
||||
struct subst_rule *next;
|
||||
regex_t re;
|
||||
char *result;
|
||||
unsigned int global:1, print:1, regular:1, symlink:1, hardlink:1;
|
||||
};
|
||||
|
||||
struct substitution {
|
||||
struct subst_rule *first_rule, *last_rule;
|
||||
};
|
||||
|
||||
static void
|
||||
init_substitution(struct bsdtar *bsdtar)
|
||||
{
|
||||
struct substitution *subst;
|
||||
|
||||
bsdtar->substitution = subst = malloc(sizeof(*subst));
|
||||
if (subst == NULL)
|
||||
lafe_errc(1, errno, "Out of memory");
|
||||
subst->first_rule = subst->last_rule = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
add_substitution(struct bsdtar *bsdtar, const char *rule_text)
|
||||
{
|
||||
struct subst_rule *rule;
|
||||
struct substitution *subst;
|
||||
const char *end_pattern, *start_subst;
|
||||
char *pattern;
|
||||
int r;
|
||||
|
||||
if ((subst = bsdtar->substitution) == NULL) {
|
||||
init_substitution(bsdtar);
|
||||
subst = bsdtar->substitution;
|
||||
}
|
||||
|
||||
rule = malloc(sizeof(*rule));
|
||||
if (rule == NULL)
|
||||
lafe_errc(1, errno, "Out of memory");
|
||||
rule->next = NULL;
|
||||
rule->result = NULL;
|
||||
|
||||
if (subst->last_rule == NULL)
|
||||
subst->first_rule = rule;
|
||||
else
|
||||
subst->last_rule->next = rule;
|
||||
subst->last_rule = rule;
|
||||
|
||||
if (*rule_text == '\0')
|
||||
lafe_errc(1, 0, "Empty replacement string");
|
||||
end_pattern = strchr(rule_text + 1, *rule_text);
|
||||
if (end_pattern == NULL)
|
||||
lafe_errc(1, 0, "Invalid replacement string");
|
||||
|
||||
pattern = malloc(end_pattern - rule_text);
|
||||
if (pattern == NULL)
|
||||
lafe_errc(1, errno, "Out of memory");
|
||||
memcpy(pattern, rule_text + 1, end_pattern - rule_text - 1);
|
||||
pattern[end_pattern - rule_text - 1] = '\0';
|
||||
|
||||
if ((r = regcomp(&rule->re, pattern, REG_BASIC)) != 0) {
|
||||
char buf[80];
|
||||
regerror(r, &rule->re, buf, sizeof(buf));
|
||||
lafe_errc(1, 0, "Invalid regular expression: %s", buf);
|
||||
}
|
||||
free(pattern);
|
||||
|
||||
start_subst = end_pattern + 1;
|
||||
end_pattern = strchr(start_subst, *rule_text);
|
||||
if (end_pattern == NULL)
|
||||
lafe_errc(1, 0, "Invalid replacement string");
|
||||
|
||||
rule->result = malloc(end_pattern - start_subst + 1);
|
||||
if (rule->result == NULL)
|
||||
lafe_errc(1, errno, "Out of memory");
|
||||
memcpy(rule->result, start_subst, end_pattern - start_subst);
|
||||
rule->result[end_pattern - start_subst] = '\0';
|
||||
|
||||
/* Defaults */
|
||||
rule->global = 0; /* Don't do multiple replacements. */
|
||||
rule->print = 0; /* Don't print. */
|
||||
rule->regular = 1; /* Rewrite regular filenames. */
|
||||
rule->symlink = 1; /* Rewrite symlink targets. */
|
||||
rule->hardlink = 1; /* Rewrite hardlink targets. */
|
||||
|
||||
while (*++end_pattern) {
|
||||
switch (*end_pattern) {
|
||||
case 'g':
|
||||
case 'G':
|
||||
rule->global = 1;
|
||||
break;
|
||||
case 'h':
|
||||
rule->hardlink = 1;
|
||||
break;
|
||||
case 'H':
|
||||
rule->hardlink = 0;
|
||||
break;
|
||||
case 'p':
|
||||
case 'P':
|
||||
rule->print = 1;
|
||||
break;
|
||||
case 'r':
|
||||
rule->regular = 1;
|
||||
break;
|
||||
case 'R':
|
||||
rule->regular = 0;
|
||||
break;
|
||||
case 's':
|
||||
rule->symlink = 1;
|
||||
break;
|
||||
case 'S':
|
||||
rule->symlink = 0;
|
||||
break;
|
||||
default:
|
||||
lafe_errc(1, 0, "Invalid replacement flag %c", *end_pattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
realloc_strncat(char **str, const char *append, size_t len)
|
||||
{
|
||||
char *new_str;
|
||||
size_t old_len;
|
||||
|
||||
if (*str == NULL)
|
||||
old_len = 0;
|
||||
else
|
||||
old_len = strlen(*str);
|
||||
|
||||
new_str = malloc(old_len + len + 1);
|
||||
if (new_str == NULL)
|
||||
lafe_errc(1, errno, "Out of memory");
|
||||
if (*str != NULL)
|
||||
memcpy(new_str, *str, old_len);
|
||||
memcpy(new_str + old_len, append, len);
|
||||
new_str[old_len + len] = '\0';
|
||||
free(*str);
|
||||
*str = new_str;
|
||||
}
|
||||
|
||||
static void
|
||||
realloc_strcat(char **str, const char *append)
|
||||
{
|
||||
char *new_str;
|
||||
size_t old_len;
|
||||
|
||||
if (*str == NULL)
|
||||
old_len = 0;
|
||||
else
|
||||
old_len = strlen(*str);
|
||||
|
||||
new_str = malloc(old_len + strlen(append) + 1);
|
||||
if (new_str == NULL)
|
||||
lafe_errc(1, errno, "Out of memory");
|
||||
if (*str != NULL)
|
||||
memcpy(new_str, *str, old_len);
|
||||
strcpy(new_str + old_len, append);
|
||||
free(*str);
|
||||
*str = new_str;
|
||||
}
|
||||
|
||||
int
|
||||
apply_substitution(struct bsdtar *bsdtar, const char *name, char **result,
|
||||
int symlink_target, int hardlink_target)
|
||||
{
|
||||
const char *path = name;
|
||||
regmatch_t matches[10];
|
||||
size_t i, j;
|
||||
struct subst_rule *rule;
|
||||
struct substitution *subst;
|
||||
int c, got_match, print_match;
|
||||
|
||||
*result = NULL;
|
||||
|
||||
if ((subst = bsdtar->substitution) == NULL)
|
||||
return 0;
|
||||
|
||||
got_match = 0;
|
||||
print_match = 0;
|
||||
|
||||
for (rule = subst->first_rule; rule != NULL; rule = rule->next) {
|
||||
if (symlink_target) {
|
||||
if (!rule->symlink)
|
||||
continue;
|
||||
} else if (hardlink_target) {
|
||||
if (!rule->hardlink)
|
||||
continue;
|
||||
} else { /* Regular filename. */
|
||||
if (!rule->regular)
|
||||
continue;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if (regexec(&rule->re, name, 10, matches, 0))
|
||||
break;
|
||||
|
||||
got_match = 1;
|
||||
print_match |= rule->print;
|
||||
realloc_strncat(result, name, matches[0].rm_so);
|
||||
|
||||
for (i = 0, j = 0; rule->result[i] != '\0'; ++i) {
|
||||
if (rule->result[i] == '~') {
|
||||
realloc_strncat(result, rule->result + j, i - j);
|
||||
realloc_strncat(result,
|
||||
name + matches[0].rm_so,
|
||||
matches[0].rm_eo - matches[0].rm_so);
|
||||
j = i + 1;
|
||||
continue;
|
||||
}
|
||||
if (rule->result[i] != '\\')
|
||||
continue;
|
||||
|
||||
++i;
|
||||
c = rule->result[i];
|
||||
switch (c) {
|
||||
case '~':
|
||||
case '\\':
|
||||
realloc_strncat(result, rule->result + j, i - j - 1);
|
||||
j = i;
|
||||
break;
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
realloc_strncat(result, rule->result + j, i - j - 1);
|
||||
if ((size_t)(c - '0') > (size_t)(rule->re.re_nsub)) {
|
||||
free(*result);
|
||||
*result = NULL;
|
||||
return -1;
|
||||
}
|
||||
realloc_strncat(result, name + matches[c - '0'].rm_so, matches[c - '0'].rm_eo - matches[c - '0'].rm_so);
|
||||
j = i + 1;
|
||||
break;
|
||||
default:
|
||||
/* Just continue; */
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
realloc_strcat(result, rule->result + j);
|
||||
|
||||
name += matches[0].rm_eo;
|
||||
|
||||
if (!rule->global)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (got_match)
|
||||
realloc_strcat(result, name);
|
||||
|
||||
if (print_match)
|
||||
fprintf(stderr, "%s >> %s\n", path, *result);
|
||||
|
||||
return got_match;
|
||||
}
|
||||
|
||||
void
|
||||
cleanup_substitution(struct bsdtar *bsdtar)
|
||||
{
|
||||
struct subst_rule *rule;
|
||||
struct substitution *subst;
|
||||
|
||||
if ((subst = bsdtar->substitution) == NULL)
|
||||
return;
|
||||
|
||||
while ((rule = subst->first_rule) != NULL) {
|
||||
subst->first_rule = rule->next;
|
||||
free(rule->result);
|
||||
free(rule);
|
||||
}
|
||||
free(subst);
|
||||
}
|
||||
#endif /* defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H) */
|
127
dependencies/libarchive-3.4.2/tar/test/CMakeLists.txt
vendored
Normal file
127
dependencies/libarchive-3.4.2/tar/test/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
############################################
|
||||
#
|
||||
# How to build bsdtar_test
|
||||
#
|
||||
############################################
|
||||
IF(ENABLE_TAR AND ENABLE_TEST)
|
||||
SET(bsdtar_test_SOURCES
|
||||
../../test_utils/test_utils.c
|
||||
../../test_utils/test_main.c
|
||||
test.h
|
||||
test_0.c
|
||||
test_basic.c
|
||||
test_copy.c
|
||||
test_empty_mtree.c
|
||||
test_extract_tar_Z.c
|
||||
test_extract_tar_bz2.c
|
||||
test_extract_tar_grz.c
|
||||
test_extract_tar_gz.c
|
||||
test_extract_tar_lrz.c
|
||||
test_extract_tar_lz.c
|
||||
test_extract_tar_lz4.c
|
||||
test_extract_tar_lzma.c
|
||||
test_extract_tar_lzo.c
|
||||
test_extract_tar_xz.c
|
||||
test_extract_tar_zstd.c
|
||||
test_format_newc.c
|
||||
test_help.c
|
||||
test_leading_slash.c
|
||||
test_missing_file.c
|
||||
test_option_C_upper.c
|
||||
test_option_C_mtree.c
|
||||
test_option_H_upper.c
|
||||
test_option_L_upper.c
|
||||
test_option_O_upper.c
|
||||
test_option_T_upper.c
|
||||
test_option_U_upper.c
|
||||
test_option_X_upper.c
|
||||
test_option_a.c
|
||||
test_option_acls.c
|
||||
test_option_b.c
|
||||
test_option_b64encode.c
|
||||
test_option_exclude.c
|
||||
test_option_exclude_vcs.c
|
||||
test_option_fflags.c
|
||||
test_option_gid_gname.c
|
||||
test_option_grzip.c
|
||||
test_option_j.c
|
||||
test_option_k.c
|
||||
test_option_keep_newer_files.c
|
||||
test_option_lrzip.c
|
||||
test_option_lz4.c
|
||||
test_option_lzma.c
|
||||
test_option_lzop.c
|
||||
test_option_n.c
|
||||
test_option_newer_than.c
|
||||
test_option_nodump.c
|
||||
test_option_older_than.c
|
||||
test_option_passphrase.c
|
||||
test_option_q.c
|
||||
test_option_r.c
|
||||
test_option_s.c
|
||||
test_option_safe_writes.c
|
||||
test_option_uid_uname.c
|
||||
test_option_uuencode.c
|
||||
test_option_xattrs.c
|
||||
test_option_xz.c
|
||||
test_option_z.c
|
||||
test_option_zstd.c
|
||||
test_patterns.c
|
||||
test_print_longpath.c
|
||||
test_stdio.c
|
||||
test_strip_components.c
|
||||
test_symlink_dir.c
|
||||
test_version.c
|
||||
test_windows.c
|
||||
)
|
||||
|
||||
#
|
||||
# Register target
|
||||
#
|
||||
ADD_EXECUTABLE(bsdtar_test ${bsdtar_test_SOURCES})
|
||||
IF(ENABLE_ACL)
|
||||
SET(TEST_ACL_LIBS "")
|
||||
IF(HAVE_LIBACL)
|
||||
LIST(APPEND TEST_ACL_LIBS ${ACL_LIBRARY})
|
||||
ENDIF(HAVE_LIBACL)
|
||||
IF(HAVE_LIBRICHACL)
|
||||
LIST(APPEND TEST_ACL_LIBS ${RICHACL_LIBRARY})
|
||||
ENDIF(HAVE_LIBRICHACL)
|
||||
TARGET_LINK_LIBRARIES(bsdtar_test ${TEST_ACL_LIBS})
|
||||
ENDIF(ENABLE_ACL)
|
||||
SET_PROPERTY(TARGET bsdtar_test PROPERTY COMPILE_DEFINITIONS LIST_H)
|
||||
|
||||
#
|
||||
# Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
|
||||
#
|
||||
GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
|
||||
${CMAKE_CURRENT_LIST_FILE} ${bsdtar_test_SOURCES})
|
||||
SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# list.h has a line DEFINE_TEST(testname) for every
|
||||
# test. We can use that to define the tests for cmake by
|
||||
# defining a DEFINE_TEST macro and reading list.h in.
|
||||
MACRO (DEFINE_TEST _testname)
|
||||
ADD_TEST(
|
||||
NAME bsdtar_${_testname}
|
||||
COMMAND bsdtar_test -vv
|
||||
-p $<TARGET_FILE:bsdtar>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${_testname})
|
||||
ENDMACRO (DEFINE_TEST _testname)
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/tar/test)
|
||||
|
||||
# Experimental new test handling
|
||||
ADD_CUSTOM_TARGET(run_bsdtar_test
|
||||
COMMAND bsdtar_test -p $<TARGET_FILE:bsdtar>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-vv)
|
||||
ADD_DEPENDENCIES(run_bsdtar_test bsdtar)
|
||||
ADD_DEPENDENCIES(run_all_tests run_bsdtar_test)
|
||||
|
||||
ENDIF(ENABLE_TAR AND ENABLE_TEST)
|
65
dependencies/libarchive-3.4.2/tar/test/list.h
vendored
Normal file
65
dependencies/libarchive-3.4.2/tar/test/list.h
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
DEFINE_TEST(test_0)
|
||||
DEFINE_TEST(test_basic)
|
||||
DEFINE_TEST(test_copy)
|
||||
DEFINE_TEST(test_empty_mtree)
|
||||
DEFINE_TEST(test_extract_tar_Z)
|
||||
DEFINE_TEST(test_extract_tar_bz2)
|
||||
DEFINE_TEST(test_extract_tar_grz)
|
||||
DEFINE_TEST(test_extract_tar_gz)
|
||||
DEFINE_TEST(test_extract_tar_lrz)
|
||||
DEFINE_TEST(test_extract_tar_lz)
|
||||
DEFINE_TEST(test_extract_tar_lz4)
|
||||
DEFINE_TEST(test_extract_tar_lzma)
|
||||
DEFINE_TEST(test_extract_tar_lzo)
|
||||
DEFINE_TEST(test_extract_tar_xz)
|
||||
DEFINE_TEST(test_extract_tar_zstd)
|
||||
DEFINE_TEST(test_format_newc)
|
||||
DEFINE_TEST(test_help)
|
||||
DEFINE_TEST(test_leading_slash)
|
||||
DEFINE_TEST(test_missing_file)
|
||||
DEFINE_TEST(test_option_C_mtree)
|
||||
DEFINE_TEST(test_option_C_upper)
|
||||
DEFINE_TEST(test_option_H_upper)
|
||||
DEFINE_TEST(test_option_L_upper)
|
||||
DEFINE_TEST(test_option_O_upper)
|
||||
DEFINE_TEST(test_option_T_upper)
|
||||
DEFINE_TEST(test_option_U_upper)
|
||||
DEFINE_TEST(test_option_X_upper)
|
||||
DEFINE_TEST(test_option_a)
|
||||
DEFINE_TEST(test_option_acls)
|
||||
DEFINE_TEST(test_option_b)
|
||||
DEFINE_TEST(test_option_b64encode)
|
||||
DEFINE_TEST(test_option_exclude)
|
||||
DEFINE_TEST(test_option_exclude_vcs)
|
||||
DEFINE_TEST(test_option_fflags)
|
||||
DEFINE_TEST(test_option_gid_gname)
|
||||
DEFINE_TEST(test_option_grzip)
|
||||
DEFINE_TEST(test_option_j)
|
||||
DEFINE_TEST(test_option_k)
|
||||
DEFINE_TEST(test_option_keep_newer_files)
|
||||
DEFINE_TEST(test_option_lrzip)
|
||||
DEFINE_TEST(test_option_lz4)
|
||||
DEFINE_TEST(test_option_lzma)
|
||||
DEFINE_TEST(test_option_lzop)
|
||||
DEFINE_TEST(test_option_n)
|
||||
DEFINE_TEST(test_option_newer_than)
|
||||
DEFINE_TEST(test_option_nodump)
|
||||
DEFINE_TEST(test_option_older_than)
|
||||
DEFINE_TEST(test_option_passphrase)
|
||||
DEFINE_TEST(test_option_q)
|
||||
DEFINE_TEST(test_option_r)
|
||||
DEFINE_TEST(test_option_s)
|
||||
DEFINE_TEST(test_option_safe_writes)
|
||||
DEFINE_TEST(test_option_uid_uname)
|
||||
DEFINE_TEST(test_option_uuencode)
|
||||
DEFINE_TEST(test_option_xattrs)
|
||||
DEFINE_TEST(test_option_xz)
|
||||
DEFINE_TEST(test_option_z)
|
||||
DEFINE_TEST(test_option_zstd)
|
||||
DEFINE_TEST(test_patterns)
|
||||
DEFINE_TEST(test_print_longpath)
|
||||
DEFINE_TEST(test_stdio)
|
||||
DEFINE_TEST(test_strip_components)
|
||||
DEFINE_TEST(test_symlink_dir)
|
||||
DEFINE_TEST(test_version)
|
||||
DEFINE_TEST(test_windows)
|
40
dependencies/libarchive-3.4.2/tar/test/test.h
vendored
Normal file
40
dependencies/libarchive-3.4.2/tar/test/test.h
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2003-2017 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/* Every test program should #include "test.h" as the first thing. */
|
||||
|
||||
#define KNOWNREF "test_patterns_2.tar.uu"
|
||||
#define ENVBASE "BSDTAR" /* Prefix for environment variables. */
|
||||
#define PROGRAM "bsdtar" /* Name of program being tested. */
|
||||
#define PROGRAM_ALIAS "tar" /* Generic alias for program */
|
||||
#undef LIBRARY /* Not testing a library. */
|
||||
#undef EXTRA_DUMP /* How to dump extra data */
|
||||
#undef EXTRA_ERRNO /* How to dump errno */
|
||||
/* How to generate extra version info. */
|
||||
#define EXTRA_VERSION (systemf("%s --version", testprog) ? "" : "")
|
||||
|
||||
#include "test_common.h"
|
75
dependencies/libarchive-3.4.2/tar/test/test_0.c
vendored
Normal file
75
dependencies/libarchive-3.4.2/tar/test/test_0.c
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_0.c,v 1.2 2008/05/26 17:10:10 kientzle Exp $");
|
||||
|
||||
/*
|
||||
* This first test does basic sanity checks on the environment. For
|
||||
* most of these, we just exit on failure.
|
||||
*/
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
#define DEV_NULL "/dev/null"
|
||||
#else
|
||||
#define DEV_NULL "NUL"
|
||||
#endif
|
||||
|
||||
DEFINE_TEST(test_0)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
failure("File %s does not exist?!", testprog);
|
||||
if (!assertEqualInt(0, stat(testprogfile, &st))) {
|
||||
fprintf(stderr,
|
||||
"\nFile %s does not exist; aborting test.\n\n",
|
||||
testprog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
failure("%s is not executable?!", testprog);
|
||||
if (!assert((st.st_mode & 0111) != 0)) {
|
||||
fprintf(stderr,
|
||||
"\nFile %s not executable; aborting test.\n\n",
|
||||
testprog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to successfully run the program; this requires that
|
||||
* we know some option that will succeed.
|
||||
*/
|
||||
if (0 == systemf("%s --version >" DEV_NULL, testprog)) {
|
||||
/* This worked. */
|
||||
} else if (0 == systemf("%s -W version >" DEV_NULL, testprog)) {
|
||||
/* This worked. */
|
||||
} else {
|
||||
failure("Unable to successfully run any of the following:\n"
|
||||
" * %s --version\n"
|
||||
" * %s -W version\n",
|
||||
testprog, testprog);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
/* TODO: Ensure that our reference files are available. */
|
||||
}
|
135
dependencies/libarchive-3.4.2/tar/test/test_basic.c
vendored
Normal file
135
dependencies/libarchive-3.4.2/tar/test/test_basic.c
vendored
Normal file
|
@ -0,0 +1,135 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_basic.c,v 1.2 2008/05/26 17:10:10 kientzle Exp $");
|
||||
|
||||
static const char *
|
||||
make_files(void)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
/* File with 10 bytes content. */
|
||||
f = fopen("file", "wb");
|
||||
assert(f != NULL);
|
||||
assertEqualInt(10, fwrite("123456789", 1, 10, f));
|
||||
fclose(f);
|
||||
|
||||
/* hardlink to above file. */
|
||||
assertMakeHardlink("linkfile", "file");
|
||||
assertIsHardlink("file", "linkfile");
|
||||
|
||||
/* Symlink to above file. */
|
||||
if (canSymlink())
|
||||
assertMakeSymlink("symlink", "file", 0);
|
||||
|
||||
/* Directory. */
|
||||
assertMakeDir("dir", 0775);
|
||||
|
||||
return canSymlink()
|
||||
? "file linkfile symlink dir"
|
||||
: "file linkfile dir";
|
||||
}
|
||||
|
||||
static void
|
||||
verify_files(const char *target)
|
||||
{
|
||||
assertChdir(target);
|
||||
|
||||
/* Regular file with 2 links. */
|
||||
failure("%s", target);
|
||||
assertIsReg("file", -1);
|
||||
failure("%s", target);
|
||||
assertFileSize("file", 10);
|
||||
failure("%s", target);
|
||||
assertFileContents("123456789", 10, "file");
|
||||
failure("%s", target);
|
||||
assertFileNLinks("file", 2);
|
||||
|
||||
/* Another name for the same file. */
|
||||
failure("%s", target);
|
||||
assertIsReg("linkfile", -1);
|
||||
failure("%s", target);
|
||||
assertFileSize("linkfile", 10);
|
||||
assertFileContents("123456789", 10, "linkfile");
|
||||
assertFileNLinks("linkfile", 2);
|
||||
assertIsHardlink("file", "linkfile");
|
||||
|
||||
/* Symlink */
|
||||
if (canSymlink())
|
||||
assertIsSymlink("symlink", "file", 0);
|
||||
|
||||
/* dir */
|
||||
failure("%s", target);
|
||||
assertIsDir("dir", 0775);
|
||||
assertChdir("..");
|
||||
}
|
||||
|
||||
static void
|
||||
run_tar(const char *target, const char *pack_options,
|
||||
const char *unpack_options, const char *flist)
|
||||
{
|
||||
int r;
|
||||
|
||||
assertMakeDir(target, 0775);
|
||||
|
||||
/* Use the tar program to create an archive. */
|
||||
r = systemf("%s cf - %s %s >%s/archive 2>%s/pack.err", testprog, pack_options, flist, target, target);
|
||||
failure("Error invoking %s cf -%s", testprog, pack_options);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
assertChdir(target);
|
||||
|
||||
/* Verify that nothing went to stderr. */
|
||||
assertEmptyFile("pack.err");
|
||||
|
||||
/*
|
||||
* Use tar to unpack the archive into another directory.
|
||||
*/
|
||||
r = systemf("%s xf archive %s >unpack.out 2>unpack.err",
|
||||
testprog, unpack_options);
|
||||
failure("Error invoking %s xf archive %s", testprog, unpack_options);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Verify that nothing went to stderr. */
|
||||
assertEmptyFile("unpack.err");
|
||||
assertChdir("..");
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_basic)
|
||||
{
|
||||
const char *flist;
|
||||
|
||||
assertUmask(0);
|
||||
flist = make_files();
|
||||
/* Archive/dearchive with a variety of options. */
|
||||
run_tar("copy", "", "", flist);
|
||||
verify_files("copy");
|
||||
|
||||
run_tar("copy_ustar", "--format=ustar", "", flist);
|
||||
verify_files("copy_ustar");
|
||||
|
||||
/* tar doesn't handle cpio symlinks correctly */
|
||||
/* run_tar("copy_odc", "--format=odc", ""); */
|
||||
}
|
375
dependencies/libarchive-3.4.2/tar/test/test_copy.c
vendored
Normal file
375
dependencies/libarchive-3.4.2/tar/test/test_copy.c
vendored
Normal file
|
@ -0,0 +1,375 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_copy.c,v 1.3 2008/08/15 06:12:02 kientzle Exp $");
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
# include <limits.h>
|
||||
# include <sys/cygwin.h>
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
# include <direct.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Try to figure out how deep we can go in our tests. Assumes that
|
||||
* the first call to this function has the longest starting cwd (which
|
||||
* is currently "<testdir>/original"). This is mostly to work around
|
||||
* limits in our Win32 support.
|
||||
*
|
||||
* Background: On Posix systems, PATH_MAX is merely a limit on the
|
||||
* length of the string passed into a system call. By repeatedly
|
||||
* calling chdir(), you can work with arbitrarily long paths on such
|
||||
* systems. In contrast, Win32 APIs apply PATH_MAX limits to the full
|
||||
* absolute path, so the permissible length of a system call argument
|
||||
* varies with the cwd. Some APIs actually enforce limits
|
||||
* significantly less than PATH_MAX to ensure that you can create
|
||||
* files within the current working directory. The Win32 limits also
|
||||
* apply to Cygwin before 1.7.
|
||||
*
|
||||
* Someday, I want to convert the Win32 support to use newer
|
||||
* wide-character paths with '\\?\' prefix, which has a 32k PATH_MAX
|
||||
* instead of the rather anemic 260 character limit of the older
|
||||
* system calls. Then we can drop this mess (unless we want to
|
||||
* continue to special-case Cygwin 1.5 and earlier).
|
||||
*/
|
||||
static int
|
||||
compute_loop_max(void)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
static int LOOP_MAX = 0;
|
||||
char buf[MAX_PATH];
|
||||
size_t cwdlen;
|
||||
|
||||
if (LOOP_MAX == 0) {
|
||||
assert(_getcwd(buf, MAX_PATH) != NULL);
|
||||
cwdlen = strlen(buf);
|
||||
/* 12 characters = length of 8.3 filename */
|
||||
/* 4 characters = length of "/../" used in symlink tests */
|
||||
/* 1 character = length of extra "/" separator */
|
||||
LOOP_MAX = MAX_PATH - (int)cwdlen - 12 - 4 - 1;
|
||||
}
|
||||
return LOOP_MAX;
|
||||
#elif defined(__CYGWIN__) && !defined(HAVE_CYGWIN_CONV_PATH)
|
||||
static int LOOP_MAX = 0;
|
||||
if (LOOP_MAX == 0) {
|
||||
char wbuf[PATH_MAX];
|
||||
char pbuf[PATH_MAX];
|
||||
size_t wcwdlen;
|
||||
size_t pcwdlen;
|
||||
size_t cwdlen;
|
||||
assert(getcwd(pbuf, PATH_MAX) != NULL);
|
||||
pcwdlen = strlen(pbuf);
|
||||
cygwin_conv_to_full_win32_path(pbuf, wbuf);
|
||||
wcwdlen = strlen(wbuf);
|
||||
cwdlen = ((wcwdlen > pcwdlen) ? wcwdlen : pcwdlen);
|
||||
/* Cygwin helper needs an extra few characters. */
|
||||
LOOP_MAX = PATH_MAX - (int)cwdlen - 12 - 4 - 4;
|
||||
}
|
||||
return LOOP_MAX;
|
||||
#else
|
||||
/* cygwin-1.7 ends up here, along with "normal" unix */
|
||||
return 200; /* restore pre-r278 depth */
|
||||
#endif
|
||||
}
|
||||
|
||||
/* filenames[i] is a distinctive filename of length i. */
|
||||
/* To simplify interpreting failures, each filename ends with a
|
||||
* decimal integer which is the length of the filename. E.g., A
|
||||
* filename ending in "_92" is 92 characters long. To detect errors
|
||||
* which drop or misplace characters, the filenames use a repeating
|
||||
* "abcdefghijklmnopqrstuvwxyz..." pattern. */
|
||||
static char *filenames[201];
|
||||
|
||||
static void
|
||||
compute_filenames(void)
|
||||
{
|
||||
char buff[250];
|
||||
size_t i,j;
|
||||
|
||||
filenames[0] = strdup("");
|
||||
filenames[1] = strdup("1");
|
||||
filenames[2] = strdup("a2");
|
||||
for (i = 3; i < sizeof(filenames)/sizeof(filenames[0]); ++i) {
|
||||
/* Fill with "abcdefghij..." */
|
||||
for (j = 0; j < i; ++j)
|
||||
buff[j] = 'a' + (j % 26);
|
||||
buff[j--] = '\0';
|
||||
/* Work from the end to fill in the number portion. */
|
||||
buff[j--] = '0' + (i % 10);
|
||||
if (i > 9) {
|
||||
buff[j--] = '0' + ((i / 10) % 10);
|
||||
if (i > 99)
|
||||
buff[j--] = '0' + (char)(i / 100);
|
||||
}
|
||||
buff[j] = '_';
|
||||
/* Guard against obvious screwups in the above code. */
|
||||
assertEqualInt(strlen(buff), i);
|
||||
filenames[i] = strdup(buff);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
create_tree(void)
|
||||
{
|
||||
char buff[260];
|
||||
char buff2[260];
|
||||
int i;
|
||||
int LOOP_MAX;
|
||||
|
||||
compute_filenames();
|
||||
|
||||
/* Log that we'll be omitting some checks. */
|
||||
if (!canSymlink()) {
|
||||
skipping("Symlink checks");
|
||||
}
|
||||
|
||||
assertMakeDir("original", 0775);
|
||||
assertEqualInt(0, chdir("original"));
|
||||
LOOP_MAX = compute_loop_max();
|
||||
|
||||
assertMakeDir("f", 0775);
|
||||
assertMakeDir("l", 0775);
|
||||
assertMakeDir("m", 0775);
|
||||
assertMakeDir("s", 0775);
|
||||
assertMakeDir("d", 0775);
|
||||
|
||||
for (i = 1; i < LOOP_MAX; i++) {
|
||||
failure("Internal sanity check failed: i = %d", i);
|
||||
assert(filenames[i] != NULL);
|
||||
|
||||
sprintf(buff, "f/%s", filenames[i]);
|
||||
assertMakeFile(buff, 0777, buff);
|
||||
|
||||
/* Create a link named "l/abcdef..." to the above. */
|
||||
sprintf(buff2, "l/%s", filenames[i]);
|
||||
assertMakeHardlink(buff2, buff);
|
||||
|
||||
/* Create a link named "m/abcdef..." to the above. */
|
||||
sprintf(buff2, "m/%s", filenames[i]);
|
||||
assertMakeHardlink(buff2, buff);
|
||||
|
||||
if (canSymlink()) {
|
||||
/* Create a symlink named "s/abcdef..." to the above. */
|
||||
sprintf(buff, "s/%s", filenames[i]);
|
||||
sprintf(buff2, "../f/%s", filenames[i]);
|
||||
failure("buff=\"%s\" buff2=\"%s\"", buff, buff2);
|
||||
assertMakeSymlink(buff, buff2, 0);
|
||||
}
|
||||
/* Create a dir named "d/abcdef...". */
|
||||
buff[0] = 'd';
|
||||
failure("buff=\"%s\"", buff);
|
||||
assertMakeDir(buff, 0775);
|
||||
}
|
||||
|
||||
assertEqualInt(0, chdir(".."));
|
||||
}
|
||||
|
||||
#define LIMIT_NONE 200
|
||||
#define LIMIT_USTAR 100
|
||||
|
||||
static void
|
||||
verify_tree(size_t limit)
|
||||
{
|
||||
char name1[260];
|
||||
char name2[260];
|
||||
size_t i, LOOP_MAX;
|
||||
|
||||
LOOP_MAX = compute_loop_max();
|
||||
|
||||
/* Generate the names we know should be there and verify them. */
|
||||
for (i = 1; i < LOOP_MAX; i++) {
|
||||
/* Verify a file named "f/abcdef..." */
|
||||
sprintf(name1, "f/%s", filenames[i]);
|
||||
if (i <= limit) {
|
||||
assertFileExists(name1);
|
||||
assertFileContents(name1, (int)strlen(name1), name1);
|
||||
}
|
||||
|
||||
sprintf(name2, "l/%s", filenames[i]);
|
||||
if (i + 2 <= limit) {
|
||||
/* Verify hardlink "l/abcdef..." */
|
||||
assertIsHardlink(name1, name2);
|
||||
/* Verify hardlink "m/abcdef..." */
|
||||
name2[0] = 'm';
|
||||
assertIsHardlink(name1, name2);
|
||||
}
|
||||
|
||||
if (canSymlink()) {
|
||||
/* Verify symlink "s/abcdef..." */
|
||||
sprintf(name1, "s/%s", filenames[i]);
|
||||
sprintf(name2, "../f/%s", filenames[i]);
|
||||
if (strlen(name2) <= limit)
|
||||
assertIsSymlink(name1, name2, 0);
|
||||
}
|
||||
|
||||
/* Verify dir "d/abcdef...". */
|
||||
sprintf(name1, "d/%s", filenames[i]);
|
||||
if (i + 1 <= limit) { /* +1 for trailing slash */
|
||||
if (assertIsDir(name1, -1)) {
|
||||
/* TODO: opendir/readdir this
|
||||
* directory and make sure
|
||||
* it's empty.
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
{
|
||||
const char *dp;
|
||||
/* Now make sure nothing is there that shouldn't be. */
|
||||
for (dp = "dflms"; *dp != '\0'; ++dp) {
|
||||
DIR *d;
|
||||
struct dirent *de;
|
||||
char dir[2];
|
||||
dir[0] = *dp; dir[1] = '\0';
|
||||
d = opendir(dir);
|
||||
failure("Unable to open dir '%s'", dir);
|
||||
if (!assert(d != NULL))
|
||||
continue;
|
||||
while ((de = readdir(d)) != NULL) {
|
||||
char *p = de->d_name;
|
||||
if (p[0] == '.')
|
||||
continue;
|
||||
switch(dp[0]) {
|
||||
case 'l': case 'm': case 'd':
|
||||
failure("strlen(p)=%zu", strlen(p));
|
||||
assert(strlen(p) < limit);
|
||||
assertEqualString(p,
|
||||
filenames[strlen(p)]);
|
||||
break;
|
||||
case 'f': case 's':
|
||||
failure("strlen(p)=%zu", strlen(p));
|
||||
assert(strlen(p) < limit + 1);
|
||||
assertEqualString(p,
|
||||
filenames[strlen(p)]);
|
||||
break;
|
||||
default:
|
||||
failure("File %s shouldn't be here", p);
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
copy_basic(void)
|
||||
{
|
||||
int r;
|
||||
|
||||
/* NOTE: for proper operation on cygwin-1.5 and windows, the
|
||||
* length of the name of the directory below, "plain", must be
|
||||
* less than or equal to the length of the name of the original
|
||||
* directory, "original" This restriction derives from the
|
||||
* extremely limited pathname lengths on those platforms.
|
||||
*/
|
||||
assertMakeDir("plain", 0775);
|
||||
assertEqualInt(0, chdir("plain"));
|
||||
|
||||
/*
|
||||
* Use the tar program to create an archive.
|
||||
*/
|
||||
r = systemf("%s cf archive -C ../original f d l m s >pack.out 2>pack.err",
|
||||
testprog);
|
||||
failure("Error invoking \"%s cf\"", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Verify that nothing went to stdout or stderr. */
|
||||
assertEmptyFile("pack.err");
|
||||
assertEmptyFile("pack.out");
|
||||
|
||||
/*
|
||||
* Use tar to unpack the archive into another directory.
|
||||
*/
|
||||
r = systemf("%s xf archive >unpack.out 2>unpack.err", testprog);
|
||||
failure("Error invoking %s xf archive", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Verify that nothing went to stdout or stderr. */
|
||||
assertEmptyFile("unpack.err");
|
||||
assertEmptyFile("unpack.out");
|
||||
|
||||
verify_tree(LIMIT_NONE);
|
||||
assertEqualInt(0, chdir(".."));
|
||||
}
|
||||
|
||||
static void
|
||||
copy_ustar(void)
|
||||
{
|
||||
const char *target = "ustar";
|
||||
int r;
|
||||
|
||||
/* NOTE: for proper operation on cygwin-1.5 and windows, the
|
||||
* length of the name of the directory below, "ustar", must be
|
||||
* less than or equal to the length of the name of the original
|
||||
* directory, "original" This restriction derives from the
|
||||
* extremely limited pathname lengths on those platforms.
|
||||
*/
|
||||
assertMakeDir(target, 0775);
|
||||
assertEqualInt(0, chdir(target));
|
||||
|
||||
/*
|
||||
* Use the tar program to create an archive.
|
||||
*/
|
||||
r = systemf("%s cf archive --format=ustar -C ../original f d l m s >pack.out 2>pack.err",
|
||||
testprog);
|
||||
failure("Error invoking \"%s cf archive --format=ustar\"", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Verify that nothing went to stdout. */
|
||||
assertEmptyFile("pack.out");
|
||||
/* Stderr is non-empty, since there are a bunch of files
|
||||
* with filenames too long to archive. */
|
||||
|
||||
/*
|
||||
* Use tar to unpack the archive into another directory.
|
||||
*/
|
||||
r = systemf("%s xf archive >unpack.out 2>unpack.err", testprog);
|
||||
failure("Error invoking %s xf archive", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Verify that nothing went to stdout or stderr. */
|
||||
assertEmptyFile("unpack.err");
|
||||
assertEmptyFile("unpack.out");
|
||||
|
||||
verify_tree(LIMIT_USTAR);
|
||||
assertEqualInt(0, chdir("../.."));
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_copy)
|
||||
{
|
||||
assertUmask(0);
|
||||
create_tree(); /* Create sample files in "original" dir. */
|
||||
|
||||
/* Test simple "tar -c | tar -x" pipeline copy. */
|
||||
copy_basic();
|
||||
|
||||
/* Same, but constrain to ustar format. */
|
||||
copy_ustar();
|
||||
}
|
45
dependencies/libarchive-3.4.2/tar/test/test_empty_mtree.c
vendored
Normal file
45
dependencies/libarchive-3.4.2/tar/test/test_empty_mtree.c
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2009 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Regression test: We used to get a bogus error message when we
|
||||
* asked tar to copy entries out of an empty archive. See
|
||||
* Issue 51 on libarchive.googlecode.com for details.
|
||||
*/
|
||||
DEFINE_TEST(test_empty_mtree)
|
||||
{
|
||||
int r;
|
||||
|
||||
assertMakeFile("test1.mtree", 0777, "#mtree\n");
|
||||
|
||||
r = systemf("%s cf test1.tar @test1.mtree >test1.out 2>test1.err",
|
||||
testprog);
|
||||
failure("Error invoking %s cf", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("test1.out");
|
||||
assertEmptyFile("test1.err");
|
||||
}
|
9
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.Z.uu
vendored
Normal file
9
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.Z.uu
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
begin 664 test_extract.tar.Z
|
||||
M'YV09M*P*1,#@,&#"!,J7,BPH<.'$",BA$'1A@T:(`!0C'&C!HR,&SM^U$BQ
|
||||
M9$D9,T#$D`%CAHP;-&"@Q`@C1HP9-FH```%#HL^?0(,*!5!G#ITP<DB.J5-F
|
||||
M:,.E39TN-$D1)-6,4K-JW<JUZ]`Q;]S0*2-V#H@W9D`$'!C#A0*O<./*G4NW
|
||||
MKMV[>//JW<O7X=HR,OH*=EC2(D:2'#U:33R2JDF4*EFZA"F31@V>-F?<Z,ES
|
||||
ML.>'18\FI0@5;FFOCJV:Q/JYM>NM8,62I6,6K5J!@-V^WLV[M^_?P(,+'TZ\
|
||||
0N/'CR),K7\Z\N?/GT*,K!P``
|
||||
`
|
||||
end
|
7
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.bz2.uu
vendored
Normal file
7
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.bz2.uu
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
begin 664 test_extract.tar.bz2
|
||||
M0EIH.3%!629368N]6:```'U[D=(0`"!``7^```AK)9X`!```$0`(,`"X#&$Q
|
||||
M,F`F``,83$R8"8``*J:")M0TCQ30-/%-3*]V3EE!&(DSM8?BJ4J)=TSJ4/"B
|
||||
M,?#R_6>?9K=+H02NT0V040P3.SHF:(573*)M5&;!-%6RO=6F5":N"+,"YZ;L
|
||||
AV+<]%F[GWYCR<%FRKAPR=7VY+'+1)_B[DBG"A(1=ZLT`
|
||||
`
|
||||
end
|
7
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.grz.uu
vendored
Normal file
7
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.grz.uu
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
begin 644 test_extract.tar.grz
|
||||
M1U)::7!)20`"!#HI``P``*P,``#U````SP```'<````[-=0OM"R^UP#^C?Z<
|
||||
MFGU0]I:>SW7]H01)1\WY:59("M_=V4[N[R*'`H&:'E=O@5B(?T,0?@)%-:_D
|
||||
M;EUP)!JVN)@V_:ABYS3+[[6/R(NU,-::]'X&;,]:,HR[*3#R!@:W)IGC`,&G
|
||||
8L+IZ7]FP=8U_R?CZ2XPO)"H-ME3@P]$`
|
||||
`
|
||||
end
|
7
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.gz.uu
vendored
Normal file
7
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.gz.uu
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
begin 664 test_extract.tar.gz
|
||||
M'XL(""S!:U```W1E<W1?97AT<F%C="YT87(`2\O,235DH"TP,#`P,S-1`-*&
|
||||
MYJ8&R#04&!DK&!H9&!N9FP"9)@H&AH;&9J8,"@8T=A<8E!:7)!8!G9)<FHI7
|
||||
M'2%YB$\4X/00`<GY>26I>27%"OEI"FF@M*#'-=!.&@5T!*`X-Z*Q'23E?Q-3
|
||||
A</XW-QC-__0`Z/G?:#3_CX)1,`I&P8@```&.A<``#```
|
||||
`
|
||||
end
|
9
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.lrz.uu
vendored
Normal file
9
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.lrz.uu
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
begin 664 test_extract.tar.lrz
|
||||
M3%):20`&``P``````````%T````!`0```@$`$`,`````#@`#`````$P``S<`
|
||||
M-P`````5``%/`!```#H``6,``0``6``!IP`!```%`@%/`/`#`3T```0`"0`!
|
||||
M=@$`!`#P!0```(5'8Z<&<`"E"````#,:2=:X2EY$(`=+>P?_D@0*H:&)P-5?
|
||||
MZX%NI60,IT@(N<,S%?7H2TLP5)FN#[-;&&[/2A#BNH4(7#C+*&ZP<>K&B)AG
|
||||
M:Z(;Y=]3<5Q$)_[[5M\7=]N7A$%\ZF:H2/,Q%BK$JA4L!,K(-RZU2X[/`%69
|
||||
.9U@/B[!N",NH4]8F,M(`
|
||||
`
|
||||
end
|
7
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.lz.uu
vendored
Normal file
7
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.lz.uu
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
begin 664 test_extract.tar.lz
|
||||
M3%I)4`$,`#,:2=:X2EY2J/TZ6]L7]]N4K?J&A)E2#"A'E"T1EP+MU&;(P1FY
|
||||
MV\,8BTS,N0/O2=#67;G5)%I'C,D.U?*T!NX("FYPYI9I40F>X))?^8\?E?#>
|
||||
MOP";"GD#8(9*K;XP318H<O&!L/<?HIOYPSNA8V5:E"239/Z<6[6>XZ\?_^SZ
|
||||
6K-(!CH7```P```````"=````````````
|
||||
`
|
||||
end
|
8
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.lz4.uu
vendored
Normal file
8
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.lz4.uu
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
begin 644 test_extract.tar.lz4
|
||||
M!")-&&1PN:L```!O9FEL93$``0!+Z#`P,#8V-"``,#`Q-S4P"``#`@#_"3(S
|
||||
M(#$R,#,R-S0P,C,T(#`Q,3,V-0`@,)<`2P("`+)U<W1A<@`P,&-U91$`#P(`
|
||||
M!`\@``T"RP``W0```@`?($8`!`\"`'[!8V]N=&5N=',@;V8@#`(O+@JD`'X/
|
||||
M`@#_2@#T`1\R80%,#P`$&B$T-0`$+S<P``3_9!\R``3_W0\"`/___^M0````
|
||||
*````````J.?`=```
|
||||
`
|
||||
end
|
7
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.lzma.uu
vendored
Normal file
7
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.lzma.uu
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
begin 664 test_extract.tar.lzma
|
||||
M70``@`#__________P`S&DG6N$I>4JC].EO;%_?;E*WZAH294@PH1Y0M$9<"
|
||||
M[=1FR,$9N=O#&(M,Q24U'H+5Z^7^*J;G!)OU]O'2D;AZ&0^IO?>-YA]$:-X_
|
||||
MD^O)YVM(4`^-MT$X`.D(6)*$]3HNB9KJ_H=1$QKYZ:`:,H_L"H[#"?#Z5A<]
|
||||
%O_OZW=D`
|
||||
`
|
||||
end
|
9
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.lzo.uu
vendored
Normal file
9
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.lzo.uu
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
begin 664 test_extract.tar.lzo
|
||||
MB4Q:3P`-"AH*$#`@8`E``04#```!``"!M%!R@T``````$'1E<W1?97AT<F%C
|
||||
M="YT87*FJ0IM```,`````+BYG#.C`V9I;&4Q`"`]```+,#`P-C8T(``P,#$W
|
||||
M-3`J'0`PH```!C(S(#$R,#,R-S0P,C,T(#`Q,3,V-0`@,"`]6`*T"PAU<W1A
|
||||
M<@`P,&-U9:`"-10`/GP`I!EP&V4!(#44`2!P6``)8V]N=&5N=',@;V8@CD$N
|
||||
M"B!PC`(@`#Q``FT^,B`^@`4@#/X/-#6>?S<P(`!6_0\R(`#/_`\@/N@/(```
|
||||
=`')X`0X``````````````````````!$`````````
|
||||
`
|
||||
end
|
8
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.xz.uu
vendored
Normal file
8
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.xz.uu
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
begin 664 test_extract.tar.xz
|
||||
M_3=Z6%H```3FUK1&`@`A`18```!T+^6CX`O_`'E=`#,:2=:X2EY2J/TZ6]L7
|
||||
M]]N4K?J&A)E2#"A'E"T1EP+MU&;(P1FYV\,8BTS%)34>@M7KY?XJIN<$F_7V
|
||||
M\=*1N'H9#ZF]]XWF'T1HWC^3Z\GG:TA0#XVW03@`Z0A8DH3U.BZ)FNK^AU$3
|
||||
M&OGIH!HRC^P*CL,)\/,MGP``````2IVA+$<(^YX``94!@!@``&X^\DRQQ&?[
|
||||
(`@`````$65H`
|
||||
`
|
||||
end
|
6
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.zst.uu
vendored
Normal file
6
dependencies/libarchive-3.4.2/tar/test/test_extract.tar.zst.uu
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
begin 644 test_extract.tar.zst
|
||||
M*+4O_010S0,`<L40$Z`5.(2U_RNV_[]L4V;Z_/R@1:7Y$3;9E`8$D$WI:W1)
|
||||
M'58'D3->Y+>!0*5E/PM"$7^K^1VI3SS-AX&_W0KQWY!-Z1(`_4$%[$"]<T!A
|
||||
L(*`#I!DXC4[J!6J8$!DJ$D"9$T*L]#G-$$/A`#`I`-(`UUKAU$Z@"`UXII``
|
||||
`
|
||||
end
|
42
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_Z.c
vendored
Normal file
42
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_Z.c
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_tar_Z)
|
||||
{
|
||||
const char *reffile = "test_extract.tar.Z";
|
||||
|
||||
extract_reference_file(reffile);
|
||||
assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
}
|
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_bz2.c
vendored
Normal file
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_bz2.c
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_tar_bz2)
|
||||
{
|
||||
const char *reffile = "test_extract.tar.bz2";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canBzip2()) {
|
||||
assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems bzip2 is not supported on this platform");
|
||||
}
|
||||
}
|
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_grz.c
vendored
Normal file
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_grz.c
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_tar_grz)
|
||||
{
|
||||
const char *reffile = "test_extract.tar.grz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canGrzip()) {
|
||||
assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems grzip is not supported on this platform");
|
||||
}
|
||||
}
|
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_gz.c
vendored
Normal file
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_gz.c
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_tar_gz)
|
||||
{
|
||||
const char *reffile = "test_extract.tar.gz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canGzip()) {
|
||||
assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems gzip is not supported on this platform");
|
||||
}
|
||||
}
|
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_lrz.c
vendored
Normal file
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_lrz.c
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_tar_lrz)
|
||||
{
|
||||
const char *reffile = "test_extract.tar.lrz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLrzip()) {
|
||||
assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems lrzip is not supported on this platform");
|
||||
}
|
||||
}
|
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_lz.c
vendored
Normal file
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_lz.c
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_tar_lz)
|
||||
{
|
||||
const char *reffile = "test_extract.tar.lz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLzip()) {
|
||||
assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems lzip is not supported on this platform");
|
||||
}
|
||||
}
|
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_lz4.c
vendored
Normal file
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_lz4.c
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012,2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_tar_lz4)
|
||||
{
|
||||
const char *reffile = "test_extract.tar.lz4";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLz4()) {
|
||||
assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems lz4 is not supported on this platform");
|
||||
}
|
||||
}
|
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_lzma.c
vendored
Normal file
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_lzma.c
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_tar_lzma)
|
||||
{
|
||||
const char *reffile = "test_extract.tar.lzma";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLzma()) {
|
||||
assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems lzma is not supported on this platform");
|
||||
}
|
||||
}
|
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_lzo.c
vendored
Normal file
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_lzo.c
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_tar_lzo)
|
||||
{
|
||||
const char *reffile = "test_extract.tar.lzo";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canLzop()) {
|
||||
assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems lzop is not supported on this platform");
|
||||
}
|
||||
}
|
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_xz.c
vendored
Normal file
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_xz.c
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_tar_xz)
|
||||
{
|
||||
const char *reffile = "test_extract.tar.xz";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canXz()) {
|
||||
assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems xz is not supported on this platform");
|
||||
}
|
||||
}
|
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_zstd.c
vendored
Normal file
48
dependencies/libarchive-3.4.2/tar/test/test_extract_tar_zstd.c
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2017 Sean Purcell
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_extract_tar_zstd)
|
||||
{
|
||||
const char *reffile = "test_extract.tar.zst";
|
||||
int f;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile);
|
||||
if (f == 0 || canZstd()) {
|
||||
assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
} else {
|
||||
skipping("It seems zstd is not supported on this platform");
|
||||
}
|
||||
}
|
64
dependencies/libarchive-3.4.2/tar/test/test_format_newc.c
vendored
Normal file
64
dependencies/libarchive-3.4.2/tar/test/test_format_newc.c
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_format_newc)
|
||||
{
|
||||
|
||||
assertMakeFile("file1", 0644, "file1");
|
||||
assertMakeFile("file2", 0644, "file2");
|
||||
assertMakeHardlink("file3", "file1");
|
||||
|
||||
/* Test 1: Create an archive file with a newc format. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf test1.cpio --format newc file1 file2 file3",
|
||||
testprog));
|
||||
assertMakeDir("test1", 0755);
|
||||
assertChdir("test1");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../test1.cpio >test.out 2>test.err", testprog));
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileContents("file2", 5, "file2");
|
||||
assertFileContents("file1", 5, "file3");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 2: Exclude one of hardlinked files. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf test2.cpio --format newc file1 file2",
|
||||
testprog));
|
||||
assertMakeDir("test2", 0755);
|
||||
assertChdir("test2");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../test2.cpio >test.out 2>test.err", testprog));
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileContents("file2", 5, "file2");
|
||||
assertFileNotExists("file3");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
}
|
84
dependencies/libarchive-3.4.2/tar/test/test_help.c
vendored
Normal file
84
dependencies/libarchive-3.4.2/tar/test/test_help.c
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_help.c,v 1.2 2008/05/26 17:10:10 kientzle Exp $");
|
||||
|
||||
/*
|
||||
* Test that "--help", "-h", and "-W help" options all work and
|
||||
* generate reasonable output.
|
||||
*/
|
||||
|
||||
static int
|
||||
in_first_line(const char *p, const char *substring)
|
||||
{
|
||||
size_t l = strlen(substring);
|
||||
|
||||
while (*p != '\0' && *p != '\n') {
|
||||
if (memcmp(p, substring, l) == 0)
|
||||
return (1);
|
||||
++p;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_help)
|
||||
{
|
||||
int r;
|
||||
char *p;
|
||||
size_t plen;
|
||||
|
||||
/* Exercise --help option. */
|
||||
r = systemf("%s --help >help.stdout 2>help.stderr", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
failure("--help should generate nothing to stderr.");
|
||||
assertEmptyFile("help.stderr");
|
||||
/* Help message should start with name of program. */
|
||||
p = slurpfile(&plen, "help.stdout");
|
||||
failure("Help output should be long enough.");
|
||||
assert(plen >= 6);
|
||||
failure("First line of help output should contain 'bsdtar': %s", p);
|
||||
assert(in_first_line(p, "bsdtar"));
|
||||
/*
|
||||
* TODO: Extend this check to further verify that --help output
|
||||
* looks approximately right.
|
||||
*/
|
||||
free(p);
|
||||
|
||||
/* -h option should generate the same output. */
|
||||
r = systemf("%s -h >h.stdout 2>h.stderr", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
failure("-h should generate nothing to stderr.");
|
||||
assertEmptyFile("h.stderr");
|
||||
failure("stdout should be same for -h and --help");
|
||||
assertEqualFile("h.stdout", "help.stdout");
|
||||
|
||||
/* -W help should be another synonym. */
|
||||
r = systemf("%s -W help >Whelp.stdout 2>Whelp.stderr", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
failure("-W help should generate nothing to stderr.");
|
||||
assertEmptyFile("Whelp.stderr");
|
||||
failure("stdout should be same for -W help and --help");
|
||||
assertEqualFile("Whelp.stdout", "help.stdout");
|
||||
}
|
50
dependencies/libarchive-3.4.2/tar/test/test_leading_slash.c
vendored
Normal file
50
dependencies/libarchive-3.4.2/tar/test/test_leading_slash.c
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2014 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_leading_slash)
|
||||
{
|
||||
const char *reffile = "test_leading_slash.tar";
|
||||
char *errfile;
|
||||
size_t errfile_size;
|
||||
const char *expected_errmsg = "Removing leading '/' from member names";
|
||||
|
||||
extract_reference_file(reffile);
|
||||
assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err", testprog, reffile));
|
||||
assertFileExists("foo/file");
|
||||
assertTextFileContents("foo\x0a", "foo/file");
|
||||
assertTextFileContents("foo\x0a", "foo/hardlink");
|
||||
assertIsHardlink("foo/file", "foo/hardlink");
|
||||
assertEmptyFile("test.out");
|
||||
|
||||
/* Verify the error output contains the expected text somewhere in it */
|
||||
if (assertFileExists("test.err")) {
|
||||
errfile = slurpfile(&errfile_size, "test.err");
|
||||
assert(strstr(errfile, expected_errmsg) != NULL);
|
||||
free(errfile);
|
||||
}
|
||||
}
|
||||
|
60
dependencies/libarchive-3.4.2/tar/test/test_leading_slash.tar.uu
vendored
Normal file
60
dependencies/libarchive-3.4.2/tar/test/test_leading_slash.tar.uu
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
begin 644 test_leading_slash.tar
|
||||
M+V9O;R]F:6QE````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````#`P,#8T-"``,#`P,#`P(``P,#`P,#`@`#`P,#`P,#`P,#`T
|
||||
M(#$R-#$V,S4U-34V(#`Q,C8V-P`@,```````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````!U<W1A<@`P,')O;W0`
|
||||
M````````````````````````````````````=VAE96P`````````````````
|
||||
M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````!F;V\*````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````"]F;V\O:&%R9&QI
|
||||
M;FL`````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````````````````````````P
|
||||
M,#`V-#0@`#`P,#`P,"``,#`P,#`P(``P,#`P,#`P,#`P,"`Q,C0Q-C,U-34U
|
||||
M-B`P,34R-#,`(#$O9F]O+V9I;&4`````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````=7-T87(`,#!R;V]T````````````````
|
||||
M`````````````````````'=H965L````````````````````````````````
|
||||
M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
H````````````````````````````````````````````````````````
|
||||
`
|
||||
end
|
41
dependencies/libarchive-3.4.2/tar/test/test_missing_file.c
vendored
Normal file
41
dependencies/libarchive-3.4.2/tar/test/test_missing_file.c
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*-
|
||||
* Copyright (c) 2016 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_missing_file)
|
||||
{
|
||||
const char * invalid_stderr[] = { "INTERNAL ERROR", NULL };
|
||||
assertMakeFile("file1", 0644, "file1");
|
||||
assertMakeFile("file2", 0644, "file2");
|
||||
assert(0 == systemf("%s -cf archive.tar file1 file2 2>stderr1", testprog));
|
||||
assertEmptyFile("stderr1");
|
||||
assert(0 != systemf("%s -cf archive.tar file1 file2 file3 2>stderr2", testprog));
|
||||
assertFileContainsNoInvalidStrings("stderr2", invalid_stderr);
|
||||
assert(0 != systemf("%s -cf archive.tar 2>stderr3", testprog));
|
||||
assertFileContainsNoInvalidStrings("stderr3", invalid_stderr);
|
||||
assert(0 != systemf("%s -cf archive.tar file3 file4 2>stderr4", testprog));
|
||||
assertFileContainsNoInvalidStrings("stderr4", invalid_stderr);
|
||||
}
|
89
dependencies/libarchive-3.4.2/tar/test/test_option_C_mtree.c
vendored
Normal file
89
dependencies/libarchive-3.4.2/tar/test/test_option_C_mtree.c
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*-
|
||||
* Copyright (c) 2018 The FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by Arshan Khanifar <arshankhanifar@gmail.com>
|
||||
* under sponsorship from the FreeBSD Foundation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_C_mtree)
|
||||
{
|
||||
char *p0;
|
||||
size_t s;
|
||||
int r;
|
||||
p0 = NULL;
|
||||
char *content = "./foo type=file uname=root gname=root mode=0755\n";
|
||||
char *filename = "output.tar";
|
||||
#if defined(_WIN32) && !defined(CYGWIN)
|
||||
char *p;
|
||||
#endif
|
||||
|
||||
/* an absolute path to mtree file */
|
||||
char *mtree_file = "/METALOG.mtree";
|
||||
char *absolute_path = malloc(strlen(testworkdir) + strlen(mtree_file) + 1);
|
||||
strcpy(absolute_path, testworkdir);
|
||||
strcat(absolute_path, mtree_file );
|
||||
|
||||
/* Create an archive using an mtree file. */
|
||||
assertMakeFile(absolute_path, 0777, content);
|
||||
assertMakeDir("bar", 0775);
|
||||
assertMakeFile("bar/foo", 0777, "abc");
|
||||
|
||||
#if defined(_WIN32) && !defined(CYGWIN)
|
||||
p = absolute_path;
|
||||
while(*p != '\0') {
|
||||
if (*p == '/')
|
||||
*p = '\\';
|
||||
p++;
|
||||
}
|
||||
|
||||
r = systemf("%s -cf %s -C bar @%s >step1.out 2>step1.err", testprog, filename, absolute_path);
|
||||
failure("Error invoking %s -cf %s -C bar @%s", testprog, filename, absolute_path);
|
||||
#else
|
||||
r = systemf("%s -cf %s -C bar \"@%s\" >step1.out 2>step1.err", testprog, filename, absolute_path);
|
||||
failure("Error invoking %s -cf %s -C bar \"@%s\"", testprog, filename, absolute_path);
|
||||
#endif
|
||||
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("step1.out");
|
||||
assertEmptyFile("step1.err");
|
||||
|
||||
/* Do validation of the constructed archive. */
|
||||
|
||||
p0 = slurpfile(&s, "output.tar");
|
||||
if (!assert(p0 != NULL))
|
||||
goto done;
|
||||
if (!assert(s >= 2048))
|
||||
goto done;
|
||||
assertEqualMem(p0 + 0, "./foo", 5);
|
||||
assertEqualMem(p0 + 512, "abc", 3);
|
||||
assertEqualMem(p0 + 1024, "\0\0\0\0\0\0\0\0", 8);
|
||||
assertEqualMem(p0 + 1536, "\0\0\0\0\0\0\0\0", 8);
|
||||
done:
|
||||
free(p0);
|
||||
free(absolute_path);
|
||||
}
|
||||
|
||||
|
149
dependencies/libarchive-3.4.2/tar/test/test_option_C_upper.c
vendored
Normal file
149
dependencies/libarchive-3.4.2/tar/test/test_option_C_upper.c
vendored
Normal file
|
@ -0,0 +1,149 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_C_upper)
|
||||
{
|
||||
int r;
|
||||
|
||||
assertMakeDir("d1", 0755);
|
||||
assertMakeDir("d2", 0755);
|
||||
assertMakeFile("d1/file1", 0644, "d1/file1");
|
||||
assertMakeFile("d1/file2", 0644, "d1/file2");
|
||||
assertMakeFile("d2/file1", 0644, "d2/file1");
|
||||
assertMakeFile("d2/file2", 0644, "d2/file2");
|
||||
|
||||
/*
|
||||
* Test 1: Basic use of -C
|
||||
*/
|
||||
assertMakeDir("test1", 0755);
|
||||
assertChdir("test1");
|
||||
assertEqualInt(0, systemf("%s -cf archive.tar -C ../d1 file1 -C ../d2 file2", testprog));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileContents("d1/file1", 8, "file1");
|
||||
assertFileContents("d2/file2", 8, "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
|
||||
/*
|
||||
* Test 2: Multiple -C
|
||||
*/
|
||||
assertMakeDir("test2", 0755);
|
||||
assertChdir("test2");
|
||||
assertEqualInt(0, systemf("%s -cf archive.tar -C .. -C d1 file1 -C .. -C d2 file2", testprog));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileContents("d1/file1", 8, "file1");
|
||||
assertFileContents("d2/file2", 8, "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/*
|
||||
* Test 3: -C fail
|
||||
*/
|
||||
assertMakeDir("test3", 0755);
|
||||
assertChdir("test3");
|
||||
r = systemf("%s -cf archive.tar -C ../XXX file1 -C ../d2 file2 2>write.err", testprog);
|
||||
assert(r != 0);
|
||||
assertNonEmptyFile("write.err");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileNotExists("file1");
|
||||
assertFileNotExists("file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/*
|
||||
* Test 4: Absolute -C
|
||||
*/
|
||||
assertMakeDir("test4", 0755);
|
||||
assertChdir("test4");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf archive.tar -C %s/d1 file1",
|
||||
testprog, testworkdir));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileContents("d1/file1", 8, "file1");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/*
|
||||
* Test 5: Unnecessary -C ignored even if directory named doesn't exist
|
||||
*/
|
||||
assertMakeDir("test5", 0755);
|
||||
assertChdir("test5");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf archive.tar -C XXX -C %s/d1 file1",
|
||||
testprog, testworkdir));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileContents("d1/file1", 8, "file1");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/*
|
||||
* Test 6: Necessary -C not ignored if directory doesn't exist
|
||||
*/
|
||||
assertMakeDir("test6", 0755);
|
||||
assertChdir("test6");
|
||||
r = systemf("%s -cf archive.tar -C XXX -C ../d1 file1 2>write.err",
|
||||
testprog);
|
||||
assert(r != 0);
|
||||
assertNonEmptyFile("write.err");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >test.out 2>test.err", testprog));
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/*
|
||||
* Test 7: -C used without specifying directory
|
||||
*/
|
||||
assertMakeDir("test7", 0755);
|
||||
assertChdir("test7");
|
||||
r = systemf("%s -cf archive.tar ../d1/file1 -C 2>write.err", testprog);
|
||||
assert(r != 0);
|
||||
assertNonEmptyFile("write.err");
|
||||
assertChdir("..");
|
||||
|
||||
/*
|
||||
* Test 8: -C used with meaningless option ''
|
||||
*/
|
||||
assertMakeDir("test8", 0755);
|
||||
assertChdir("test8");
|
||||
r = systemf("%s -cf archive.tar ../d1/file1 -C \"\" 2>write.err",
|
||||
testprog);
|
||||
assert(r != 0);
|
||||
assertNonEmptyFile("write.err");
|
||||
assertChdir("..");
|
||||
}
|
92
dependencies/libarchive-3.4.2/tar/test/test_option_H_upper.c
vendored
Normal file
92
dependencies/libarchive-3.4.2/tar/test/test_option_H_upper.c
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_H_upper)
|
||||
{
|
||||
|
||||
if (!canSymlink()) {
|
||||
skipping("Can't test symlinks on this filesystem");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a sample archive.
|
||||
*/
|
||||
assertMakeDir("in", 0755);
|
||||
assertChdir("in");
|
||||
assertMakeDir("d1", 0755);
|
||||
assertMakeSymlink("ld1", "d1", 1);
|
||||
assertMakeFile("d1/file1", 0644, "d1/file1");
|
||||
assertMakeFile("d1/file2", 0644, "d1/file2");
|
||||
assertMakeSymlink("d1/link1", "file1", 0);
|
||||
assertMakeSymlink("d1/linkX", "fileX", 0);
|
||||
assertMakeSymlink("link2", "d1/file2", 0);
|
||||
assertMakeSymlink("linkY", "d1/fileY", 0);
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 1: Without -H */
|
||||
assertMakeDir("test1", 0755);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf test1/archive.tar -C in . >test1/c.out 2>test1/c.err", testprog));
|
||||
assertChdir("test1");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
|
||||
assertIsSymlink("ld1", "d1", 1);
|
||||
assertIsSymlink("d1/link1", "file1", 0);
|
||||
assertIsSymlink("d1/linkX", "fileX", 0);
|
||||
assertIsSymlink("link2", "d1/file2", 0);
|
||||
assertIsSymlink("linkY", "d1/fileY", 0);
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 2: With -H, no symlink on command line. */
|
||||
assertMakeDir("test2", 0755);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf test2/archive.tar -H -C in . >test2/c.out 2>test2/c.err", testprog));
|
||||
assertChdir("test2");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
|
||||
assertIsSymlink("ld1", "d1", 1);
|
||||
assertIsSymlink("d1/link1", "file1", 0);
|
||||
assertIsSymlink("d1/linkX", "fileX", 0);
|
||||
assertIsSymlink("link2", "d1/file2", 0);
|
||||
assertIsSymlink("linkY", "d1/fileY", 0);
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 3: With -H, some symlinks on command line. */
|
||||
assertMakeDir("test3", 0755);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf test3/archive.tar -H -C in ld1 d1 link2 linkY >test2/c.out 2>test2/c.err", testprog));
|
||||
assertChdir("test3");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
|
||||
assertIsDir("ld1", umasked(0755));
|
||||
assertIsSymlink("d1/linkX", "fileX", 0);
|
||||
assertIsSymlink("d1/link1", "file1", 0);
|
||||
assertIsReg("link2", umasked(0644));
|
||||
assertIsSymlink("linkY", "d1/fileY", 0);
|
||||
assertChdir("..");
|
||||
}
|
92
dependencies/libarchive-3.4.2/tar/test/test_option_L_upper.c
vendored
Normal file
92
dependencies/libarchive-3.4.2/tar/test/test_option_L_upper.c
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_L_upper)
|
||||
{
|
||||
|
||||
if (!canSymlink()) {
|
||||
skipping("Can't test symlinks on this filesystem");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a sample archive.
|
||||
*/
|
||||
assertMakeDir("in", 0755);
|
||||
assertChdir("in");
|
||||
assertMakeDir("d1", 0755);
|
||||
assertMakeSymlink("ld1", "d1", 1);
|
||||
assertMakeFile("d1/file1", 0644, "d1/file1");
|
||||
assertMakeFile("d1/file2", 0644, "d1/file2");
|
||||
assertMakeSymlink("d1/link1", "file1", 0);
|
||||
assertMakeSymlink("d1/linkX", "fileX", 0);
|
||||
assertMakeSymlink("link2", "d1/file2", 0);
|
||||
assertMakeSymlink("linkY", "d1/fileY", 0);
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 1: Without -L */
|
||||
assertMakeDir("test1", 0755);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf test1/archive.tar -C in . >test1/c.out 2>test1/c.err", testprog));
|
||||
assertChdir("test1");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
|
||||
assertIsSymlink("ld1", "d1", 1);
|
||||
assertIsSymlink("d1/link1", "file1", 0);
|
||||
assertIsSymlink("d1/linkX", "fileX", 0);
|
||||
assertIsSymlink("link2", "d1/file2", 0);
|
||||
assertIsSymlink("linkY", "d1/fileY", 0);
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 2: With -L, no symlink on command line. */
|
||||
assertMakeDir("test2", 0755);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf test2/archive.tar -L -C in . >test2/c.out 2>test2/c.err", testprog));
|
||||
assertChdir("test2");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
|
||||
assertIsDir("ld1", umasked(0755));
|
||||
assertIsReg("d1/link1", umasked(0644));
|
||||
assertIsSymlink("d1/linkX", "fileX", 0);
|
||||
assertIsReg("link2", umasked(0644));
|
||||
assertIsSymlink("linkY", "d1/fileY", 0);
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 3: With -L, some symlinks on command line. */
|
||||
assertMakeDir("test3", 0755);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf test3/archive.tar -L -C in ld1 d1 link2 linkY >test2/c.out 2>test2/c.err", testprog));
|
||||
assertChdir("test3");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
|
||||
assertIsDir("ld1", umasked(0755));
|
||||
assertIsReg("d1/link1", umasked(0644));
|
||||
assertIsSymlink("d1/linkX", "fileX", 0);
|
||||
assertIsReg("link2", umasked(0644));
|
||||
assertIsSymlink("linkY", "d1/fileY", 0);
|
||||
assertChdir("..");
|
||||
}
|
87
dependencies/libarchive-3.4.2/tar/test/test_option_O_upper.c
vendored
Normal file
87
dependencies/libarchive-3.4.2/tar/test/test_option_O_upper.c
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
static const char *test4out[] = {"file1", "file2", NULL};
|
||||
static const char *test5err[] = {"file1", "file2", NULL};
|
||||
|
||||
DEFINE_TEST(test_option_O_upper)
|
||||
{
|
||||
assertMakeFile("file1", 0644, "file1");
|
||||
assertMakeFile("file2", 0644, "file2");
|
||||
assertEqualInt(0, systemf("%s -cf archive.tar file1 file2", testprog));
|
||||
|
||||
/* Test 1: -x without -O */
|
||||
assertMakeDir("test1", 0755);
|
||||
assertChdir("test1");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileContents("file2", 5, "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 2: -x with -O */
|
||||
assertMakeDir("test2", 0755);
|
||||
assertChdir("test2");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xOf ../archive.tar file1 >test.out 2>test.err", testprog));
|
||||
assertFileNotExists("file1");
|
||||
assertFileNotExists("file2");
|
||||
assertFileContents("file1", 5, "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 3: -x with -O and multiple files */
|
||||
assertMakeDir("test3", 0755);
|
||||
assertChdir("test3");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xOf ../archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileNotExists("file1");
|
||||
assertFileNotExists("file2");
|
||||
assertFileContents("file1file2", 10, "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 4: -t without -O */
|
||||
assertMakeDir("test4", 0755);
|
||||
assertChdir("test4");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileContainsLinesAnyOrder("test.out", test4out);
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 5: -t with -O */
|
||||
assertMakeDir("test5", 0755);
|
||||
assertChdir("test5");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tOf ../archive.tar >test.out 2>test.err", testprog));
|
||||
assertEmptyFile("test.out");
|
||||
assertFileContainsLinesAnyOrder("test.err", test5err);
|
||||
assertChdir("..");
|
||||
}
|
160
dependencies/libarchive-3.4.2/tar/test/test_option_T_upper.c
vendored
Normal file
160
dependencies/libarchive-3.4.2/tar/test/test_option_T_upper.c
vendored
Normal file
|
@ -0,0 +1,160 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2008 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_option_T.c,v 1.3 2008/08/15 06:12:02 kientzle Exp $");
|
||||
|
||||
static int
|
||||
tryMakeFile(const char *fn)
|
||||
{
|
||||
FILE *f = fopen(fn, "w");
|
||||
if (f == NULL)
|
||||
return (0);
|
||||
fclose(f);
|
||||
return (1);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_option_T_upper)
|
||||
{
|
||||
FILE *f;
|
||||
int r;
|
||||
int gnarlyFilesSupported;
|
||||
|
||||
/* Create a simple dir hierarchy; bail if anything fails. */
|
||||
if (!assertMakeDir("d1", 0755)) return;
|
||||
if (!assertMakeDir("d1/d2", 0755)) return;
|
||||
if (!assertMakeFile("f", 0644, "")) return;
|
||||
if (!assertMakeFile("d1/f1", 0644, "")) return;
|
||||
if (!assertMakeFile("d1/f2", 0644, "")) return;
|
||||
if (!assertMakeFile("d1/d2/f3", 0644, "")) return;
|
||||
if (!assertMakeFile("d1/d2/f4", 0644, "")) return;
|
||||
if (!assertMakeFile("d1/d2/f5", 0644, "")) return;
|
||||
if (!assertMakeFile("d1/d2/f6", 0644, "")) return;
|
||||
/* Some platforms don't permit such things; just skip it. */
|
||||
gnarlyFilesSupported = tryMakeFile("d1/d2/f\x0a");
|
||||
|
||||
/* Populate a file list */
|
||||
f = fopen("filelist", "w+");
|
||||
if (!assert(f != NULL))
|
||||
return;
|
||||
/* Use a variety of text line endings. */
|
||||
fprintf(f, "f\x0d"); /* CR */
|
||||
fprintf(f, "d1/f1\x0d\x0a"); /* CRLF */
|
||||
fprintf(f, "d1/d2/f4\x0a"); /* NL */
|
||||
fprintf(f, "d1/d2/f6"); /* EOF */
|
||||
fclose(f);
|
||||
|
||||
/* Populate a second file list */
|
||||
f = fopen("filelist2", "w+");
|
||||
if (!assert(f != NULL))
|
||||
return;
|
||||
/* Use null-terminated names. */
|
||||
fprintf(f, "d1/d2/f3");
|
||||
assertEqualInt(1, fwrite("\0", 1, 1, f));
|
||||
fprintf(f, "d1/d2/f5");
|
||||
assertEqualInt(1, fwrite("\0", 1, 1, f));
|
||||
if (gnarlyFilesSupported) {
|
||||
fprintf(f, "d1/d2/f\x0a");
|
||||
assertEqualInt(1, fwrite("\0", 1, 1, f));
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
/* Use -c -T to archive up the files. */
|
||||
r = systemf("%s -c -f test1.tar -T filelist > test1.out 2> test1.err",
|
||||
testprog);
|
||||
assert(r == 0);
|
||||
assertEmptyFile("test1.out");
|
||||
assertEmptyFile("test1.err");
|
||||
|
||||
/* Use -x -T to dearchive the files */
|
||||
if (!assertMakeDir("test1", 0755)) return;
|
||||
systemf("%s -x -f test1.tar -T filelist -C test1"
|
||||
" > test1b.out 2> test1b.err", testprog);
|
||||
assertEmptyFile("test1b.out");
|
||||
assertEmptyFile("test1b.err");
|
||||
|
||||
/* Verify the files were extracted. */
|
||||
assertFileExists("test1/f");
|
||||
assertFileExists("test1/d1/f1");
|
||||
assertFileNotExists("test1/d1/f2");
|
||||
assertFileNotExists("test1/d1/d2/f3");
|
||||
assertFileExists("test1/d1/d2/f4");
|
||||
assertFileNotExists("test1/d1/d2/f5");
|
||||
assertFileExists("test1/d1/d2/f6");
|
||||
if (gnarlyFilesSupported) {
|
||||
assertFileNotExists("test1/d1/d2/f\x0a");
|
||||
}
|
||||
|
||||
/* Use -r -T to add more files to the archive. */
|
||||
systemf("%s -r -f test1.tar --null -T filelist2 > test2.out 2> test2.err",
|
||||
testprog);
|
||||
assertEmptyFile("test2.out");
|
||||
assertEmptyFile("test2.err");
|
||||
|
||||
/* Use -x without -T to dearchive the files (ensure -r worked) */
|
||||
if (!assertMakeDir("test3", 0755)) return;
|
||||
systemf("%s -x -f test1.tar -C test3"
|
||||
" > test3.out 2> test3.err", testprog);
|
||||
assertEmptyFile("test3.out");
|
||||
assertEmptyFile("test3.err");
|
||||
/* Verify the files were extracted.*/
|
||||
assertFileExists("test3/f");
|
||||
assertFileExists("test3/d1/f1");
|
||||
assertFileNotExists("test3/d1/f2");
|
||||
assertFileExists("test3/d1/d2/f3");
|
||||
assertFileExists("test3/d1/d2/f4");
|
||||
assertFileExists("test3/d1/d2/f5");
|
||||
assertFileExists("test3/d1/d2/f6");
|
||||
if (gnarlyFilesSupported) {
|
||||
assertFileExists("test3/d1/d2/f\x0a");
|
||||
}
|
||||
|
||||
/* Use -x -T to dearchive the files (verify -x -T together) */
|
||||
if (!assertMakeDir("test2", 0755)) return;
|
||||
systemf("%s -x -f test1.tar -T filelist -C test2"
|
||||
" > test2b.out 2> test2b.err", testprog);
|
||||
assertEmptyFile("test2b.out");
|
||||
assertEmptyFile("test2b.err");
|
||||
/* Verify the files were extracted.*/
|
||||
assertFileExists("test2/f");
|
||||
assertFileExists("test2/d1/f1");
|
||||
assertFileNotExists("test2/d1/f2");
|
||||
assertFileNotExists("test2/d1/d2/f3");
|
||||
assertFileExists("test2/d1/d2/f4");
|
||||
assertFileNotExists("test2/d1/d2/f5");
|
||||
assertFileExists("test2/d1/d2/f6");
|
||||
if (gnarlyFilesSupported) {
|
||||
assertFileNotExists("test2/d1/d2/f\x0a");
|
||||
}
|
||||
|
||||
assertMakeDir("test4", 0755);
|
||||
assertMakeDir("test4_out", 0755);
|
||||
assertMakeDir("test4_out2", 0755);
|
||||
assertMakeDir("test4/d1", 0755);
|
||||
assertMakeFile("test4/d1/foo", 0644, "");
|
||||
|
||||
|
||||
/* TODO: Include some use of -C directory-changing within the filelist. */
|
||||
/* I'm pretty sure -C within the filelist is broken on extract. */
|
||||
}
|
159
dependencies/libarchive-3.4.2/tar/test/test_option_U_upper.c
vendored
Normal file
159
dependencies/libarchive-3.4.2/tar/test/test_option_U_upper.c
vendored
Normal file
|
@ -0,0 +1,159 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_U_upper)
|
||||
{
|
||||
int r;
|
||||
|
||||
assertMakeFile("file1", 0644, "file1");
|
||||
assertMakeDir("d1", 0755);
|
||||
assertMakeFile("d1/file1", 0644, "d1/file1");
|
||||
assertEqualInt(0, systemf("%s -cf archive.tar file1 d1/file1", testprog));
|
||||
|
||||
/*
|
||||
* bsdtar's man page used to claim that -x without -U would
|
||||
* not break hard links. This was and is nonsense. The first
|
||||
* two tests here simply verify that existing hard links get
|
||||
* broken regardless.
|
||||
*/
|
||||
|
||||
/* Test 1: -x without -U */
|
||||
assertMakeDir("test1", 0755);
|
||||
assertChdir("test1");
|
||||
assertMakeFile("file1", 0644, "file1new");
|
||||
assertMakeHardlink("file2", "file1");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileContents("file1new", 8, "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
|
||||
/* Test 2: -x with -U */
|
||||
assertMakeDir("test2", 0755);
|
||||
assertChdir("test2");
|
||||
assertMakeFile("file1", 0644, "file1new");
|
||||
assertMakeHardlink("file2", "file1");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xUf ../archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileContents("file1new", 8, "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/*
|
||||
* -U does make a difference in how bsdtar handles unwanted symlinks,
|
||||
* though. It interacts with -P.
|
||||
*/
|
||||
if (!canSymlink())
|
||||
return;
|
||||
|
||||
/* Test 3: Intermediate dir symlink causes error by default */
|
||||
assertMakeDir("test3", 0755);
|
||||
assertChdir("test3");
|
||||
assertMakeDir("realDir", 0755);
|
||||
assertMakeSymlink("d1", "realDir", 1);
|
||||
r = systemf("%s -xf ../archive.tar d1/file1 >test.out 2>test.err", testprog);
|
||||
assert(r != 0);
|
||||
assertIsSymlink("d1", "realDir", 1);
|
||||
assertFileNotExists("d1/file1");
|
||||
assertEmptyFile("test.out");
|
||||
assertNonEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 4: Intermediate dir symlink gets removed with -U */
|
||||
assertMakeDir("test4", 0755);
|
||||
assertChdir("test4");
|
||||
assertMakeDir("realDir", 0755);
|
||||
assertMakeSymlink("d1", "realDir", 1);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xUf ../archive.tar >test.out 2>test.err", testprog));
|
||||
assertIsDir("d1", -1);
|
||||
assertFileContents("d1/file1", 8, "d1/file1");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 5: Intermediate dir symlink is followed with -P */
|
||||
assertMakeDir("test5", 0755);
|
||||
assertChdir("test5");
|
||||
assertMakeDir("realDir", 0755);
|
||||
assertMakeSymlink("d1", "realDir", 1);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xPf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
|
||||
assertIsSymlink("d1", "realDir", 1);
|
||||
assertFileContents("d1/file1", 8, "d1/file1");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 6: Intermediate dir symlink is followed with -PU */
|
||||
assertMakeDir("test6", 0755);
|
||||
assertChdir("test6");
|
||||
assertMakeDir("realDir", 0755);
|
||||
assertMakeSymlink("d1", "realDir", 1);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xPUf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
|
||||
assertIsSymlink("d1", "realDir", 1);
|
||||
assertFileContents("d1/file1", 8, "d1/file1");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 7: Final file symlink replaced by default */
|
||||
assertMakeDir("test7", 0755);
|
||||
assertChdir("test7");
|
||||
assertMakeDir("d1", 0755);
|
||||
assertMakeFile("d1/realfile1", 0644, "realfile1");
|
||||
assertMakeSymlink("d1/file1", "d1/realfile1", 0);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
|
||||
assertIsReg("d1/file1", umasked(0644));
|
||||
assertFileContents("d1/file1", 8, "d1/file1");
|
||||
assertFileContents("realfile1", 9, "d1/realfile1");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 8: Final file symlink replaced with -PU */
|
||||
assertMakeDir("test8", 0755);
|
||||
assertChdir("test8");
|
||||
assertMakeDir("d1", 0755);
|
||||
assertMakeFile("d1/realfile1", 0644, "realfile1");
|
||||
assertMakeSymlink("d1/file1", "d1/realfile1", 0);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xPUf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
|
||||
assertIsReg("d1/file1", umasked(0644));
|
||||
assertFileContents("d1/file1", 8, "d1/file1");
|
||||
assertFileContents("realfile1", 9, "d1/realfile1");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
}
|
159
dependencies/libarchive-3.4.2/tar/test/test_option_X_upper.c
vendored
Normal file
159
dependencies/libarchive-3.4.2/tar/test/test_option_X_upper.c
vendored
Normal file
|
@ -0,0 +1,159 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_X_upper)
|
||||
{
|
||||
int r;
|
||||
|
||||
/*
|
||||
* Create a sample archive.
|
||||
*/
|
||||
assertMakeFile("file1", 0644, "file1");
|
||||
assertMakeFile("file2", 0644, "file2");
|
||||
assertMakeFile("file3a", 0644, "file3a");
|
||||
assertMakeFile("file4a", 0644, "file4a");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf archive.tar file1 file2 file3a file4a", testprog));
|
||||
|
||||
/*
|
||||
* Now, try extracting from the test archive with various -X usage.
|
||||
*/
|
||||
|
||||
/* Test 1: Without -X */
|
||||
assertMakeDir("test1", 0755);
|
||||
assertChdir("test1");
|
||||
r = systemf("%s -xf ../archive.tar >test.out 2>test.err",
|
||||
testprog);
|
||||
if (!assertEqualInt(0, r))
|
||||
return;
|
||||
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileContents("file2", 5, "file2");
|
||||
assertFileContents("file3a", 6, "file3a");
|
||||
assertFileContents("file4a", 6, "file4a");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 2: Use -X to skip one file */
|
||||
assertMakeDir("test2", 0755);
|
||||
assertChdir("test2");
|
||||
assertMakeFile("exclusions", 0644, "file1\n");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar -X exclusions >test.out 2>test.err", testprog));
|
||||
assertFileNotExists("file1");
|
||||
assertFileContents("file2", 5, "file2");
|
||||
assertFileContents("file3a", 6, "file3a");
|
||||
assertFileContents("file4a", 6, "file4a");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 3: Use -X to skip multiple files */
|
||||
assertMakeDir("test3", 0755);
|
||||
assertChdir("test3");
|
||||
assertMakeFile("exclusions", 0644, "file1\nfile2\n");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar -X exclusions >test.out 2>test.err", testprog));
|
||||
assertFileNotExists("file1");
|
||||
assertFileNotExists("file2");
|
||||
assertFileContents("file3a", 6, "file3a");
|
||||
assertFileContents("file4a", 6, "file4a");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 4: Omit trailing \n */
|
||||
assertMakeDir("test4", 0755);
|
||||
assertChdir("test4");
|
||||
assertMakeFile("exclusions", 0644, "file1\nfile2");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar -X exclusions >test.out 2>test.err", testprog));
|
||||
assertFileNotExists("file1");
|
||||
assertFileNotExists("file2");
|
||||
assertFileContents("file3a", 6, "file3a");
|
||||
assertFileContents("file4a", 6, "file4a");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 5: include/exclude without overlap */
|
||||
assertMakeDir("test5", 0755);
|
||||
assertChdir("test5");
|
||||
assertMakeFile("exclusions", 0644, "file1\nfile2");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar -X exclusions file3a >test.out 2>test.err", testprog));
|
||||
assertFileNotExists("file1");
|
||||
assertFileNotExists("file2");
|
||||
assertFileContents("file3a", 6, "file3a");
|
||||
assertFileNotExists("file4a");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 6: Overlapping include/exclude */
|
||||
assertMakeDir("test6", 0755);
|
||||
assertChdir("test6");
|
||||
assertMakeFile("exclusions", 0644, "file1\nfile2");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar -X exclusions file1 file3a >test.out 2>test.err", testprog));
|
||||
assertFileNotExists("file1");
|
||||
assertFileNotExists("file2");
|
||||
assertFileContents("file3a", 6, "file3a");
|
||||
assertFileNotExists("file4a");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 7: with pattern */
|
||||
assertMakeDir("test7", 0755);
|
||||
assertChdir("test7");
|
||||
assertMakeFile("exclusions", 0644, "file*a\nfile1");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar -X exclusions >test.out 2>test.err", testprog));
|
||||
assertFileNotExists("file1");
|
||||
assertFileContents("file2", 5, "file2");
|
||||
assertFileNotExists("file3a");
|
||||
assertFileNotExists("file4a");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 8: with empty exclusions file */
|
||||
assertMakeDir("test8", 0755);
|
||||
assertChdir("test8");
|
||||
assertMakeFile("exclusions", 0644, "");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar -X exclusions >test.out 2>test.err", testprog));
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileContents("file2", 5, "file2");
|
||||
assertFileContents("file3a", 6, "file3a");
|
||||
assertFileContents("file4a", 6, "file4a");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
}
|
117
dependencies/libarchive-3.4.2/tar/test/test_option_a.c
vendored
Normal file
117
dependencies/libarchive-3.4.2/tar/test/test_option_a.c
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_a)
|
||||
{
|
||||
size_t s;
|
||||
char *p;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Test1: archive it with .tar.Z suffix. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -acf test1.tar.Z f 2>test1.err", testprog));
|
||||
assertEmptyFile("test1.err");
|
||||
/* Check that the archive file has a compress signature. */
|
||||
p = slurpfile(&s, "test1.tar.Z");
|
||||
assert(s > 2);
|
||||
failure("The archive should be compressed");
|
||||
assertEqualMem(p, "\x1f\x9d", 2);
|
||||
free(p);
|
||||
|
||||
/* Test2: archive it with .taZ suffix. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -acf test2.taZ f 2>test2.err", testprog));
|
||||
assertEmptyFile("test2.err");
|
||||
/* Check that the archive file has a compress signature. */
|
||||
p = slurpfile(&s, "test2.taZ");
|
||||
assert(s > 2);
|
||||
failure("The archive should be compressed");
|
||||
assertEqualMem(p, "\x1f\x9d", 2);
|
||||
free(p);
|
||||
|
||||
/* Test3: archive it with .tar.Z.uu suffix. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -acf test3.tar.Z.uu f 2>test3.err", testprog));
|
||||
assertEmptyFile("test3.err");
|
||||
/* Check that the archive file has a compress signature. */
|
||||
p = slurpfile(&s, "test3.tar.Z.uu");
|
||||
assert(s > 12);
|
||||
failure("The archive should be uuencoded");
|
||||
assertEqualMem(p, "begin 644 -\n", 12);
|
||||
free(p);
|
||||
|
||||
/* Test4: archive it with .zip suffix. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -acf test4.zip f 2>test4.err", testprog));
|
||||
assertEmptyFile("test4.err");
|
||||
/* Check that the archive file has a compress signature. */
|
||||
p = slurpfile(&s, "test4.zip");
|
||||
assert(s > 4);
|
||||
failure("The archive should be zipped");
|
||||
assertEqualMem(p, "\x50\x4b\x03\x04", 4);
|
||||
free(p);
|
||||
|
||||
/* Test5: archive it with .tar.Z suffix and --uuencode option. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -acf test5.tar.Z --uuencode f 2>test5.err",
|
||||
testprog));
|
||||
assertEmptyFile("test5.err");
|
||||
/* Check that the archive file has a compress signature. */
|
||||
p = slurpfile(&s, "test5.tar.Z");
|
||||
assert(s > 2);
|
||||
failure("The archive should be compressed, ignoring --uuencode option");
|
||||
assertEqualMem(p, "\x1f\x9d", 2);
|
||||
free(p);
|
||||
|
||||
/* Test6: archive it with .xxx suffix(unknown suffix) and
|
||||
* --uuencode option. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -acf test6.xxx --uuencode f 2>test6.err",
|
||||
testprog));
|
||||
assertEmptyFile("test6.err");
|
||||
/* Check that the archive file has a compress signature. */
|
||||
p = slurpfile(&s, "test6.xxx");
|
||||
assert(s > 12);
|
||||
failure("The archive should be uuencoded");
|
||||
assertEqualMem(p, "begin 644 -\n", 12);
|
||||
free(p);
|
||||
|
||||
/* Test7: archive it with .tar.Z suffix using a long-name option. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s --auto-compress -cf test7.tar.Z f 2>test7.err",
|
||||
testprog));
|
||||
assertEmptyFile("test7.err");
|
||||
/* Check that the archive file has a compress signature. */
|
||||
p = slurpfile(&s, "test7.tar.Z");
|
||||
assert(s > 2);
|
||||
failure("The archive should be compressed");
|
||||
assertEqualMem(p, "\x1f\x9d", 2);
|
||||
free(p);
|
||||
}
|
512
dependencies/libarchive-3.4.2/tar/test/test_option_acls.c
vendored
Normal file
512
dependencies/libarchive-3.4.2/tar/test/test_option_acls.c
vendored
Normal file
|
@ -0,0 +1,512 @@
|
|||
/*-
|
||||
* Copyright (c) 2017 Martin Matuska
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_LIBACL
|
||||
static const acl_perm_t acl_perms[] = {
|
||||
#if ARCHIVE_ACL_DARWIN
|
||||
ACL_READ_DATA,
|
||||
ACL_LIST_DIRECTORY,
|
||||
ACL_WRITE_DATA,
|
||||
ACL_ADD_FILE,
|
||||
ACL_EXECUTE,
|
||||
ACL_SEARCH,
|
||||
ACL_DELETE,
|
||||
ACL_APPEND_DATA,
|
||||
ACL_ADD_SUBDIRECTORY,
|
||||
ACL_DELETE_CHILD,
|
||||
ACL_READ_ATTRIBUTES,
|
||||
ACL_WRITE_ATTRIBUTES,
|
||||
ACL_READ_EXTATTRIBUTES,
|
||||
ACL_WRITE_EXTATTRIBUTES,
|
||||
ACL_READ_SECURITY,
|
||||
ACL_WRITE_SECURITY,
|
||||
ACL_CHANGE_OWNER,
|
||||
ACL_SYNCHRONIZE
|
||||
#else /* !ARCHIVE_ACL_DARWIN */
|
||||
ACL_EXECUTE,
|
||||
ACL_WRITE,
|
||||
ACL_READ,
|
||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
||||
ACL_READ_DATA,
|
||||
ACL_LIST_DIRECTORY,
|
||||
ACL_WRITE_DATA,
|
||||
ACL_ADD_FILE,
|
||||
ACL_APPEND_DATA,
|
||||
ACL_ADD_SUBDIRECTORY,
|
||||
ACL_READ_NAMED_ATTRS,
|
||||
ACL_WRITE_NAMED_ATTRS,
|
||||
ACL_DELETE_CHILD,
|
||||
ACL_READ_ATTRIBUTES,
|
||||
ACL_WRITE_ATTRIBUTES,
|
||||
ACL_DELETE,
|
||||
ACL_READ_ACL,
|
||||
ACL_WRITE_ACL,
|
||||
ACL_WRITE_OWNER,
|
||||
ACL_SYNCHRONIZE
|
||||
#endif /* ARCHIVE_ACL_FREEBSD_NFS4 */
|
||||
#endif /* !ARCHIVE_ACL_DARWIN */
|
||||
};
|
||||
#if ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD_NFS4
|
||||
static const acl_flag_t acl_flags[] = {
|
||||
#if ARCHIVE_ACL_DARWIN
|
||||
ACL_ENTRY_INHERITED,
|
||||
ACL_ENTRY_FILE_INHERIT,
|
||||
ACL_ENTRY_DIRECTORY_INHERIT,
|
||||
ACL_ENTRY_LIMIT_INHERIT,
|
||||
ACL_ENTRY_ONLY_INHERIT
|
||||
#else /* ARCHIVE_ACL_FREEBSD_NFS4 */
|
||||
ACL_ENTRY_FILE_INHERIT,
|
||||
ACL_ENTRY_DIRECTORY_INHERIT,
|
||||
ACL_ENTRY_NO_PROPAGATE_INHERIT,
|
||||
ACL_ENTRY_INHERIT_ONLY,
|
||||
ACL_ENTRY_SUCCESSFUL_ACCESS,
|
||||
ACL_ENTRY_FAILED_ACCESS,
|
||||
#ifdef ACL_ENTRY_INHERITED
|
||||
ACL_ENTRY_INHERITED
|
||||
#endif
|
||||
#endif /* ARCHIVE_ACL_FREEBSD_NFS4 */
|
||||
};
|
||||
#endif /* ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD_NFS4 */
|
||||
|
||||
/*
|
||||
* Compare two ACL entries on FreeBSD or on Mac OS X
|
||||
*/
|
||||
static int
|
||||
compare_acl_entry(acl_entry_t ae_a, acl_entry_t ae_b, int is_nfs4)
|
||||
{
|
||||
acl_tag_t tag_a, tag_b;
|
||||
acl_permset_t permset_a, permset_b;
|
||||
int perm_a, perm_b, perm_start, perm_end;
|
||||
void *qual_a, *qual_b;
|
||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
||||
acl_entry_type_t type_a, type_b;
|
||||
#endif
|
||||
#if ARCHIVE_ACL_FREEBSD_NFS4 || ARCHIVE_ACL_DARWIN
|
||||
acl_flagset_t flagset_a, flagset_b;
|
||||
int flag_a, flag_b;
|
||||
#endif
|
||||
int i, r;
|
||||
|
||||
|
||||
/* Compare ACL tag */
|
||||
r = acl_get_tag_type(ae_a, &tag_a);
|
||||
failure("acl_get_tag_type() error: %s", strerror(errno));
|
||||
if (assertEqualInt(r, 0) == 0)
|
||||
return (-1);
|
||||
r = acl_get_tag_type(ae_b, &tag_b);
|
||||
failure("acl_get_tag_type() error: %s", strerror(errno));
|
||||
if (assertEqualInt(r, 0) == 0)
|
||||
return (-1);
|
||||
if (tag_a != tag_b)
|
||||
return (0);
|
||||
|
||||
/* Compare ACL qualifier */
|
||||
#if ARCHIVE_ACL_DARWIN
|
||||
if (tag_a == ACL_EXTENDED_ALLOW || tag_b == ACL_EXTENDED_DENY)
|
||||
#else
|
||||
if (tag_a == ACL_USER || tag_a == ACL_GROUP)
|
||||
#endif
|
||||
{
|
||||
qual_a = acl_get_qualifier(ae_a);
|
||||
failure("acl_get_qualifier() error: %s", strerror(errno));
|
||||
if (assert(qual_a != NULL) == 0)
|
||||
return (-1);
|
||||
qual_b = acl_get_qualifier(ae_b);
|
||||
failure("acl_get_qualifier() error: %s", strerror(errno));
|
||||
if (assert(qual_b != NULL) == 0) {
|
||||
acl_free(qual_a);
|
||||
return (-1);
|
||||
}
|
||||
#if ARCHIVE_ACL_DARWIN
|
||||
if (memcmp(((guid_t *)qual_a)->g_guid,
|
||||
((guid_t *)qual_b)->g_guid, KAUTH_GUID_SIZE) != 0)
|
||||
#else
|
||||
if ((tag_a == ACL_USER &&
|
||||
(*(uid_t *)qual_a != *(uid_t *)qual_b)) ||
|
||||
(tag_a == ACL_GROUP &&
|
||||
(*(gid_t *)qual_a != *(gid_t *)qual_b)))
|
||||
#endif
|
||||
{
|
||||
acl_free(qual_a);
|
||||
acl_free(qual_b);
|
||||
return (0);
|
||||
}
|
||||
acl_free(qual_a);
|
||||
acl_free(qual_b);
|
||||
}
|
||||
|
||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
||||
if (is_nfs4) {
|
||||
/* Compare NFS4 ACL type */
|
||||
r = acl_get_entry_type_np(ae_a, &type_a);
|
||||
failure("acl_get_entry_type_np() error: %s", strerror(errno));
|
||||
if (assertEqualInt(r, 0) == 0)
|
||||
return (-1);
|
||||
r = acl_get_entry_type_np(ae_b, &type_b);
|
||||
failure("acl_get_entry_type_np() error: %s", strerror(errno));
|
||||
if (assertEqualInt(r, 0) == 0)
|
||||
return (-1);
|
||||
if (type_a != type_b)
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Compare ACL perms */
|
||||
r = acl_get_permset(ae_a, &permset_a);
|
||||
failure("acl_get_permset() error: %s", strerror(errno));
|
||||
if (assertEqualInt(r, 0) == 0)
|
||||
return (-1);
|
||||
r = acl_get_permset(ae_b, &permset_b);
|
||||
failure("acl_get_permset() error: %s", strerror(errno));
|
||||
if (assertEqualInt(r, 0) == 0)
|
||||
return (-1);
|
||||
|
||||
perm_start = 0;
|
||||
perm_end = (int)(sizeof(acl_perms) / sizeof(acl_perms[0]));
|
||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
||||
if (is_nfs4)
|
||||
perm_start = 3;
|
||||
else
|
||||
perm_end = 3;
|
||||
#endif
|
||||
/* Cycle through all perms and compare their value */
|
||||
for (i = perm_start; i < perm_end; i++) {
|
||||
#if ARCHIVE_ACL_LIBACL
|
||||
perm_a = acl_get_perm(permset_a, acl_perms[i]);
|
||||
perm_b = acl_get_perm(permset_b, acl_perms[i]);
|
||||
#else
|
||||
perm_a = acl_get_perm_np(permset_a, acl_perms[i]);
|
||||
perm_b = acl_get_perm_np(permset_b, acl_perms[i]);
|
||||
#endif
|
||||
if (perm_a == -1 || perm_b == -1)
|
||||
return (-1);
|
||||
if (perm_a != perm_b)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if ARCHIVE_ACL_FREEBSD_NFS4 || ARCHIVE_ACL_DARWIN
|
||||
if (is_nfs4) {
|
||||
r = acl_get_flagset_np(ae_a, &flagset_a);
|
||||
failure("acl_get_flagset_np() error: %s", strerror(errno));
|
||||
if (assertEqualInt(r, 0) == 0)
|
||||
return (-1);
|
||||
r = acl_get_flagset_np(ae_b, &flagset_b);
|
||||
failure("acl_get_flagset_np() error: %s", strerror(errno));
|
||||
if (assertEqualInt(r, 0) == 0)
|
||||
return (-1);
|
||||
/* Cycle through all flags and compare their status */
|
||||
for (i = 0; i < (int)(sizeof(acl_flags) / sizeof(acl_flags[0]));
|
||||
i++) {
|
||||
flag_a = acl_get_flag_np(flagset_a, acl_flags[i]);
|
||||
flag_b = acl_get_flag_np(flagset_b, acl_flags[i]);
|
||||
if (flag_a == -1 || flag_b == -1)
|
||||
return (-1);
|
||||
if (flag_a != flag_b)
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
#else /* ARCHIVE_ACL_FREEBSD_NFS4 || ARCHIVE_ACL_DARWIN */
|
||||
(void)is_nfs4; /* UNUSED */
|
||||
#endif
|
||||
return (1);
|
||||
}
|
||||
#endif /* ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_LIBACL */
|
||||
|
||||
#if ARCHIVE_ACL_SUPPORT
|
||||
/*
|
||||
* Clear default ACLs or inheritance flags
|
||||
*/
|
||||
static void
|
||||
clear_inheritance_flags(const char *path, int type)
|
||||
{
|
||||
switch (type) {
|
||||
case ARCHIVE_TEST_ACL_TYPE_POSIX1E:
|
||||
#if ARCHIVE_ACL_POSIX1E
|
||||
#if !ARCHIVE_ACL_SUNOS
|
||||
acl_delete_def_file(path);
|
||||
#else
|
||||
/* Solaris */
|
||||
setTestAcl(path);
|
||||
#endif
|
||||
#endif /* ARCHIVE_ACL_POSIX1E */
|
||||
break;
|
||||
case ARCHIVE_TEST_ACL_TYPE_NFS4:
|
||||
#if ARCHIVE_ACL_NFS4
|
||||
setTestAcl(path);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
(void)path; /* UNUSED */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
compare_acls(const char *path_a, const char *path_b)
|
||||
{
|
||||
int ret = 1;
|
||||
int is_nfs4 = 0;
|
||||
#if ARCHIVE_ACL_SUNOS
|
||||
void *acl_a, *acl_b;
|
||||
int aclcnt_a, aclcnt_b;
|
||||
aclent_t *aclent_a, *aclent_b;
|
||||
ace_t *ace_a, *ace_b;
|
||||
int e;
|
||||
#elif ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_LIBACL
|
||||
acl_t acl_a, acl_b;
|
||||
acl_entry_t aclent_a, aclent_b;
|
||||
int a, b, r;
|
||||
#endif
|
||||
#if ARCHIVE_ACL_LIBRICHACL
|
||||
struct richacl *richacl_a, *richacl_b;
|
||||
|
||||
richacl_a = NULL;
|
||||
richacl_b = NULL;
|
||||
#endif
|
||||
|
||||
#if ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_LIBACL || \
|
||||
ARCHIVE_ACL_SUNOS
|
||||
acl_a = NULL;
|
||||
acl_b = NULL;
|
||||
#endif
|
||||
#if ARCHIVE_ACL_SUNOS
|
||||
acl_a = sunacl_get(GETACL, &aclcnt_a, 0, path_a);
|
||||
if (acl_a == NULL) {
|
||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
||||
is_nfs4 = 1;
|
||||
acl_a = sunacl_get(ACE_GETACL, &aclcnt_a, 0, path_a);
|
||||
#endif
|
||||
failure("acl_get() error: %s", strerror(errno));
|
||||
if (assert(acl_a != NULL) == 0)
|
||||
return (-1);
|
||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
||||
acl_b = sunacl_get(ACE_GETACL, &aclcnt_b, 0, path_b);
|
||||
#endif
|
||||
} else
|
||||
acl_b = sunacl_get(GETACL, &aclcnt_b, 0, path_b);
|
||||
if (acl_b == NULL && (errno == ENOSYS || errno == ENOTSUP)) {
|
||||
free(acl_a);
|
||||
return (0);
|
||||
}
|
||||
failure("acl_get() error: %s", strerror(errno));
|
||||
if (assert(acl_b != NULL) == 0) {
|
||||
free(acl_a);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (aclcnt_a != aclcnt_b) {
|
||||
ret = 0;
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
for (e = 0; e < aclcnt_a; e++) {
|
||||
if (!is_nfs4) {
|
||||
aclent_a = &((aclent_t *)acl_a)[e];
|
||||
aclent_b = &((aclent_t *)acl_b)[e];
|
||||
if (aclent_a->a_type != aclent_b->a_type ||
|
||||
aclent_a->a_id != aclent_b->a_id ||
|
||||
aclent_a->a_perm != aclent_b->a_perm) {
|
||||
ret = 0;
|
||||
goto exit_free;
|
||||
}
|
||||
}
|
||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
||||
else {
|
||||
ace_a = &((ace_t *)acl_a)[e];
|
||||
ace_b = &((ace_t *)acl_b)[e];
|
||||
if (ace_a->a_who != ace_b->a_who ||
|
||||
ace_a->a_access_mask != ace_b->a_access_mask ||
|
||||
ace_a->a_flags != ace_b->a_flags ||
|
||||
ace_a->a_type != ace_b->a_type) {
|
||||
ret = 0;
|
||||
goto exit_free;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else /* !ARCHIVE_ACL_SUNOS */
|
||||
#if ARCHIVE_ACL_LIBRICHACL
|
||||
richacl_a = richacl_get_file(path_a);
|
||||
#if !ARCHIVE_ACL_LIBACL
|
||||
if (richacl_a == NULL &&
|
||||
(errno == ENODATA || errno == ENOTSUP || errno == ENOSYS))
|
||||
return (0);
|
||||
failure("richacl_get_file() error: %s (%s)", path_a, strerror(errno));
|
||||
if (assert(richacl_a != NULL) == 0)
|
||||
return (-1);
|
||||
#endif
|
||||
if (richacl_a != NULL) {
|
||||
richacl_b = richacl_get_file(path_b);
|
||||
if (richacl_b == NULL &&
|
||||
(errno == ENODATA || errno == ENOTSUP || errno == ENOSYS)) {
|
||||
richacl_free(richacl_a);
|
||||
return (0);
|
||||
}
|
||||
failure("richacl_get_file() error: %s (%s)", path_b,
|
||||
strerror(errno));
|
||||
if (assert(richacl_b != NULL) == 0) {
|
||||
richacl_free(richacl_a);
|
||||
return (-1);
|
||||
}
|
||||
if (richacl_compare(richacl_a, richacl_b) == 0)
|
||||
ret = 0;
|
||||
richacl_free(richacl_a);
|
||||
richacl_free(richacl_b);
|
||||
return (ret);
|
||||
}
|
||||
#endif /* ARCHIVE_ACL_LIBRICHACL */
|
||||
#if ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_LIBACL
|
||||
#if ARCHIVE_ACL_DARWIN
|
||||
is_nfs4 = 1;
|
||||
acl_a = acl_get_file(path_a, ACL_TYPE_EXTENDED);
|
||||
#elif ARCHIVE_ACL_FREEBSD_NFS4
|
||||
acl_a = acl_get_file(path_a, ACL_TYPE_NFS4);
|
||||
if (acl_a != NULL)
|
||||
is_nfs4 = 1;
|
||||
#endif
|
||||
if (acl_a == NULL)
|
||||
acl_a = acl_get_file(path_a, ACL_TYPE_ACCESS);
|
||||
failure("acl_get_file() error: %s (%s)", path_a, strerror(errno));
|
||||
if (assert(acl_a != NULL) == 0)
|
||||
return (-1);
|
||||
#if ARCHIVE_ACL_DARWIN
|
||||
acl_b = acl_get_file(path_b, ACL_TYPE_EXTENDED);
|
||||
#elif ARCHIVE_ACL_FREEBSD_NFS4
|
||||
acl_b = acl_get_file(path_b, ACL_TYPE_NFS4);
|
||||
#endif
|
||||
#if !ARCHIVE_ACL_DARWIN
|
||||
if (acl_b == NULL) {
|
||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
||||
if (is_nfs4) {
|
||||
acl_free(acl_a);
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
acl_b = acl_get_file(path_b, ACL_TYPE_ACCESS);
|
||||
}
|
||||
failure("acl_get_file() error: %s (%s)", path_b, strerror(errno));
|
||||
if (assert(acl_b != NULL) == 0) {
|
||||
acl_free(acl_a);
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
a = acl_get_entry(acl_a, ACL_FIRST_ENTRY, &aclent_a);
|
||||
if (a == -1) {
|
||||
ret = 0;
|
||||
goto exit_free;
|
||||
}
|
||||
b = acl_get_entry(acl_b, ACL_FIRST_ENTRY, &aclent_b);
|
||||
if (b == -1) {
|
||||
ret = 0;
|
||||
goto exit_free;
|
||||
}
|
||||
#if ARCHIVE_ACL_DARWIN
|
||||
while (a == 0 && b == 0)
|
||||
#else /* FreeBSD, Linux */
|
||||
while (a == 1 && b == 1)
|
||||
#endif
|
||||
{
|
||||
r = compare_acl_entry(aclent_a, aclent_b, is_nfs4);
|
||||
if (r != 1) {
|
||||
ret = r;
|
||||
goto exit_free;
|
||||
}
|
||||
a = acl_get_entry(acl_a, ACL_NEXT_ENTRY, &aclent_a);
|
||||
b = acl_get_entry(acl_b, ACL_NEXT_ENTRY, &aclent_b);
|
||||
}
|
||||
/* Entry count must match */
|
||||
if (a != b)
|
||||
ret = 0;
|
||||
#endif /* ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_LIBACL */
|
||||
#endif /* !ARCHIVE_ACL_SUNOS */
|
||||
exit_free:
|
||||
#if ARCHIVE_ACL_SUNOS
|
||||
free(acl_a);
|
||||
free(acl_b);
|
||||
#else
|
||||
acl_free(acl_a);
|
||||
acl_free(acl_b);
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
#endif /* ARCHIVE_ACL_SUPPORT */
|
||||
|
||||
DEFINE_TEST(test_option_acls)
|
||||
{
|
||||
#if !ARCHIVE_ACL_SUPPORT
|
||||
skipping("ACLs are not supported on this platform");
|
||||
#else /* ARCHIVE_ACL_SUPPORT */
|
||||
int acltype, r;
|
||||
|
||||
assertMakeFile("f", 0644, "a");
|
||||
acltype = setTestAcl("f");
|
||||
if (acltype == 0) {
|
||||
skipping("Can't write ACLs on the filesystem");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Archive it with acls */
|
||||
r = systemf("%s -c --no-mac-metadata --acls -f acls.tar f >acls.out 2>acls.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Archive it without acls */
|
||||
r = systemf("%s -c --no-mac-metadata --no-acls -f noacls.tar f >noacls.out 2>noacls.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Extract acls with acls */
|
||||
assertMakeDir("acls_acls", 0755);
|
||||
clear_inheritance_flags("acls_acls", acltype);
|
||||
r = systemf("%s -x -C acls_acls --no-same-permissions --acls -f acls.tar >acls_acls.out 2>acls_acls.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
r = compare_acls("f", "acls_acls/f");
|
||||
assertEqualInt(r, 1);
|
||||
|
||||
/* Extract acls without acls */
|
||||
assertMakeDir("acls_noacls", 0755);
|
||||
clear_inheritance_flags("acls_noacls", acltype);
|
||||
r = systemf("%s -x -C acls_noacls -p --no-acls -f acls.tar >acls_noacls.out 2>acls_noacls.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
r = compare_acls("f", "acls_noacls/f");
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Extract noacls with acls flag */
|
||||
assertMakeDir("noacls_acls", 0755);
|
||||
clear_inheritance_flags("noacls_acls", acltype);
|
||||
r = systemf("%s -x -C noacls_acls --no-same-permissions --acls -f noacls.tar >noacls_acls.out 2>noacls_acls.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
r = compare_acls("f", "noacls_acls/f");
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Extract noacls with noacls */
|
||||
assertMakeDir("noacls_noacls", 0755);
|
||||
clear_inheritance_flags("noacls_noacls", acltype);
|
||||
r = systemf("%s -x -C noacls_noacls -p --no-acls -f noacls.tar >noacls_noacls.out 2>noacls_noacls.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
r = compare_acls("f", "noacls_noacls/f");
|
||||
assertEqualInt(r, 0);
|
||||
#endif /* ARCHIVE_ACL_SUPPORT */
|
||||
}
|
83
dependencies/libarchive-3.4.2/tar/test/test_option_b.c
vendored
Normal file
83
dependencies/libarchive-3.4.2/tar/test/test_option_b.c
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#define USTAR_OPT " --format=ustar"
|
||||
|
||||
DEFINE_TEST(test_option_b)
|
||||
{
|
||||
char *testprog_ustar;
|
||||
|
||||
assertMakeFile("file1", 0644, "file1");
|
||||
if (systemf("cat file1 > test_cat.out 2> test_cat.err") != 0) {
|
||||
skipping("This test requires a `cat` program");
|
||||
return;
|
||||
}
|
||||
testprog_ustar = malloc(strlen(testprog) + sizeof(USTAR_OPT) + 1);
|
||||
strcpy(testprog_ustar, testprog);
|
||||
strcat(testprog_ustar, USTAR_OPT);
|
||||
|
||||
/*
|
||||
* Bsdtar does not pad if the output is going directly to a disk file.
|
||||
*/
|
||||
assertEqualInt(0, systemf("%s -cf archive1.tar file1 >test1.out 2>test1.err", testprog_ustar));
|
||||
failure("bsdtar does not pad archives written directly to regular files");
|
||||
assertFileSize("archive1.tar", 2048);
|
||||
assertEmptyFile("test1.out");
|
||||
assertEmptyFile("test1.err");
|
||||
|
||||
/*
|
||||
* Bsdtar does pad to the block size if the output is going to a socket.
|
||||
*/
|
||||
/* Default is -b 20 */
|
||||
assertEqualInt(0, systemf("%s -cf - file1 2>test2.err | cat >archive2.tar ", testprog_ustar));
|
||||
failure("bsdtar does pad archives written to pipes");
|
||||
assertFileSize("archive2.tar", 10240);
|
||||
assertEmptyFile("test2.err");
|
||||
|
||||
assertEqualInt(0, systemf("%s -cf - -b 20 file1 2>test3.err | cat >archive3.tar ", testprog_ustar));
|
||||
assertFileSize("archive3.tar", 10240);
|
||||
assertEmptyFile("test3.err");
|
||||
|
||||
assertEqualInt(0, systemf("%s -cf - -b 10 file1 2>test4.err | cat >archive4.tar ", testprog_ustar));
|
||||
assertFileSize("archive4.tar", 5120);
|
||||
assertEmptyFile("test4.err");
|
||||
|
||||
assertEqualInt(0, systemf("%s -cf - -b 1 file1 2>test5.err | cat >archive5.tar ", testprog_ustar));
|
||||
assertFileSize("archive5.tar", 2048);
|
||||
assertEmptyFile("test5.err");
|
||||
|
||||
assertEqualInt(0, systemf("%s -cf - -b 8192 file1 2>test6.err | cat >archive6.tar ", testprog_ustar));
|
||||
assertFileSize("archive6.tar", 4194304);
|
||||
assertEmptyFile("test6.err");
|
||||
|
||||
/*
|
||||
* Note: It's not possible to verify at this level that blocks
|
||||
* are getting written with the
|
||||
*/
|
||||
|
||||
free(testprog_ustar);
|
||||
}
|
56
dependencies/libarchive-3.4.2/tar/test/test_option_b64encode.c
vendored
Normal file
56
dependencies/libarchive-3.4.2/tar/test/test_option_b64encode.c
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_b64encode)
|
||||
{
|
||||
char *p;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with compress compression and uuencode. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf - -Z --b64encode f >archive.out 2>archive.err",
|
||||
testprog));
|
||||
/* Check that the archive file has an uuencode signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "begin-base64 644", 16);
|
||||
free(p);
|
||||
|
||||
/* Archive it with uuencode only. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf - --b64encode f >archive.out 2>archive.err",
|
||||
testprog));
|
||||
/* Check that the archive file has an uuencode signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "begin-base64 644", 16);
|
||||
free(p);
|
||||
}
|
142
dependencies/libarchive-3.4.2/tar/test/test_option_exclude.c
vendored
Normal file
142
dependencies/libarchive-3.4.2/tar/test/test_option_exclude.c
vendored
Normal file
|
@ -0,0 +1,142 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_exclude)
|
||||
{
|
||||
int r;
|
||||
|
||||
assertMakeFile("file1", 0644, "file1");
|
||||
assertMakeFile("file2", 0644, "file2");
|
||||
assertEqualInt(0, systemf("%s -cf archive.tar file1 file2", testprog));
|
||||
|
||||
/*
|
||||
* Now, try extracting from the test archive with various --exclude options.
|
||||
*/
|
||||
|
||||
/* Test 1: Without --exclude */
|
||||
assertMakeDir("test1", 0755);
|
||||
assertChdir("test1");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileContents("file2", 5, "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 2: Selecting just one file */
|
||||
assertMakeDir("test2", 0755);
|
||||
assertChdir("test2");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar file1 >test.out 2>test.err", testprog));
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileNotExists("file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 3: Use --exclude to skip one file */
|
||||
assertMakeDir("test3", 0755);
|
||||
assertChdir("test3");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar --exclude file1 >test.out 2>test.err", testprog));
|
||||
assertFileNotExists("file1");
|
||||
assertFileContents("file2", 5, "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 4: Selecting one valid and one invalid file */
|
||||
assertMakeDir("test4", 0755);
|
||||
assertChdir("test4");
|
||||
r = systemf("%s -xf ../archive.tar file1 file3 >test.out 2>test.err", testprog);
|
||||
assert(r != 0);
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileNotExists("file2");
|
||||
assertFileNotExists("file3");
|
||||
assertEmptyFile("test.out");
|
||||
assertNonEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 5: Selecting one valid file twice */
|
||||
assertMakeDir("test5", 0755);
|
||||
assertChdir("test5");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar file1 file1 >test.out 2>test.err", testprog));
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileNotExists("file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 6: Include and exclude the same file */
|
||||
assertMakeDir("test6", 0755);
|
||||
assertChdir("test6");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar --exclude file1 file1 >test.out 2>test.err", testprog));
|
||||
assertFileNotExists("file1");
|
||||
assertFileNotExists("file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 7: Exclude a non-existent file */
|
||||
assertMakeDir("test7", 0755);
|
||||
assertChdir("test7");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar --exclude file3 file1 >test.out 2>test.err", testprog));
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileNotExists("file2");
|
||||
assertFileNotExists("file3");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 8: Include a non-existent file */
|
||||
assertMakeDir("test8", 0755);
|
||||
assertChdir("test8");
|
||||
r = systemf("%s -xf ../archive.tar file3 >test.out 2>test.err", testprog);
|
||||
assert(r != 0);
|
||||
assertFileNotExists("file1");
|
||||
assertFileNotExists("file2");
|
||||
assertFileNotExists("file3");
|
||||
assertEmptyFile("test.out");
|
||||
assertNonEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 9: Include a non-existent file plus an exclusion */
|
||||
assertMakeDir("test9", 0755);
|
||||
assertChdir("test9");
|
||||
r = systemf("%s -xf ../archive.tar --exclude file1 file3 >test.out 2>test.err", testprog);
|
||||
assert(r != 0);
|
||||
assertFileNotExists("file1");
|
||||
assertFileNotExists("file2");
|
||||
assertFileNotExists("file3");
|
||||
assertEmptyFile("test.out");
|
||||
assertNonEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
}
|
230
dependencies/libarchive-3.4.2/tar/test/test_option_exclude_vcs.c
vendored
Normal file
230
dependencies/libarchive-3.4.2/tar/test/test_option_exclude_vcs.c
vendored
Normal file
|
@ -0,0 +1,230 @@
|
|||
/*-
|
||||
* Copyright (c) 2019 Martin Matuska
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_exclude_vcs)
|
||||
{
|
||||
assertMakeDir("in", 0755);
|
||||
assertChdir("in");
|
||||
assertMakeFile("file", 0644, "");
|
||||
assertMakeDir("dir", 0755);
|
||||
assertMakeDir("CVS", 0755);
|
||||
assertMakeFile("CVS/fileattr", 0644, "");
|
||||
assertMakeFile(".cvsignore", 0644, "");
|
||||
assertMakeDir("RCS", 0755);
|
||||
assertMakeFile("RCS/somefile", 0655, "");
|
||||
assertMakeDir("SCCS", 0755);
|
||||
assertMakeFile("SCCS/somefile", 0655, "");
|
||||
assertMakeDir(".svn", 0755);
|
||||
assertMakeFile(".svn/format", 0655, "");
|
||||
assertMakeDir(".git", 0755);
|
||||
assertMakeFile(".git/config", 0655, "");
|
||||
assertMakeFile(".gitignore", 0644, "");
|
||||
assertMakeFile(".gitattributes", 0644, "");
|
||||
assertMakeFile(".gitmodules", 0644, "");
|
||||
assertMakeDir(".arch-ids", 0755);
|
||||
assertMakeFile(".arch-ids/somefile", 0644, "");
|
||||
assertMakeDir("{arch}", 0755);
|
||||
assertMakeFile("{arch}/somefile", 0644, "");
|
||||
assertMakeFile("=RELEASE-ID", 0644, "");
|
||||
assertMakeFile("=meta-update", 0644, "");
|
||||
assertMakeFile("=update", 0644, "");
|
||||
assertMakeDir(".bzr", 0755);
|
||||
assertMakeDir(".bzr/checkout", 0755);
|
||||
assertMakeFile(".bzrignore", 0644, "");
|
||||
assertMakeFile(".bzrtags", 0644, "");
|
||||
assertMakeDir(".hg", 0755);
|
||||
assertMakeFile(".hg/dirstate", 0644, "");
|
||||
assertMakeFile(".hgignore", 0644, "");
|
||||
assertMakeFile(".hgtags", 0644, "");
|
||||
assertMakeDir("_darcs", 0755);
|
||||
assertMakeFile("_darcs/format", 0644, "");
|
||||
assertChdir("..");
|
||||
|
||||
assertEqualInt(0, systemf("%s -c -C in -f included.tar .", testprog));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -c --exclude-vcs -C in -f excluded.tar .", testprog));
|
||||
|
||||
/* No flags, archive with vcs files */
|
||||
assertMakeDir("vcs-noexclude", 0755);
|
||||
assertEqualInt(0, systemf("%s -x -C vcs-noexclude -f included.tar",
|
||||
testprog));
|
||||
assertChdir("vcs-noexclude");
|
||||
assertFileExists("file");
|
||||
assertIsDir("dir", 0755);
|
||||
assertIsDir("CVS", 0755);
|
||||
assertFileExists("CVS/fileattr");
|
||||
assertFileExists(".cvsignore");
|
||||
assertIsDir("RCS", 0755);
|
||||
assertFileExists("RCS/somefile");
|
||||
assertIsDir("SCCS", 0755);
|
||||
assertFileExists("SCCS/somefile");
|
||||
assertIsDir(".svn", 0755);
|
||||
assertFileExists(".svn/format");
|
||||
assertIsDir(".git", 0755);
|
||||
assertFileExists(".git/config");
|
||||
assertFileExists(".gitignore");
|
||||
assertFileExists(".gitattributes");
|
||||
assertFileExists(".gitmodules");
|
||||
assertIsDir(".arch-ids", 0755);
|
||||
assertFileExists(".arch-ids/somefile");
|
||||
assertIsDir("{arch}", 0755);
|
||||
assertFileExists("{arch}/somefile");
|
||||
assertFileExists("=RELEASE-ID");
|
||||
assertFileExists("=meta-update");
|
||||
assertFileExists("=update");
|
||||
assertIsDir(".bzr", 0755);
|
||||
assertIsDir(".bzr/checkout", 0755);
|
||||
assertFileExists(".bzrignore");
|
||||
assertFileExists(".bzrtags");
|
||||
assertIsDir(".hg", 0755);
|
||||
assertFileExists(".hg/dirstate");
|
||||
assertFileExists(".hgignore");
|
||||
assertFileExists(".hgtags");
|
||||
assertIsDir("_darcs", 0755);
|
||||
assertFileExists("_darcs/format");
|
||||
assertChdir("..");
|
||||
|
||||
/* --exclude-vcs, archive with vcs files */
|
||||
assertMakeDir("vcs-exclude", 0755);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -x --exclude-vcs -C vcs-exclude -f included.tar", testprog));
|
||||
assertChdir("vcs-exclude");
|
||||
assertFileExists("file");
|
||||
assertIsDir("dir", 0755);
|
||||
assertFileNotExists("CVS");
|
||||
assertFileNotExists("CVS/fileattr");
|
||||
assertFileNotExists(".cvsignore");
|
||||
assertFileNotExists("RCS");
|
||||
assertFileNotExists("RCS/somefile");
|
||||
assertFileNotExists("SCCS");
|
||||
assertFileNotExists("SCCS/somefile");
|
||||
assertFileNotExists(".svn");
|
||||
assertFileNotExists(".svn/format");
|
||||
assertFileNotExists(".git");
|
||||
assertFileNotExists(".git/config");
|
||||
assertFileNotExists(".gitignore");
|
||||
assertFileNotExists(".gitattributes");
|
||||
assertFileNotExists(".gitmodules");
|
||||
assertFileNotExists(".arch-ids");
|
||||
assertFileNotExists(".arch-ids/somefile");
|
||||
assertFileNotExists("{arch}");
|
||||
assertFileNotExists("{arch}/somefile");
|
||||
assertFileNotExists("=RELEASE-ID");
|
||||
assertFileNotExists("=meta-update");
|
||||
assertFileNotExists("=update");
|
||||
assertFileNotExists(".bzr");
|
||||
assertFileNotExists(".bzr/checkout");
|
||||
assertFileNotExists(".bzrignore");
|
||||
assertFileNotExists(".bzrtags");
|
||||
assertFileNotExists(".hg");
|
||||
assertFileNotExists(".hg/dirstate");
|
||||
assertFileNotExists(".hgignore");
|
||||
assertFileNotExists(".hgtags");
|
||||
assertFileNotExists("_darcs");
|
||||
assertFileNotExists("_darcs/format");
|
||||
assertChdir("..");
|
||||
|
||||
/* --exclude-vcs, archive without vcs files */
|
||||
assertMakeDir("novcs-exclude", 0755);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -x --exclude-vcs -C novcs-exclude -f excluded.tar",
|
||||
testprog));
|
||||
assertChdir("novcs-exclude");
|
||||
assertFileExists("file");
|
||||
assertIsDir("dir", 0755);
|
||||
assertFileNotExists("CVS");
|
||||
assertFileNotExists("CVS/fileattr");
|
||||
assertFileNotExists(".cvsignore");
|
||||
assertFileNotExists("RCS");
|
||||
assertFileNotExists("RCS/somefile");
|
||||
assertFileNotExists("SCCS");
|
||||
assertFileNotExists("SCCS/somefile");
|
||||
assertFileNotExists(".svn");
|
||||
assertFileNotExists(".svn/format");
|
||||
assertFileNotExists(".git");
|
||||
assertFileNotExists(".git/config");
|
||||
assertFileNotExists(".gitignore");
|
||||
assertFileNotExists(".gitattributes");
|
||||
assertFileNotExists(".gitmodules");
|
||||
assertFileNotExists(".arch-ids");
|
||||
assertFileNotExists(".arch-ids/somefile");
|
||||
assertFileNotExists("{arch}");
|
||||
assertFileNotExists("{arch}/somefile");
|
||||
assertFileNotExists("=RELEASE-ID");
|
||||
assertFileNotExists("=meta-update");
|
||||
assertFileNotExists("=update");
|
||||
assertFileNotExists(".bzr");
|
||||
assertFileNotExists(".bzr/checkout");
|
||||
assertFileNotExists(".bzrignore");
|
||||
assertFileNotExists(".bzrtags");
|
||||
assertFileNotExists(".hg");
|
||||
assertFileNotExists(".hg/dirstate");
|
||||
assertFileNotExists(".hgignore");
|
||||
assertFileNotExists(".hgtags");
|
||||
assertFileNotExists("_darcs");
|
||||
assertFileNotExists("_darcs/format");
|
||||
assertChdir("..");
|
||||
|
||||
/* No flags, archive without vcs files */
|
||||
assertMakeDir("novcs-noexclude", 0755);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -x -C novcs-noexclude -f excluded.tar", testprog));
|
||||
assertChdir("novcs-noexclude");
|
||||
assertFileExists("file");
|
||||
assertIsDir("dir", 0755);
|
||||
assertFileNotExists("CVS");
|
||||
assertFileNotExists("CVS/fileattr");
|
||||
assertFileNotExists(".cvsignore");
|
||||
assertFileNotExists("RCS");
|
||||
assertFileNotExists("RCS/somefile");
|
||||
assertFileNotExists("SCCS");
|
||||
assertFileNotExists("SCCS/somefile");
|
||||
assertFileNotExists(".svn");
|
||||
assertFileNotExists(".svn/format");
|
||||
assertFileNotExists(".git");
|
||||
assertFileNotExists(".git/config");
|
||||
assertFileNotExists(".gitignore");
|
||||
assertFileNotExists(".gitattributes");
|
||||
assertFileNotExists(".gitmodules");
|
||||
assertFileNotExists(".arch-ids");
|
||||
assertFileNotExists(".arch-ids/somefile");
|
||||
assertFileNotExists("{arch}");
|
||||
assertFileNotExists("{arch}/somefile");
|
||||
assertFileNotExists("=RELEASE-ID");
|
||||
assertFileNotExists("=meta-update");
|
||||
assertFileNotExists("=update");
|
||||
assertFileNotExists(".bzr");
|
||||
assertFileNotExists(".bzr/checkout");
|
||||
assertFileNotExists(".bzrignore");
|
||||
assertFileNotExists(".bzrtags");
|
||||
assertFileNotExists(".hg");
|
||||
assertFileNotExists(".hg/dirstate");
|
||||
assertFileNotExists(".hgignore");
|
||||
assertFileNotExists(".hgtags");
|
||||
assertFileNotExists("_darcs");
|
||||
assertFileNotExists("_darcs/format");
|
||||
}
|
110
dependencies/libarchive-3.4.2/tar/test/test_option_fflags.c
vendored
Normal file
110
dependencies/libarchive-3.4.2/tar/test/test_option_fflags.c
vendored
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*-
|
||||
* Copyright (c) 2017 Martin Matuska
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__)
|
||||
#define chmod _chmod
|
||||
#endif
|
||||
|
||||
static void
|
||||
clear_fflags(const char *pathname)
|
||||
{
|
||||
#if defined(HAVE_STRUCT_STAT_ST_FLAGS)
|
||||
chflags(pathname, 0);
|
||||
#elif (defined(FS_IOC_GETFLAGS) && defined(HAVE_WORKING_FS_IOC_GETFLAGS)) || \
|
||||
(defined(EXT2_IOC_GETFLAGS) && defined(HAVE_WORKING_EXT2_IOC_GETFLAGS))
|
||||
int fd;
|
||||
|
||||
fd = open(pathname, O_RDONLY | O_NONBLOCK);
|
||||
if (fd < 0)
|
||||
return;
|
||||
ioctl(fd,
|
||||
#ifdef FS_IOC_GETFLAGS
|
||||
FS_IOC_GETFLAGS,
|
||||
#else
|
||||
EXT2_IOC_GETFLAGS,
|
||||
#endif
|
||||
0);
|
||||
#else
|
||||
(void)pathname; /* UNUSED */
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_option_fflags)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!canNodump()) {
|
||||
skipping("Can't test nodump flag on this filesystem");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Set nodump flag on the file */
|
||||
assertSetNodump("f");
|
||||
|
||||
/* FreeBSD ZFS workaround: ZFS sets uarch on all touched files and dirs */
|
||||
chmod("f", 0644);
|
||||
|
||||
/* Archive it with fflags */
|
||||
r = systemf("%s -c --fflags -f fflags.tar f >fflags.out 2>fflags.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Archive it without fflags */
|
||||
r = systemf("%s -c --no-fflags -f nofflags.tar f >nofflags.out 2>nofflags.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Extract fflags with fflags */
|
||||
assertMakeDir("fflags_fflags", 0755);
|
||||
clear_fflags("fflags_fflags");
|
||||
r = systemf("%s -x -C fflags_fflags --no-same-permissions --fflags -f fflags.tar >fflags_fflags.out 2>fflags_fflags.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEqualFflags("f", "fflags_fflags/f");
|
||||
|
||||
/* Extract fflags without fflags */
|
||||
assertMakeDir("fflags_nofflags", 0755);
|
||||
clear_fflags("fflags_nofflags");
|
||||
r = systemf("%s -x -C fflags_nofflags -p --no-fflags -f fflags.tar >fflags_nofflags.out 2>fflags_nofflags.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertUnequalFflags("f", "fflags_nofflags/f");
|
||||
|
||||
/* Extract nofflags with fflags */
|
||||
assertMakeDir("nofflags_fflags", 0755);
|
||||
clear_fflags("nofflags_fflags");
|
||||
r = systemf("%s -x -C nofflags_fflags --no-same-permissions --fflags -f nofflags.tar >nofflags_fflags.out 2>nofflags_fflags.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertUnequalFflags("f", "nofflags_fflags/f");
|
||||
|
||||
/* Extract nofflags with nofflags */
|
||||
assertMakeDir("nofflags_nofflags", 0755);
|
||||
clear_fflags("nofflags_nofflags");
|
||||
r = systemf("%s -x -C nofflags_nofflags -p --no-fflags -f nofflags.tar >nofflags_nofflags.out 2>nofflags_nofflags.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertUnequalFflags("f", "nofflags_nofflags/f");
|
||||
}
|
92
dependencies/libarchive-3.4.2/tar/test/test_option_gid_gname.c
vendored
Normal file
92
dependencies/libarchive-3.4.2/tar/test/test_option_gid_gname.c
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_gid_gname)
|
||||
{
|
||||
char *reference, *data;
|
||||
size_t s;
|
||||
|
||||
assertUmask(0);
|
||||
assertMakeFile("file", 0644, "1234567890");
|
||||
|
||||
/* Create archive with no special options. */
|
||||
failure("Error invoking %s c", testprog);
|
||||
assertEqualInt(0,
|
||||
systemf("%s cf archive1 --format=ustar file >stdout1.txt 2>stderr1.txt",
|
||||
testprog));
|
||||
assertEmptyFile("stdout1.txt");
|
||||
assertEmptyFile("stderr1.txt");
|
||||
reference = slurpfile(&s, "archive1");
|
||||
|
||||
/* Again with both --gid and --gname */
|
||||
failure("Error invoking %s c", testprog);
|
||||
assertEqualInt(0,
|
||||
systemf("%s cf archive2 --gid=17 --gname=foofoofoo --format=ustar file >stdout2.txt 2>stderr2.txt",
|
||||
testprog));
|
||||
assertEmptyFile("stdout2.txt");
|
||||
assertEmptyFile("stderr2.txt");
|
||||
data = slurpfile(&s, "archive2");
|
||||
/* Should force gid and gname fields in ustar header. */
|
||||
assertEqualMem(data + 116, "000021 \0", 8);
|
||||
assertEqualMem(data + 297, "foofoofoo\0", 10);
|
||||
free(data);
|
||||
|
||||
/* Again with just --gname */
|
||||
failure("Error invoking %s c", testprog);
|
||||
assertEqualInt(0,
|
||||
systemf("%s cf archive4 --gname=foofoofoo --format=ustar file >stdout4.txt 2>stderr4.txt",
|
||||
testprog));
|
||||
assertEmptyFile("stdout4.txt");
|
||||
assertEmptyFile("stderr4.txt");
|
||||
data = slurpfile(&s, "archive4");
|
||||
/* Gid should be unchanged from original reference. */
|
||||
assertEqualMem(data + 116, reference + 116, 8);
|
||||
assertEqualMem(data + 297, "foofoofoo\0", 10);
|
||||
free(data);
|
||||
free(reference);
|
||||
|
||||
/* Again with --gid and force gname to empty. */
|
||||
failure("Error invoking %s c", testprog);
|
||||
assertEqualInt(0,
|
||||
systemf("%s cf archive3 --gid=17 --gname= --format=ustar file >stdout3.txt 2>stderr3.txt",
|
||||
testprog));
|
||||
assertEmptyFile("stdout3.txt");
|
||||
assertEmptyFile("stderr3.txt");
|
||||
data = slurpfile(&s, "archive3");
|
||||
assertEqualMem(data + 116, "000021 \0", 8);
|
||||
/* Gname field in ustar header should be empty. */
|
||||
assertEqualMem(data + 297, "\0", 1);
|
||||
free(data);
|
||||
|
||||
/* TODO: It would be nice to verify that --gid= by itself
|
||||
* will look up the associated gname and use that, but
|
||||
* that requires some system-specific code. */
|
||||
|
||||
/* TODO: It would be nice to verify that --gid= will
|
||||
* leave the gname field blank if the specified gid
|
||||
* isn't used on the local system. */
|
||||
}
|
55
dependencies/libarchive-3.4.2/tar/test/test_option_grzip.c
vendored
Normal file
55
dependencies/libarchive-3.4.2/tar/test/test_option_grzip.c
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_grzip)
|
||||
{
|
||||
char *p;
|
||||
size_t s;
|
||||
|
||||
if (!canGrzip()) {
|
||||
skipping("grzip is not supported on this platform");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with grzip compression. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf - --grzip f >archive.out 2>archive.err",
|
||||
testprog));
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
free(p);
|
||||
|
||||
/* Check that the archive file has an grzip signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "GRZipII\x00\x02\x04:)", 12);
|
||||
free(p);
|
||||
}
|
59
dependencies/libarchive-3.4.2/tar/test/test_option_j.c
vendored
Normal file
59
dependencies/libarchive-3.4.2/tar/test/test_option_j.c
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_j)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with bzip2 compression. */
|
||||
r = systemf("%s -jcf archive.out f 2>archive.err", testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (!canBzip2()) {
|
||||
skipping("bzip2 is not supported on this platform");
|
||||
goto done;
|
||||
}
|
||||
failure("-j option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
goto done;
|
||||
}
|
||||
free(p);
|
||||
assertEmptyFile("archive.err");
|
||||
/* Check that the archive file has a bzip2 signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "BZh9", 4);
|
||||
done:
|
||||
free(p);
|
||||
}
|
107
dependencies/libarchive-3.4.2/tar/test/test_option_k.c
vendored
Normal file
107
dependencies/libarchive-3.4.2/tar/test/test_option_k.c
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_k)
|
||||
{
|
||||
/*
|
||||
* Create an archive with a couple of different versions of the
|
||||
* same file.
|
||||
*/
|
||||
|
||||
assertMakeFile("foo", 0644, "foo1");
|
||||
|
||||
assertEqualInt(0, systemf("%s -cf archive.tar foo", testprog));
|
||||
|
||||
assertMakeFile("foo", 0644, "foo2");
|
||||
|
||||
assertEqualInt(0, systemf("%s -rf archive.tar foo", testprog));
|
||||
|
||||
assertMakeFile("bar", 0644, "bar1");
|
||||
|
||||
assertEqualInt(0, systemf("%s -rf archive.tar bar", testprog));
|
||||
|
||||
assertMakeFile("foo", 0644, "foo3");
|
||||
|
||||
assertEqualInt(0, systemf("%s -rf archive.tar foo", testprog));
|
||||
|
||||
assertMakeFile("bar", 0644, "bar2");
|
||||
|
||||
assertEqualInt(0, systemf("%s -rf archive.tar bar", testprog));
|
||||
|
||||
/*
|
||||
* Now, try extracting from the test archive with various
|
||||
* combinations of -k
|
||||
*/
|
||||
|
||||
/* Test 1: No option */
|
||||
assertMakeDir("test1", 0755);
|
||||
assertChdir("test1");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileContents("foo3", 4, "foo");
|
||||
assertFileContents("bar2", 4, "bar");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 2: With -k, we should just get the first versions. */
|
||||
assertMakeDir("test2", 0755);
|
||||
assertChdir("test2");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar -k >test.out 2>test.err", testprog));
|
||||
assertFileContents("foo1", 4, "foo");
|
||||
assertFileContents("bar1", 4, "bar");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 3: Without -k, existing files should get overwritten */
|
||||
assertMakeDir("test3", 0755);
|
||||
assertChdir("test3");
|
||||
assertMakeFile("bar", 0644, "bar0");
|
||||
assertMakeFile("foo", 0644, "foo0");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar >test.out 2>test.err", testprog));
|
||||
assertFileContents("foo3", 4, "foo");
|
||||
assertFileContents("bar2", 4, "bar");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 4: With -k, existing files should not get overwritten */
|
||||
assertMakeDir("test4", 0755);
|
||||
assertChdir("test4");
|
||||
assertMakeFile("bar", 0644, "bar0");
|
||||
assertMakeFile("foo", 0644, "foo0");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar -k >test.out 2>test.err", testprog));
|
||||
assertFileContents("foo0", 4, "foo");
|
||||
assertFileContents("bar0", 4, "bar");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
}
|
56
dependencies/libarchive-3.4.2/tar/test/test_option_keep_newer_files.c
vendored
Normal file
56
dependencies/libarchive-3.4.2/tar/test/test_option_keep_newer_files.c
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_keep_newer_files)
|
||||
{
|
||||
const char *reffile = "test_option_keep_newer_files.tar.Z";
|
||||
|
||||
/* Reference file has one entry "file" with a very old timestamp. */
|
||||
extract_reference_file(reffile);
|
||||
|
||||
/* Test 1: Without --keep-newer-files */
|
||||
assertMakeDir("test1", 0755);
|
||||
assertChdir("test1");
|
||||
assertMakeFile("file", 0644, "new");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../%s >test.out 2>test.err", testprog, reffile));
|
||||
assertFileContents("old\n", 4, "file");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 2: With --keep-newer-files */
|
||||
assertMakeDir("test2", 0755);
|
||||
assertChdir("test2");
|
||||
assertMakeFile("file", 0644, "new");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../%s --keep-newer-files >test.out 2>test.err", testprog, reffile));
|
||||
assertFileContents("new", 3, "file");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
}
|
7
dependencies/libarchive-3.4.2/tar/test/test_option_keep_newer_files.tar.Z.uu
vendored
Normal file
7
dependencies/libarchive-3.4.2/tar/test/test_option_keep_newer_files.tar.Z.uu
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
begin 644 test_option_keep_newer_files.tar.Z
|
||||
M'YV09M*P*0.@H,&#"!,J7,BPH<.'$!'"F&B#!@T0`";&N%$#!D:-'#UFG$BR
|
||||
MY$48,F38F&$CY8P8)V/$F,$2``@8$7/JW,FS)X`Z<^B$D3.23IHV/AD:19I4
|
||||
M8<F)'Y]B;$JUJM6K6'V^84-&0=:O8,.*'4NVK-FS:-.J7<NVK=NW<./*G4NW
|
||||
.KMV[>//JW<NWK]^_/0$`
|
||||
`
|
||||
end
|
54
dependencies/libarchive-3.4.2/tar/test/test_option_lrzip.c
vendored
Normal file
54
dependencies/libarchive-3.4.2/tar/test/test_option_lrzip.c
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_lrzip)
|
||||
{
|
||||
char *p;
|
||||
size_t s;
|
||||
|
||||
if (!canLrzip()) {
|
||||
skipping("lrzip is not supported on this platform");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with lrzip compression. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf - --lrzip f >archive.out 2>archive.err",
|
||||
testprog));
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
free(p);
|
||||
/* Check that the archive file has an lzma signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "LRZI\x00", 5);
|
||||
free(p);
|
||||
}
|
85
dependencies/libarchive-3.4.2/tar/test/test_option_lz4.c
vendored
Normal file
85
dependencies/libarchive-3.4.2/tar/test/test_option_lz4.c
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_lz4)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with lz4 compression. */
|
||||
r = systemf("%s -cf - --lz4 f >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "Unsupported compression") != NULL) {
|
||||
skipping("This version of bsdtar was compiled "
|
||||
"without lz4 support");
|
||||
goto done;
|
||||
}
|
||||
/* POSIX permits different handling of the spawnp
|
||||
* system call used to launch the subsidiary
|
||||
* program: */
|
||||
/* Some systems fail immediately to spawn the new process. */
|
||||
if (strstr(p, "Can't launch") != NULL && !canLz4()) {
|
||||
skipping("This version of bsdtar uses an external lz4 program "
|
||||
"but no such program is available on this system.");
|
||||
goto done;
|
||||
}
|
||||
/* Some systems successfully spawn the new process,
|
||||
* but fail to exec a program within that process.
|
||||
* This results in failure at the first attempt to
|
||||
* write. */
|
||||
if (strstr(p, "Can't write") != NULL && !canLz4()) {
|
||||
skipping("This version of bsdtar uses an external lz4 program "
|
||||
"but no such program is available on this system.");
|
||||
goto done;
|
||||
}
|
||||
/* On some systems the error won't be detected until closing
|
||||
time, by a 127 exit error returned by waitpid. */
|
||||
if (strstr(p, "Error closing") != NULL && !canLz4()) {
|
||||
skipping("This version of bsdcpio uses an external lz4 program "
|
||||
"but no such program is available on this system.");
|
||||
return;
|
||||
}
|
||||
failure("--lz4 option is broken: %s", p);
|
||||
assertEqualInt(r, 0);
|
||||
goto done;
|
||||
}
|
||||
free(p);
|
||||
/* Check that the archive file has an lz4 signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\x04\x22\x4d\x18", 4);
|
||||
|
||||
done:
|
||||
free(p);
|
||||
}
|
60
dependencies/libarchive-3.4.2/tar/test/test_option_lzma.c
vendored
Normal file
60
dependencies/libarchive-3.4.2/tar/test/test_option_lzma.c
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_lzma)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with lzma compression. */
|
||||
r = systemf("%s -cf - --lzma f >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "Unsupported compression") != NULL) {
|
||||
skipping("This version of bsdtar was compiled "
|
||||
"without lzma support");
|
||||
return;
|
||||
}
|
||||
failure("--lzma option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
goto done;
|
||||
}
|
||||
free(p);
|
||||
/* Check that the archive file has an lzma signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\x5d\00\00", 3);
|
||||
done:
|
||||
free(p);
|
||||
}
|
58
dependencies/libarchive-3.4.2/tar/test/test_option_lzop.c
vendored
Normal file
58
dependencies/libarchive-3.4.2/tar/test/test_option_lzop.c
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_lzop)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with lzop compression. */
|
||||
r = systemf("%s -cf - --lzop f >archive.out 2>archive.err", testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (!canLzop()) {
|
||||
skipping("lzop is not supported on this platform");
|
||||
goto done;
|
||||
}
|
||||
failure("--lzop option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
goto done;
|
||||
}
|
||||
free(p);
|
||||
/* Check that the archive file has an lzma signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a", 9);
|
||||
done:
|
||||
free(p);
|
||||
}
|
142
dependencies/libarchive-3.4.2/tar/test/test_option_n.c
vendored
Normal file
142
dependencies/libarchive-3.4.2/tar/test/test_option_n.c
vendored
Normal file
|
@ -0,0 +1,142 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
DEFINE_TEST(test_option_n)
|
||||
{
|
||||
int status;
|
||||
|
||||
assertMakeDir("d1", 0755);
|
||||
assertMakeFile("d1/file1", 0644, "d1/file1");
|
||||
|
||||
/* Test 1: -c without -n */
|
||||
assertMakeDir("test1", 0755);
|
||||
assertChdir("test1");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf archive.tar -C .. d1 >c.out 2>c.err", testprog));
|
||||
assertEmptyFile("c.out");
|
||||
assertEmptyFile("c.err");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >x.out 2>x.err", testprog));
|
||||
assertEmptyFile("x.out");
|
||||
assertEmptyFile("x.err");
|
||||
assertFileContents("d1/file1", 8, "d1/file1");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 2: -c with -n */
|
||||
assertMakeDir("test2", 0755);
|
||||
assertChdir("test2");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cnf archive.tar -C .. d1 >c.out 2>c.err", testprog));
|
||||
assertEmptyFile("c.out");
|
||||
assertEmptyFile("c.err");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf archive.tar >x.out 2>x.err", testprog));
|
||||
assertEmptyFile("x.out");
|
||||
assertEmptyFile("x.err");
|
||||
assertIsDir("d1", umasked(0755));
|
||||
assertFileNotExists("d1/file1");
|
||||
assertChdir("..");
|
||||
|
||||
/*
|
||||
* Create a test archive with the following content:
|
||||
* d1/
|
||||
* d1/file1
|
||||
* d1/file2
|
||||
* file3
|
||||
* d2/file4
|
||||
*
|
||||
* Extracting uses the same code as listing and thus does not
|
||||
* get tested separately. This also covers the
|
||||
* archive_match_set_inclusion_recursion()
|
||||
* API.
|
||||
*/
|
||||
assertMakeFile("d1/file2", 0644, "d1/file2");
|
||||
assertMakeFile("file3", 0644, "file3");
|
||||
assertMakeDir("d2", 0755);
|
||||
assertMakeFile("d2/file4", 0644, "d2/file4");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cnf partial-archive.tar d1 d1/file1 d1/file2 file3 "
|
||||
"d2/file4 >c.out 2>c.err", testprog));
|
||||
|
||||
/* Test 3: -t without other options */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf partial-archive.tar >test3.out 2>test3.err",
|
||||
testprog));
|
||||
assertEmptyFile("test3.err");
|
||||
assertTextFileContents("d1/\n"
|
||||
"d1/file1\n"
|
||||
"d1/file2\n"
|
||||
"file3\n"
|
||||
"d2/file4\n",
|
||||
"test3.out");
|
||||
|
||||
/* Test 4: -t without -n and some entries selected */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf partial-archive.tar d1 file3 d2/file4 "
|
||||
">test4.out 2>test4.err", testprog));
|
||||
assertEmptyFile("test4.err");
|
||||
assertTextFileContents("d1/\n"
|
||||
"d1/file1\n"
|
||||
"d1/file2\n"
|
||||
"file3\n"
|
||||
"d2/file4\n",
|
||||
"test4.out");
|
||||
|
||||
/* Test 5: -t with -n and some entries selected */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tnf partial-archive.tar d1 file3 d2/file4 "
|
||||
">test5.out 2>test5.err", testprog));
|
||||
assertEmptyFile("test5.err");
|
||||
assertTextFileContents("d1/\n"
|
||||
"file3\n"
|
||||
"d2/file4\n",
|
||||
"test5.out");
|
||||
|
||||
/* Test 6: -t without -n and non-existent directory selected */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf partial-archive.tar d2 >test6.out 2>test6.err",
|
||||
testprog));
|
||||
assertEmptyFile("test6.err");
|
||||
assertTextFileContents("d2/file4\n",
|
||||
"test6.out");
|
||||
|
||||
/* Test 7: -t with -n and non-existent directory selected */
|
||||
status = systemf("%s -tnf partial-archive.tar d2 "
|
||||
">test7.out 2>test7.err", testprog);
|
||||
assert(status);
|
||||
assert(status != -1);
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
assert(WIFEXITED(status));
|
||||
assertEqualInt(1, WEXITSTATUS(status));
|
||||
#endif
|
||||
assertNonEmptyFile("test7.err");
|
||||
assertEmptyFile("test7.out");
|
||||
}
|
78
dependencies/libarchive-3.4.2/tar/test/test_option_newer_than.c
vendored
Normal file
78
dependencies/libarchive-3.4.2/tar/test/test_option_newer_than.c
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_newer_than)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
/*
|
||||
* Basic test of --newer-than.
|
||||
* First, create three files with different mtimes.
|
||||
* Create test1.tar with --newer-than, test2.tar without.
|
||||
*/
|
||||
assertMakeDir("test1in", 0755);
|
||||
assertChdir("test1in");
|
||||
assertMakeDir("a", 0755);
|
||||
assertMakeDir("a/b", 0755);
|
||||
assertMakeFile("old.txt", 0644, "old.txt");
|
||||
assertEqualInt(0, stat("old.txt", &st));
|
||||
sleepUntilAfter(st.st_mtime);
|
||||
assertMakeFile("middle.txt", 0644, "middle.txt");
|
||||
assertEqualInt(0, stat("middle.txt", &st));
|
||||
sleepUntilAfter(st.st_mtime);
|
||||
assertMakeFile("new.txt", 0644, "new");
|
||||
assertMakeFile("a/b/new.txt", 0644, "new file in old directory");
|
||||
|
||||
/* Test --newer-than on create */
|
||||
assertEqualInt(0,
|
||||
systemf("%s --format pax -cf ../test1.tar "
|
||||
"--newer-than middle.txt *.txt a", testprog));
|
||||
assertEqualInt(0,
|
||||
systemf("%s --format pax -cf ../test2.tar *.txt a", testprog));
|
||||
assertChdir("..");
|
||||
|
||||
/* Extract test1.tar to a clean dir and verify what got archived. */
|
||||
assertMakeDir("test1out", 0755);
|
||||
assertChdir("test1out");
|
||||
assertEqualInt(0, systemf("%s xf ../test1.tar", testprog));
|
||||
assertFileExists("new.txt");
|
||||
assertFileExists("a/b/new.txt");
|
||||
assertFileNotExists("middle.txt");
|
||||
assertFileNotExists("old.txt");
|
||||
assertChdir("..");
|
||||
|
||||
/* Extract test2.tar to a clean dir with --newer-than and verify. */
|
||||
assertMakeDir("test2out", 0755);
|
||||
assertChdir("test2out");
|
||||
assertEqualInt(0, systemf("%s xf ../test2.tar --newer-than ../test1in/middle.txt", testprog));
|
||||
assertFileExists("new.txt");
|
||||
assertFileExists("a/b/new.txt");
|
||||
assertFileNotExists("middle.txt");
|
||||
assertFileNotExists("old.txt");
|
||||
assertChdir("..");
|
||||
|
||||
}
|
68
dependencies/libarchive-3.4.2/tar/test/test_option_nodump.c
vendored
Normal file
68
dependencies/libarchive-3.4.2/tar/test/test_option_nodump.c
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_nodump)
|
||||
{
|
||||
|
||||
if (!canNodump()) {
|
||||
skipping("Can't test nodump on this filesystem");
|
||||
return;
|
||||
}
|
||||
|
||||
assertMakeFile("file1", 0644, "file1");
|
||||
assertMakeFile("file2", 0644, "file2");
|
||||
assertMakeFile("file3", 0644, "file3");
|
||||
assertSetNodump("file2");
|
||||
|
||||
/* Test 1: Without --nodump */
|
||||
assertEqualInt(0, systemf("%s -cf test1.tar file1 file2 file3",
|
||||
testprog));
|
||||
assertMakeDir("test1", 0755);
|
||||
assertChdir("test1");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../test1.tar >test.out 2>test.err", testprog));
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileContents("file2", 5, "file2");
|
||||
assertFileContents("file3", 5, "file3");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 2: With --nodump */
|
||||
assertEqualInt(0, systemf("%s -cf test2.tar --nodump file1 file2 file3",
|
||||
testprog));
|
||||
assertMakeDir("test2", 0755);
|
||||
assertChdir("test2");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../test2.tar >test.out 2>test.err", testprog));
|
||||
assertFileContents("file1", 5, "file1");
|
||||
assertFileNotExists("file2");
|
||||
assertFileContents("file3", 5, "file3");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
}
|
85
dependencies/libarchive-3.4.2/tar/test/test_option_older_than.c
vendored
Normal file
85
dependencies/libarchive-3.4.2/tar/test/test_option_older_than.c
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*-
|
||||
* Copyright (c) 2010 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_older_than)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
/*
|
||||
* Basic test of --older-than.
|
||||
* First, create three files with different mtimes.
|
||||
* Create test1.tar with --older-than, test2.tar without.
|
||||
*/
|
||||
assertMakeDir("test1in", 0755);
|
||||
assertChdir("test1in");
|
||||
assertMakeDir("a", 0755);
|
||||
assertMakeDir("a/b", 0755);
|
||||
assertMakeFile("old.txt", 0644, "old.txt");
|
||||
assertMakeFile("a/b/old.txt", 0644, "old file in old directory");
|
||||
assertEqualInt(0, stat("old.txt", &st));
|
||||
sleepUntilAfter(st.st_mtime);
|
||||
assertMakeFile("middle.txt", 0644, "middle.txt");
|
||||
assertEqualInt(0, stat("middle.txt", &st));
|
||||
sleepUntilAfter(st.st_mtime);
|
||||
assertMakeFile("new.txt", 0644, "new");
|
||||
assertMakeFile("a/b/new.txt", 0644, "new file in old directory");
|
||||
|
||||
/* Test --older-than on create */
|
||||
assertEqualInt(0,
|
||||
systemf("%s --format pax -cf ../test1.tar "
|
||||
"--older-than middle.txt *.txt a",
|
||||
testprog));
|
||||
assertEqualInt(0,
|
||||
systemf("%s --format pax -cf ../test2.tar *.txt a",
|
||||
testprog));
|
||||
assertChdir("..");
|
||||
|
||||
/* Extract test1.tar to a clean dir and verify what got archived. */
|
||||
assertMakeDir("test1out", 0755);
|
||||
assertChdir("test1out");
|
||||
assertEqualInt(0, systemf("%s xf ../test1.tar", testprog));
|
||||
assertFileNotExists("new.txt");
|
||||
assertFileNotExists("a/b/new.txt");
|
||||
assertFileNotExists("middle.txt");
|
||||
assertFileExists("old.txt");
|
||||
assertFileExists("a/b/old.txt");
|
||||
assertChdir("..");
|
||||
|
||||
/* Extract test2.tar to a clean dir with --older-than and verify. */
|
||||
assertMakeDir("test2out", 0755);
|
||||
assertChdir("test2out");
|
||||
assertEqualInt(0,
|
||||
systemf("%s xf ../test2.tar --older-than ../test1in/middle.txt",
|
||||
testprog));
|
||||
assertFileNotExists("new.txt");
|
||||
assertFileNotExists("a/b/new.txt");
|
||||
assertFileNotExists("middle.txt");
|
||||
assertFileExists("old.txt");
|
||||
assertFileExists("a/b/old.txt");
|
||||
assertChdir("..");
|
||||
}
|
43
dependencies/libarchive-3.4.2/tar/test/test_option_passphrase.c
vendored
Normal file
43
dependencies/libarchive-3.4.2/tar/test/test_option_passphrase.c
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_passphrase)
|
||||
{
|
||||
const char *reffile = "test_option_passphrase.zip";
|
||||
|
||||
extract_reference_file(reffile);
|
||||
failure("--passphrase option is broken");
|
||||
assertEqualInt(0, systemf(
|
||||
"%s --passphrase pass1 -xf %s >test.out 2>test.err",
|
||||
testprog, reffile));
|
||||
assertFileExists("file1");
|
||||
assertTextFileContents("contents of file1.\n", "file1");
|
||||
assertFileExists("file2");
|
||||
assertTextFileContents("contents of file2.\n", "file2");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
}
|
12
dependencies/libarchive-3.4.2/tar/test/test_option_passphrase.zip.uu
vendored
Normal file
12
dependencies/libarchive-3.4.2/tar/test/test_option_passphrase.zip.uu
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
begin 644 test_option_passphrase.zip
|
||||
M4$L#!`H`"0```#B91$7D$C4,'P```!,````%`!P`9FEL93%55`D``VS'+U0"
|
||||
MQR]4=7@+``$$]0$```04````BHPD*"^*I04=XKI\_FQ*TE+#),TD7TTKSP/7
|
||||
MR6R35%!+!PCD$C4,'P```!,```!02P,$"@`)````09E$1;VL<PX?````$P``
|
||||
M``4`'`!F:6QE,E54"0`#><<O5`+'+U1U>`L``03U`0``!!0```!D#6Z\@CI8
|
||||
MV1GIJO5TISQF^I:7.;Y3<-G3$YOCL(C_4$L'"+VL<PX?````$P```%!+`0(>
|
||||
M`PH`"0```#B91$7D$C4,'P```!,````%`!@```````$```"D@0````!F:6QE
|
||||
M,554!0`#;,<O5'5X"P`!!/4!```$%````%!+`0(>`PH`"0```$&91$6]K',.
|
||||
M'P```!,````%`!@```````$```"D@6X```!F:6QE,E54!0`#><<O5'5X"P`!
|
||||
@!/4!```$%````%!+!08``````@`"`)8```#<````````
|
||||
`
|
||||
end
|
113
dependencies/libarchive-3.4.2/tar/test/test_option_q.c
vendored
Normal file
113
dependencies/libarchive-3.4.2/tar/test/test_option_q.c
vendored
Normal file
|
@ -0,0 +1,113 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_option_q.c,v 1.3 2008/08/22 01:35:08 kientzle Exp $");
|
||||
|
||||
DEFINE_TEST(test_option_q)
|
||||
{
|
||||
int r;
|
||||
|
||||
/*
|
||||
* Create an archive with several different versions of the
|
||||
* same files. By default, the last version will overwrite
|
||||
* any earlier versions. The -q/--fast-read option will
|
||||
* stop early, so we can verify -q/--fast-read by seeing
|
||||
* which version of each file actually ended up being
|
||||
* extracted. This also exercises -r mode, since that's
|
||||
* what we use to build up the test archive.
|
||||
*/
|
||||
|
||||
assertMakeFile("foo", 0644, "foo1");
|
||||
|
||||
assertEqualInt(0, systemf("%s -cf archive.tar foo", testprog));
|
||||
|
||||
assertMakeFile("foo", 0644, "foo2");
|
||||
|
||||
assertEqualInt(0, systemf("%s -rf archive.tar foo", testprog));
|
||||
|
||||
assertMakeFile("bar", 0644, "bar1");
|
||||
|
||||
assertEqualInt(0, systemf("%s -rf archive.tar bar", testprog));
|
||||
|
||||
assertMakeFile("foo", 0644, "foo3");
|
||||
|
||||
assertEqualInt(0, systemf("%s -rf archive.tar foo", testprog));
|
||||
|
||||
assertMakeFile("bar", 0644, "bar2");
|
||||
|
||||
assertEqualInt(0, systemf("%s -rf archive.tar bar", testprog));
|
||||
|
||||
/*
|
||||
* Now, try extracting from the test archive with various
|
||||
* combinations of -q.
|
||||
*/
|
||||
|
||||
/* Test 1: -q foo should only extract the first foo. */
|
||||
assertMakeDir("test1", 0755);
|
||||
assertChdir("test1");
|
||||
r = systemf("%s -xf ../archive.tar -q foo >test.out 2>test.err",
|
||||
testprog);
|
||||
failure("Fatal error trying to use -q option");
|
||||
if (!assertEqualInt(0, r))
|
||||
return;
|
||||
|
||||
assertFileContents("foo1", 4, "foo");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 2: -q foo bar should extract up to the first bar. */
|
||||
assertMakeDir("test2", 0755);
|
||||
assertChdir("test2");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar -q foo bar >test.out 2>test.err", testprog));
|
||||
assertFileContents("foo2", 4, "foo");
|
||||
assertFileContents("bar1", 4, "bar");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 3: Same as test 2, but use --fast-read spelling. */
|
||||
assertMakeDir("test3", 0755);
|
||||
assertChdir("test3");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar --fast-read foo bar >test.out 2>test.err", testprog));
|
||||
assertFileContents("foo2", 4, "foo");
|
||||
assertFileContents("bar1", 4, "bar");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
|
||||
/* Test 4: Without -q, should extract everything. */
|
||||
assertMakeDir("test4", 0755);
|
||||
assertChdir("test4");
|
||||
assertEqualInt(0,
|
||||
systemf("%s -xf ../archive.tar foo bar >test.out 2>test.err", testprog));
|
||||
assertFileContents("foo3", 4, "foo");
|
||||
assertFileContents("bar2", 4, "bar");
|
||||
assertEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
assertChdir("..");
|
||||
}
|
133
dependencies/libarchive-3.4.2/tar/test/test_option_r.c
vendored
Normal file
133
dependencies/libarchive-3.4.2/tar/test/test_option_r.c
vendored
Normal file
|
@ -0,0 +1,133 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Also see test_option_q for additional validation of -r support.
|
||||
*/
|
||||
DEFINE_TEST(test_option_r)
|
||||
{
|
||||
char *buff;
|
||||
char *p0, *p1;
|
||||
size_t buff_size = 35000;
|
||||
size_t s, buff_size_rounded;
|
||||
int r, i;
|
||||
|
||||
buff = NULL;
|
||||
p0 = NULL;
|
||||
p1 = NULL;
|
||||
|
||||
/* Create an archive with one file. */
|
||||
assertMakeFile("f1", 0644, "abc");
|
||||
r = systemf("%s cf archive.tar --format=ustar f1 >step1.out 2>step1.err", testprog);
|
||||
failure("Error invoking %s cf archive.tar f1", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("step1.out");
|
||||
assertEmptyFile("step1.err");
|
||||
|
||||
/* Do some basic validation of the constructed archive. */
|
||||
p0 = slurpfile(&s, "archive.tar");
|
||||
if (!assert(p0 != NULL))
|
||||
goto done;
|
||||
if (!assert(s >= 2048))
|
||||
goto done;
|
||||
assertEqualMem(p0 + 0, "f1", 3);
|
||||
assertEqualMem(p0 + 512, "abc", 3);
|
||||
assertEqualMem(p0 + 1024, "\0\0\0\0\0\0\0\0", 8);
|
||||
assertEqualMem(p0 + 1536, "\0\0\0\0\0\0\0\0", 8);
|
||||
|
||||
/* Edit that file with a lot more data and update the archive with a new copy. */
|
||||
buff = malloc(buff_size);
|
||||
assert(buff != NULL);
|
||||
if (buff == NULL)
|
||||
goto done;
|
||||
|
||||
for (i = 0; i < (int)buff_size; ++i)
|
||||
buff[i] = "abcdefghijklmnopqrstuvwxyz"[rand() % 26];
|
||||
buff[buff_size - 1] = '\0';
|
||||
assertMakeFile("f1", 0644, buff);
|
||||
r = systemf("%s rf archive.tar --format=ustar f1 >step2.out 2>step2.err", testprog);
|
||||
failure("Error invoking %s rf archive.tar f1", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("step2.out");
|
||||
assertEmptyFile("step2.err");
|
||||
|
||||
/* The constructed archive should just have the new entry appended. */
|
||||
p1 = slurpfile(&s, "archive.tar");
|
||||
if (!assert(p1 != NULL))
|
||||
goto done;
|
||||
buff_size_rounded = ((buff_size + 511) / 512) * 512;
|
||||
assert(s >= 2560 + buff_size_rounded);
|
||||
/* Verify first entry is unchanged. */
|
||||
assertEqualMem(p0, p1, 1024);
|
||||
/* Verify that second entry is correct. */
|
||||
assertEqualMem(p1 + 1024, "f1", 3);
|
||||
assertEqualMem(p1 + 1536, buff, buff_size);
|
||||
/* Verify end-of-archive marker. */
|
||||
assertEqualMem(p1 + 1536 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8);
|
||||
assertEqualMem(p1 + 2048 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8);
|
||||
|
||||
free(p0);
|
||||
p0 = p1;
|
||||
|
||||
/* Update the archive by adding a different file. */
|
||||
assertMakeFile("f2", 0644, "f2");
|
||||
r = systemf("%s rf archive.tar --format=ustar f2 >step3.out 2>step3.err", testprog);
|
||||
failure("Error invoking %s rf archive.tar f2", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("step3.out");
|
||||
assertEmptyFile("step3.err");
|
||||
|
||||
/* Validate the constructed archive. */
|
||||
p1 = slurpfile(&s, "archive.tar");
|
||||
if (!assert(p1 != NULL))
|
||||
goto done;
|
||||
assert(s >= 3584 + buff_size_rounded);
|
||||
/* Verify first two entries are unchanged. */
|
||||
assertEqualMem(p0, p1, 1536 + buff_size_rounded);
|
||||
/* Verify that new entry is correct. */
|
||||
assertEqualMem(p1 + 1536 + buff_size_rounded, "f2", 3);
|
||||
assertEqualMem(p1 + 2048 + buff_size_rounded, "f2", 3);
|
||||
/* Verify end-of-archive marker. */
|
||||
assertEqualMem(p1 + 2560 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8);
|
||||
assertEqualMem(p1 + 3072 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8);
|
||||
free(p1);
|
||||
|
||||
/* Unpack everything */
|
||||
assertMakeDir("extract", 0775);
|
||||
assertChdir("extract");
|
||||
r = systemf("%s xf ../archive.tar >extract.out 2>extract.err", testprog);
|
||||
failure("Error invoking %s xf archive.tar", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("extract.out");
|
||||
assertEmptyFile("extract.err");
|
||||
|
||||
/* Verify that the second copy of f1 overwrote the first. */
|
||||
assertFileContents(buff, (int)strlen(buff), "f1");
|
||||
done:
|
||||
free(buff);
|
||||
free(p0);
|
||||
}
|
278
dependencies/libarchive-3.4.2/tar/test/test_option_s.c
vendored
Normal file
278
dependencies/libarchive-3.4.2/tar/test/test_option_s.c
vendored
Normal file
|
@ -0,0 +1,278 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2008 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_option_T.c,v 1.3 2008/08/15 06:12:02 kientzle Exp $");
|
||||
|
||||
DEFINE_TEST(test_option_s)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
/* Create a sample file hierarchy. */
|
||||
assertMakeDir("in", 0755);
|
||||
assertMakeDir("in/d1", 0755);
|
||||
assertMakeFile("in/d1/foo", 0644, "foo");
|
||||
assertMakeFile("in/d1/bar", 0644, "bar");
|
||||
if (canSymlink()) {
|
||||
assertMakeFile("in/d1/realfile", 0644, "realfile");
|
||||
assertMakeSymlink("in/d1/symlink", "realfile", 0);
|
||||
}
|
||||
assertMakeFile("in/d1/hardlink1", 0644, "hardlinkedfile");
|
||||
assertMakeHardlink("in/d1/hardlink2", "in/d1/hardlink1");
|
||||
|
||||
/* Does tar support -s option ? */
|
||||
systemf("%s -cf - -s /foo/bar/ in/d1/foo > NUL 2> check.err",
|
||||
testprog);
|
||||
assertEqualInt(0, stat("check.err", &st));
|
||||
if (st.st_size != 0) {
|
||||
skipping("%s does not support -s option on this platform",
|
||||
testprog);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test 1: Filename substitution when creating archives.
|
||||
*/
|
||||
assertMakeDir("test1", 0755);
|
||||
systemf("%s -cf test1_1.tar -s /foo/bar/ in/d1/foo", testprog);
|
||||
systemf("%s -xf test1_1.tar -C test1", testprog);
|
||||
assertFileContents("foo", 3, "test1/in/d1/bar");
|
||||
systemf("%s -cf test1_2.tar -s /d1/d2/ in/d1/foo", testprog);
|
||||
systemf("%s -xf test1_2.tar -C test1", testprog);
|
||||
assertFileContents("foo", 3, "test1/in/d2/foo");
|
||||
|
||||
/*
|
||||
* Test 2: Basic substitution when extracting archive.
|
||||
*/
|
||||
assertMakeDir("test2", 0755);
|
||||
systemf("%s -cf test2.tar in/d1/foo", testprog);
|
||||
systemf("%s -xf test2.tar -s /foo/bar/ -C test2", testprog);
|
||||
assertFileContents("foo", 3, "test2/in/d1/bar");
|
||||
|
||||
/*
|
||||
* Test 3: Files with empty names shouldn't be archived.
|
||||
*/
|
||||
systemf("%s -cf test3.tar -s ,in/d1/foo,, in/d1/foo", testprog);
|
||||
systemf("%s -tvf test3.tar > in.lst", testprog);
|
||||
assertEmptyFile("in.lst");
|
||||
|
||||
/*
|
||||
* Test 4: Multiple substitutions when extracting archive.
|
||||
*/
|
||||
assertMakeDir("test4", 0755);
|
||||
systemf("%s -cf test4.tar in/d1/foo in/d1/bar",
|
||||
testprog);
|
||||
systemf("%s -xf test4.tar -s /foo/bar/ -s }bar}baz} -C test4",
|
||||
testprog);
|
||||
assertFileContents("foo", 3, "test4/in/d1/bar");
|
||||
assertFileContents("bar", 3, "test4/in/d1/baz");
|
||||
|
||||
/*
|
||||
* Test 5: Name-switching substitutions when extracting archive.
|
||||
*/
|
||||
assertMakeDir("test5", 0755);
|
||||
systemf("%s -cf test5.tar in/d1/foo in/d1/bar", testprog);
|
||||
systemf("%s -xf test5.tar -s /foo/bar/ -s }bar}foo} -C test5", testprog);
|
||||
assertFileContents("foo", 3, "test5/in/d1/bar");
|
||||
assertFileContents("bar", 3, "test5/in/d1/foo");
|
||||
|
||||
/*
|
||||
* Test 6: symlinks get renamed by default
|
||||
*/
|
||||
if (canSymlink()) {
|
||||
/* At extraction time. */
|
||||
assertMakeDir("test6a", 0755);
|
||||
systemf("%s -cf - in/d1 | %s -xf - -s /d1/d2/ -C test6a",
|
||||
testprog, testprog);
|
||||
assertFileContents("realfile", 8, "test6a/in/d2/realfile");
|
||||
assertFileContents("realfile", 8, "test6a/in/d2/symlink");
|
||||
assertIsSymlink("test6a/in/d2/symlink", "realfile", 0);
|
||||
/* At creation time. */
|
||||
assertMakeDir("test6b", 0755);
|
||||
systemf("%s -cf - -s /d1/d2/ in/d1 | %s -xf - -C test6b",
|
||||
testprog, testprog);
|
||||
assertFileContents("realfile", 8, "test6b/in/d2/realfile");
|
||||
assertFileContents("realfile", 8, "test6b/in/d2/symlink");
|
||||
assertIsSymlink("test6b/in/d2/symlink", "realfile", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test 7: selective renaming of symlink target
|
||||
*/
|
||||
if (canSymlink()) {
|
||||
/* At extraction. */
|
||||
assertMakeDir("test7a", 0755);
|
||||
systemf("%s -cf - in/d1 | %s -xf - -s /realfile/realfile-renamed/ -C test7a",
|
||||
testprog, testprog);
|
||||
assertFileContents("realfile", 8, "test7a/in/d1/realfile-renamed");
|
||||
assertFileContents("realfile", 8, "test7a/in/d1/symlink");
|
||||
assertIsSymlink("test7a/in/d1/symlink", "realfile-renamed", 0);
|
||||
/* At creation. */
|
||||
assertMakeDir("test7b", 0755);
|
||||
systemf("%s -cf - -s /realfile/realfile-renamed/ in/d1 | %s -xf - -C test7b",
|
||||
testprog, testprog);
|
||||
assertFileContents("realfile", 8, "test7b/in/d1/realfile-renamed");
|
||||
assertFileContents("realfile", 8, "test7b/in/d1/symlink");
|
||||
assertIsSymlink("test7b/in/d1/symlink", "realfile-renamed", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test 8: hardlinks get renamed by default
|
||||
*/
|
||||
/* At extraction time. */
|
||||
assertMakeDir("test8a", 0755);
|
||||
systemf("%s -cf test8a.tar in/d1", testprog);
|
||||
systemf("%s -xf test8a.tar -s /d1/d2/ -C test8a", testprog);
|
||||
assertIsHardlink("test8a/in/d2/hardlink1", "test8a/in/d2/hardlink2");
|
||||
/* At creation time. */
|
||||
assertMakeDir("test8b", 0755);
|
||||
systemf("%s -cf test8b.tar -s /d1/d2/ in/d1", testprog);
|
||||
systemf("%s -xf test8b.tar -C test8b", testprog);
|
||||
assertIsHardlink("test8b/in/d2/hardlink1", "test8b/in/d2/hardlink2");
|
||||
|
||||
/*
|
||||
* Test 9: selective renaming of hardlink target
|
||||
*/
|
||||
/* At extraction. (assuming hardlink2 is the hardlink entry) */
|
||||
assertMakeDir("test9a", 0755);
|
||||
systemf("%s -cf test9a.tar in/d1", testprog);
|
||||
systemf("%s -xf test9a.tar -s /hardlink1/hardlink1-renamed/ -C test9a",
|
||||
testprog);
|
||||
assertIsHardlink("test9a/in/d1/hardlink1-renamed", "test9a/in/d1/hardlink2");
|
||||
/* At extraction. (assuming hardlink1 is the hardlink entry) */
|
||||
assertMakeDir("test9b", 0755);
|
||||
systemf("%s -cf test9b.tar in/d1", testprog);
|
||||
systemf("%s -xf test9b.tar -s /hardlink2/hardlink2-renamed/ -C test9b",
|
||||
testprog);
|
||||
assertIsHardlink("test9b/in/d1/hardlink1", "test9b/in/d1/hardlink2-renamed");
|
||||
/* At creation. (assuming hardlink2 is the hardlink entry) */
|
||||
assertMakeDir("test9c", 0755);
|
||||
systemf("%s -cf test9c.tar -s /hardlink1/hardlink1-renamed/ in/d1",
|
||||
testprog);
|
||||
systemf("%s -xf test9c.tar -C test9c", testprog);
|
||||
assertIsHardlink("test9c/in/d1/hardlink1-renamed", "test9c/in/d1/hardlink2");
|
||||
/* At creation. (assuming hardlink1 is the hardlink entry) */
|
||||
assertMakeDir("test9d", 0755);
|
||||
systemf("%s -cf test9d.tar -s /hardlink2/hardlink2-renamed/ in/d1",
|
||||
testprog);
|
||||
systemf("%s -xf test9d.tar -C test9d", testprog);
|
||||
assertIsHardlink("test9d/in/d1/hardlink1", "test9d/in/d1/hardlink2-renamed");
|
||||
|
||||
/*
|
||||
* Test 10: renaming symlink target without repointing symlink
|
||||
*/
|
||||
if (canSymlink()) {
|
||||
/* At extraction. */
|
||||
assertMakeDir("test10a", 0755);
|
||||
systemf("%s -cf - in/d1 | %s -xf - -s /realfile/foo/S -s /foo/realfile/ -C test10a",
|
||||
testprog, testprog);
|
||||
assertFileContents("realfile", 8, "test10a/in/d1/foo");
|
||||
assertFileContents("foo", 3, "test10a/in/d1/realfile");
|
||||
assertFileContents("foo", 3, "test10a/in/d1/symlink");
|
||||
assertIsSymlink("test10a/in/d1/symlink", "realfile", 0);
|
||||
/* At creation. */
|
||||
assertMakeDir("test10b", 0755);
|
||||
systemf("%s -cf - -s /realfile/foo/S -s /foo/realfile/ in/d1 | %s -xf - -C test10b",
|
||||
testprog, testprog);
|
||||
assertFileContents("realfile", 8, "test10b/in/d1/foo");
|
||||
assertFileContents("foo", 3, "test10b/in/d1/realfile");
|
||||
assertFileContents("foo", 3, "test10b/in/d1/symlink");
|
||||
assertIsSymlink("test10b/in/d1/symlink", "realfile", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test 11: repointing symlink without renaming file
|
||||
*/
|
||||
if (canSymlink()) {
|
||||
/* At extraction. */
|
||||
assertMakeDir("test11a", 0755);
|
||||
systemf("%s -cf - in/d1 | %s -xf - -s /realfile/foo/sR -C test11a",
|
||||
testprog, testprog);
|
||||
assertFileContents("foo", 3, "test11a/in/d1/foo");
|
||||
assertFileContents("realfile", 8, "test11a/in/d1/realfile");
|
||||
assertFileContents("foo", 3, "test11a/in/d1/symlink");
|
||||
assertIsSymlink("test11a/in/d1/symlink", "foo", 0);
|
||||
/* At creation. */
|
||||
assertMakeDir("test11b", 0755);
|
||||
systemf("%s -cf - -s /realfile/foo/R in/d1 | %s -xf - -C test11b",
|
||||
testprog, testprog);
|
||||
assertFileContents("foo", 3, "test11b/in/d1/foo");
|
||||
assertFileContents("realfile", 8, "test11b/in/d1/realfile");
|
||||
assertFileContents("foo", 3, "test11b/in/d1/symlink");
|
||||
assertIsSymlink("test11b/in/d1/symlink", "foo", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test 12: renaming hardlink target without changing hardlink.
|
||||
* (Requires a pre-built archive, since we otherwise can't know
|
||||
* which element will be stored as the hardlink.)
|
||||
*/
|
||||
extract_reference_file("test_option_s.tar.Z");
|
||||
assertMakeDir("test12a", 0755);
|
||||
systemf("%s -xf test_option_s.tar.Z -s /hardlink1/foo/H -s /foo/hardlink1/ %s -C test12a",
|
||||
testprog, canSymlink()?"":"--exclude in/d1/symlink");
|
||||
assertFileContents("foo", 3, "test12a/in/d1/hardlink1");
|
||||
assertFileContents("hardlinkedfile", 14, "test12a/in/d1/foo");
|
||||
assertFileContents("foo", 3, "test12a/in/d1/hardlink2");
|
||||
assertIsHardlink("test12a/in/d1/hardlink1", "test12a/in/d1/hardlink2");
|
||||
/* TODO: Expand this test to verify creation as well.
|
||||
* Since either hardlink1 or hardlink2 might get stored as a hardlink,
|
||||
* this will either requiring testing both cases and accepting either
|
||||
* pass, or some very creative renames that can be tested regardless.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test 13: repoint hardlink without changing files
|
||||
* (Requires a pre-built archive, since we otherwise can't know
|
||||
* which element will be stored as the hardlink.)
|
||||
*/
|
||||
extract_reference_file("test_option_s.tar.Z");
|
||||
assertMakeDir("test13a", 0755);
|
||||
systemf("%s -xf test_option_s.tar.Z -s /hardlink1/foo/Rh -s /foo/hardlink1/Rh %s -C test13a",
|
||||
testprog, canSymlink()?"":"--exclude in/d1/symlink");
|
||||
assertFileContents("foo", 3, "test13a/in/d1/foo");
|
||||
assertFileContents("hardlinkedfile", 14, "test13a/in/d1/hardlink1");
|
||||
assertFileContents("foo", 3, "test13a/in/d1/hardlink2");
|
||||
assertIsHardlink("test13a/in/d1/foo", "test13a/in/d1/hardlink2");
|
||||
/* TODO: See above; expand this test to verify renames at creation. */
|
||||
|
||||
/*
|
||||
* Test 14: Global substitutions when extracting archive.
|
||||
*/
|
||||
/* Global substitution. */
|
||||
assertMakeDir("test14", 0755);
|
||||
systemf("%s -cf test14.tar in/d1/foo in/d1/bar",
|
||||
testprog);
|
||||
systemf("%s -xf test14.tar -s /o/z/g -s /bar/baz/ -C test14",
|
||||
testprog);
|
||||
assertFileContents("foo", 3, "test14/in/d1/fzz");
|
||||
assertFileContents("bar", 3, "test14/in/d1/baz");
|
||||
/* Singular substitution. */
|
||||
systemf("%s -cf test14.tar in/d1/foo in/d1/bar",
|
||||
testprog);
|
||||
systemf("%s -xf test14.tar -s /o/z/ -s /bar/baz/ -C test14",
|
||||
testprog);
|
||||
assertFileContents("foo", 3, "test14/in/d1/fzo");
|
||||
assertFileContents("bar", 3, "test14/in/d1/baz");
|
||||
}
|
16
dependencies/libarchive-3.4.2/tar/test/test_option_s.tar.Z.uu
vendored
Normal file
16
dependencies/libarchive-3.4.2/tar/test/test_option_s.tar.Z.uu
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
begin 644 test_option_s.tar.Z
|
||||
M'YV0:=R\(!/C!8"#"!,J7,BPH<.'$"-*1`BCXHT:-4``J`CCAHV,&SG*H*&1
|
||||
MHTF3(&+$^%@C!HT8,&C(``%#Y0T9,P"`J#&QI\^?0(,"J#.'3A@Y(>FD:2/4
|
||||
M8=$P9LPT77@21LF3&J=JW<JUJU>A`0<6%'/TJ]FS"3G:H$$R9,>/5RN.C%L5
|
||||
MQHR4*S&ZA"F39HR1=G7"0$NX<$*B1I%65,KTZ].H7JO2K9C5L.7+F+>219JY
|
||||
ML^?/H$.+'DVZM&G+80F^,//FS6G0:MG&]0C2Y%RW=>^J9+DWYLR:(V7($/SZ
|
||||
M->*RBY>:?2RUJV3<E(M+GQZ1M6OJV+-KW\Z]NW?3J0NB.4J&3<`U,;YKC=V6
|
||||
M(VVZM^M67(F7]TO??F?4D#&8IGK,QRD&`V/+&069<UA!9]5_#'8VGASEG5<&
|
||||
M&6:DP489#6:HX88<=NAA3^&]\&"$;JPQW(<0L3<;7+C%)Q]EN^EU7U\UV2!<
|
||||
M3BF%.*)Y)::'XD,!)J6<8P8VQ]5SS_VHI$\ARE%&&&Q4>.&2#JGHUGLMMB<?
|
||||
M3/7)R-=O,<P@4W^#4=E4D,DUYA5SD268I)EP,N0DE%)B&.>=>.:IYYX'A3A'
|
||||
M'FWPN`:?[F&T8FTB:?EBERW-"&8-=N$HPYQ16F@GGPBA.>"0:Q;9)DH*5H;I
|
||||
MJ*26:NJIJ*:JZJJLMNKJJ[#&*NNLM-9JZZVXYJKKKKSVZNNOP`8K[+#$%FOL
|
||||
)L<@FJ^RRS.X)
|
||||
`
|
||||
end
|
77
dependencies/libarchive-3.4.2/tar/test/test_option_safe_writes.c
vendored
Normal file
77
dependencies/libarchive-3.4.2/tar/test/test_option_safe_writes.c
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*-
|
||||
* Copyright (c) 2020 Martin Matuska
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_safe_writes)
|
||||
{
|
||||
/* Create files */
|
||||
assertMakeDir("in", 0755);
|
||||
assertEqualInt(0, chdir("in"));
|
||||
assertMakeFile("f", 0644, "a");
|
||||
assertMakeFile("fh", 0644, "b");
|
||||
assertMakeFile("d", 0644, "c");
|
||||
assertMakeFile("fs", 0644, "d");
|
||||
assertMakeFile("ds", 0644, "e");
|
||||
assertEqualInt(0, chdir(".."));
|
||||
|
||||
/* Tar files up */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -c -C in -f t.tar f fh d fs ds "
|
||||
">pack.out 2>pack.err", testprog));
|
||||
|
||||
/* Verify that nothing went to stdout or stderr. */
|
||||
assertEmptyFile("pack.err");
|
||||
assertEmptyFile("pack.out");
|
||||
|
||||
/* Create various objects */
|
||||
assertMakeDir("out", 0755);
|
||||
assertEqualInt(0, chdir("out"));
|
||||
assertMakeFile("f", 0644, "a");
|
||||
assertMakeHardlink("fh", "f");
|
||||
assertMakeDir("d", 0755);
|
||||
if (canSymlink()) {
|
||||
assertMakeSymlink("fs", "f", 0);
|
||||
assertMakeSymlink("ds", "d", 1);
|
||||
}
|
||||
assertEqualInt(0, chdir(".."));
|
||||
|
||||
/* Extract created archive withe safe writes */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -x -C out --safe-writes -f t.tar "
|
||||
">unpack.out 2>unpack.err", testprog));
|
||||
|
||||
/* Verify that nothing went to stdout or stderr. */
|
||||
assertEmptyFile("unpack.err");
|
||||
assertEmptyFile("unpack.out");
|
||||
|
||||
/* Verify that files were overwritten properly */
|
||||
assertEqualInt(0, chdir("out"));
|
||||
assertTextFileContents("a","f");
|
||||
assertTextFileContents("b","fh");
|
||||
assertTextFileContents("c","d");
|
||||
assertTextFileContents("d","fs");
|
||||
assertTextFileContents("e","ds");
|
||||
}
|
85
dependencies/libarchive-3.4.2/tar/test/test_option_uid_uname.c
vendored
Normal file
85
dependencies/libarchive-3.4.2/tar/test/test_option_uid_uname.c
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2010 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_uid_uname)
|
||||
{
|
||||
char *reference, *data;
|
||||
size_t s;
|
||||
|
||||
assertUmask(0);
|
||||
assertMakeFile("file", 0644, "1234567890");
|
||||
|
||||
/* Create archive with no special options. */
|
||||
failure("Error invoking %s c", testprog);
|
||||
assertEqualInt(0,
|
||||
systemf("%s cf archive1 --format=ustar file >stdout1.txt 2>stderr1.txt",
|
||||
testprog));
|
||||
assertEmptyFile("stdout1.txt");
|
||||
assertEmptyFile("stderr1.txt");
|
||||
reference = slurpfile(&s, "archive1");
|
||||
|
||||
/* Again with both --uid and --uname */
|
||||
failure("Error invoking %s c", testprog);
|
||||
assertEqualInt(0,
|
||||
systemf("%s cf archive2 --uid=65123 --uname=foofoofoo --format=ustar file >stdout2.txt 2>stderr2.txt",
|
||||
testprog));
|
||||
assertEmptyFile("stdout2.txt");
|
||||
assertEmptyFile("stderr2.txt");
|
||||
data = slurpfile(&s, "archive2");
|
||||
/* Should force uid and uname fields in ustar header. */
|
||||
assertEqualMem(data + 108, "177143 \0", 8);
|
||||
assertEqualMem(data + 265, "foofoofoo\0", 10);
|
||||
free(data);
|
||||
|
||||
/* Again with just --uid */
|
||||
failure("Error invoking %s c", testprog);
|
||||
assertEqualInt(0,
|
||||
systemf("%s cf archive3 --uid=65123 --format=ustar file >stdout3.txt 2>stderr3.txt",
|
||||
testprog));
|
||||
assertEmptyFile("stdout3.txt");
|
||||
assertEmptyFile("stderr3.txt");
|
||||
data = slurpfile(&s, "archive3");
|
||||
assertEqualMem(data + 108, "177143 \0", 8);
|
||||
/* Uname field in ustar header should be empty. */
|
||||
assertEqualMem(data + 265, "\0", 1);
|
||||
free(data);
|
||||
|
||||
/* Again with just --uname */
|
||||
failure("Error invoking %s c", testprog);
|
||||
assertEqualInt(0,
|
||||
systemf("%s cf archive4 --uname=foofoofoo --format=ustar file >stdout4.txt 2>stderr4.txt",
|
||||
testprog));
|
||||
assertEmptyFile("stdout4.txt");
|
||||
assertEmptyFile("stderr4.txt");
|
||||
data = slurpfile(&s, "archive4");
|
||||
/* Uid should be unchanged from original reference. */
|
||||
assertEqualMem(data + 108, reference + 108, 8);
|
||||
assertEqualMem(data + 265, "foofoofoo\0", 10);
|
||||
free(data);
|
||||
|
||||
free(reference);
|
||||
}
|
56
dependencies/libarchive-3.4.2/tar/test/test_option_uuencode.c
vendored
Normal file
56
dependencies/libarchive-3.4.2/tar/test/test_option_uuencode.c
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_uuencode)
|
||||
{
|
||||
char *p;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with compress compression and uuencode. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf - -Z --uuencode f >archive.out 2>archive.err",
|
||||
testprog));
|
||||
/* Check that the archive file has an uuencode signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "begin 644", 9);
|
||||
free(p);
|
||||
|
||||
/* Archive it with uuencode only. */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf - --uuencode f >archive.out 2>archive.err",
|
||||
testprog));
|
||||
/* Check that the archive file has an uuencode signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "begin 644", 9);
|
||||
free(p);
|
||||
}
|
88
dependencies/libarchive-3.4.2/tar/test/test_option_xattrs.c
vendored
Normal file
88
dependencies/libarchive-3.4.2/tar/test/test_option_xattrs.c
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*-
|
||||
* Copyright (c) 2017 Martin Matuska
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_xattrs)
|
||||
{
|
||||
#if !ARCHIVE_XATTR_SUPPORT
|
||||
skipping("Extended attributes are not supported on this platform");
|
||||
#else /* ARCHIVE_XATTR_SUPPORT */
|
||||
|
||||
const char *testattr = "user.libarchive.test";
|
||||
const char *testval = "testval";
|
||||
void *readval;
|
||||
size_t size;
|
||||
int r;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
if (!setXattr("f", "user.libarchive.test", testval,
|
||||
strlen(testval) + 1)) {
|
||||
skipping("Can't set user extended attributes on this "
|
||||
"filesystem");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Archive with xattrs */
|
||||
r = systemf("%s -c --no-mac-metadata --xattrs -f xattrs.tar f >xattrs.out 2>xattrs.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Archive without xattrs */
|
||||
r = systemf("%s -c --no-mac-metadata --no-xattrs -f noxattrs.tar f >noxattrs.out 2>noxattrs.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
|
||||
/* Extract xattrs with xattrs */
|
||||
assertMakeDir("xattrs_xattrs", 0755);
|
||||
r = systemf("%s -x -C xattrs_xattrs --no-same-permissions --xattrs -f xattrs.tar >xattrs_xattrs.out 2>xattrs_xattrs.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
readval = getXattr("xattrs_xattrs/f", testattr, &size);
|
||||
if(assertEqualInt(size, strlen(testval) + 1) != 0)
|
||||
assertEqualMem(readval, testval, size);
|
||||
free(readval);
|
||||
|
||||
/* Extract xattrs without xattrs */
|
||||
assertMakeDir("xattrs_noxattrs", 0755);
|
||||
r = systemf("%s -x -C xattrs_noxattrs -p --no-xattrs -f xattrs.tar >xattrs_noxattrs.out 2>xattrs_noxattrs.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
readval = getXattr("xattrs_noxattrs/f", testattr, &size);
|
||||
assert(readval == NULL);
|
||||
|
||||
/* Extract noxattrs with xattrs */
|
||||
assertMakeDir("noxattrs_xattrs", 0755);
|
||||
r = systemf("%s -x -C noxattrs_xattrs --no-same-permissions --xattrs -f noxattrs.tar >noxattrs_xattrs.out 2>noxattrs_xattrs.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
readval = getXattr("noxattrs_xattrs/f", testattr, &size);
|
||||
assert(readval == NULL);
|
||||
|
||||
/* Extract noxattrs with noxattrs */
|
||||
assertMakeDir("noxattrs_noxattrs", 0755);
|
||||
r = systemf("%s -x -C noxattrs_noxattrs -p --no-xattrs -f noxattrs.tar >noxattrs_noxattrs.out 2>noxattrs_noxattrs.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
readval = getXattr("noxattrs_noxattrs/f", testattr, &size);
|
||||
assert(readval == NULL);
|
||||
#endif /* ARCHIVE_XATTR_SUPPORT */
|
||||
}
|
60
dependencies/libarchive-3.4.2/tar/test/test_option_xz.c
vendored
Normal file
60
dependencies/libarchive-3.4.2/tar/test/test_option_xz.c
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_xz)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with xz compression. */
|
||||
r = systemf("%s -cf - --xz f >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "Unsupported compression") != NULL) {
|
||||
skipping("This version of bsdtar was compiled "
|
||||
"without xz support");
|
||||
goto done;
|
||||
}
|
||||
failure("--xz option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
goto done;
|
||||
}
|
||||
free(p);
|
||||
/* Check that the archive file has an xz signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\xFD\x37\x7A\x58\x5A\x00", 6);
|
||||
done:
|
||||
free(p);
|
||||
}
|
58
dependencies/libarchive-3.4.2/tar/test/test_option_z.c
vendored
Normal file
58
dependencies/libarchive-3.4.2/tar/test/test_option_z.c
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_z)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with gzip compression. */
|
||||
r = systemf("%s -zcf archive.out f 2>archive.err", testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (!canGzip()) {
|
||||
skipping("gzip is not supported on this platform");
|
||||
goto done;
|
||||
}
|
||||
failure("-z option is broken");
|
||||
assertEqualInt(r, 0);
|
||||
goto done;
|
||||
}
|
||||
free(p);
|
||||
/* Check that the archive file has a gzip signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 4);
|
||||
assertEqualMem(p, "\x1f\x8b\x08\x00", 4);
|
||||
done:
|
||||
free(p);
|
||||
}
|
85
dependencies/libarchive-3.4.2/tar/test/test_option_zstd.c
vendored
Normal file
85
dependencies/libarchive-3.4.2/tar/test/test_option_zstd.c
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*-
|
||||
* Copyright (c) 2017 Sean Purcell
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_option_zstd)
|
||||
{
|
||||
char *p;
|
||||
int r;
|
||||
size_t s;
|
||||
|
||||
/* Create a file. */
|
||||
assertMakeFile("f", 0644, "a");
|
||||
|
||||
/* Archive it with lz4 compression. */
|
||||
r = systemf("%s -cf - --zstd f >archive.out 2>archive.err",
|
||||
testprog);
|
||||
p = slurpfile(&s, "archive.err");
|
||||
p[s] = '\0';
|
||||
if (r != 0) {
|
||||
if (strstr(p, "Unsupported compression") != NULL) {
|
||||
skipping("This version of bsdtar was compiled "
|
||||
"without zstd support");
|
||||
goto done;
|
||||
}
|
||||
/* POSIX permits different handling of the spawnp
|
||||
* system call used to launch the subsidiary
|
||||
* program: */
|
||||
/* Some systems fail immediately to spawn the new process. */
|
||||
if (strstr(p, "Can't launch") != NULL && !canZstd()) {
|
||||
skipping("This version of bsdtar uses an external zstd program "
|
||||
"but no such program is available on this system.");
|
||||
goto done;
|
||||
}
|
||||
/* Some systems successfully spawn the new process,
|
||||
* but fail to exec a program within that process.
|
||||
* This results in failure at the first attempt to
|
||||
* write. */
|
||||
if (strstr(p, "Can't write") != NULL && !canZstd()) {
|
||||
skipping("This version of bsdtar uses an external zstd program "
|
||||
"but no such program is available on this system.");
|
||||
goto done;
|
||||
}
|
||||
/* On some systems the error won't be detected until closing
|
||||
time, by a 127 exit error returned by waitpid. */
|
||||
if (strstr(p, "Error closing") != NULL && !canZstd()) {
|
||||
skipping("This version of bsdcpio uses an external zstd program "
|
||||
"but no such program is available on this system.");
|
||||
return;
|
||||
}
|
||||
failure("--zstd option is broken: %s", p);
|
||||
assertEqualInt(r, 0);
|
||||
goto done;
|
||||
}
|
||||
free(p);
|
||||
/* Check that the archive file has an lz4 signature. */
|
||||
p = slurpfile(&s, "archive.out");
|
||||
assert(s > 2);
|
||||
assertEqualMem(p, "\x28\xb5\x2f\xfd", 4);
|
||||
|
||||
done:
|
||||
free(p);
|
||||
}
|
190
dependencies/libarchive-3.4.2/tar/test/test_patterns.c
vendored
Normal file
190
dependencies/libarchive-3.4.2/tar/test/test_patterns.c
vendored
Normal file
|
@ -0,0 +1,190 @@
|
|||
/*-
|
||||
* Copyright (c) 2009 Michihiro NAKAJIMA
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_patterns.c,v 1.6 2008/08/21 22:28:00 kientzle Exp $");
|
||||
|
||||
DEFINE_TEST(test_patterns)
|
||||
{
|
||||
FILE *f;
|
||||
int r;
|
||||
const char *reffile2 = "test_patterns_2.tar";
|
||||
const char *reffile3 = "test_patterns_3.tar";
|
||||
const char *reffile4 = "test_patterns_4.tar";
|
||||
|
||||
const char *tar2aExpected[] = {
|
||||
"/tmp/foo/bar/",
|
||||
"/tmp/foo/bar/baz",
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* Test basic command-line pattern handling.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test 1: Files on the command line that don't get matched
|
||||
* didn't produce an error.
|
||||
*
|
||||
* John Baldwin reported this problem in PR bin/121598
|
||||
*/
|
||||
f = fopen("foo", "w");
|
||||
assert(f != NULL);
|
||||
fclose(f);
|
||||
r = systemf("%s cfv tar1.tgz foo > tar1a.out 2> tar1a.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
r = systemf("%s xv --no-same-owner -f tar1.tgz foo bar > tar1b.out 2> tar1b.err", testprog);
|
||||
failure("tar should return non-zero because a file was given on the command line that's not in the archive");
|
||||
assert(r != 0);
|
||||
|
||||
/*
|
||||
* Test 2: Check basic matching of full paths that start with /
|
||||
*/
|
||||
extract_reference_file(reffile2);
|
||||
|
||||
r = systemf("%s tf %s /tmp/foo/bar > tar2a.out 2> tar2a.err",
|
||||
testprog, reffile2);
|
||||
assertEqualInt(r, 0);
|
||||
assertFileContainsLinesAnyOrder("tar2a.out", tar2aExpected);
|
||||
assertEmptyFile("tar2a.err");
|
||||
|
||||
/*
|
||||
* Test 3 archive has some entries starting with '/' and some not.
|
||||
*/
|
||||
extract_reference_file(reffile3);
|
||||
|
||||
/* Test 3a: Pattern tmp/foo/bar should not match /tmp/foo/bar */
|
||||
r = systemf("%s x --no-same-owner -f %s tmp/foo/bar > tar3a.out 2> tar3a.err",
|
||||
testprog, reffile3);
|
||||
assert(r != 0);
|
||||
assertEmptyFile("tar3a.out");
|
||||
|
||||
/* Test 3b: Pattern /tmp/foo/baz should not match tmp/foo/baz */
|
||||
assertNonEmptyFile("tar3a.err");
|
||||
/* Again, with the '/' */
|
||||
r = systemf("%s x --no-same-owner -f %s /tmp/foo/baz > tar3b.out 2> tar3b.err",
|
||||
testprog, reffile3);
|
||||
assert(r != 0);
|
||||
assertEmptyFile("tar3b.out");
|
||||
assertNonEmptyFile("tar3b.err");
|
||||
|
||||
/* Test 3c: ./tmp/foo/bar should not match /tmp/foo/bar */
|
||||
r = systemf("%s x --no-same-owner -f %s ./tmp/foo/bar > tar3c.out 2> tar3c.err",
|
||||
testprog, reffile3);
|
||||
assert(r != 0);
|
||||
assertEmptyFile("tar3c.out");
|
||||
assertNonEmptyFile("tar3c.err");
|
||||
|
||||
/* Test 3d: ./tmp/foo/baz should match tmp/foo/baz */
|
||||
r = systemf("%s x --no-same-owner -f %s ./tmp/foo/baz > tar3d.out 2> tar3d.err",
|
||||
testprog, reffile3);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("tar3d.out");
|
||||
assertEmptyFile("tar3d.err");
|
||||
assertFileExists("tmp/foo/baz/bar");
|
||||
|
||||
/*
|
||||
* Test 4 archive has some entries starting with windows drive letters
|
||||
* such as 'c:\', '//./c:/' or '//?/c:/'.
|
||||
*/
|
||||
extract_reference_file(reffile4);
|
||||
|
||||
r = systemf("%s x --no-same-owner -f %s -C tmp > tar4.out 2> tar4.err",
|
||||
testprog, reffile4);
|
||||
assert(r != 0);
|
||||
assertEmptyFile("tar4.out");
|
||||
assertNonEmptyFile("tar4.err");
|
||||
|
||||
for (r = 1; r <= 54; r++) {
|
||||
char file_a[] = "tmp/fileXX";
|
||||
char file_b1[] = "tmp/server/share/fileXX";
|
||||
char file_b2[] = "tmp/server\\share\\fileXX";
|
||||
char file_c[] = "tmp/../fileXX";
|
||||
char file_d[] = "tmp/../../fileXX";
|
||||
char *filex;
|
||||
int xsize;
|
||||
|
||||
switch (r) {
|
||||
case 15: case 18:
|
||||
/*
|
||||
* Including server and share names.
|
||||
* //?/UNC/server/share/file15
|
||||
* //?/unc/server/share/file18
|
||||
*/
|
||||
filex = file_b1;
|
||||
xsize = sizeof(file_b1);
|
||||
break;
|
||||
case 35: case 38: case 52:
|
||||
/*
|
||||
* Including server and share names.
|
||||
* \\?\UNC\server\share\file35
|
||||
* \\?\unc\server\share\file38
|
||||
* \/?/uNc/server\share\file52
|
||||
*/
|
||||
filex = file_b2;
|
||||
xsize = sizeof(file_b2);
|
||||
break;
|
||||
default:
|
||||
filex = file_a;
|
||||
xsize = sizeof(file_a);
|
||||
break;
|
||||
}
|
||||
filex[xsize-3] = '0' + r / 10;
|
||||
filex[xsize-2] = '0' + r % 10;
|
||||
switch (r) {
|
||||
case 5: case 6: case 17: case 20: case 25:
|
||||
case 26: case 37: case 40: case 43: case 54:
|
||||
/*
|
||||
* Not extracted patterns.
|
||||
* D:../file05
|
||||
* c:../../file06
|
||||
* //?/UNC/../file17
|
||||
* //?/unc/../file20
|
||||
* z:..\file25
|
||||
* c:..\..\file26
|
||||
* \\?\UNC\..\file37
|
||||
* \\?\unc\..\file40
|
||||
* c:../..\file43
|
||||
* \/?\UnC\../file54
|
||||
*/
|
||||
assertFileNotExists(filex);
|
||||
if (r == 6 || r == 26 || r == 43) {
|
||||
filex = file_d;
|
||||
xsize = sizeof(file_d);
|
||||
} else {
|
||||
filex = file_c;
|
||||
xsize = sizeof(file_c);
|
||||
}
|
||||
filex[xsize-3] = '0' + r / 10;
|
||||
filex[xsize-2] = '0' + r % 10;
|
||||
assertFileNotExists(filex);
|
||||
break;
|
||||
default:
|
||||
/* Extracted patterns. */
|
||||
assertFileExists(filex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
231
dependencies/libarchive-3.4.2/tar/test/test_patterns_2.tar.uu
vendored
Normal file
231
dependencies/libarchive-3.4.2/tar/test/test_patterns_2.tar.uu
vendored
Normal file
|
@ -0,0 +1,231 @@
|
|||
begin 644 test_patterns_2.tar
|
||||
M+W1M<"]F;V\O````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````#`P,#<U-2``,#`Q-S4P(``P,#`P,#`@`#`P,#`P,#`P,#`P
|
||||
M(#$Q,#4Q,C$R-C4V(#`Q,C0T,0`@-0``````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````!U<W1A<@`P,'1I;0``
|
||||
M````````````````````````````````````=VAE96P`````````````````
|
||||
M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````O=&UP+V9O;R]B87(O````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````,#`P-S4U(``P,#$W-3`@`#`P
|
||||
M,#`P,"``,#`P,#`P,#`P,#`@,3$P-3$R,3(V-3,@,#$S,C`R`"`U````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````'5S=&%R`#`P=&EM``````````````````````````````````````!W
|
||||
M:&5E;````````````````````````````````````#`P,#`P,"``,#`P,#`P
|
||||
M(```````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````"]T;7`O9F]O+V)A
|
||||
M>@``````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````````````````````````P
|
||||
M,#`V-#0@`#`P,3<U,"``,#`P,#`P(``P,#`P,#`P,#`P,"`Q,3`U,3(Q,C8U
|
||||
M-B`P,3,Q,C8`(#``````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````=7-T87(`,#!T:6T`````````````````
|
||||
M`````````````````````'=H965L````````````````````````````````
|
||||
M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````+W1M<"]F;V\O8F%R+V)A>@``````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````#`P,#8T-"``,#`Q-S4P(``P,#`P,#`@`#`P,#`P
|
||||
M,#`P,#`P(#$Q,#4Q,C$R-C4S(#`Q,S8V-P`@,```````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````````````!U<W1A<@`P
|
||||
M,'1I;0``````````````````````````````````````=VAE96P`````````
|
||||
M```````````````````````````P,#`P,#`@`#`P,#`P,"``````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
9````````````````````````````````````
|
||||
`
|
||||
end
|
231
dependencies/libarchive-3.4.2/tar/test/test_patterns_3.tar.uu
vendored
Normal file
231
dependencies/libarchive-3.4.2/tar/test/test_patterns_3.tar.uu
vendored
Normal file
|
@ -0,0 +1,231 @@
|
|||
begin 644 test_patterns_3.tar
|
||||
M+W1M<"]F;V\O8F%R+P``````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````#`P,#<U-2``,#`Q-S4P(``P,#`P,#`@`#`P,#`P,#`P,#`P
|
||||
M(#$Q,#4S,C`W-34R(#`Q,S(P-@`@-0``````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````!U<W1A<@`P,'1I;0``
|
||||
M````````````````````````````````````=VAE96P`````````````````
|
||||
M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````O=&UP+V9O;R]B87(O8F%Z+P``````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````,#`P-S4U(``P,#$W-3`@`#`P
|
||||
M,#`P,"``,#`P,#`P,#`P,#`@,3$P-3,R,#<U-3(@,#$S-S8R`"`U````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````'5S=&%R`#`P=&EM``````````````````````````````````````!W
|
||||
M:&5E;````````````````````````````````````#`P,#`P,"``,#`P,#`P
|
||||
M(```````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````'1M<"]F;V\O8F%Z
|
||||
M+P``````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````````````````````````P
|
||||
M,#`W-34@`#`P,3<U,"``,#`P,#`P(``P,#`P,#`P,#`P,"`Q,3`U,S(P-S4V
|
||||
M,"`P,3,Q,S8`(#4`````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````=7-T87(`,#!T:6T`````````````````
|
||||
M`````````````````````'=H965L````````````````````````````````
|
||||
M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````=&UP+V9O;R]B87HO8F%R+P``````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````#`P,#<U-2``,#`Q-S4P(``P,#`P,#`@`#`P,#`P
|
||||
M,#`P,#`P(#$Q,#4S,C`W-38P(#`Q,S<P,@`@-0``````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````````````!U<W1A<@`P
|
||||
M,'1I;0``````````````````````````````````````=VAE96P`````````
|
||||
M```````````````````````````P,#`P,#`@`#`P,#`P,"``````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
9````````````````````````````````````
|
||||
`
|
||||
end
|
641
dependencies/libarchive-3.4.2/tar/test/test_patterns_4.tar.uu
vendored
Normal file
641
dependencies/libarchive-3.4.2/tar/test/test_patterns_4.tar.uu
vendored
Normal file
|
@ -0,0 +1,641 @@
|
|||
begin 644 test_patterns_4.tar
|
||||
M+V9I;&4P,0``````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P
|
||||
M(#$Q,34P-C<T-C0R(#`Q,#,S-@`@,```````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````!U<W1A<@`P,```````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````O+BXO9FEL93`R````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````,#`P-C0T(``P,#$W-3$@`#`P
|
||||
M,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$P-34R`"`P````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````'5S=&%R`#`P````````````````````````````````````````````
|
||||
M`````````````````````````````````````````#`P,#`P,"``,#`P,#`P
|
||||
M(```````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````"\N+B\N+B]F:6QE
|
||||
M,#,`````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````````````````````````P
|
||||
M,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T
|
||||
M,B`P,3`W-C8`(#``````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````=7-T87(`,#``````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````8SHO9FEL93`T````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P
|
||||
M,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,#4W-@`@,```````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````````````!U<W1A<@`P
|
||||
M,```````````````````````````````````````````````````````````
|
||||
M```````````````````````````P,#`P,#`@`#`P,#`P,"``````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````!$.BXN+V9I;&4P-0``````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````,#`P-C0T(``P,#$W
|
||||
M-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$P-C<T`"`P
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````'5S=&%R`#`P````````````````````````````````````
|
||||
M`````````````````````````````````````````````````#`P,#`P,"``
|
||||
M,#`P,#`P(```````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````````````&,Z+BXO
|
||||
M+BXO9FEL93`V````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U
|
||||
M,#8W-#8T,B`P,3$Q-#<`(#``````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````=7-T87(`,#``````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````,#`P,#`P(``P,#`P,#`@````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````0SHO+BXO9FEL93`W````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@
|
||||
M`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,#<U-``@,```````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````````````````````!U
|
||||
M<W1A<@`P,```````````````````````````````````````````````````
|
||||
M```````````````````````````````````P,#`P,#`@`#`P,#`P,"``````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````!A.B\N+B\N+B]F:6QE,#@`
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````,#`P-C0T
|
||||
M(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q
|
||||
M,C(V`"`P````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````'5S=&%R`#`P````````````````````````````
|
||||
M`````````````````````````````````````````````````````````#`P
|
||||
M,#`P,"``,#`P,#`P(```````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`"\O+B]C.B]F:6QE,#D`````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P
|
||||
M,"`Q,3$U,#8W-#8T,B`P,3$P-S8`(#``````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````=7-T87(`,#``````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````,#`P,#`P(``P,#`P,#`@````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````+R\N+T,Z+RXN+V9I;&4Q,```````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````#`P,#8T-"``,#`Q-S4Q(``P
|
||||
M,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,3(T,0`@,```````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````!U<W1A<@`P,```````````````````````````````````````````
|
||||
M```````````````````````````````````````````P,#`P,#`@`#`P,#`P
|
||||
M,"``````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````````````O+S\O8SHO9FEL
|
||||
M93$Q````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V
|
||||
M-#(@,#$Q,3$P`"`P````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````'5S=&%R`#`P````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````#`P,#`P,"``,#`P,#`P(```````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````"\O/R]#.B\N+B]F:6QE,3(`````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P
|
||||
M,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3$R-C0`(#``````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````=7-T87(`
|
||||
M,#``````````````````````````````````````````````````````````
|
||||
M````````````````````````````,#`P,#`P(``P,#`P,#`@````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````+R\O+V,Z+V9I;&4Q,P``````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````#`P,#8T-"``,#`Q
|
||||
M-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,3`W,@`@
|
||||
M,```````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````!U<W1A<@`P,```````````````````````````````````
|
||||
M```````````````````````````````````````````````````P,#`P,#`@
|
||||
M`#`P,#`P,"``````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````````````````````O+R\O
|
||||
M0SHO+R\O+V9I;&4Q-```````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q
|
||||
M-3`V-S0V-#(@,#$Q,S(W`"`P````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````'5S=&%R`#`P````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````#`P,#`P,"``,#`P,#`P(```````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````"\O/R]53D,O<V5R=F5R+W-H87)E+V9I;&4Q-0``````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q
|
||||
M(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3,V,S4`(#``````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M=7-T87(`,#``````````````````````````````````````````````````
|
||||
M````````````````````````````````````,#`P,#`P(``P,#`P,#`@````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````+R\_+U5.0R]F:6QE,38`
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````````````#`P,#8T
|
||||
M-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q
|
||||
M,3(R-@`@,```````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````!U<W1A<@`P,```````````````````````````
|
||||
M```````````````````````````````````````````````````````````P
|
||||
M,#`P,#`@`#`P,#`P,"``````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```O+S\O54Y#+RXN+V9I;&4Q-P``````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P
|
||||
M,#`@,3$Q-3`V-S0V-#(@,#$Q-#0R`"`P````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````'5S=&%R`#`P````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````#`P,#`P,"``,#`P,#`P(```````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````"\O/R]U;F,O<V5R=F5R+W-H87)E+V9I;&4Q
|
||||
M.```````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````P,#`V-#0@`#`P,3<U,2``
|
||||
M,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,30P,#``(#``````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````=7-T87(`,#``````````````````````````````````````````
|
||||
M````````````````````````````````````````````,#`P,#`P(``P,#`P
|
||||
M,#`@````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````+R\_+W5N8R]F
|
||||
M:6QE,3D`````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T
|
||||
M-C0R(#`Q,3,W,0`@,```````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````!U<W1A<@`P,```````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````P,#`P,#`@`#`P,#`P,"``````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````O+S\O=6YC+RXN+V9I;&4R,```````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P
|
||||
M,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q-3<T`"`P````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````````````'5S=&%R
|
||||
M`#`P````````````````````````````````````````````````````````
|
||||
M`````````````````````````````#`P,#`P,"``,#`P,#`P(```````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````%QF:6QE,C$`````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````````````P,#`V-#0@`#`P
|
||||
M,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3`T,34`
|
||||
M(#``````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````=7-T87(`,#``````````````````````````````````
|
||||
M````````````````````````````````````````````````````,#`P,#`P
|
||||
M(``P,#`P,#`@````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````7"XN
|
||||
M7&9I;&4R,@``````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q
|
||||
M,34P-C<T-C0R(#`Q,#<P-@`@,```````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````!U<W1A<@`P,```````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````P,#`P,#`@`#`P,#`P,"``````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````!<+BY<+BY<9FEL93(S````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````,#`P-C0T(``P,#$W-3$@`#`P,3<U
|
||||
M,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q,3<W`"`P````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`'5S=&%R`#`P````````````````````````````````````````````````
|
||||
M`````````````````````````````````````#`P,#`P,"``,#`P,#`P(```
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````$,Z7&9I;&4R-```````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````````````````````P,#`V
|
||||
M-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P
|
||||
M,3`V,34`(#``````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````=7-T87(`,#``````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M,#`P,#`P(``P,#`P,#`@````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````>CHN+EQF:6QE,C4`````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P
|
||||
M,#`P(#$Q,34P-C<T-C0R(#`Q,3`T,0`@,```````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````````!U<W1A<@`P,```
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````P,#`P,#`@`#`P,#`P,"``````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````!C.BXN7"XN7&9I;&4R-@``````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````,#`P-C0T(``P,#$W-3$@
|
||||
M`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q,S`S`"`P````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````'5S=&%R`#`P````````````````````````````````````````
|
||||
M`````````````````````````````````````````````#`P,#`P,"``,#`P
|
||||
M,#`P(```````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````````%HZ7"XN7&9I
|
||||
M;&4R-P``````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W
|
||||
M-#8T,B`P,3$Q,S<`(#``````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````=7-T87(`,#``````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````,#`P,#`P(``P,#`P,#`@````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````0SI<+BY<+BY<9FEL93(X````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P
|
||||
M,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,30P,0`@,```````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````````````````!U<W1A
|
||||
M<@`P,```````````````````````````````````````````````````````
|
||||
M```````````````````````````````P,#`P,#`@`#`P,#`P,"``````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````!<7"Y<8SI<9FEL93(Y````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````,#`P-C0T(``P
|
||||
M,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q,S8T
|
||||
M`"`P````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````'5S=&%R`#`P````````````````````````````````
|
||||
M`````````````````````````````````````````````````````#`P,#`P
|
||||
M,"``,#`P,#`P(```````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````````````````%Q<
|
||||
M+EQ#.EPN+EQF:6QE,S``````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q
|
||||
M,3$U,#8W-#8T,B`P,3$V,#0`(#``````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````=7-T87(`,#``````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````,#`P,#`P(``P,#`P,#`@````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````7%P_7&,Z7&9I;&4S,0``````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W
|
||||
M-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,3,W-@`@,```````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``!U<W1A<@`P,```````````````````````````````````````````````
|
||||
M```````````````````````````````````````P,#`P,#`@`#`P,#`P,"``
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````!<7#]<1#I<+BY<9FEL
|
||||
M93,R````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````,#`P
|
||||
M-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@
|
||||
M,#$Q-C,P`"`P````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````'5S=&%R`#`P````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`#`P,#`P,"``,#`P,#`P(```````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````%Q<7%QC.EQF:6QE,S,`````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P
|
||||
M,#`P,"`Q,3$U,#8W-#8T,B`P,3$T,S4`(#``````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````=7-T87(`,#``
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````,#`P,#`P(``P,#`P,#`@````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````7%Q<7$,Z7%Q<7%QF:6QE,S0`````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````#`P,#8T-"``,#`Q-S4Q
|
||||
M(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,C$U-@`@,```
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````!U<W1A<@`P,```````````````````````````````````````
|
||||
M```````````````````````````````````````````````P,#`P,#`@`#`P
|
||||
M,#`P,"``````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````````````!<7#]<54Y#
|
||||
M7'-E<G9E<EQS:&%R95QF:6QE,S4`````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V
|
||||
M-S0V-#(@,#$T,C4U`"`P````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````'5S=&%R`#`P````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````#`P,#`P,"``,#`P,#`P(```````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````%Q</UQ53D-<9FEL93,V````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P
|
||||
M,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3$U,30`(#``````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````=7-T
|
||||
M87(`,#``````````````````````````````````````````````````````
|
||||
M````````````````````````````````,#`P,#`P(``P,#`P,#`@````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````7%P_7%5.0UPN+EQF:6QE,S<`
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````````#`P,#8T-"``
|
||||
M,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,C`P
|
||||
M-0`@,```````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````!U<W1A<@`P,```````````````````````````````
|
||||
M```````````````````````````````````````````````````````P,#`P
|
||||
M,#`@`#`P,#`P,"``````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````````````````````!<
|
||||
M7#]<=6YC7'-E<G9E<EQS:&%R95QF:6QE,S@`````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@
|
||||
M,3$Q-3`V-S0V-#(@,#$T-#(P`"`P````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````'5S=&%R`#`P````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````#`P,#`P,"``,#`P,#`P(```````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````%Q</UQU;F-<9FEL93,Y````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````P,#`V-#0@`#`P,3<U,2``,#`Q
|
||||
M-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3$V-3<`(#``````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````=7-T87(`,#``````````````````````````````````````````````
|
||||
M````````````````````````````````````````,#`P,#`P(``P,#`P,#`@
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````7%P_7'5N8UPN+EQF
|
||||
M:6QE-#``````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````````````````#`P
|
||||
M,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R
|
||||
M(#`Q,C$S-P`@,```````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````!U<W1A<@`P,```````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```P,#`P,#`@`#`P,#`P,"``````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````!<+BXO9FEL930Q````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P
|
||||
M,#`P,#`@,3$Q-3`V-S0V-#(@,#$P-C,R`"`P````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````````'5S=&%R`#`P
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````#`P,#`P,"``,#`P,#`P(```````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````%PN+B\N+EQF:6QE-#(`````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````````P,#`V-#0@`#`P,3<U
|
||||
M,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3$Q,C,`(#``
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````=7-T87(`,#``````````````````````````````````````
|
||||
M````````````````````````````````````````````````,#`P,#`P(``P
|
||||
M,#`P,#`@````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````8SHN+B\N
|
||||
M+EQF:6QE-#,`````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P(#$Q,34P
|
||||
M-C<T-C0R(#`Q,3(R-0`@,```````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````!U<W1A<@`P,```````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````P,#`P,#`@`#`P,#`P,"``````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````!#.B\N+EQF:6QE-#0`````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````,#`P-C0T(``P,#$W-3$@`#`P,3<U,2``
|
||||
M,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q,#,R`"`P````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````````````````'5S
|
||||
M=&%R`#`P````````````````````````````````````````````````````
|
||||
M`````````````````````````````````#`P,#`P,"``,#`P,#`P(```````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````$0Z7"XN+RXN7&9I;&4T-0``
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````````````````P,#`V-#0@
|
||||
M`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T,B`P,3$S
|
||||
M,C0`(#``````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````=7-T87(`,#``````````````````````````````
|
||||
M````````````````````````````````````````````````````````,#`P
|
||||
M,#`P(``P,#`P,#`@````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M7"\N+V,Z7&9I;&4T-@``````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P,#`P,#`P
|
||||
M(#$Q,34P-C<T-C0R(#`Q,3(S,0`@,```````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````!U<W1A<@`P,```````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````!<7"XO0SI<+BY<9FEL930W````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````,#`P-C0T(``P,#$W-3$@`#`P
|
||||
M,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q-3,W`"`P````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````'5S=&%R`#`P````````````````````````````````````````````
|
||||
M`````````````````````````````````````````#`P,#`P,"``,#`P,#`P
|
||||
M(```````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````%PO/UQC.B]F:6QE
|
||||
M-#@`````````````````````````````````````````````````````````
|
||||
M```````````````````````````````````````````````````````````P
|
||||
M,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U,#8W-#8T
|
||||
M,B`P,3$R-30`(#``````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````=7-T87(`,#``````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````7%P_+T0Z+RXN7&9I;&4T.0``````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@`#`P,#`P
|
||||
M,#`P,#`P(#$Q,34P-C<T-C0R(#`Q,34P-@`@,```````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````````````!U<W1A<@`P
|
||||
M,```````````````````````````````````````````````````````````
|
||||
M```````````````````````````P,#`P,#`@`#`P,#`P,"``````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````!<+R]<1#I<9FEL934P````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````,#`P-C0T(``P,#$W
|
||||
M-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q,C0S`"`P
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````'5S=&%R`#`P````````````````````````````````````
|
||||
M`````````````````````````````````````````````````#`P,#`P,"``
|
||||
M,#`P,#`P(```````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````````````````````````````%Q<+R]C
|
||||
M.EPO+UQ<9FEL934Q````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P,"`Q,3$U
|
||||
M,#8W-#8T,B`P,3$W,S$`(#``````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````=7-T87(`,#``````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````,#`P,#`P(``P,#`P,#`@````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````7"\_+W5.8R]S97)V97)<<VAA<F5<9FEL934R````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````````````#`P,#8T-"``,#`Q-S4Q(``P,#$W-3$@
|
||||
M`#`P,#`P,#`P,#`P(#$Q,34P-C<T-C0R(#`Q-#$T-0`@,```````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````````````````````````!U
|
||||
M<W1A<@`P,```````````````````````````````````````````````````
|
||||
M```````````````````````````````````P,#`P,#`@`#`P,#`P,"``````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M``````````````````````````````````````!<7#\O54YC7&9I;&4U,P``
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````,#`P-C0T
|
||||
M(``P,#$W-3$@`#`P,3<U,2``,#`P,#`P,#`P,#`@,3$Q-3`V-S0V-#(@,#$Q
|
||||
M-#<V`"`P````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`````````````````````'5S=&%R`#`P````````````````````````````
|
||||
M`````````````````````````````````````````````````````````#`P
|
||||
M,#`P,"``,#`P,#`P(```````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M`%PO/UQ5;D-<+BXO9FEL934T````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M```````````````P,#`V-#0@`#`P,3<U,2``,#`Q-S4Q(``P,#`P,#`P,#`P
|
||||
M,"`Q,3$U,#8W-#8T,B`P,3$W,3(`(#``````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````=7-T87(`,#``````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````,#`P,#`P(``P,#`P,#`@````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
'````````````
|
||||
`
|
||||
end
|
54
dependencies/libarchive-3.4.2/tar/test/test_print_longpath.c
vendored
Normal file
54
dependencies/libarchive-3.4.2/tar/test/test_print_longpath.c
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*-
|
||||
* Copyright (c) 2011 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
DEFINE_TEST(test_print_longpath)
|
||||
{
|
||||
const char *reffile = "test_print_longpath.tar.Z";
|
||||
char buff[2048];
|
||||
int i, j, k;
|
||||
|
||||
/* Reference file has one entry "file" with a very old timestamp. */
|
||||
extract_reference_file(reffile);
|
||||
|
||||
/* Build long path pattern. */
|
||||
memset(buff, 0, sizeof(buff));
|
||||
for (k = 0; k < 4; k++) {
|
||||
for (j = 0; j < k+1; j++) {
|
||||
for (i = 0; i < 10; i++)
|
||||
strncat(buff, "0123456789",
|
||||
sizeof(buff) - strlen(buff) -1);
|
||||
strncat(buff, "/", sizeof(buff) - strlen(buff) -1);
|
||||
}
|
||||
strncat(buff, "\n", sizeof(buff) - strlen(buff) -1);
|
||||
}
|
||||
buff[sizeof(buff)-1] = '\0';
|
||||
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf %s >test.out 2>test.err", testprog, reffile));
|
||||
assertTextFileContents(buff, "test.out");
|
||||
assertEmptyFile("test.err");
|
||||
}
|
24
dependencies/libarchive-3.4.2/tar/test/test_print_longpath.tar.Z.uu
vendored
Normal file
24
dependencies/libarchive-3.4.2/tar/test/test_print_longpath.tar.Z.uu
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
begin 644 test_print_longpath.tar.Z
|
||||
M'YV04,+@05(F#)DR<E[`B"%C!HT:-F[@R+&PX<.($RLZA"B1(L.-&#U:Y)CQ
|
||||
MX\6.&D^6'!DR)4<``&#(O%&C!HB8"VG&N"DSADZ>,H/*E$$31(P8$6_0"$H4
|
||||
M!`R+-&@``($'IM6K6+-JW<JUJ]>O8+O6F4,GC!R<8^J4"<LV[5JV8(7*!"KT
|
||||
M)MR[>//JW<NWK]>C.^&$H8.FA\N6)DF*!(DR,6*6C2&O9#Q9Y6++ASN^4"`#
|
||||
M!H@Q=-*T*=,CQ@P9-638\%B#L^?!HDF;1JV:M8(9.$`P22(DB)0A2))8*>)B
|
||||
MC)R"H=^X"3VZ].G4-B;FP*'`K_7KV+-KW\Z]N_?O5S-75BS^,GG'D2F;?ZR^
|
||||
M?.87.&'0M(G39XV=]7_&EQO4*-(;2C%U@U,RH`;15#6`IZ!V8Y5UEDQN:1=A
|
||||
M=OS1U=^"&&:H85@!#53000FYA]YX[&$VXGKIF2@9BC`%-1]0]N'7DW[\R125
|
||||
M#/XEM91,-3DU`T0TS#!551L6"5>#9J&EEH1+4BB7A7/%=**(*U+9WI185IFE
|
||||
M>D;Z)0-#(`A&F&%;JGBEEFB>J::9;"JF4)GGI=EFB7&N6>><FKGV&7.R/5<;
|
||||
M##/<H"=LS<T&'44U4(>;;KSY!IQPQ!F'7!K*\>D<;:M55%V7G';J:896XDEB
|
||||
MBG>62N>II$8$GXL]YG<?C#36V-]1.@;5(Z`TW&!##`A^ZJM52#X(PX38$7M=
|
||||
MA?M%&:JIJ38[ZK,H0EO>KW=U2)!!"+TI)[/2PHEJMY"U.%.K,[[JJHPUVB!?
|
||||
MC@#N&$-J/@(I%574^AJLDF\5VR1VR/;KK;/1!KSLMP*?6"];,Y@6YF"%#0RP
|
||||
MP^#:27!YVDK\\+\1BUKPBA5K#/'&%F?,;0Z;=;9G;)<>"L-T@UIJZ)\RY'!;
|
||||
M;KOU]EMPPQ5W'&R5HOQRIC%O>O#07WUL-,8@>XS>JN/25RZZ,4)9(:WM]@0O
|
||||
MKC3=T"O17=X+X;[7&6M=OT]*N>W$2!]]-L!<>V7MA]FJ'7+2(SLLKGSDYF3N
|
||||
MTU+/!(,-[`:X4)#QVA#5D&T;Z?6P8%LGME]DUV7VW'(KO;;((27.%0TQT+#P
|
||||
MF)77G?;HEY,<.MJEGPYPQZ*G3CKE2+...NRNUSYWR9Z!YK.?F>800\N[8TJ1
|
||||
M[T(3K3KF%]N.)]-X.ZTWU+'*ZAG5@G<^@X^YUJ`U"`EJKN'BC_<5/E^17W@\
|
||||
:W;-;/K?W[+?O_OOPQR___/37;__]^.>OOU<`
|
||||
`
|
||||
end
|
126
dependencies/libarchive-3.4.2/tar/test/test_stdio.c
vendored
Normal file
126
dependencies/libarchive-3.4.2/tar/test/test_stdio.c
vendored
Normal file
|
@ -0,0 +1,126 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_stdio.c,v 1.2 2008/05/26 17:10:10 kientzle Exp $");
|
||||
|
||||
DEFINE_TEST(test_stdio)
|
||||
{
|
||||
FILE *filelist;
|
||||
char *p;
|
||||
size_t s;
|
||||
int r;
|
||||
|
||||
assertUmask(0);
|
||||
|
||||
/*
|
||||
* Create a couple of files on disk.
|
||||
*/
|
||||
/* File */
|
||||
assertMakeFile("f", 0755, "abc");
|
||||
/* Link to above file. */
|
||||
assertMakeHardlink("l", "f");
|
||||
|
||||
/* Create file list (text mode here) */
|
||||
filelist = fopen("filelist", "w");
|
||||
assert(filelist != NULL);
|
||||
fprintf(filelist, "f\n");
|
||||
fprintf(filelist, "l\n");
|
||||
fclose(filelist);
|
||||
|
||||
/*
|
||||
* Archive/dearchive with a variety of options, verifying
|
||||
* stdio paths.
|
||||
*/
|
||||
|
||||
/* 'cf' should generate no output unless there's an error. */
|
||||
r = systemf("%s cf archive f l >cf.out 2>cf.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("cf.out");
|
||||
assertEmptyFile("cf.err");
|
||||
|
||||
/* 'cvf' should generate file list on stderr, empty stdout. */
|
||||
r = systemf("%s cvf archive f l >cvf.out 2>cvf.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
failure("'cv' writes filenames to stderr, nothing to stdout (SUSv2)\n"
|
||||
"Note that GNU tar writes the file list to stdout by default.");
|
||||
assertEmptyFile("cvf.out");
|
||||
/* TODO: Verify cvf.err has file list in SUSv2-prescribed format. */
|
||||
|
||||
/* 'cvf -' should generate file list on stderr, archive on stdout. */
|
||||
r = systemf("%s cvf - f l >cvf-.out 2>cvf-.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
failure("cvf - should write archive to stdout");
|
||||
/* TODO: Verify cvf-.out has archive. */
|
||||
failure("cvf - should write file list to stderr (SUSv2)");
|
||||
/* TODO: Verify cvf-.err has verbose file list. */
|
||||
|
||||
/* 'tf' should generate file list on stdout, empty stderr. */
|
||||
r = systemf("%s tf archive >tf.out 2>tf.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("tf.err");
|
||||
failure("'t' mode should write results to stdout");
|
||||
/* TODO: Verify tf.out has file list. */
|
||||
|
||||
/* 'tvf' should generate file list on stdout, empty stderr. */
|
||||
r = systemf("%s tvf archive >tvf.out 2>tvf.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("tvf.err");
|
||||
failure("'tv' mode should write results to stdout");
|
||||
/* TODO: Verify tvf.out has file list. */
|
||||
|
||||
/* 'tvf -' uses stdin, file list on stdout, empty stderr. */
|
||||
r = systemf("%s tvf - < archive >tvf-.out 2>tvf-.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("tvf-.err");
|
||||
/* TODO: Verify tvf-.out has file list. */
|
||||
|
||||
/* Basic 'xf' should generate no output on stdout or stderr. */
|
||||
r = systemf("%s xf archive >xf.out 2>xf.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("xf.err");
|
||||
assertEmptyFile("xf.out");
|
||||
|
||||
/* 'xvf' should generate list on stderr, empty stdout. */
|
||||
r = systemf("%s xvf archive >xvf.out 2>xvf.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("xvf.out");
|
||||
/* TODO: Verify xvf.err */
|
||||
|
||||
/* 'xvOf' should generate list on stderr, file contents on stdout. */
|
||||
r = systemf("%s xvOf archive >xvOf.out 2>xvOf.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
/* Verify xvOf.out is the file contents */
|
||||
p = slurpfile(&s, "xvOf.out");
|
||||
assertEqualInt((int)s, 3);
|
||||
assertEqualMem(p, "abc", 3);
|
||||
/* TODO: Verify xvf.err */
|
||||
free(p);
|
||||
|
||||
/* 'xvf -' should generate list on stderr, empty stdout. */
|
||||
r = systemf("%s xvf - < archive >xvf-.out 2>xvf-.err", testprog);
|
||||
assertEqualInt(r, 0);
|
||||
assertEmptyFile("xvf-.out");
|
||||
/* TODO: Verify xvf-.err */
|
||||
}
|
140
dependencies/libarchive-3.4.2/tar/test/test_strip_components.c
vendored
Normal file
140
dependencies/libarchive-3.4.2/tar/test/test_strip_components.c
vendored
Normal file
|
@ -0,0 +1,140 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_strip_components.c,v 1.2 2008/11/10 05:24:13 kientzle Exp $");
|
||||
|
||||
DEFINE_TEST(test_strip_components)
|
||||
{
|
||||
assertMakeDir("d0", 0755);
|
||||
assertChdir("d0");
|
||||
assertMakeDir("d1", 0755);
|
||||
assertMakeDir("d1/d2", 0755);
|
||||
assertMakeDir("d1/d2/d3", 0755);
|
||||
assertMakeFile("d1/d2/f1", 0644, "");
|
||||
assertMakeHardlink("l1", "d1/d2/f1");
|
||||
assertMakeHardlink("d1/l2", "d1/d2/f1");
|
||||
if (canSymlink()) {
|
||||
assertMakeSymlink("s1", "d1/d2/f1", 0);
|
||||
assertMakeSymlink("d1/s2", "d2/f1", 0);
|
||||
}
|
||||
assertChdir("..");
|
||||
|
||||
/*
|
||||
* Test 1: Strip components when extracting archives.
|
||||
*/
|
||||
if (canSymlink())
|
||||
assertEqualInt(0, systemf("%s -cf test.tar d0/l1 d0/s1 d0/d1",
|
||||
testprog));
|
||||
else
|
||||
assertEqualInt(0, systemf("%s -cf test.tar d0/l1 d0/d1",
|
||||
testprog));
|
||||
|
||||
assertMakeDir("target", 0755);
|
||||
assertEqualInt(0, systemf("%s -x -C target --strip-components 2 "
|
||||
"-f test.tar", testprog));
|
||||
|
||||
failure("d0/ is too short and should not get restored");
|
||||
assertFileNotExists("target/d0");
|
||||
failure("d0/d1/ is too short and should not get restored");
|
||||
assertFileNotExists("target/d1");
|
||||
failure("d0/s1 is too short and should not get restored");
|
||||
assertFileNotExists("target/s1");
|
||||
failure("d0/d1/s2 is a symlink to something that won't be extracted");
|
||||
/* If platform supports symlinks, target/s2 is a broken symlink. */
|
||||
/* If platform does not support symlink, target/s2 doesn't exist. */
|
||||
if (canSymlink())
|
||||
assertIsSymlink("target/s2", "d2/f1", 0);
|
||||
else
|
||||
assertFileNotExists("target/s2");
|
||||
failure("d0/d1/d2 should be extracted");
|
||||
assertIsDir("target/d2", -1);
|
||||
|
||||
/*
|
||||
* Test 1b: Strip components extracting archives involving hardlinks.
|
||||
*
|
||||
* This next is a complicated case. d0/l1, d0/d1/l2, and
|
||||
* d0/d1/d2/f1 are all hardlinks to the same file; d0/l1 can't
|
||||
* be extracted with --strip-components=2 and the other two
|
||||
* can. Remember that tar normally stores the first file with
|
||||
* a body and the other as hardlink entries to the first
|
||||
* appearance. So the final result depends on the order in
|
||||
* which these three names get archived. If d0/l1 is first,
|
||||
* none of the three can be restored. If either of the longer
|
||||
* names are first, then the two longer ones can both be
|
||||
* restored. Note that the "tar -cf" command above explicitly
|
||||
* lists d0/l1 before d0/d1.
|
||||
*
|
||||
* It may be worth extending this test to exercise other
|
||||
* archiving orders.
|
||||
*
|
||||
* Of course, this is all totally different for cpio and newc
|
||||
* formats because the hardlink management is different.
|
||||
* TODO: Rename this to test_strip_components_tar and create
|
||||
* parallel tests for cpio and newc formats.
|
||||
*/
|
||||
failure("d0/l1 is too short and should not get restored");
|
||||
assertFileNotExists("target/l1");
|
||||
failure("d0/d1/l2 is a hardlink to file whose name was too short");
|
||||
assertFileNotExists("target/l2");
|
||||
failure("d0/d1/d2/f1 is a hardlink to file whose name was too short");
|
||||
assertFileNotExists("target/d2/f1");
|
||||
|
||||
/*
|
||||
* Test 2: Strip components when creating archives.
|
||||
*/
|
||||
if (canSymlink())
|
||||
assertEqualInt(0, systemf("%s --strip-components 2 -cf test2.tar "
|
||||
"d0/l1 d0/s1 d0/d1", testprog));
|
||||
else
|
||||
assertEqualInt(0, systemf("%s --strip-components 2 -cf test2.tar "
|
||||
"d0/l1 d0/d1", testprog));
|
||||
|
||||
assertMakeDir("target2", 0755);
|
||||
assertEqualInt(0, systemf("%s -x -C target2 -f test2.tar", testprog));
|
||||
|
||||
failure("d0/ is too short and should not have been archived");
|
||||
assertFileNotExists("target2/d0");
|
||||
failure("d0/d1/ is too short and should not have been archived");
|
||||
assertFileNotExists("target2/d1");
|
||||
failure("d0/s1 is too short and should not get restored");
|
||||
assertFileNotExists("target/s1");
|
||||
/* If platform supports symlinks, target/s2 is included. */
|
||||
if (canSymlink()) {
|
||||
failure("d0/d1/s2 is a symlink to something included in archive");
|
||||
assertIsSymlink("target2/s2", "d2/f1", 0);
|
||||
}
|
||||
failure("d0/d1/d2 should be archived");
|
||||
assertIsDir("target2/d2", -1);
|
||||
|
||||
/*
|
||||
* Test 2b: Strip components creating archives involving hardlinks.
|
||||
*/
|
||||
failure("d0/l1 is too short and should not have been archived");
|
||||
assertFileNotExists("target/l1");
|
||||
failure("d0/d1/l2 is a hardlink to file whose name was too short");
|
||||
assertFileNotExists("target/l2");
|
||||
failure("d0/d1/d2/f1 is a hardlink to file whose name was too short");
|
||||
assertFileNotExists("target/d2/f1");
|
||||
}
|
160
dependencies/libarchive-3.4.2/tar/test/test_symlink_dir.c
vendored
Normal file
160
dependencies/libarchive-3.4.2/tar/test/test_symlink_dir.c
vendored
Normal file
|
@ -0,0 +1,160 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_symlink_dir.c,v 1.1 2008/09/14 02:16:04 kientzle Exp $");
|
||||
|
||||
/*
|
||||
* tar -x -P should follow existing symlinks for dirs, but not other
|
||||
* content. Plain tar -x should remove symlinks when they're in the
|
||||
* way of a dir extraction.
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_symlink_dir)
|
||||
{
|
||||
assertUmask(0);
|
||||
|
||||
assertMakeDir("source", 0755);
|
||||
assertMakeFile("source/file", 0755, "a");
|
||||
assertMakeFile("source/file2", 0755, "ab");
|
||||
assertMakeDir("source/dir", 0755);
|
||||
assertMakeDir("source/dir/d", 0755);
|
||||
assertMakeFile("source/dir/f", 0755, "abc");
|
||||
assertMakeDir("source/dir2", 0755);
|
||||
assertMakeDir("source/dir2/d2", 0755);
|
||||
assertMakeFile("source/dir2/f2", 0755, "abcd");
|
||||
assertMakeDir("source/dir3", 0755);
|
||||
assertMakeDir("source/dir3/d3", 0755);
|
||||
assertMakeFile("source/dir3/f3", 0755, "abcde");
|
||||
assertMakeDir("source/dir4", 0755);
|
||||
assertMakeFile("source/dir4/file3", 0755, "abcdef");
|
||||
assertMakeHardlink("source/dir4/file4", "source/dir4/file3");
|
||||
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf test.tar -C source dir dir2 dir3 file file2",
|
||||
testprog));
|
||||
|
||||
/* Second archive with hardlinks */
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf test2.tar -C source dir4", testprog));
|
||||
|
||||
/*
|
||||
* Extract with -x and without -P.
|
||||
*/
|
||||
assertMakeDir("dest1", 0755);
|
||||
/* "dir" is a symlink to an existing "dest1/real_dir" */
|
||||
assertMakeDir("dest1/real_dir", 0755);
|
||||
if (canSymlink()) {
|
||||
assertMakeSymlink("dest1/dir", "real_dir", 1);
|
||||
/* "dir2" is a symlink to a non-existing "real_dir2" */
|
||||
assertMakeSymlink("dest1/dir2", "real_dir2", 1);
|
||||
} else {
|
||||
skipping("Symlinks are not supported on this platform");
|
||||
}
|
||||
/* "dir3" is a symlink to an existing "non_dir3" */
|
||||
assertMakeFile("dest1/non_dir3", 0755, "abcdef");
|
||||
if (canSymlink())
|
||||
assertMakeSymlink("dest1/dir3", "non_dir3", 1);
|
||||
/* "file" is a symlink to existing "real_file" */
|
||||
assertMakeFile("dest1/real_file", 0755, "abcdefg");
|
||||
if (canSymlink()) {
|
||||
assertMakeSymlink("dest1/file", "real_file", 0);
|
||||
/* "file2" is a symlink to non-existing "real_file2" */
|
||||
assertMakeSymlink("dest1/file2", "real_file2", 0);
|
||||
}
|
||||
assertEqualInt(0, systemf("%s -xf test.tar -C dest1", testprog));
|
||||
|
||||
/* dest1/dir symlink should be replaced */
|
||||
failure("symlink to dir was followed when it shouldn't be");
|
||||
assertIsDir("dest1/dir", -1);
|
||||
/* dest1/dir2 symlink should be replaced */
|
||||
failure("Broken symlink wasn't replaced with dir");
|
||||
assertIsDir("dest1/dir2", -1);
|
||||
/* dest1/dir3 symlink should be replaced */
|
||||
failure("Symlink to non-dir wasn't replaced with dir");
|
||||
assertIsDir("dest1/dir3", -1);
|
||||
/* dest1/file symlink should be replaced */
|
||||
failure("Symlink to existing file should be replaced");
|
||||
assertIsReg("dest1/file", -1);
|
||||
/* dest1/file2 symlink should be replaced */
|
||||
failure("Symlink to non-existing file should be replaced");
|
||||
assertIsReg("dest1/file2", -1);
|
||||
|
||||
/*
|
||||
* Extract with both -x and -P
|
||||
*/
|
||||
assertMakeDir("dest2", 0755);
|
||||
/* "dir" is a symlink to existing "real_dir" */
|
||||
assertMakeDir("dest2/real_dir", 0755);
|
||||
if (canSymlink())
|
||||
assertMakeSymlink("dest2/dir", "real_dir", 1);
|
||||
/* "dir2" is a symlink to a non-existing "real_dir2" */
|
||||
if (canSymlink())
|
||||
assertMakeSymlink("dest2/dir2", "real_dir2", 1);
|
||||
/* "dir3" is a symlink to an existing "non_dir3" */
|
||||
assertMakeFile("dest2/non_dir3", 0755, "abcdefgh");
|
||||
if (canSymlink())
|
||||
assertMakeSymlink("dest2/dir3", "non_dir3", 1);
|
||||
/* "file" is a symlink to existing "real_file" */
|
||||
assertMakeFile("dest2/real_file", 0755, "abcdefghi");
|
||||
if (canSymlink())
|
||||
assertMakeSymlink("dest2/file", "real_file", 0);
|
||||
/* "file2" is a symlink to non-existing "real_file2" */
|
||||
if (canSymlink())
|
||||
assertMakeSymlink("dest2/file2", "real_file2", 0);
|
||||
assertEqualInt(0, systemf("%s -xPf test.tar -C dest2", testprog));
|
||||
|
||||
/* "dir4" is a symlink to existing "real_dir" */
|
||||
if (canSymlink())
|
||||
assertMakeSymlink("dest2/dir4", "real_dir", 1);
|
||||
assertEqualInt(0, systemf("%s -xPf test2.tar -C dest2", testprog));
|
||||
|
||||
/* dest2/dir and dest2/dir4 symlinks should be followed */
|
||||
if (canSymlink()) {
|
||||
assertIsSymlink("dest2/dir", "real_dir", 1);
|
||||
assertIsSymlink("dest2/dir4", "real_dir", 1);
|
||||
assertIsDir("dest2/real_dir", -1);
|
||||
}
|
||||
|
||||
/* Contents of 'dir' should be restored */
|
||||
assertIsDir("dest2/dir/d", -1);
|
||||
assertIsReg("dest2/dir/f", -1);
|
||||
assertFileSize("dest2/dir/f", 3);
|
||||
/* dest2/dir2 symlink should be removed */
|
||||
failure("Broken symlink wasn't replaced with dir");
|
||||
assertIsDir("dest2/dir2", -1);
|
||||
/* dest2/dir3 symlink should be removed */
|
||||
failure("Symlink to non-dir wasn't replaced with dir");
|
||||
assertIsDir("dest2/dir3", -1);
|
||||
/* dest2/file symlink should be removed;
|
||||
* even -P shouldn't follow symlinks for files */
|
||||
failure("Symlink to existing file should be removed");
|
||||
assertIsReg("dest2/file", -1);
|
||||
/* dest2/file2 symlink should be removed */
|
||||
failure("Symlink to non-existing file should be removed");
|
||||
assertIsReg("dest2/file2", -1);
|
||||
|
||||
/* dest2/dir4/file3 and dest2/dir4/file4 should be hard links */
|
||||
assertIsHardlink("dest2/dir4/file3", "dest2/dir4/file4");
|
||||
}
|
34
dependencies/libarchive-3.4.2/tar/test/test_version.c
vendored
Normal file
34
dependencies/libarchive-3.4.2/tar/test/test_version.c
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2017 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
/*
|
||||
* Test that --version option works and generates reasonable output.
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_version)
|
||||
{
|
||||
assertVersion(testprog, "bsdtar");
|
||||
}
|
324
dependencies/libarchive-3.4.2/tar/test/test_windows.c
vendored
Normal file
324
dependencies/libarchive-3.4.2/tar/test/test_windows.c
vendored
Normal file
|
@ -0,0 +1,324 @@
|
|||
/*-
|
||||
* Copyright (c) 2009 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include <direct.h>
|
||||
#include <windows.h>
|
||||
|
||||
static void
|
||||
mkfile(const char *name)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = fopen(name, "wb");
|
||||
assert(f != NULL);
|
||||
assertEqualInt(5, fwrite("01234", 1, 5, f));
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static void
|
||||
mkfullpath(char **path1, char **path2, const char *tpath, int type)
|
||||
{
|
||||
char *fp1 = NULL, *fp2 = NULL, *p1 = NULL, *p2 = NULL;
|
||||
size_t l;
|
||||
|
||||
/*
|
||||
* Get full path name of "tpath"
|
||||
*/
|
||||
l = GetFullPathNameA(tpath, 0, NULL, NULL);
|
||||
assert(0 != l);
|
||||
fp1 = malloc(l);
|
||||
assert(NULL != fp1);
|
||||
fp2 = malloc(l*2);
|
||||
assert(NULL != fp2);
|
||||
l = GetFullPathNameA(tpath, (DWORD)l, fp1, NULL);
|
||||
if ((type & 0x01) == 0) {
|
||||
for (p1 = fp1; *p1 != '\0'; p1++)
|
||||
if (*p1 == '\\')
|
||||
*p1 = '/';
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case 0: /* start with "/" */
|
||||
case 1: /* start with "\" */
|
||||
/* strip "c:" */
|
||||
memmove(fp1, fp1 + 2, l - 2);
|
||||
fp1[l -2] = '\0';
|
||||
p1 = fp1 + 1;
|
||||
break;
|
||||
case 2: /* start with "c:/" */
|
||||
case 3: /* start with "c:\" */
|
||||
p1 = fp1 + 3;
|
||||
break;
|
||||
case 4: /* start with "//./c:/" */
|
||||
case 5: /* start with "\\.\c:\" */
|
||||
case 6: /* start with "//?/c:/" */
|
||||
case 7: /* start with "\\?\c:\" */
|
||||
p1 = malloc(l + 4 + 1);
|
||||
assert(NULL != p1);
|
||||
if (type & 0x1)
|
||||
memcpy(p1, "\\\\.\\", 4);
|
||||
else
|
||||
memcpy(p1, "//./", 4);
|
||||
if (type == 6 || type == 7)
|
||||
p1[2] = '?';
|
||||
memcpy(p1 + 4, fp1, l);
|
||||
p1[l + 4] = '\0';
|
||||
free(fp1);
|
||||
fp1 = p1;
|
||||
p1 = fp1 + 7;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Strip leading drive names and converting "\" to "\\"
|
||||
*/
|
||||
p2 = fp2;
|
||||
while (*p1 != '\0') {
|
||||
if (*p1 == '\\')
|
||||
*p2 = '/';
|
||||
else
|
||||
*p2 = *p1;
|
||||
++p1;
|
||||
++p2;
|
||||
}
|
||||
*p2++ = '\r';
|
||||
*p2++ = '\n';
|
||||
*p2 = '\0';
|
||||
|
||||
*path1 = fp1;
|
||||
*path2 = fp2;
|
||||
}
|
||||
|
||||
static const char *list1[] = {"aaa/", "aaa/file1", "aaa/xxa/", "aaa/xxb/",
|
||||
"aaa/zzc/", "aaa/zzc/file1", "aaa/xxb/file1", "aaa/xxa/file1",
|
||||
"aab/", "aac/", "abb/", "abc/", "abd/", NULL};
|
||||
static const char *list2[] = {"bbb/", "bbb/file1", "bbb/xxa/", "bbb/xxb/",
|
||||
"bbb/zzc/", "bbb/zzc/file1", "bbb/xxb/file1", "bbb/xxa/file1", "bbc/",
|
||||
"bbd/", "bcc/", "bcd/", "bce/", NULL};
|
||||
static const char *list3[] = {"aac/", "abc/", "bbc/", "bcc/", "ccc/", NULL};
|
||||
static const char *list4[] = {"fff/abca", "fff/acca", NULL};
|
||||
static const char *list5[] = {"aaa/file1", "aaa/xxa/", "aaa/xxa/file1",
|
||||
"aaa/xxb/", "aaa/xxb/file1", "aaa/zzc/", "aaa/zzc/file1", NULL};
|
||||
static const char *list6[] = {"fff/abca", "fff/acca", "aaa/xxa/",
|
||||
"aaa/xxa/file1", "aaa/xxb/", "aaa/xxb/file1", NULL};
|
||||
#endif /* _WIN32 && !__CYGWIN__ */
|
||||
|
||||
DEFINE_TEST(test_windows)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
char *fp1, *fp2;
|
||||
|
||||
/*
|
||||
* Prepare tests.
|
||||
* Create directories and files.
|
||||
*/
|
||||
assertMakeDir("tmp", 0775);
|
||||
assertChdir("tmp");
|
||||
|
||||
assertMakeDir("aaa", 0775);
|
||||
assertMakeDir("aaa/xxa", 0775);
|
||||
assertMakeDir("aaa/xxb", 0775);
|
||||
assertMakeDir("aaa/zzc", 0775);
|
||||
mkfile("aaa/file1");
|
||||
mkfile("aaa/xxa/file1");
|
||||
mkfile("aaa/xxb/file1");
|
||||
mkfile("aaa/zzc/file1");
|
||||
assertMakeDir("aab", 0775);
|
||||
assertMakeDir("aac", 0775);
|
||||
assertMakeDir("abb", 0775);
|
||||
assertMakeDir("abc", 0775);
|
||||
assertMakeDir("abd", 0775);
|
||||
assertMakeDir("bbb", 0775);
|
||||
assertMakeDir("bbb/xxa", 0775);
|
||||
assertMakeDir("bbb/xxb", 0775);
|
||||
assertMakeDir("bbb/zzc", 0775);
|
||||
mkfile("bbb/file1");
|
||||
mkfile("bbb/xxa/file1");
|
||||
mkfile("bbb/xxb/file1");
|
||||
mkfile("bbb/zzc/file1");
|
||||
assertMakeDir("bbc", 0775);
|
||||
assertMakeDir("bbd", 0775);
|
||||
assertMakeDir("bcc", 0775);
|
||||
assertMakeDir("bcd", 0775);
|
||||
assertEqualInt(0, _mkdir("bce"));
|
||||
assertEqualInt(0, _mkdir("ccc"));
|
||||
assertEqualInt(0, _mkdir("fff"));
|
||||
mkfile("fff/aaaa");
|
||||
mkfile("fff/abba");
|
||||
mkfile("fff/abca");
|
||||
mkfile("fff/acba");
|
||||
mkfile("fff/acca");
|
||||
|
||||
/*
|
||||
* Test1: Command line pattern matching.
|
||||
*/
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive1.tar a*", testprog));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive1.tar > ../list1", testprog));
|
||||
assertFileContainsLinesAnyOrder("../list1", list1);
|
||||
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive2.tar b*", testprog));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive2.tar > ../list2", testprog));
|
||||
assertFileContainsLinesAnyOrder("../list2", list2);
|
||||
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive3.tar ??c", testprog));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive3.tar > ../list3", testprog));
|
||||
assertFileContainsLinesAnyOrder("../list3", list3);
|
||||
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive3b.tar *c", testprog));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive3b.tar > ../list3b", testprog));
|
||||
assertFileContainsLinesAnyOrder("../list3b", list3);
|
||||
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive4.tar fff/a?ca", testprog));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive4.tar > ../list4", testprog));
|
||||
assertFileContainsLinesAnyOrder("../list4", list4);
|
||||
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive5.tar aaa\\*", testprog));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive5.tar > ../list5", testprog));
|
||||
assertFileContainsLinesAnyOrder("../list5", list5);
|
||||
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive6.tar fff\\a?ca aaa\\xx*", testprog));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive6.tar > ../list6", testprog));
|
||||
assertFileContainsLinesAnyOrder("../list6", list6);
|
||||
|
||||
/*
|
||||
* Test2: Archive the file start with drive letters.
|
||||
*/
|
||||
/* Test2a: start with "/" */
|
||||
mkfullpath(&fp1, &fp2, "aaa/file1", 0);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive10.tar %s > ../out10 2> ../err10",
|
||||
testprog, fp1));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive10.tar > ../list10", testprog));
|
||||
/* Check drive letters have been stripped. */
|
||||
assertFileContents(fp2, (int)strlen(fp2), "../list10");
|
||||
free(fp1);
|
||||
free(fp2);
|
||||
|
||||
/* Test2b: start with "\" */
|
||||
mkfullpath(&fp1, &fp2, "aaa/file1", 1);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive11.tar %s > ../out11 2> ../err11",
|
||||
testprog, fp1));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive11.tar > ../list11", testprog));
|
||||
/* Check drive letters have been stripped. */
|
||||
assertFileContents(fp2, (int)strlen(fp2), "../list11");
|
||||
free(fp1);
|
||||
free(fp2);
|
||||
|
||||
/* Test2c: start with "c:/" */
|
||||
mkfullpath(&fp1, &fp2, "aaa/file1", 2);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive12.tar %s > ../out12 2> ../err12",
|
||||
testprog, fp1));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive12.tar > ../list12", testprog));
|
||||
/* Check drive letters have been stripped. */
|
||||
assertFileContents(fp2, (int)strlen(fp2), "../list12");
|
||||
free(fp1);
|
||||
free(fp2);
|
||||
|
||||
/* Test2d: start with "c:\" */
|
||||
mkfullpath(&fp1, &fp2, "aaa/file1", 3);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive13.tar %s > ../out13 2> ../err13",
|
||||
testprog, fp1));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive13.tar > ../list13", testprog));
|
||||
/* Check drive letters have been stripped. */
|
||||
assertFileContents(fp2, (int)strlen(fp2), "../list13");
|
||||
free(fp1);
|
||||
free(fp2);
|
||||
|
||||
/* Test2e: start with "//./c:/" */
|
||||
mkfullpath(&fp1, &fp2, "aaa/file1", 4);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive14.tar %s > ../out14 2> ../err14",
|
||||
testprog, fp1));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive14.tar > ../list14", testprog));
|
||||
/* Check drive letters have been stripped. */
|
||||
assertFileContents(fp2, (int)strlen(fp2), "../list14");
|
||||
free(fp1);
|
||||
free(fp2);
|
||||
|
||||
/* Test2f: start with "\\.\c:\" */
|
||||
mkfullpath(&fp1, &fp2, "aaa/file1", 5);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive15.tar %s > ../out15 2> ../err15",
|
||||
testprog, fp1));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive15.tar > ../list15", testprog));
|
||||
/* Check drive letters have been stripped. */
|
||||
assertFileContents(fp2, (int)strlen(fp2), "../list15");
|
||||
free(fp1);
|
||||
free(fp2);
|
||||
|
||||
/* Test2g: start with "//?/c:/" */
|
||||
mkfullpath(&fp1, &fp2, "aaa/file1", 6);
|
||||
failure("fp1=%s, fp2=%s", fp1, fp2);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive16.tar %s > ../out16 2> ../err16",
|
||||
testprog, fp1));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive16.tar > ../list16", testprog));
|
||||
/* Check drive letters have been stripped. */
|
||||
assertFileContents(fp2, (int)strlen(fp2), "../list16");
|
||||
free(fp1);
|
||||
free(fp2);
|
||||
|
||||
/* Test2h: start with "\\?\c:\" */
|
||||
mkfullpath(&fp1, &fp2, "aaa/file1", 7);
|
||||
failure("fp1=%s, fp2=%s", fp1, fp2);
|
||||
assertEqualInt(0,
|
||||
systemf("%s -cf ../archive17.tar %s > ../out17 2> ../err17",
|
||||
testprog, fp1));
|
||||
assertEqualInt(0,
|
||||
systemf("%s -tf ../archive17.tar > ../list17", testprog));
|
||||
/* Check drive letters have been stripped. */
|
||||
assertFileContents(fp2, (int)strlen(fp2), "../list17");
|
||||
free(fp1);
|
||||
free(fp2);
|
||||
#else
|
||||
skipping("Windows specific test");
|
||||
#endif /* _WIN32 && !__CYGWIN__ */
|
||||
}
|
770
dependencies/libarchive-3.4.2/tar/util.c
vendored
Normal file
770
dependencies/libarchive-3.4.2/tar/util.c
vendored
Normal file
|
@ -0,0 +1,770 @@
|
|||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "bsdtar_platform.h"
|
||||
__FBSDID("$FreeBSD: src/usr.bin/tar/util.c,v 1.23 2008/12/15 06:00:25 kientzle Exp $");
|
||||
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h> /* Linux doesn't define mode_t, etc. in sys/stat.h. */
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#ifdef HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_WCTYPE_H
|
||||
#include <wctype.h>
|
||||
#else
|
||||
/* If we don't have wctype, we need to hack up some version of iswprint(). */
|
||||
#define iswprint isprint
|
||||
#endif
|
||||
|
||||
#include "bsdtar.h"
|
||||
#include "err.h"
|
||||
#include "passphrase.h"
|
||||
|
||||
static size_t bsdtar_expand_char(char *, size_t, char);
|
||||
static const char *strip_components(const char *path, int elements);
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#define read _read
|
||||
#endif
|
||||
|
||||
/* TODO: Hack up a version of mbtowc for platforms with no wide
|
||||
* character support at all. I think the following might suffice,
|
||||
* but it needs careful testing.
|
||||
* #if !HAVE_MBTOWC
|
||||
* #define mbtowc(wcp, p, n) ((*wcp = *p), 1)
|
||||
* #endif
|
||||
*/
|
||||
|
||||
/*
|
||||
* Print a string, taking care with any non-printable characters.
|
||||
*
|
||||
* Note that we use a stack-allocated buffer to receive the formatted
|
||||
* string if we can. This is partly performance (avoiding a call to
|
||||
* malloc()), partly out of expedience (we have to call vsnprintf()
|
||||
* before malloc() anyway to find out how big a buffer we need; we may
|
||||
* as well point that first call at a small local buffer in case it
|
||||
* works), but mostly for safety (so we can use this to print messages
|
||||
* about out-of-memory conditions).
|
||||
*/
|
||||
|
||||
void
|
||||
safe_fprintf(FILE *f, const char *fmt, ...)
|
||||
{
|
||||
char fmtbuff_stack[256]; /* Place to format the printf() string. */
|
||||
char outbuff[256]; /* Buffer for outgoing characters. */
|
||||
char *fmtbuff_heap; /* If fmtbuff_stack is too small, we use malloc */
|
||||
char *fmtbuff; /* Pointer to fmtbuff_stack or fmtbuff_heap. */
|
||||
int fmtbuff_length;
|
||||
int length, n;
|
||||
va_list ap;
|
||||
const char *p;
|
||||
unsigned i;
|
||||
wchar_t wc;
|
||||
char try_wc;
|
||||
|
||||
/* Use a stack-allocated buffer if we can, for speed and safety. */
|
||||
fmtbuff_heap = NULL;
|
||||
fmtbuff_length = sizeof(fmtbuff_stack);
|
||||
fmtbuff = fmtbuff_stack;
|
||||
|
||||
/* Try formatting into the stack buffer. */
|
||||
va_start(ap, fmt);
|
||||
length = vsnprintf(fmtbuff, fmtbuff_length, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* If the result was too large, allocate a buffer on the heap. */
|
||||
while (length < 0 || length >= fmtbuff_length) {
|
||||
if (length >= fmtbuff_length)
|
||||
fmtbuff_length = length+1;
|
||||
else if (fmtbuff_length < 8192)
|
||||
fmtbuff_length *= 2;
|
||||
else if (fmtbuff_length < 1000000)
|
||||
fmtbuff_length += fmtbuff_length / 4;
|
||||
else {
|
||||
length = fmtbuff_length;
|
||||
fmtbuff_heap[length-1] = '\0';
|
||||
break;
|
||||
}
|
||||
free(fmtbuff_heap);
|
||||
fmtbuff_heap = malloc(fmtbuff_length);
|
||||
|
||||
/* Reformat the result into the heap buffer if we can. */
|
||||
if (fmtbuff_heap != NULL) {
|
||||
fmtbuff = fmtbuff_heap;
|
||||
va_start(ap, fmt);
|
||||
length = vsnprintf(fmtbuff, fmtbuff_length, fmt, ap);
|
||||
va_end(ap);
|
||||
} else {
|
||||
/* Leave fmtbuff pointing to the truncated
|
||||
* string in fmtbuff_stack. */
|
||||
fmtbuff = fmtbuff_stack;
|
||||
length = sizeof(fmtbuff_stack) - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Note: mbrtowc() has a cleaner API, but mbtowc() seems a bit
|
||||
* more portable, so we use that here instead. */
|
||||
if (mbtowc(NULL, NULL, 1) == -1) { /* Reset the shift state. */
|
||||
/* mbtowc() should never fail in practice, but
|
||||
* handle the theoretical error anyway. */
|
||||
free(fmtbuff_heap);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Write data, expanding unprintable characters. */
|
||||
p = fmtbuff;
|
||||
i = 0;
|
||||
try_wc = 1;
|
||||
while (*p != '\0') {
|
||||
|
||||
/* Convert to wide char, test if the wide
|
||||
* char is printable in the current locale. */
|
||||
if (try_wc && (n = mbtowc(&wc, p, length)) != -1) {
|
||||
length -= n;
|
||||
if (iswprint(wc) && wc != L'\\') {
|
||||
/* Printable, copy the bytes through. */
|
||||
while (n-- > 0)
|
||||
outbuff[i++] = *p++;
|
||||
} else {
|
||||
/* Not printable, format the bytes. */
|
||||
while (n-- > 0)
|
||||
i += (unsigned)bsdtar_expand_char(
|
||||
outbuff, i, *p++);
|
||||
}
|
||||
} else {
|
||||
/* After any conversion failure, don't bother
|
||||
* trying to convert the rest. */
|
||||
i += (unsigned)bsdtar_expand_char(outbuff, i, *p++);
|
||||
try_wc = 0;
|
||||
}
|
||||
|
||||
/* If our output buffer is full, dump it and keep going. */
|
||||
if (i > (sizeof(outbuff) - 128)) {
|
||||
outbuff[i] = '\0';
|
||||
fprintf(f, "%s", outbuff);
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
outbuff[i] = '\0';
|
||||
fprintf(f, "%s", outbuff);
|
||||
|
||||
/* If we allocated a heap-based formatting buffer, free it now. */
|
||||
free(fmtbuff_heap);
|
||||
}
|
||||
|
||||
/*
|
||||
* Render an arbitrary sequence of bytes into printable ASCII characters.
|
||||
*/
|
||||
static size_t
|
||||
bsdtar_expand_char(char *buff, size_t offset, char c)
|
||||
{
|
||||
size_t i = offset;
|
||||
|
||||
if (isprint((unsigned char)c) && c != '\\')
|
||||
buff[i++] = c;
|
||||
else {
|
||||
buff[i++] = '\\';
|
||||
switch (c) {
|
||||
case '\a': buff[i++] = 'a'; break;
|
||||
case '\b': buff[i++] = 'b'; break;
|
||||
case '\f': buff[i++] = 'f'; break;
|
||||
case '\n': buff[i++] = 'n'; break;
|
||||
#if '\r' != '\n'
|
||||
/* On some platforms, \n and \r are the same. */
|
||||
case '\r': buff[i++] = 'r'; break;
|
||||
#endif
|
||||
case '\t': buff[i++] = 't'; break;
|
||||
case '\v': buff[i++] = 'v'; break;
|
||||
case '\\': buff[i++] = '\\'; break;
|
||||
default:
|
||||
sprintf(buff + i, "%03o", 0xFF & (int)c);
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
|
||||
return (i - offset);
|
||||
}
|
||||
|
||||
int
|
||||
yes(const char *fmt, ...)
|
||||
{
|
||||
char buff[32];
|
||||
char *p;
|
||||
ssize_t l;
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
fprintf(stderr, " (y/N)? ");
|
||||
fflush(stderr);
|
||||
|
||||
l = read(2, buff, sizeof(buff) - 1);
|
||||
if (l < 0) {
|
||||
fprintf(stderr, "Keyboard read failed\n");
|
||||
exit(1);
|
||||
}
|
||||
if (l == 0)
|
||||
return (0);
|
||||
buff[l] = 0;
|
||||
|
||||
for (p = buff; *p != '\0'; p++) {
|
||||
if (isspace((unsigned char)*p))
|
||||
continue;
|
||||
switch(*p) {
|
||||
case 'y': case 'Y':
|
||||
return (1);
|
||||
case 'n': case 'N':
|
||||
return (0);
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*-
|
||||
* The logic here for -C <dir> attempts to avoid
|
||||
* chdir() as long as possible. For example:
|
||||
* "-C /foo -C /bar file" needs chdir("/bar") but not chdir("/foo")
|
||||
* "-C /foo -C bar file" needs chdir("/foo/bar")
|
||||
* "-C /foo -C bar /file1" does not need chdir()
|
||||
* "-C /foo -C bar /file1 file2" needs chdir("/foo/bar") before file2
|
||||
*
|
||||
* The only correct way to handle this is to record a "pending" chdir
|
||||
* request and combine multiple requests intelligently until we
|
||||
* need to process a non-absolute file. set_chdir() adds the new dir
|
||||
* to the pending list; do_chdir() actually executes any pending chdir.
|
||||
*
|
||||
* This way, programs that build tar command lines don't have to worry
|
||||
* about -C with non-existent directories; such requests will only
|
||||
* fail if the directory must be accessed.
|
||||
*
|
||||
*/
|
||||
void
|
||||
set_chdir(struct bsdtar *bsdtar, const char *newdir)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
if (newdir[0] == '/' || newdir[0] == '\\' ||
|
||||
/* Detect this type, for example, "C:\" or "C:/" */
|
||||
(((newdir[0] >= 'a' && newdir[0] <= 'z') ||
|
||||
(newdir[0] >= 'A' && newdir[0] <= 'Z')) &&
|
||||
newdir[1] == ':' && (newdir[2] == '/' || newdir[2] == '\\'))) {
|
||||
#else
|
||||
if (newdir[0] == '/') {
|
||||
#endif
|
||||
/* The -C /foo -C /bar case; dump first one. */
|
||||
free(bsdtar->pending_chdir);
|
||||
bsdtar->pending_chdir = NULL;
|
||||
}
|
||||
if (bsdtar->pending_chdir == NULL)
|
||||
/* Easy case: no previously-saved dir. */
|
||||
bsdtar->pending_chdir = strdup(newdir);
|
||||
else {
|
||||
/* The -C /foo -C bar case; concatenate */
|
||||
char *old_pending = bsdtar->pending_chdir;
|
||||
size_t old_len = strlen(old_pending);
|
||||
bsdtar->pending_chdir = malloc(old_len + strlen(newdir) + 2);
|
||||
if (old_pending[old_len - 1] == '/')
|
||||
old_pending[old_len - 1] = '\0';
|
||||
if (bsdtar->pending_chdir != NULL)
|
||||
sprintf(bsdtar->pending_chdir, "%s/%s",
|
||||
old_pending, newdir);
|
||||
free(old_pending);
|
||||
}
|
||||
if (bsdtar->pending_chdir == NULL)
|
||||
lafe_errc(1, errno, "No memory");
|
||||
}
|
||||
|
||||
void
|
||||
do_chdir(struct bsdtar *bsdtar)
|
||||
{
|
||||
if (bsdtar->pending_chdir == NULL)
|
||||
return;
|
||||
|
||||
if (chdir(bsdtar->pending_chdir) != 0) {
|
||||
lafe_errc(1, 0, "could not chdir to '%s'\n",
|
||||
bsdtar->pending_chdir);
|
||||
}
|
||||
free(bsdtar->pending_chdir);
|
||||
bsdtar->pending_chdir = NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
strip_components(const char *p, int elements)
|
||||
{
|
||||
/* Skip as many elements as necessary. */
|
||||
while (elements > 0) {
|
||||
switch (*p++) {
|
||||
case '/':
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
case '\\': /* Support \ path sep on Windows ONLY. */
|
||||
#endif
|
||||
elements--;
|
||||
break;
|
||||
case '\0':
|
||||
/* Path is too short, skip it. */
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Skip any / characters. This handles short paths that have
|
||||
* additional / termination. This also handles the case where
|
||||
* the logic above stops in the middle of a duplicate //
|
||||
* sequence (which would otherwise get converted to an
|
||||
* absolute path). */
|
||||
for (;;) {
|
||||
switch (*p) {
|
||||
case '/':
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
case '\\': /* Support \ path sep on Windows ONLY. */
|
||||
#endif
|
||||
++p;
|
||||
break;
|
||||
case '\0':
|
||||
return (NULL);
|
||||
default:
|
||||
return (p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
warn_strip_leading_char(struct bsdtar *bsdtar, const char *c)
|
||||
{
|
||||
if (!bsdtar->warned_lead_slash) {
|
||||
lafe_warnc(0,
|
||||
"Removing leading '%c' from member names",
|
||||
c[0]);
|
||||
bsdtar->warned_lead_slash = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
warn_strip_drive_letter(struct bsdtar *bsdtar)
|
||||
{
|
||||
if (!bsdtar->warned_lead_slash) {
|
||||
lafe_warnc(0,
|
||||
"Removing leading drive letter from "
|
||||
"member names");
|
||||
bsdtar->warned_lead_slash = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert absolute path to non-absolute path by skipping leading
|
||||
* absolute path prefixes.
|
||||
*/
|
||||
static const char*
|
||||
strip_absolute_path(struct bsdtar *bsdtar, const char *p)
|
||||
{
|
||||
const char *rp;
|
||||
|
||||
/* Remove leading "//./" or "//?/" or "//?/UNC/"
|
||||
* (absolute path prefixes used by Windows API) */
|
||||
if ((p[0] == '/' || p[0] == '\\') &&
|
||||
(p[1] == '/' || p[1] == '\\') &&
|
||||
(p[2] == '.' || p[2] == '?') &&
|
||||
(p[3] == '/' || p[3] == '\\'))
|
||||
{
|
||||
if (p[2] == '?' &&
|
||||
(p[4] == 'U' || p[4] == 'u') &&
|
||||
(p[5] == 'N' || p[5] == 'n') &&
|
||||
(p[6] == 'C' || p[6] == 'c') &&
|
||||
(p[7] == '/' || p[7] == '\\'))
|
||||
p += 8;
|
||||
else
|
||||
p += 4;
|
||||
warn_strip_drive_letter(bsdtar);
|
||||
}
|
||||
|
||||
/* Remove multiple leading slashes and Windows drive letters. */
|
||||
do {
|
||||
rp = p;
|
||||
if (((p[0] >= 'a' && p[0] <= 'z') ||
|
||||
(p[0] >= 'A' && p[0] <= 'Z')) &&
|
||||
p[1] == ':') {
|
||||
p += 2;
|
||||
warn_strip_drive_letter(bsdtar);
|
||||
}
|
||||
|
||||
/* Remove leading "/../", "/./", "//", etc. */
|
||||
while (p[0] == '/' || p[0] == '\\') {
|
||||
if (p[1] == '.' &&
|
||||
p[2] == '.' &&
|
||||
(p[3] == '/' || p[3] == '\\')) {
|
||||
p += 3; /* Remove "/..", leave "/" for next pass. */
|
||||
} else if (p[1] == '.' &&
|
||||
(p[2] == '/' || p[2] == '\\')) {
|
||||
p += 2; /* Remove "/.", leave "/" for next pass. */
|
||||
} else
|
||||
p += 1; /* Remove "/". */
|
||||
warn_strip_leading_char(bsdtar, rp);
|
||||
}
|
||||
} while (rp != p);
|
||||
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle --strip-components and any future path-rewriting options.
|
||||
* Returns non-zero if the pathname should not be extracted.
|
||||
*
|
||||
* Note: The rewrites are applied uniformly to pathnames and hardlink
|
||||
* names but not to symlink bodies. This is deliberate: Symlink
|
||||
* bodies are not necessarily filenames. Even when they are, they
|
||||
* need to be interpreted relative to the directory containing them,
|
||||
* so simple rewrites like this are rarely appropriate.
|
||||
*
|
||||
* TODO: Support pax-style regex path rewrites.
|
||||
*/
|
||||
int
|
||||
edit_pathname(struct bsdtar *bsdtar, struct archive_entry *entry)
|
||||
{
|
||||
const char *name = archive_entry_pathname(entry);
|
||||
const char *original_name = name;
|
||||
const char *hardlinkname = archive_entry_hardlink(entry);
|
||||
const char *original_hardlinkname = hardlinkname;
|
||||
#if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H)
|
||||
char *subst_name;
|
||||
int r;
|
||||
|
||||
/* Apply user-specified substitution to pathname. */
|
||||
r = apply_substitution(bsdtar, name, &subst_name, 0, 0);
|
||||
if (r == -1) {
|
||||
lafe_warnc(0, "Invalid substitution, skipping entry");
|
||||
return 1;
|
||||
}
|
||||
if (r == 1) {
|
||||
archive_entry_copy_pathname(entry, subst_name);
|
||||
if (*subst_name == '\0') {
|
||||
free(subst_name);
|
||||
return -1;
|
||||
} else
|
||||
free(subst_name);
|
||||
name = archive_entry_pathname(entry);
|
||||
original_name = name;
|
||||
}
|
||||
|
||||
/* Apply user-specified substitution to hardlink target. */
|
||||
if (hardlinkname != NULL) {
|
||||
r = apply_substitution(bsdtar, hardlinkname, &subst_name, 0, 1);
|
||||
if (r == -1) {
|
||||
lafe_warnc(0, "Invalid substitution, skipping entry");
|
||||
return 1;
|
||||
}
|
||||
if (r == 1) {
|
||||
archive_entry_copy_hardlink(entry, subst_name);
|
||||
free(subst_name);
|
||||
}
|
||||
hardlinkname = archive_entry_hardlink(entry);
|
||||
original_hardlinkname = hardlinkname;
|
||||
}
|
||||
|
||||
/* Apply user-specified substitution to symlink body. */
|
||||
if (archive_entry_symlink(entry) != NULL) {
|
||||
r = apply_substitution(bsdtar, archive_entry_symlink(entry), &subst_name, 1, 0);
|
||||
if (r == -1) {
|
||||
lafe_warnc(0, "Invalid substitution, skipping entry");
|
||||
return 1;
|
||||
}
|
||||
if (r == 1) {
|
||||
archive_entry_copy_symlink(entry, subst_name);
|
||||
free(subst_name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Strip leading dir names as per --strip-components option. */
|
||||
if (bsdtar->strip_components > 0) {
|
||||
name = strip_components(name, bsdtar->strip_components);
|
||||
if (name == NULL)
|
||||
return (1);
|
||||
|
||||
if (hardlinkname != NULL) {
|
||||
hardlinkname = strip_components(hardlinkname,
|
||||
bsdtar->strip_components);
|
||||
if (hardlinkname == NULL)
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
if ((bsdtar->flags & OPTFLAG_ABSOLUTE_PATHS) == 0) {
|
||||
/* By default, don't write or restore absolute pathnames. */
|
||||
name = strip_absolute_path(bsdtar, name);
|
||||
if (*name == '\0')
|
||||
name = ".";
|
||||
|
||||
if (hardlinkname != NULL) {
|
||||
hardlinkname = strip_absolute_path(bsdtar, hardlinkname);
|
||||
if (*hardlinkname == '\0')
|
||||
return (1);
|
||||
}
|
||||
} else {
|
||||
/* Strip redundant leading '/' characters. */
|
||||
while (name[0] == '/' && name[1] == '/')
|
||||
name++;
|
||||
}
|
||||
|
||||
/* Replace name in archive_entry. */
|
||||
if (name != original_name) {
|
||||
archive_entry_copy_pathname(entry, name);
|
||||
}
|
||||
if (hardlinkname != original_hardlinkname) {
|
||||
archive_entry_copy_hardlink(entry, hardlinkname);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* It would be nice to just use printf() for formatting large numbers,
|
||||
* but the compatibility problems are quite a headache. Hence the
|
||||
* following simple utility function.
|
||||
*/
|
||||
const char *
|
||||
tar_i64toa(int64_t n0)
|
||||
{
|
||||
static char buff[24];
|
||||
uint64_t n = n0 < 0 ? -n0 : n0;
|
||||
char *p = buff + sizeof(buff);
|
||||
|
||||
*--p = '\0';
|
||||
do {
|
||||
*--p = '0' + (int)(n % 10);
|
||||
} while (n /= 10);
|
||||
if (n0 < 0)
|
||||
*--p = '-';
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
* Like strcmp(), but try to be a little more aware of the fact that
|
||||
* we're comparing two paths. Right now, it just handles leading
|
||||
* "./" and trailing '/' specially, so that "a/b/" == "./a/b"
|
||||
*
|
||||
* TODO: Make this better, so that "./a//b/./c/" == "a/b/c"
|
||||
* TODO: After this works, push it down into libarchive.
|
||||
* TODO: Publish the path normalization routines in libarchive so
|
||||
* that bsdtar can normalize paths and use fast strcmp() instead
|
||||
* of this.
|
||||
*
|
||||
* Note: This is currently only used within write.c, so should
|
||||
* not handle \ path separators.
|
||||
*/
|
||||
|
||||
int
|
||||
pathcmp(const char *a, const char *b)
|
||||
{
|
||||
/* Skip leading './' */
|
||||
if (a[0] == '.' && a[1] == '/' && a[2] != '\0')
|
||||
a += 2;
|
||||
if (b[0] == '.' && b[1] == '/' && b[2] != '\0')
|
||||
b += 2;
|
||||
/* Find the first difference, or return (0) if none. */
|
||||
while (*a == *b) {
|
||||
if (*a == '\0')
|
||||
return (0);
|
||||
a++;
|
||||
b++;
|
||||
}
|
||||
/*
|
||||
* If one ends in '/' and the other one doesn't,
|
||||
* they're the same.
|
||||
*/
|
||||
if (a[0] == '/' && a[1] == '\0' && b[0] == '\0')
|
||||
return (0);
|
||||
if (a[0] == '\0' && b[0] == '/' && b[1] == '\0')
|
||||
return (0);
|
||||
/* They're really different, return the correct sign. */
|
||||
return (*(const unsigned char *)a - *(const unsigned char *)b);
|
||||
}
|
||||
|
||||
#define PPBUFF_SIZE 1024
|
||||
const char *
|
||||
passphrase_callback(struct archive *a, void *_client_data)
|
||||
{
|
||||
struct bsdtar *bsdtar = (struct bsdtar *)_client_data;
|
||||
(void)a; /* UNUSED */
|
||||
|
||||
if (bsdtar->ppbuff == NULL) {
|
||||
bsdtar->ppbuff = malloc(PPBUFF_SIZE);
|
||||
if (bsdtar->ppbuff == NULL)
|
||||
lafe_errc(1, errno, "Out of memory");
|
||||
}
|
||||
return lafe_readpassphrase("Enter passphrase:",
|
||||
bsdtar->ppbuff, PPBUFF_SIZE);
|
||||
}
|
||||
|
||||
void
|
||||
passphrase_free(char *ppbuff)
|
||||
{
|
||||
if (ppbuff != NULL) {
|
||||
memset(ppbuff, 0, PPBUFF_SIZE);
|
||||
free(ppbuff);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Display information about the current file.
|
||||
*
|
||||
* The format here roughly duplicates the output of 'ls -l'.
|
||||
* This is based on SUSv2, where 'tar tv' is documented as
|
||||
* listing additional information in an "unspecified format,"
|
||||
* and 'pax -l' is documented as using the same format as 'ls -l'.
|
||||
*/
|
||||
void
|
||||
list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry)
|
||||
{
|
||||
char tmp[100];
|
||||
size_t w;
|
||||
const char *p;
|
||||
const char *fmt;
|
||||
time_t tim;
|
||||
static time_t now;
|
||||
struct tm *ltime;
|
||||
#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
|
||||
struct tm tmbuf;
|
||||
#endif
|
||||
#if defined(HAVE__LOCALTIME64_S)
|
||||
errno_t terr;
|
||||
__time64_t tmptime;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We avoid collecting the entire list in memory at once by
|
||||
* listing things as we see them. However, that also means we can't
|
||||
* just pre-compute the field widths. Instead, we start with guesses
|
||||
* and just widen them as necessary. These numbers are completely
|
||||
* arbitrary.
|
||||
*/
|
||||
if (!bsdtar->u_width) {
|
||||
bsdtar->u_width = 6;
|
||||
bsdtar->gs_width = 13;
|
||||
}
|
||||
if (!now)
|
||||
time(&now);
|
||||
fprintf(out, "%s %d ",
|
||||
archive_entry_strmode(entry),
|
||||
archive_entry_nlink(entry));
|
||||
|
||||
/* Use uname if it's present, else uid. */
|
||||
p = archive_entry_uname(entry);
|
||||
if ((p == NULL) || (*p == '\0')) {
|
||||
sprintf(tmp, "%lu ",
|
||||
(unsigned long)archive_entry_uid(entry));
|
||||
p = tmp;
|
||||
}
|
||||
w = strlen(p);
|
||||
if (w > bsdtar->u_width)
|
||||
bsdtar->u_width = w;
|
||||
fprintf(out, "%-*s ", (int)bsdtar->u_width, p);
|
||||
|
||||
/* Use gname if it's present, else gid. */
|
||||
p = archive_entry_gname(entry);
|
||||
if (p != NULL && p[0] != '\0') {
|
||||
fprintf(out, "%s", p);
|
||||
w = strlen(p);
|
||||
} else {
|
||||
sprintf(tmp, "%lu",
|
||||
(unsigned long)archive_entry_gid(entry));
|
||||
w = strlen(tmp);
|
||||
fprintf(out, "%s", tmp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print device number or file size, right-aligned so as to make
|
||||
* total width of group and devnum/filesize fields be gs_width.
|
||||
* If gs_width is too small, grow it.
|
||||
*/
|
||||
if (archive_entry_filetype(entry) == AE_IFCHR
|
||||
|| archive_entry_filetype(entry) == AE_IFBLK) {
|
||||
sprintf(tmp, "%lu,%lu",
|
||||
(unsigned long)archive_entry_rdevmajor(entry),
|
||||
(unsigned long)archive_entry_rdevminor(entry));
|
||||
} else {
|
||||
strcpy(tmp, tar_i64toa(archive_entry_size(entry)));
|
||||
}
|
||||
if (w + strlen(tmp) >= bsdtar->gs_width)
|
||||
bsdtar->gs_width = w+strlen(tmp)+1;
|
||||
fprintf(out, "%*s", (int)(bsdtar->gs_width - w), tmp);
|
||||
|
||||
/* Format the time using 'ls -l' conventions. */
|
||||
tim = archive_entry_mtime(entry);
|
||||
#define HALF_YEAR (time_t)365 * 86400 / 2
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#define DAY_FMT "%d" /* Windows' strftime function does not support %e format. */
|
||||
#else
|
||||
#define DAY_FMT "%e" /* Day number without leading zeros */
|
||||
#endif
|
||||
if (tim < now - HALF_YEAR || tim > now + HALF_YEAR)
|
||||
fmt = bsdtar->day_first ? DAY_FMT " %b %Y" : "%b " DAY_FMT " %Y";
|
||||
else
|
||||
fmt = bsdtar->day_first ? DAY_FMT " %b %H:%M" : "%b " DAY_FMT " %H:%M";
|
||||
#if defined(HAVE_LOCALTIME_R)
|
||||
ltime = localtime_r(&tim, &tmbuf);
|
||||
#elif defined(HAVE__LOCALTIME64_S)
|
||||
tmptime = tim;
|
||||
terr = _localtime64_s(&tmbuf, &tmptime);
|
||||
if (terr)
|
||||
ltime = NULL;
|
||||
else
|
||||
ltime = &tmbuf;
|
||||
#else
|
||||
ltime = localtime(&tim);
|
||||
#endif
|
||||
strftime(tmp, sizeof(tmp), fmt, ltime);
|
||||
fprintf(out, " %s ", tmp);
|
||||
safe_fprintf(out, "%s", archive_entry_pathname(entry));
|
||||
|
||||
/* Extra information for links. */
|
||||
if (archive_entry_hardlink(entry)) /* Hard link */
|
||||
safe_fprintf(out, " link to %s",
|
||||
archive_entry_hardlink(entry));
|
||||
else if (archive_entry_symlink(entry)) /* Symbolic link */
|
||||
safe_fprintf(out, " -> %s", archive_entry_symlink(entry));
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue