aboutsummaryrefslogtreecommitdiff
path: root/src/lpm.c
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2023-01-01 18:44:09 -0500
committerAdam Harrison <adamdharrison@gmail.com>2023-01-01 18:44:09 -0500
commitf6829ebb5730ec0ee2908ec390b04fc28374f88d (patch)
tree0d337d73c95990eaecf4d5b3e43c2172c959cd4e /src/lpm.c
parent702c1611985f5292da8a0d788d5a009bb217b06e (diff)
downloadlite-xl-plugin-manager-f6829ebb5730ec0ee2908ec390b04fc28374f88d.tar.gz
lite-xl-plugin-manager-f6829ebb5730ec0ee2908ec390b04fc28374f88d.zip
Fixed chmodding on zips.
Diffstat (limited to 'src/lpm.c')
-rw-r--r--src/lpm.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lpm.c b/src/lpm.c
index 2cfe1a6..14d75b8 100644
--- a/src/lpm.c
+++ b/src/lpm.c
@@ -593,14 +593,19 @@ static int lpm_extract(lua_State* L) {
zip_close(archive);
return luaL_error(L, "can't write file %s: %s", target, strerror(errno));
}
+
+ mode_t m = S_IRUSR | S_IRGRP | S_IROTH;
zip_uint8_t os;
zip_uint32_t attr;
zip_file_get_external_attributes(archive, i, 0, &os, &attr);
- mode_t m = S_IRUSR | S_IRGRP | S_IROTH;
- if (0 == (attr & FA_RDONLY))
- m |= S_IWUSR | S_IWGRP | S_IWOTH;
- if (attr & FA_DIREC)
- m = (S_IFDIR | (m & ~S_IFMT)) | S_IXUSR | S_IXGRP | S_IXOTH;
+ if (os == ZIP_OPSYS_DOS) {
+ if (0 == (attr & FA_RDONLY))
+ m |= S_IWUSR | S_IWGRP | S_IWOTH;
+ if (attr & FA_DIREC)
+ m = (S_IFDIR | (m & ~S_IFMT)) | S_IXUSR | S_IXGRP | S_IXOTH;
+ } else {
+ m = (attr >> 16) & ~0222;
+ }
if (chmod(target, m)) {
zip_fclose(zip_file);
zip_close(archive);