Skip to content

Commit d983ae9

Browse files
committed
fix(server): 修复因为权限降级无法使用 sudo
1 parent 66dd583 commit d983ae9

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/commands/server.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ exports.setOptions = function (optimist) {
3636
};
3737

3838
exports.run = function (options) {
39-
// 权限降级
40-
if (process.env['SUDO_UID']) {
41-
process.setuid(parseInt(process.env['SUDO_UID']));
42-
}
43-
4439
var app = connect(),
4540
cwd = options.cwd,
4641
verbose = options.v || options.verbose,
@@ -376,6 +371,11 @@ exports.run = function (options) {
376371
proxyProcess = child_process.fork(proxyPath);
377372
}
378373

374+
// 权限降级
375+
if (process.env['SUDO_UID']) {
376+
process.setuid(parseInt(process.env['SUDO_UID']));
377+
}
378+
379379
// exitHandler && catches ctrl+c event
380380
process.on('exit', exitHandler.bind(null));
381381
process.on('SIGINT', exitHandler.bind(null));

src/commands/server.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ exports.setOptions = (optimist) => {
3232
};
3333

3434
exports.run = (options) => {
35-
// 权限降级
36-
if (process.env['SUDO_UID']) {
37-
process.setuid(parseInt(process.env['SUDO_UID']));
38-
}
39-
4035
let app = connect(),
4136
cwd = options.cwd,
4237
verbose = options.v || options.verbose,
@@ -367,6 +362,11 @@ exports.run = (options) => {
367362
proxyProcess = child_process.fork(proxyPath);
368363
}
369364

365+
// 权限降级
366+
if (process.env['SUDO_UID']) {
367+
process.setuid(parseInt(process.env['SUDO_UID']));
368+
}
369+
370370
// exitHandler && catches ctrl+c event
371371
process.on('exit', exitHandler.bind(null));
372372
process.on('SIGINT', exitHandler.bind(null));

0 commit comments

Comments
 (0)