_archive_set_options(struct archive *a, const char *options,
int magic, const char *fn, option_handler use_option)
{
- int allok = 1, anyok = 0, r;
+ int allok = 1, anyok = 0, ignore_mod_err = 0, r;
char *data;
const char *s, *mod, *opt, *val;
mod = opt = val = NULL;
parse_option(&s, &mod, &opt, &val);
+ if (mod == NULL && opt != NULL &&
+ strcmp("__ignore_wrong_module_name__", opt) == 0) {
+ /* Ignore module name error */
+ if (val != NULL) {
+ ignore_mod_err = 1;
+ anyok = 1;
+ }
+ continue;
+ }
r = use_option(a, mod, opt, val);
if (r == ARCHIVE_FATAL) {
return (ARCHIVE_FAILED);
}
if (r == ARCHIVE_WARN - 1) {
+ if (ignore_mod_err)
+ continue;
/* The module name is wrong. */
archive_set_error(a, ARCHIVE_ERRNO_MISC,
"Unknown module name: `%s'", mod);
FILE *out;
struct archive *a;
struct archive_entry *entry;
+ const char *reader_options;
int r;
while (*bsdtar->argv) {
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) {
+ char *p;
+ /* Set default read options. */
+ p = malloc(sizeof(IGNORE_WRONG_MODULE_NAME)
+ + strlen(reader_options) + 1);
+ if (p == 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. */
+ strncpy(p, IGNORE_WRONG_MODULE_NAME,
+ sizeof(IGNORE_WRONG_MODULE_NAME) -1);
+ strcpy(p + sizeof(IGNORE_WRONG_MODULE_NAME) -1, reader_options);
+ 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 (archive_read_open_filename(a, bsdtar->filename,
#define lseek seek_file
#endif
+static void
+set_writer_options(struct bsdtar *bsdtar, struct archive *a)
+{
+ const char *writer_options;
+ int r;
+
+ writer_options = getenv(ENV_WRITER_OPTIONS);
+ if (writer_options != NULL) {
+ char *p;
+ /* Set default write options. */
+ p = malloc(sizeof(IGNORE_WRONG_MODULE_NAME)
+ + strlen(writer_options) + 1);
+ if (p == NULL)
+ lafe_errc(1, errno, "Out of memory");
+ /* Prepend magic code to ignore options for
+ * a format or filters which are not added to
+ * the archive write object. */
+ strncpy(p, IGNORE_WRONG_MODULE_NAME,
+ sizeof(IGNORE_WRONG_MODULE_NAME) -1);
+ strcpy(p + sizeof(IGNORE_WRONG_MODULE_NAME) -1, writer_options);
+ r = archive_write_set_options(a, p);
+ free(p);
+ if (r < ARCHIVE_WARN)
+ lafe_errc(1, 0, "%s", archive_error_string(a));
+ else
+ archive_clear_error(a);
+ }
+ if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options))
+ lafe_errc(1, 0, "%s", archive_error_string(a));
+}
+
+static void
+set_reader_options(struct bsdtar *bsdtar, struct archive *a)
+{
+ const char *reader_options;
+ int r;
+
+ (void)bsdtar; /* UNUSED */
+
+ reader_options = getenv(ENV_READER_OPTIONS);
+ if (reader_options != NULL) {
+ char *p;
+ /* Set default write options. */
+ p = malloc(sizeof(IGNORE_WRONG_MODULE_NAME)
+ + strlen(reader_options) + 1);
+ if (p == NULL)
+ lafe_errc(1, errno, "Out of memory");
+ /* Prepend magic code to ignore options for
+ * a format or filters which are not added to
+ * the archive write object. */
+ strncpy(p, IGNORE_WRONG_MODULE_NAME,
+ sizeof(IGNORE_WRONG_MODULE_NAME) -1);
+ strcpy(p + sizeof(IGNORE_WRONG_MODULE_NAME) -1, reader_options);
+ r = archive_read_set_options(a, p);
+ free(p);
+ if (r < ARCHIVE_WARN)
+ lafe_errc(1, 0, "%s", archive_error_string(a));
+ else
+ archive_clear_error(a);
+ }
+}
+
void
tar_mode_c(struct bsdtar *bsdtar)
{
(const char *)filter_name);
}
- if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options))
- lafe_errc(1, 0, "%s", archive_error_string(a));
+ set_writer_options(bsdtar, a);
if (ARCHIVE_OK != archive_write_open_filename(a, bsdtar->filename))
lafe_errc(1, 0, "%s", archive_error_string(a));
write_archive(a, bsdtar);
archive_read_support_format_empty(a);
archive_read_support_format_tar(a);
archive_read_support_format_gnutar(a);
+ set_reader_options(bsdtar, a);
r = archive_read_open_fd(a, bsdtar->fd, 10240);
if (r != ARCHIVE_OK)
lafe_errc(1, archive_errno(a),
}
if (lseek(bsdtar->fd, end_offset, SEEK_SET) < 0)
lafe_errc(1, errno, "Could not seek to archive end");
- if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options))
- lafe_errc(1, 0, "%s", archive_error_string(a));
+ set_writer_options(bsdtar, a);
if (ARCHIVE_OK != archive_write_open_fd(a, bsdtar->fd))
lafe_errc(1, 0, "%s", archive_error_string(a));
archive_read_support_filter_all(a);
archive_read_support_format_tar(a);
archive_read_support_format_gnutar(a);
+ set_reader_options(bsdtar, a);
if (archive_read_open_fd(a, bsdtar->fd, bsdtar->bytes_per_block)
!= ARCHIVE_OK) {
lafe_errc(1, 0,
if (lseek(bsdtar->fd, end_offset, SEEK_SET) < 0)
lafe_errc(1, errno, "Could not seek to archive end");
- if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options))
- lafe_errc(1, 0, "%s", archive_error_string(a));
+ set_writer_options(bsdtar, a);
if (ARCHIVE_OK != archive_write_open_fd(a, bsdtar->fd))
lafe_errc(1, 0, "%s", archive_error_string(a));
ina = archive_read_new();
archive_read_support_format_all(ina);
archive_read_support_filter_all(ina);
+ set_reader_options(bsdtar, a);
if (archive_read_open_filename(ina, filename,
bsdtar->bytes_per_block)) {
lafe_warnc(0, "%s", archive_error_string(ina));