mirror of https://github.com/proot-me/proot.git
Do not treat libarchive warnings as errors (#293)
This commit is contained in:
parent
e5a1af0818
commit
3bd4a3c757
|
@ -300,14 +300,22 @@ Archive *new_archive(TALLOC_CTX *context, const Tracee* tracee,
|
||||||
}
|
}
|
||||||
|
|
||||||
status = archive_write_disk_set_options(archive->handle, flags);
|
status = archive_write_disk_set_options(archive->handle, flags);
|
||||||
if (status != ARCHIVE_OK) {
|
if (status == ARCHIVE_WARN) {
|
||||||
|
note(tracee, WARNING, INTERNAL, "set archive options: %s",
|
||||||
|
archive_error_string(archive->handle));
|
||||||
|
}
|
||||||
|
else if (status != ARCHIVE_OK) {
|
||||||
note(tracee, ERROR, INTERNAL, "can't set archive options: %s",
|
note(tracee, ERROR, INTERNAL, "can't set archive options: %s",
|
||||||
archive_error_string(archive->handle));
|
archive_error_string(archive->handle));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = archive_write_disk_set_standard_lookup(archive->handle);
|
status = archive_write_disk_set_standard_lookup(archive->handle);
|
||||||
if (status != ARCHIVE_OK) {
|
if (status == ARCHIVE_WARN) {
|
||||||
|
note(tracee, WARNING, INTERNAL, "set archive lookup: %s",
|
||||||
|
archive_error_string(archive->handle));
|
||||||
|
}
|
||||||
|
else if (status != ARCHIVE_OK) {
|
||||||
note(tracee, ERROR, INTERNAL, "can't set archive lookup: %s",
|
note(tracee, ERROR, INTERNAL, "can't set archive lookup: %s",
|
||||||
archive_error_string(archive->handle));
|
archive_error_string(archive->handle));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -329,7 +337,11 @@ Archive *new_archive(TALLOC_CTX *context, const Tracee* tracee,
|
||||||
|
|
||||||
assert(format.set_format != NULL);
|
assert(format.set_format != NULL);
|
||||||
status = format.set_format(archive->handle);
|
status = format.set_format(archive->handle);
|
||||||
if (status != ARCHIVE_OK) {
|
if (status == ARCHIVE_WARN) {
|
||||||
|
note(tracee, WARNING, INTERNAL, "set archive format: %s",
|
||||||
|
archive_error_string(archive->handle));
|
||||||
|
}
|
||||||
|
else if (status != ARCHIVE_OK) {
|
||||||
note(tracee, ERROR, INTERNAL, "can't set archive format: %s",
|
note(tracee, ERROR, INTERNAL, "can't set archive format: %s",
|
||||||
archive_error_string(archive->handle));
|
archive_error_string(archive->handle));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -344,7 +356,11 @@ Archive *new_archive(TALLOC_CTX *context, const Tracee* tracee,
|
||||||
|
|
||||||
if (format.add_filter != NULL) {
|
if (format.add_filter != NULL) {
|
||||||
status = format.add_filter(archive->handle);
|
status = format.add_filter(archive->handle);
|
||||||
if (status != ARCHIVE_OK) {
|
if (status == ARCHIVE_WARN) {
|
||||||
|
note(tracee, WARNING, INTERNAL, "add archive filter: %s",
|
||||||
|
archive_error_string(archive->handle));
|
||||||
|
}
|
||||||
|
else if (status != ARCHIVE_OK) {
|
||||||
note(tracee, ERROR, INTERNAL, "can't add archive filter: %s",
|
note(tracee, ERROR, INTERNAL, "can't add archive filter: %s",
|
||||||
archive_error_string(archive->handle));
|
archive_error_string(archive->handle));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -353,7 +369,11 @@ Archive *new_archive(TALLOC_CTX *context, const Tracee* tracee,
|
||||||
|
|
||||||
if (format.options != NULL) {
|
if (format.options != NULL) {
|
||||||
status = archive_write_set_options(archive->handle, format.options);
|
status = archive_write_set_options(archive->handle, format.options);
|
||||||
if (status != ARCHIVE_OK) {
|
if (status == ARCHIVE_WARN) {
|
||||||
|
note(tracee, WARNING, INTERNAL, "set archive options: %s",
|
||||||
|
archive_error_string(archive->handle));
|
||||||
|
}
|
||||||
|
else if (status != ARCHIVE_OK) {
|
||||||
note(tracee, ERROR, INTERNAL, "can't set archive options: %s",
|
note(tracee, ERROR, INTERNAL, "can't set archive options: %s",
|
||||||
archive_error_string(archive->handle));
|
archive_error_string(archive->handle));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -396,7 +416,11 @@ Archive *new_archive(TALLOC_CTX *context, const Tracee* tracee,
|
||||||
status = archive_write_open_filename(archive->handle, output);
|
status = archive_write_open_filename(archive->handle, output);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (status != ARCHIVE_OK) {
|
if (status == ARCHIVE_WARN) {
|
||||||
|
note(tracee, WARNING, INTERNAL, "open archive '%s': %s",
|
||||||
|
output, archive_error_string(archive->handle));
|
||||||
|
}
|
||||||
|
else if (status != ARCHIVE_OK) {
|
||||||
note(tracee, ERROR, INTERNAL, "can't open archive '%s': %s",
|
note(tracee, ERROR, INTERNAL, "can't open archive '%s': %s",
|
||||||
output, archive_error_string(archive->handle));
|
output, archive_error_string(archive->handle));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -420,11 +444,11 @@ int finalize_archive(Archive *archive)
|
||||||
archive_entry_linkresolver_free(archive->hardlink_resolver);
|
archive_entry_linkresolver_free(archive->hardlink_resolver);
|
||||||
|
|
||||||
status = archive_write_close(archive->handle);
|
status = archive_write_close(archive->handle);
|
||||||
if (status != ARCHIVE_OK)
|
if (status != ARCHIVE_OK && status != ARCHIVE_WARN)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
status = archive_write_free(archive->handle);
|
status = archive_write_free(archive->handle);
|
||||||
if (status != ARCHIVE_OK)
|
if (status != ARCHIVE_OK && status != ARCHIVE_WARN)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -487,8 +511,12 @@ int archive(const Tracee* tracee, Archive *archive,
|
||||||
}
|
}
|
||||||
|
|
||||||
status = archive_write_header(archive->handle, entry);
|
status = archive_write_header(archive->handle, entry);
|
||||||
if (status != ARCHIVE_OK) {
|
if (status == ARCHIVE_WARN) {
|
||||||
note(tracee, WARNING, INTERNAL, "can't write header for '%s': %s",
|
note(tracee, WARNING, INTERNAL, "write header for '%s': %s",
|
||||||
|
path, archive_error_string(archive->handle));
|
||||||
|
}
|
||||||
|
else if (status != ARCHIVE_OK) {
|
||||||
|
note(tracee, ERROR, INTERNAL, "can't write header for '%s': %s",
|
||||||
path, archive_error_string(archive->handle));
|
path, archive_error_string(archive->handle));
|
||||||
status = -1;
|
status = -1;
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -63,6 +63,11 @@ static int extract_archive(struct archive *archive)
|
||||||
while (archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
|
while (archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
|
||||||
status = archive_read_extract(archive, entry, flags);
|
status = archive_read_extract(archive, entry, flags);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
case ARCHIVE_WARN:
|
||||||
|
note(NULL, WARNING, INTERNAL, "%s: %s",
|
||||||
|
archive_error_string(archive),
|
||||||
|
strerror(archive_errno(archive)));
|
||||||
|
/* FALLTHROUGH */
|
||||||
case ARCHIVE_OK:
|
case ARCHIVE_OK:
|
||||||
note(NULL, INFO, USER, "extracted: %s", archive_entry_pathname(entry));
|
note(NULL, INFO, USER, "extracted: %s", archive_entry_pathname(entry));
|
||||||
break;
|
break;
|
||||||
|
@ -235,7 +240,11 @@ int extract_archive_from_file(const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
status = archive_read_support_format_cpio(archive);
|
status = archive_read_support_format_cpio(archive);
|
||||||
if (status != ARCHIVE_OK) {
|
if (status == ARCHIVE_WARN) {
|
||||||
|
note(NULL, WARNING, INTERNAL, "set archive format: %s",
|
||||||
|
archive_error_string(archive));
|
||||||
|
}
|
||||||
|
else if (status != ARCHIVE_OK) {
|
||||||
note(NULL, ERROR, INTERNAL, "can't set archive format: %s",
|
note(NULL, ERROR, INTERNAL, "can't set archive format: %s",
|
||||||
archive_error_string(archive));
|
archive_error_string(archive));
|
||||||
status = -1;
|
status = -1;
|
||||||
|
@ -243,7 +252,11 @@ int extract_archive_from_file(const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
status = archive_read_support_format_gnutar(archive);
|
status = archive_read_support_format_gnutar(archive);
|
||||||
if (status != ARCHIVE_OK) {
|
if (status == ARCHIVE_WARN) {
|
||||||
|
note(NULL, WARNING, INTERNAL, "set archive format: %s",
|
||||||
|
archive_error_string(archive));
|
||||||
|
}
|
||||||
|
else if (status != ARCHIVE_OK) {
|
||||||
note(NULL, ERROR, INTERNAL, "can't set archive format: %s",
|
note(NULL, ERROR, INTERNAL, "can't set archive format: %s",
|
||||||
archive_error_string(archive));
|
archive_error_string(archive));
|
||||||
status = -1;
|
status = -1;
|
||||||
|
@ -251,7 +264,11 @@ int extract_archive_from_file(const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
status = archive_read_support_filter_gzip(archive);
|
status = archive_read_support_filter_gzip(archive);
|
||||||
if (status != ARCHIVE_OK) {
|
if (status == ARCHIVE_WARN) {
|
||||||
|
note(NULL, WARNING, INTERNAL, "add archive filter: %s",
|
||||||
|
archive_error_string(archive));
|
||||||
|
}
|
||||||
|
else if (status != ARCHIVE_OK) {
|
||||||
note(NULL, ERROR, INTERNAL, "can't add archive filter: %s",
|
note(NULL, ERROR, INTERNAL, "can't add archive filter: %s",
|
||||||
archive_error_string(archive));
|
archive_error_string(archive));
|
||||||
status = -1;
|
status = -1;
|
||||||
|
@ -259,7 +276,11 @@ int extract_archive_from_file(const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
status = archive_read_support_filter_lzop(archive);
|
status = archive_read_support_filter_lzop(archive);
|
||||||
if (status != ARCHIVE_OK) {
|
if (status == ARCHIVE_WARN) {
|
||||||
|
note(NULL, WARNING, INTERNAL, "add archive filter: %s",
|
||||||
|
archive_error_string(archive));
|
||||||
|
}
|
||||||
|
else if (status != ARCHIVE_OK) {
|
||||||
note(NULL, ERROR, INTERNAL, "can't add archive filter: %s",
|
note(NULL, ERROR, INTERNAL, "can't add archive filter: %s",
|
||||||
archive_error_string(archive));
|
archive_error_string(archive));
|
||||||
status = -1;
|
status = -1;
|
||||||
|
@ -283,7 +304,12 @@ int extract_archive_from_file(const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
status = archive_read_open(archive, data, open_callback, read_callback, close_callback);
|
status = archive_read_open(archive, data, open_callback, read_callback, close_callback);
|
||||||
if (status != ARCHIVE_OK) {
|
if (status == ARCHIVE_WARN) {
|
||||||
|
if (archive_error_string(archive) != NULL)
|
||||||
|
note(NULL, WARNING, INTERNAL, "read archive: %s",
|
||||||
|
archive_error_string(archive));
|
||||||
|
}
|
||||||
|
else if (status != ARCHIVE_OK) {
|
||||||
/* Don't complain if no error message were registered,
|
/* Don't complain if no error message were registered,
|
||||||
* ie. when testing for a self-extracting archive. */
|
* ie. when testing for a self-extracting archive. */
|
||||||
if (archive_error_string(archive) != NULL)
|
if (archive_error_string(archive) != NULL)
|
||||||
|
|
Loading…
Reference in New Issue