unplugin-https-reverse-proxy 4.1.0-beta.10 → 4.1.0-beta.12
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/dist/{chunk-U7KAIPZC.js → chunk-OVYS4ED4.js} +21 -6
- package/dist/esbuild.cjs +21 -6
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +21 -6
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +21 -6
- package/dist/nuxt.js +1 -1
- package/dist/privileged-helper.cjs +34 -10
- package/dist/privileged-helper.js +34 -10
- package/dist/rollup.cjs +21 -6
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +21 -6
- package/dist/rspack.js +1 -1
- package/dist/vite.cjs +21 -6
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +21 -6
- package/dist/webpack.js +1 -1
- package/package.json +1 -1
- package/src/caddy/index.ts +3 -1
- package/src/privileged/launch.ts +20 -8
- package/src/privileged/path-guard.ts +35 -10
|
@@ -13659,16 +13659,29 @@ async function startPrivilegedHelper(options) {
|
|
|
13659
13659
|
stdio: ["ignore", "pipe", "pipe"]
|
|
13660
13660
|
});
|
|
13661
13661
|
(_a4 = child.stdout) == null ? void 0 : _a4.on("data", (data) => log == null ? void 0 : log(data.toString().trimEnd()));
|
|
13662
|
-
|
|
13663
|
-
|
|
13662
|
+
let stderr = "";
|
|
13663
|
+
(_b3 = child.stderr) == null ? void 0 : _b3.on("data", (data) => {
|
|
13664
|
+
stderr = (stderr + data.toString()).slice(-4096);
|
|
13665
|
+
log == null ? void 0 : log(data.toString().trimEnd());
|
|
13666
|
+
});
|
|
13667
|
+
const exited = new Promise((resolve2) => {
|
|
13668
|
+
child.once("error", (error) => {
|
|
13669
|
+
stderr = error.message;
|
|
13670
|
+
});
|
|
13671
|
+
child.once("close", (code) => resolve2(code));
|
|
13672
|
+
});
|
|
13664
13673
|
const earlyExit = await Promise.race([
|
|
13665
13674
|
exited,
|
|
13666
13675
|
new Promise((resolve2) => setTimeout(() => resolve2(void 0), 500))
|
|
13667
13676
|
]);
|
|
13668
13677
|
if (earlyExit !== void 0 && earlyExit !== 0) {
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
)
|
|
13678
|
+
const detail = stderr.trim();
|
|
13679
|
+
let guidance = "";
|
|
13680
|
+
if (/\b(?:EACCES|EPERM)\b/.test(detail))
|
|
13681
|
+
guidance = " Check the path named above and its parent directories. Fix ownership or access manually; do not use chmod 777.";
|
|
13682
|
+
else if (!direct && /^sudo:/m.test(detail))
|
|
13683
|
+
guidance = " Retry from a terminal where sudo can request permission, or ask an administrator to grant access.";
|
|
13684
|
+
throw new Error(`privileged helper exited with code ${earlyExit}.${detail ? ` ${detail}${guidance}` : " No diagnostic output from the helper or sudo."}`);
|
|
13672
13685
|
}
|
|
13673
13686
|
}
|
|
13674
13687
|
try {
|
|
@@ -14099,8 +14112,10 @@ var CaddyInstant = class {
|
|
|
14099
14112
|
async session(reason) {
|
|
14100
14113
|
if (this._session && !this._session.client.connected)
|
|
14101
14114
|
this._session = void 0;
|
|
14102
|
-
if (!this._session)
|
|
14115
|
+
if (!this._session) {
|
|
14116
|
+
await this.deps.config().writeCaddyConfig([], this.proxyKey);
|
|
14103
14117
|
this._session = await this.deps.openSession(TEMP_DIR, reason);
|
|
14118
|
+
}
|
|
14104
14119
|
return this._session;
|
|
14105
14120
|
}
|
|
14106
14121
|
async getCaddyfile() {
|
package/dist/esbuild.cjs
CHANGED
|
@@ -13758,16 +13758,29 @@ async function startPrivilegedHelper(options) {
|
|
|
13758
13758
|
stdio: ["ignore", "pipe", "pipe"]
|
|
13759
13759
|
});
|
|
13760
13760
|
(_a4 = child.stdout) == null ? void 0 : _a4.on("data", (data) => log == null ? void 0 : log(data.toString().trimEnd()));
|
|
13761
|
-
|
|
13762
|
-
|
|
13761
|
+
let stderr = "";
|
|
13762
|
+
(_b3 = child.stderr) == null ? void 0 : _b3.on("data", (data) => {
|
|
13763
|
+
stderr = (stderr + data.toString()).slice(-4096);
|
|
13764
|
+
log == null ? void 0 : log(data.toString().trimEnd());
|
|
13765
|
+
});
|
|
13766
|
+
const exited = new Promise((resolve2) => {
|
|
13767
|
+
child.once("error", (error) => {
|
|
13768
|
+
stderr = error.message;
|
|
13769
|
+
});
|
|
13770
|
+
child.once("close", (code) => resolve2(code));
|
|
13771
|
+
});
|
|
13763
13772
|
const earlyExit = await Promise.race([
|
|
13764
13773
|
exited,
|
|
13765
13774
|
new Promise((resolve2) => setTimeout(() => resolve2(void 0), 500))
|
|
13766
13775
|
]);
|
|
13767
13776
|
if (earlyExit !== void 0 && earlyExit !== 0) {
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
)
|
|
13777
|
+
const detail = stderr.trim();
|
|
13778
|
+
let guidance = "";
|
|
13779
|
+
if (/\b(?:EACCES|EPERM)\b/.test(detail))
|
|
13780
|
+
guidance = " Check the path named above and its parent directories. Fix ownership or access manually; do not use chmod 777.";
|
|
13781
|
+
else if (!direct && /^sudo:/m.test(detail))
|
|
13782
|
+
guidance = " Retry from a terminal where sudo can request permission, or ask an administrator to grant access.";
|
|
13783
|
+
throw new Error(`privileged helper exited with code ${earlyExit}.${detail ? ` ${detail}${guidance}` : " No diagnostic output from the helper or sudo."}`);
|
|
13771
13784
|
}
|
|
13772
13785
|
}
|
|
13773
13786
|
try {
|
|
@@ -14199,8 +14212,10 @@ var CaddyInstant = class {
|
|
|
14199
14212
|
async session(reason) {
|
|
14200
14213
|
if (this._session && !this._session.client.connected)
|
|
14201
14214
|
this._session = void 0;
|
|
14202
|
-
if (!this._session)
|
|
14215
|
+
if (!this._session) {
|
|
14216
|
+
await this.deps.config().writeCaddyConfig([], this.proxyKey);
|
|
14203
14217
|
this._session = await this.deps.openSession(TEMP_DIR, reason);
|
|
14218
|
+
}
|
|
14204
14219
|
return this._session;
|
|
14205
14220
|
}
|
|
14206
14221
|
async getCaddyfile() {
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -13758,16 +13758,29 @@ async function startPrivilegedHelper(options) {
|
|
|
13758
13758
|
stdio: ["ignore", "pipe", "pipe"]
|
|
13759
13759
|
});
|
|
13760
13760
|
(_a4 = child.stdout) == null ? void 0 : _a4.on("data", (data) => log == null ? void 0 : log(data.toString().trimEnd()));
|
|
13761
|
-
|
|
13762
|
-
|
|
13761
|
+
let stderr = "";
|
|
13762
|
+
(_b3 = child.stderr) == null ? void 0 : _b3.on("data", (data) => {
|
|
13763
|
+
stderr = (stderr + data.toString()).slice(-4096);
|
|
13764
|
+
log == null ? void 0 : log(data.toString().trimEnd());
|
|
13765
|
+
});
|
|
13766
|
+
const exited = new Promise((resolve2) => {
|
|
13767
|
+
child.once("error", (error) => {
|
|
13768
|
+
stderr = error.message;
|
|
13769
|
+
});
|
|
13770
|
+
child.once("close", (code) => resolve2(code));
|
|
13771
|
+
});
|
|
13763
13772
|
const earlyExit = await Promise.race([
|
|
13764
13773
|
exited,
|
|
13765
13774
|
new Promise((resolve2) => setTimeout(() => resolve2(void 0), 500))
|
|
13766
13775
|
]);
|
|
13767
13776
|
if (earlyExit !== void 0 && earlyExit !== 0) {
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
)
|
|
13777
|
+
const detail = stderr.trim();
|
|
13778
|
+
let guidance = "";
|
|
13779
|
+
if (/\b(?:EACCES|EPERM)\b/.test(detail))
|
|
13780
|
+
guidance = " Check the path named above and its parent directories. Fix ownership or access manually; do not use chmod 777.";
|
|
13781
|
+
else if (!direct && /^sudo:/m.test(detail))
|
|
13782
|
+
guidance = " Retry from a terminal where sudo can request permission, or ask an administrator to grant access.";
|
|
13783
|
+
throw new Error(`privileged helper exited with code ${earlyExit}.${detail ? ` ${detail}${guidance}` : " No diagnostic output from the helper or sudo."}`);
|
|
13771
13784
|
}
|
|
13772
13785
|
}
|
|
13773
13786
|
try {
|
|
@@ -14199,8 +14212,10 @@ var CaddyInstant = class {
|
|
|
14199
14212
|
async session(reason) {
|
|
14200
14213
|
if (this._session && !this._session.client.connected)
|
|
14201
14214
|
this._session = void 0;
|
|
14202
|
-
if (!this._session)
|
|
14215
|
+
if (!this._session) {
|
|
14216
|
+
await this.deps.config().writeCaddyConfig([], this.proxyKey);
|
|
14203
14217
|
this._session = await this.deps.openSession(TEMP_DIR, reason);
|
|
14218
|
+
}
|
|
14204
14219
|
return this._session;
|
|
14205
14220
|
}
|
|
14206
14221
|
async getCaddyfile() {
|
package/dist/index.js
CHANGED
package/dist/nuxt.cjs
CHANGED
|
@@ -13759,16 +13759,29 @@ async function startPrivilegedHelper(options) {
|
|
|
13759
13759
|
stdio: ["ignore", "pipe", "pipe"]
|
|
13760
13760
|
});
|
|
13761
13761
|
(_a4 = child.stdout) == null ? void 0 : _a4.on("data", (data) => log == null ? void 0 : log(data.toString().trimEnd()));
|
|
13762
|
-
|
|
13763
|
-
|
|
13762
|
+
let stderr = "";
|
|
13763
|
+
(_b3 = child.stderr) == null ? void 0 : _b3.on("data", (data) => {
|
|
13764
|
+
stderr = (stderr + data.toString()).slice(-4096);
|
|
13765
|
+
log == null ? void 0 : log(data.toString().trimEnd());
|
|
13766
|
+
});
|
|
13767
|
+
const exited = new Promise((resolve2) => {
|
|
13768
|
+
child.once("error", (error) => {
|
|
13769
|
+
stderr = error.message;
|
|
13770
|
+
});
|
|
13771
|
+
child.once("close", (code) => resolve2(code));
|
|
13772
|
+
});
|
|
13764
13773
|
const earlyExit = await Promise.race([
|
|
13765
13774
|
exited,
|
|
13766
13775
|
new Promise((resolve2) => setTimeout(() => resolve2(void 0), 500))
|
|
13767
13776
|
]);
|
|
13768
13777
|
if (earlyExit !== void 0 && earlyExit !== 0) {
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
)
|
|
13778
|
+
const detail = stderr.trim();
|
|
13779
|
+
let guidance = "";
|
|
13780
|
+
if (/\b(?:EACCES|EPERM)\b/.test(detail))
|
|
13781
|
+
guidance = " Check the path named above and its parent directories. Fix ownership or access manually; do not use chmod 777.";
|
|
13782
|
+
else if (!direct && /^sudo:/m.test(detail))
|
|
13783
|
+
guidance = " Retry from a terminal where sudo can request permission, or ask an administrator to grant access.";
|
|
13784
|
+
throw new Error(`privileged helper exited with code ${earlyExit}.${detail ? ` ${detail}${guidance}` : " No diagnostic output from the helper or sudo."}`);
|
|
13772
13785
|
}
|
|
13773
13786
|
}
|
|
13774
13787
|
try {
|
|
@@ -14200,8 +14213,10 @@ var CaddyInstant = class {
|
|
|
14200
14213
|
async session(reason) {
|
|
14201
14214
|
if (this._session && !this._session.client.connected)
|
|
14202
14215
|
this._session = void 0;
|
|
14203
|
-
if (!this._session)
|
|
14216
|
+
if (!this._session) {
|
|
14217
|
+
await this.deps.config().writeCaddyConfig([], this.proxyKey);
|
|
14204
14218
|
this._session = await this.deps.openSession(TEMP_DIR, reason);
|
|
14219
|
+
}
|
|
14205
14220
|
return this._session;
|
|
14206
14221
|
}
|
|
14207
14222
|
async getCaddyfile() {
|
package/dist/nuxt.js
CHANGED
|
@@ -42,21 +42,45 @@ function checkPrivilegedPath(path, options) {
|
|
|
42
42
|
try {
|
|
43
43
|
stats = (0, import_node_fs.lstatSync)(path);
|
|
44
44
|
} catch (error) {
|
|
45
|
-
return {
|
|
45
|
+
return {
|
|
46
|
+
path,
|
|
47
|
+
reason: `${options.label} is not readable: ${error.message}`,
|
|
48
|
+
guidance: "Check that this path exists and that you can access its parent directories. Fix access manually; do not make the path group- or world-writable."
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (stats.isSymbolicLink()) {
|
|
52
|
+
return {
|
|
53
|
+
path,
|
|
54
|
+
reason: `${options.label} is a symbolic link (${describe(stats)})`,
|
|
55
|
+
guidance: "Replace this symlink with a regular file manually or reinstall the affected file; do not bypass the safety check."
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (!stats.isFile() && !stats.isDirectory()) {
|
|
59
|
+
return {
|
|
60
|
+
path,
|
|
61
|
+
reason: `${options.label} is neither a file nor a directory`,
|
|
62
|
+
guidance: "Provide a regular file or directory at this path manually."
|
|
63
|
+
};
|
|
46
64
|
}
|
|
47
|
-
if (stats.isSymbolicLink())
|
|
48
|
-
return { path, reason: `${options.label} is a symbolic link (${describe(stats)})` };
|
|
49
|
-
if (!stats.isFile() && !stats.isDirectory())
|
|
50
|
-
return { path, reason: `${options.label} is neither a file nor a directory` };
|
|
51
65
|
const allowedOwner = stats.uid === 0 || options.ownerUid !== void 0 && stats.uid === options.ownerUid;
|
|
52
|
-
if (!allowedOwner)
|
|
53
|
-
return {
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
if (!allowedOwner) {
|
|
67
|
+
return {
|
|
68
|
+
path,
|
|
69
|
+
reason: `${options.label} is owned by another user (${describe(stats)})`,
|
|
70
|
+
guidance: "Check ownership manually. This path must be owned by root or the user running the dev server."
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (stats.mode & 18) {
|
|
74
|
+
return {
|
|
75
|
+
path,
|
|
76
|
+
reason: `${options.label} is group- or world-writable (${describe(stats)})`,
|
|
77
|
+
guidance: "Remove group and world write access manually; do not use chmod 777."
|
|
78
|
+
};
|
|
79
|
+
}
|
|
56
80
|
return void 0;
|
|
57
81
|
}
|
|
58
82
|
function describeRejection(rejection) {
|
|
59
|
-
return `refusing to start: ${rejection.reason} (${rejection.path})`;
|
|
83
|
+
return `refusing to start: ${rejection.reason} (${rejection.path}). ${rejection.guidance}`;
|
|
60
84
|
}
|
|
61
85
|
|
|
62
86
|
// src/privileged/server.ts
|
|
@@ -22,21 +22,45 @@ function checkPrivilegedPath(path, options) {
|
|
|
22
22
|
try {
|
|
23
23
|
stats = lstatSync(path);
|
|
24
24
|
} catch (error) {
|
|
25
|
-
return {
|
|
25
|
+
return {
|
|
26
|
+
path,
|
|
27
|
+
reason: `${options.label} is not readable: ${error.message}`,
|
|
28
|
+
guidance: "Check that this path exists and that you can access its parent directories. Fix access manually; do not make the path group- or world-writable."
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (stats.isSymbolicLink()) {
|
|
32
|
+
return {
|
|
33
|
+
path,
|
|
34
|
+
reason: `${options.label} is a symbolic link (${describe(stats)})`,
|
|
35
|
+
guidance: "Replace this symlink with a regular file manually or reinstall the affected file; do not bypass the safety check."
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (!stats.isFile() && !stats.isDirectory()) {
|
|
39
|
+
return {
|
|
40
|
+
path,
|
|
41
|
+
reason: `${options.label} is neither a file nor a directory`,
|
|
42
|
+
guidance: "Provide a regular file or directory at this path manually."
|
|
43
|
+
};
|
|
26
44
|
}
|
|
27
|
-
if (stats.isSymbolicLink())
|
|
28
|
-
return { path, reason: `${options.label} is a symbolic link (${describe(stats)})` };
|
|
29
|
-
if (!stats.isFile() && !stats.isDirectory())
|
|
30
|
-
return { path, reason: `${options.label} is neither a file nor a directory` };
|
|
31
45
|
const allowedOwner = stats.uid === 0 || options.ownerUid !== void 0 && stats.uid === options.ownerUid;
|
|
32
|
-
if (!allowedOwner)
|
|
33
|
-
return {
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
if (!allowedOwner) {
|
|
47
|
+
return {
|
|
48
|
+
path,
|
|
49
|
+
reason: `${options.label} is owned by another user (${describe(stats)})`,
|
|
50
|
+
guidance: "Check ownership manually. This path must be owned by root or the user running the dev server."
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (stats.mode & 18) {
|
|
54
|
+
return {
|
|
55
|
+
path,
|
|
56
|
+
reason: `${options.label} is group- or world-writable (${describe(stats)})`,
|
|
57
|
+
guidance: "Remove group and world write access manually; do not use chmod 777."
|
|
58
|
+
};
|
|
59
|
+
}
|
|
36
60
|
return void 0;
|
|
37
61
|
}
|
|
38
62
|
function describeRejection(rejection) {
|
|
39
|
-
return `refusing to start: ${rejection.reason} (${rejection.path})`;
|
|
63
|
+
return `refusing to start: ${rejection.reason} (${rejection.path}). ${rejection.guidance}`;
|
|
40
64
|
}
|
|
41
65
|
|
|
42
66
|
// src/privileged/server.ts
|
package/dist/rollup.cjs
CHANGED
|
@@ -13758,16 +13758,29 @@ async function startPrivilegedHelper(options) {
|
|
|
13758
13758
|
stdio: ["ignore", "pipe", "pipe"]
|
|
13759
13759
|
});
|
|
13760
13760
|
(_a4 = child.stdout) == null ? void 0 : _a4.on("data", (data) => log == null ? void 0 : log(data.toString().trimEnd()));
|
|
13761
|
-
|
|
13762
|
-
|
|
13761
|
+
let stderr = "";
|
|
13762
|
+
(_b3 = child.stderr) == null ? void 0 : _b3.on("data", (data) => {
|
|
13763
|
+
stderr = (stderr + data.toString()).slice(-4096);
|
|
13764
|
+
log == null ? void 0 : log(data.toString().trimEnd());
|
|
13765
|
+
});
|
|
13766
|
+
const exited = new Promise((resolve2) => {
|
|
13767
|
+
child.once("error", (error) => {
|
|
13768
|
+
stderr = error.message;
|
|
13769
|
+
});
|
|
13770
|
+
child.once("close", (code) => resolve2(code));
|
|
13771
|
+
});
|
|
13763
13772
|
const earlyExit = await Promise.race([
|
|
13764
13773
|
exited,
|
|
13765
13774
|
new Promise((resolve2) => setTimeout(() => resolve2(void 0), 500))
|
|
13766
13775
|
]);
|
|
13767
13776
|
if (earlyExit !== void 0 && earlyExit !== 0) {
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
)
|
|
13777
|
+
const detail = stderr.trim();
|
|
13778
|
+
let guidance = "";
|
|
13779
|
+
if (/\b(?:EACCES|EPERM)\b/.test(detail))
|
|
13780
|
+
guidance = " Check the path named above and its parent directories. Fix ownership or access manually; do not use chmod 777.";
|
|
13781
|
+
else if (!direct && /^sudo:/m.test(detail))
|
|
13782
|
+
guidance = " Retry from a terminal where sudo can request permission, or ask an administrator to grant access.";
|
|
13783
|
+
throw new Error(`privileged helper exited with code ${earlyExit}.${detail ? ` ${detail}${guidance}` : " No diagnostic output from the helper or sudo."}`);
|
|
13771
13784
|
}
|
|
13772
13785
|
}
|
|
13773
13786
|
try {
|
|
@@ -14199,8 +14212,10 @@ var CaddyInstant = class {
|
|
|
14199
14212
|
async session(reason) {
|
|
14200
14213
|
if (this._session && !this._session.client.connected)
|
|
14201
14214
|
this._session = void 0;
|
|
14202
|
-
if (!this._session)
|
|
14215
|
+
if (!this._session) {
|
|
14216
|
+
await this.deps.config().writeCaddyConfig([], this.proxyKey);
|
|
14203
14217
|
this._session = await this.deps.openSession(TEMP_DIR, reason);
|
|
14218
|
+
}
|
|
14204
14219
|
return this._session;
|
|
14205
14220
|
}
|
|
14206
14221
|
async getCaddyfile() {
|
package/dist/rollup.js
CHANGED
package/dist/rspack.cjs
CHANGED
|
@@ -13757,16 +13757,29 @@ async function startPrivilegedHelper(options) {
|
|
|
13757
13757
|
stdio: ["ignore", "pipe", "pipe"]
|
|
13758
13758
|
});
|
|
13759
13759
|
(_a4 = child.stdout) == null ? void 0 : _a4.on("data", (data) => log == null ? void 0 : log(data.toString().trimEnd()));
|
|
13760
|
-
|
|
13761
|
-
|
|
13760
|
+
let stderr = "";
|
|
13761
|
+
(_b3 = child.stderr) == null ? void 0 : _b3.on("data", (data) => {
|
|
13762
|
+
stderr = (stderr + data.toString()).slice(-4096);
|
|
13763
|
+
log == null ? void 0 : log(data.toString().trimEnd());
|
|
13764
|
+
});
|
|
13765
|
+
const exited = new Promise((resolve2) => {
|
|
13766
|
+
child.once("error", (error) => {
|
|
13767
|
+
stderr = error.message;
|
|
13768
|
+
});
|
|
13769
|
+
child.once("close", (code) => resolve2(code));
|
|
13770
|
+
});
|
|
13762
13771
|
const earlyExit = await Promise.race([
|
|
13763
13772
|
exited,
|
|
13764
13773
|
new Promise((resolve2) => setTimeout(() => resolve2(void 0), 500))
|
|
13765
13774
|
]);
|
|
13766
13775
|
if (earlyExit !== void 0 && earlyExit !== 0) {
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
)
|
|
13776
|
+
const detail = stderr.trim();
|
|
13777
|
+
let guidance = "";
|
|
13778
|
+
if (/\b(?:EACCES|EPERM)\b/.test(detail))
|
|
13779
|
+
guidance = " Check the path named above and its parent directories. Fix ownership or access manually; do not use chmod 777.";
|
|
13780
|
+
else if (!direct && /^sudo:/m.test(detail))
|
|
13781
|
+
guidance = " Retry from a terminal where sudo can request permission, or ask an administrator to grant access.";
|
|
13782
|
+
throw new Error(`privileged helper exited with code ${earlyExit}.${detail ? ` ${detail}${guidance}` : " No diagnostic output from the helper or sudo."}`);
|
|
13770
13783
|
}
|
|
13771
13784
|
}
|
|
13772
13785
|
try {
|
|
@@ -14198,8 +14211,10 @@ var CaddyInstant = class {
|
|
|
14198
14211
|
async session(reason) {
|
|
14199
14212
|
if (this._session && !this._session.client.connected)
|
|
14200
14213
|
this._session = void 0;
|
|
14201
|
-
if (!this._session)
|
|
14214
|
+
if (!this._session) {
|
|
14215
|
+
await this.deps.config().writeCaddyConfig([], this.proxyKey);
|
|
14202
14216
|
this._session = await this.deps.openSession(TEMP_DIR, reason);
|
|
14217
|
+
}
|
|
14203
14218
|
return this._session;
|
|
14204
14219
|
}
|
|
14205
14220
|
async getCaddyfile() {
|
package/dist/rspack.js
CHANGED
package/dist/vite.cjs
CHANGED
|
@@ -13758,16 +13758,29 @@ async function startPrivilegedHelper(options) {
|
|
|
13758
13758
|
stdio: ["ignore", "pipe", "pipe"]
|
|
13759
13759
|
});
|
|
13760
13760
|
(_a4 = child.stdout) == null ? void 0 : _a4.on("data", (data) => log == null ? void 0 : log(data.toString().trimEnd()));
|
|
13761
|
-
|
|
13762
|
-
|
|
13761
|
+
let stderr = "";
|
|
13762
|
+
(_b3 = child.stderr) == null ? void 0 : _b3.on("data", (data) => {
|
|
13763
|
+
stderr = (stderr + data.toString()).slice(-4096);
|
|
13764
|
+
log == null ? void 0 : log(data.toString().trimEnd());
|
|
13765
|
+
});
|
|
13766
|
+
const exited = new Promise((resolve2) => {
|
|
13767
|
+
child.once("error", (error) => {
|
|
13768
|
+
stderr = error.message;
|
|
13769
|
+
});
|
|
13770
|
+
child.once("close", (code) => resolve2(code));
|
|
13771
|
+
});
|
|
13763
13772
|
const earlyExit = await Promise.race([
|
|
13764
13773
|
exited,
|
|
13765
13774
|
new Promise((resolve2) => setTimeout(() => resolve2(void 0), 500))
|
|
13766
13775
|
]);
|
|
13767
13776
|
if (earlyExit !== void 0 && earlyExit !== 0) {
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
)
|
|
13777
|
+
const detail = stderr.trim();
|
|
13778
|
+
let guidance = "";
|
|
13779
|
+
if (/\b(?:EACCES|EPERM)\b/.test(detail))
|
|
13780
|
+
guidance = " Check the path named above and its parent directories. Fix ownership or access manually; do not use chmod 777.";
|
|
13781
|
+
else if (!direct && /^sudo:/m.test(detail))
|
|
13782
|
+
guidance = " Retry from a terminal where sudo can request permission, or ask an administrator to grant access.";
|
|
13783
|
+
throw new Error(`privileged helper exited with code ${earlyExit}.${detail ? ` ${detail}${guidance}` : " No diagnostic output from the helper or sudo."}`);
|
|
13771
13784
|
}
|
|
13772
13785
|
}
|
|
13773
13786
|
try {
|
|
@@ -14199,8 +14212,10 @@ var CaddyInstant = class {
|
|
|
14199
14212
|
async session(reason) {
|
|
14200
14213
|
if (this._session && !this._session.client.connected)
|
|
14201
14214
|
this._session = void 0;
|
|
14202
|
-
if (!this._session)
|
|
14215
|
+
if (!this._session) {
|
|
14216
|
+
await this.deps.config().writeCaddyConfig([], this.proxyKey);
|
|
14203
14217
|
this._session = await this.deps.openSession(TEMP_DIR, reason);
|
|
14218
|
+
}
|
|
14204
14219
|
return this._session;
|
|
14205
14220
|
}
|
|
14206
14221
|
async getCaddyfile() {
|
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -13758,16 +13758,29 @@ async function startPrivilegedHelper(options) {
|
|
|
13758
13758
|
stdio: ["ignore", "pipe", "pipe"]
|
|
13759
13759
|
});
|
|
13760
13760
|
(_a4 = child.stdout) == null ? void 0 : _a4.on("data", (data) => log == null ? void 0 : log(data.toString().trimEnd()));
|
|
13761
|
-
|
|
13762
|
-
|
|
13761
|
+
let stderr = "";
|
|
13762
|
+
(_b3 = child.stderr) == null ? void 0 : _b3.on("data", (data) => {
|
|
13763
|
+
stderr = (stderr + data.toString()).slice(-4096);
|
|
13764
|
+
log == null ? void 0 : log(data.toString().trimEnd());
|
|
13765
|
+
});
|
|
13766
|
+
const exited = new Promise((resolve2) => {
|
|
13767
|
+
child.once("error", (error) => {
|
|
13768
|
+
stderr = error.message;
|
|
13769
|
+
});
|
|
13770
|
+
child.once("close", (code) => resolve2(code));
|
|
13771
|
+
});
|
|
13763
13772
|
const earlyExit = await Promise.race([
|
|
13764
13773
|
exited,
|
|
13765
13774
|
new Promise((resolve2) => setTimeout(() => resolve2(void 0), 500))
|
|
13766
13775
|
]);
|
|
13767
13776
|
if (earlyExit !== void 0 && earlyExit !== 0) {
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
)
|
|
13777
|
+
const detail = stderr.trim();
|
|
13778
|
+
let guidance = "";
|
|
13779
|
+
if (/\b(?:EACCES|EPERM)\b/.test(detail))
|
|
13780
|
+
guidance = " Check the path named above and its parent directories. Fix ownership or access manually; do not use chmod 777.";
|
|
13781
|
+
else if (!direct && /^sudo:/m.test(detail))
|
|
13782
|
+
guidance = " Retry from a terminal where sudo can request permission, or ask an administrator to grant access.";
|
|
13783
|
+
throw new Error(`privileged helper exited with code ${earlyExit}.${detail ? ` ${detail}${guidance}` : " No diagnostic output from the helper or sudo."}`);
|
|
13771
13784
|
}
|
|
13772
13785
|
}
|
|
13773
13786
|
try {
|
|
@@ -14199,8 +14212,10 @@ var CaddyInstant = class {
|
|
|
14199
14212
|
async session(reason) {
|
|
14200
14213
|
if (this._session && !this._session.client.connected)
|
|
14201
14214
|
this._session = void 0;
|
|
14202
|
-
if (!this._session)
|
|
14215
|
+
if (!this._session) {
|
|
14216
|
+
await this.deps.config().writeCaddyConfig([], this.proxyKey);
|
|
14203
14217
|
this._session = await this.deps.openSession(TEMP_DIR, reason);
|
|
14218
|
+
}
|
|
14204
14219
|
return this._session;
|
|
14205
14220
|
}
|
|
14206
14221
|
async getCaddyfile() {
|
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
package/src/caddy/index.ts
CHANGED
|
@@ -212,8 +212,10 @@ export class CaddyInstant {
|
|
|
212
212
|
if (this._session && !this._session.client.connected)
|
|
213
213
|
this._session = undefined
|
|
214
214
|
|
|
215
|
-
if (!this._session)
|
|
215
|
+
if (!this._session) {
|
|
216
|
+
await this.deps.config().writeCaddyConfig([], this.proxyKey)
|
|
216
217
|
this._session = await this.deps.openSession(TEMP_DIR, reason)
|
|
218
|
+
}
|
|
217
219
|
return this._session
|
|
218
220
|
}
|
|
219
221
|
|
package/src/privileged/launch.ts
CHANGED
|
@@ -279,22 +279,34 @@ export async function startPrivilegedHelper(options: LaunchOptions): Promise<Pri
|
|
|
279
279
|
})
|
|
280
280
|
|
|
281
281
|
child.stdout?.on('data', (data: Buffer) => log?.(data.toString().trimEnd()))
|
|
282
|
-
|
|
282
|
+
let stderr = ''
|
|
283
|
+
child.stderr?.on('data', (data: Buffer) => {
|
|
284
|
+
stderr = (stderr + data.toString()).slice(-4096)
|
|
285
|
+
log?.(data.toString().trimEnd())
|
|
286
|
+
})
|
|
283
287
|
|
|
284
|
-
const exited = new Promise<number | null>(resolve =>
|
|
288
|
+
const exited = new Promise<number | null>((resolve) => {
|
|
289
|
+
child!.once('error', (error) => {
|
|
290
|
+
stderr = error.message
|
|
291
|
+
})
|
|
292
|
+
child!.once('close', code => resolve(code))
|
|
293
|
+
})
|
|
285
294
|
|
|
286
|
-
//
|
|
287
|
-
//
|
|
295
|
+
// A failed helper should report its own diagnostic (or sudo's) before the
|
|
296
|
+
// connection timeout. A nonzero exit does not imply denied permission.
|
|
288
297
|
const earlyExit = await Promise.race([
|
|
289
298
|
exited,
|
|
290
299
|
new Promise<undefined>(resolve => setTimeout(() => resolve(undefined), 500)),
|
|
291
300
|
])
|
|
292
301
|
|
|
293
302
|
if (earlyExit !== undefined && earlyExit !== 0) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
303
|
+
const detail = stderr.trim()
|
|
304
|
+
let guidance = ''
|
|
305
|
+
if (/\b(?:EACCES|EPERM)\b/.test(detail))
|
|
306
|
+
guidance = ' Check the path named above and its parent directories. Fix ownership or access manually; do not use chmod 777.'
|
|
307
|
+
else if (!direct && /^sudo:/m.test(detail))
|
|
308
|
+
guidance = ' Retry from a terminal where sudo can request permission, or ask an administrator to grant access.'
|
|
309
|
+
throw new Error(`privileged helper exited with code ${earlyExit}.${detail ? ` ${detail}${guidance}` : ' No diagnostic output from the helper or sudo.'}`)
|
|
298
310
|
}
|
|
299
311
|
}
|
|
300
312
|
|
|
@@ -12,6 +12,7 @@ import { lstatSync } from 'node:fs'
|
|
|
12
12
|
export interface PathRejection {
|
|
13
13
|
path: string
|
|
14
14
|
reason: string
|
|
15
|
+
guidance: string
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export interface PathCheckOptions {
|
|
@@ -47,28 +48,52 @@ export function checkPrivilegedPath(
|
|
|
47
48
|
stats = lstatSync(path)
|
|
48
49
|
}
|
|
49
50
|
catch (error) {
|
|
50
|
-
return {
|
|
51
|
+
return {
|
|
52
|
+
path,
|
|
53
|
+
reason: `${options.label} is not readable: ${(error as Error).message}`,
|
|
54
|
+
guidance: 'Check that this path exists and that you can access its parent directories. Fix access manually; do not make the path group- or world-writable.',
|
|
55
|
+
}
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
if (stats.isSymbolicLink())
|
|
54
|
-
return {
|
|
58
|
+
if (stats.isSymbolicLink()) {
|
|
59
|
+
return {
|
|
60
|
+
path,
|
|
61
|
+
reason: `${options.label} is a symbolic link (${describe(stats)})`,
|
|
62
|
+
guidance: 'Replace this symlink with a regular file manually or reinstall the affected file; do not bypass the safety check.',
|
|
63
|
+
}
|
|
64
|
+
}
|
|
55
65
|
|
|
56
|
-
if (!stats.isFile() && !stats.isDirectory())
|
|
57
|
-
return {
|
|
66
|
+
if (!stats.isFile() && !stats.isDirectory()) {
|
|
67
|
+
return {
|
|
68
|
+
path,
|
|
69
|
+
reason: `${options.label} is neither a file nor a directory`,
|
|
70
|
+
guidance: 'Provide a regular file or directory at this path manually.',
|
|
71
|
+
}
|
|
72
|
+
}
|
|
58
73
|
|
|
59
74
|
const allowedOwner = stats.uid === 0 || (options.ownerUid !== undefined && stats.uid === options.ownerUid)
|
|
60
|
-
if (!allowedOwner)
|
|
61
|
-
return {
|
|
75
|
+
if (!allowedOwner) {
|
|
76
|
+
return {
|
|
77
|
+
path,
|
|
78
|
+
reason: `${options.label} is owned by another user (${describe(stats)})`,
|
|
79
|
+
guidance: 'Check ownership manually. This path must be owned by root or the user running the dev server.',
|
|
80
|
+
}
|
|
81
|
+
}
|
|
62
82
|
|
|
63
83
|
// Root's own files are fine at 644/755; the point is that no one else can
|
|
64
84
|
// write them.
|
|
65
|
-
if (stats.mode & 0o022)
|
|
66
|
-
return {
|
|
85
|
+
if (stats.mode & 0o022) {
|
|
86
|
+
return {
|
|
87
|
+
path,
|
|
88
|
+
reason: `${options.label} is group- or world-writable (${describe(stats)})`,
|
|
89
|
+
guidance: 'Remove group and world write access manually; do not use chmod 777.',
|
|
90
|
+
}
|
|
91
|
+
}
|
|
67
92
|
|
|
68
93
|
return undefined
|
|
69
94
|
}
|
|
70
95
|
|
|
71
96
|
/** Formats a rejection for the helper log; one place keeps the wording stable. */
|
|
72
97
|
export function describeRejection(rejection: PathRejection): string {
|
|
73
|
-
return `refusing to start: ${rejection.reason} (${rejection.path})`
|
|
98
|
+
return `refusing to start: ${rejection.reason} (${rejection.path}). ${rejection.guidance}`
|
|
74
99
|
}
|