donsetch 3.2.3 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install.js +8 -2
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -74,6 +74,7 @@ if (process.platform === 'linux') {
|
|
|
74
74
|
// skip musl check
|
|
75
75
|
} else {
|
|
76
76
|
let isMusl = false;
|
|
77
|
+
let detected = false;
|
|
77
78
|
try {
|
|
78
79
|
// Read the ELF interpreter of /proc/self/exe (this Node process).
|
|
79
80
|
// The .interp section starts at offset 0x18 in the ELF header
|
|
@@ -98,16 +99,21 @@ if (process.platform === 'linux') {
|
|
|
98
99
|
const p_filesz = ph.readBigUInt64LE(0x20);
|
|
99
100
|
const interp = Buffer.alloc(Number(p_filesz));
|
|
100
101
|
fs.readSync(fd, interp, 0, Number(p_filesz), p_offset);
|
|
101
|
-
fs.closeSync(fd);
|
|
102
102
|
const loaderPath = interp.toString('ascii').replace(/\0/g, '').trim();
|
|
103
103
|
isMusl = loaderPath.includes('ld-musl');
|
|
104
|
+
detected = true;
|
|
104
105
|
break;
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
+
fs.closeSync(fd);
|
|
108
109
|
} catch (_) {
|
|
109
110
|
// /proc/self/exe not readable (some containers). Fall back to
|
|
110
111
|
// the old existence check, but only as a last resort.
|
|
112
|
+
}
|
|
113
|
+
// Only fall back to the existence check if we could not read
|
|
114
|
+
// the ELF interpreter at all. A successful read that found glibc
|
|
115
|
+
// (isMusl=false, detected=true) must NOT fall back.
|
|
116
|
+
if (!detected) {
|
|
111
117
|
isMusl = fs.existsSync('/lib/ld-musl-x86_64.so.1')
|
|
112
118
|
|| fs.existsSync('/lib/ld-musl-aarch64.so.1');
|
|
113
119
|
}
|