|
| 1 | +diff --git a/libarchive/archive_read_disk_posix.c b/libarchive/archive_read_disk_posix.c |
| 2 | +index 76a4fa44..ec6d2c79 100644 |
| 3 | +--- a/libarchive/archive_read_disk_posix.c |
| 4 | ++++ b/libarchive/archive_read_disk_posix.c |
| 5 | +@@ -97,8 +97,11 @@ |
| 6 | + #include "archive_private.h" |
| 7 | + #include "archive_read_disk_private.h" |
| 8 | + |
| 9 | ++static int dup(int oldfd) { abort(); } |
| 10 | ++static int fchdir(int fd) { abort(); } |
| 11 | ++ |
| 12 | + #ifndef HAVE_FCHDIR |
| 13 | +-#error fchdir function required. |
| 14 | ++// #error fchdir function required. |
| 15 | + #endif |
| 16 | + #ifndef O_BINARY |
| 17 | + #define O_BINARY 0 |
| 18 | +diff --git a/libarchive/archive_read_disk_set_standard_lookup.c b/libarchive/archive_read_disk_set_standard_lookup.c |
| 19 | +index 3512d343..6ff685f9 100644 |
| 20 | +--- a/libarchive/archive_read_disk_set_standard_lookup.c |
| 21 | ++++ b/libarchive/archive_read_disk_set_standard_lookup.c |
| 22 | +@@ -230,15 +230,7 @@ lookup_uname_helper(struct name_cache *cache, id_t id) |
| 23 | + static const char * |
| 24 | + lookup_uname_helper(struct name_cache *cache, id_t id) |
| 25 | + { |
| 26 | +- struct passwd *result; |
| 27 | +- (void)cache; /* UNUSED */ |
| 28 | +- |
| 29 | +- result = getpwuid((uid_t)id); |
| 30 | +- |
| 31 | +- if (result == NULL) |
| 32 | +- return (NULL); |
| 33 | +- |
| 34 | +- return strdup(result->pw_name); |
| 35 | ++ return (NULL); |
| 36 | + } |
| 37 | + #endif |
| 38 | + |
| 39 | +@@ -297,15 +289,7 @@ lookup_gname_helper(struct name_cache *cache, id_t id) |
| 40 | + static const char * |
| 41 | + lookup_gname_helper(struct name_cache *cache, id_t id) |
| 42 | + { |
| 43 | +- struct group *result; |
| 44 | +- (void)cache; /* UNUSED */ |
| 45 | +- |
| 46 | +- result = getgrgid((gid_t)id); |
| 47 | +- |
| 48 | +- if (result == NULL) |
| 49 | +- return (NULL); |
| 50 | +- |
| 51 | +- return strdup(result->gr_name); |
| 52 | ++ return (NULL); |
| 53 | + } |
| 54 | + #endif |
| 55 | + |
| 56 | +diff --git a/libarchive/archive_read_support_filter_program.c b/libarchive/archive_read_support_filter_program.c |
| 57 | +index 0482c57c..5efd17d2 100644 |
| 58 | +--- a/libarchive/archive_read_support_filter_program.c |
| 59 | ++++ b/libarchive/archive_read_support_filter_program.c |
| 60 | +@@ -226,6 +226,7 @@ program_bidder_bid(struct archive_read_filter_bidder *self, |
| 61 | + static int |
| 62 | + child_stop(struct archive_read_filter *self, struct program_filter *state) |
| 63 | + { |
| 64 | ++#if !defined(__wasi__) |
| 65 | + /* Close our side of the I/O with the child. */ |
| 66 | + if (state->child_stdin != -1) { |
| 67 | + close(state->child_stdin); |
| 68 | +@@ -284,7 +285,7 @@ child_stop(struct archive_read_filter *self, struct program_filter *state) |
| 69 | + WEXITSTATUS(state->exit_status)); |
| 70 | + return (ARCHIVE_WARN); |
| 71 | + } |
| 72 | +- |
| 73 | ++#endif |
| 74 | + return (ARCHIVE_WARN); |
| 75 | + } |
| 76 | + |
| 77 | +@@ -390,6 +391,10 @@ program_reader_vtable = { |
| 78 | + int |
| 79 | + __archive_read_program(struct archive_read_filter *self, const char *cmd) |
| 80 | + { |
| 81 | ++ #if defined(__wasi__) |
| 82 | ++ // We can't run programs but don't want this to fail our whole thing. |
| 83 | ++ return (ARCHIVE_WARN); |
| 84 | ++ #endif |
| 85 | + struct program_filter *state; |
| 86 | + static const size_t out_buf_len = 65536; |
| 87 | + char *out_buf; |
| 88 | +diff --git a/libarchive/archive_write_add_filter_program.c b/libarchive/archive_write_add_filter_program.c |
| 89 | +index c661cc7f..bca03921 100644 |
| 90 | +--- a/libarchive/archive_write_add_filter_program.c |
| 91 | ++++ b/libarchive/archive_write_add_filter_program.c |
| 92 | +@@ -329,6 +329,7 @@ int |
| 93 | + __archive_write_program_close(struct archive_write_filter *f, |
| 94 | + struct archive_write_program_data *data) |
| 95 | + { |
| 96 | ++#if !defined(__wasi__) |
| 97 | + int ret, status; |
| 98 | + ssize_t bytes_read; |
| 99 | + |
| 100 | +@@ -386,5 +387,7 @@ cleanup: |
| 101 | + ret = ARCHIVE_FATAL; |
| 102 | + } |
| 103 | + return ret; |
| 104 | ++#endif |
| 105 | ++ return ARCHIVE_WARN; |
| 106 | + } |
| 107 | + |
| 108 | +diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c |
| 109 | +index bac906d2..9d6a1029 100644 |
| 110 | +--- a/libarchive/archive_write_disk_posix.c |
| 111 | ++++ b/libarchive/archive_write_disk_posix.c |
| 112 | +@@ -637,7 +637,7 @@ _archive_write_disk_header(struct archive *_a, struct archive_entry *entry) |
| 113 | + * user edits their umask during the extraction for some |
| 114 | + * reason. |
| 115 | + */ |
| 116 | +- umask(a->user_umask = umask(0)); |
| 117 | ++ a->user_umask = 0; // umask(a->user_umask = umask(0)); |
| 118 | + |
| 119 | + /* Figure out what we need to do for this entry. */ |
| 120 | + a->todo = TODO_MODE_BASE; |
| 121 | +@@ -2000,7 +2000,8 @@ archive_write_disk_new(void) |
| 122 | + a->archive.vtable = &archive_write_disk_vtable; |
| 123 | + a->start_time = time(NULL); |
| 124 | + /* Query and restore the umask. */ |
| 125 | +- umask(a->user_umask = umask(0)); |
| 126 | ++ // umask(a->user_umask = umask(0)); |
| 127 | ++ a->user_umask = 0; |
| 128 | + #ifdef HAVE_GETEUID |
| 129 | + a->user_uid = geteuid(); |
| 130 | + #endif /* HAVE_GETEUID */ |
| 131 | +diff --git a/libarchive/archive_write_disk_set_standard_lookup.c b/libarchive/archive_write_disk_set_standard_lookup.c |
| 132 | +index 96416989..fc2c1eb4 100644 |
| 133 | +--- a/libarchive/archive_write_disk_set_standard_lookup.c |
| 134 | ++++ b/libarchive/archive_write_disk_set_standard_lookup.c |
| 135 | +@@ -157,7 +157,7 @@ lookup_gid(void *private_data, const char *gname, int64_t gid) |
| 136 | + #elif defined(_WIN32) && !defined(__CYGWIN__) |
| 137 | + /* TODO: do a gname->gid lookup for Windows. */ |
| 138 | + #else |
| 139 | +- #error No way to perform gid lookups on this platform |
| 140 | ++ // #error No way to perform gid lookups on this platform |
| 141 | + #endif |
| 142 | + b->id = (gid_t)gid; |
| 143 | + |
| 144 | +@@ -226,7 +226,7 @@ lookup_uid(void *private_data, const char *uname, int64_t uid) |
| 145 | + #elif defined(_WIN32) && !defined(__CYGWIN__) |
| 146 | + /* TODO: do a uname->uid lookup for Windows. */ |
| 147 | + #else |
| 148 | +- #error No way to look up uids on this platform |
| 149 | ++ // #error No way to look up uids on this platform |
| 150 | + #endif |
| 151 | + b->id = (uid_t)uid; |
| 152 | + |
| 153 | +diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c |
| 154 | +index 2a3ae07f..d4c427fe 100644 |
| 155 | +--- a/libarchive/archive_write_set_format_iso9660.c |
| 156 | ++++ b/libarchive/archive_write_set_format_iso9660.c |
| 157 | +@@ -2524,7 +2524,7 @@ get_tmfromtime(struct tm *tm, time_t *t) |
| 158 | + #if HAVE_LOCALTIME_S |
| 159 | + localtime_s(tm, t); |
| 160 | + #elif HAVE_LOCALTIME_R |
| 161 | +- tzset(); |
| 162 | ++ // tzset(); |
| 163 | + localtime_r(t, tm); |
| 164 | + #else |
| 165 | + memcpy(tm, localtime(t), sizeof(*tm)); |
| 166 | +@@ -5193,8 +5193,8 @@ isoent_create_virtual_dir(struct archive_write *a, struct iso9660 *iso9660, cons |
| 167 | + archive_entry_unset_mtime(file->entry); |
| 168 | + archive_entry_unset_atime(file->entry); |
| 169 | + archive_entry_unset_ctime(file->entry); |
| 170 | +- archive_entry_set_uid(file->entry, getuid()); |
| 171 | +- archive_entry_set_gid(file->entry, getgid()); |
| 172 | ++ // archive_entry_set_uid(file->entry, getuid()); |
| 173 | ++ // archive_entry_set_gid(file->entry, getgid()); |
| 174 | + archive_entry_set_mode(file->entry, 0555 | AE_IFDIR); |
| 175 | + archive_entry_set_nlink(file->entry, 2); |
| 176 | + if (isofile_gen_utility_names(a, file) < ARCHIVE_WARN) { |
| 177 | +@@ -7123,8 +7123,8 @@ isoent_create_boot_catalog(struct archive_write *a, struct isoent *rootent) |
| 178 | + archive_entry_set_mtime(file->entry, iso9660->birth_time, 0); |
| 179 | + archive_entry_set_atime(file->entry, iso9660->birth_time, 0); |
| 180 | + archive_entry_set_ctime(file->entry, iso9660->birth_time, 0); |
| 181 | +- archive_entry_set_uid(file->entry, getuid()); |
| 182 | +- archive_entry_set_gid(file->entry, getgid()); |
| 183 | ++ // archive_entry_set_uid(file->entry, getuid()); |
| 184 | ++ // archive_entry_set_gid(file->entry, getgid()); |
| 185 | + archive_entry_set_mode(file->entry, AE_IFREG | 0444); |
| 186 | + archive_entry_set_nlink(file->entry, 1); |
| 187 | + |
| 188 | +diff --git a/libarchive/filter_fork_posix.c b/libarchive/filter_fork_posix.c |
| 189 | +index c895c08e..8bf73365 100644 |
| 190 | +--- a/libarchive/filter_fork_posix.c |
| 191 | ++++ b/libarchive/filter_fork_posix.c |
| 192 | +@@ -26,6 +26,20 @@ |
| 193 | + |
| 194 | + #include "archive_platform.h" |
| 195 | + |
| 196 | ++#if defined(__wasi__) |
| 197 | ++int |
| 198 | ++__archive_create_child(const char *cmd, int *child_stdin, int *child_stdout, |
| 199 | ++ void *out_child) |
| 200 | ++{ |
| 201 | ++ return -1; |
| 202 | ++} |
| 203 | ++ |
| 204 | ++void |
| 205 | ++__archive_check_child(int in, int out) |
| 206 | ++{ |
| 207 | ++} |
| 208 | ++#endif |
| 209 | ++ |
| 210 | + /* This capability is only available on POSIX systems. */ |
| 211 | + #if defined(HAVE_PIPE) && defined(HAVE_FCNTL) && \ |
| 212 | + (defined(HAVE_FORK) || defined(HAVE_VFORK) || defined(HAVE_POSIX_SPAWNP)) |
0 commit comments