File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,16 @@ exports.run = function (options) {
48
48
while ( 1 ) {
49
49
switch ( _context . prev = _context . next ) {
50
50
case 0 :
51
+ // http://man7.org/linux/man-pages/man2/setuid.2.html
52
+ // 以sudo身份执行的时候,会自动设置此环境变量
51
53
if ( process . env [ 'SUDO_UID' ] ) {
52
- process . setuid ( parseInt ( process . env [ 'SUDO_UID' ] ) ) ;
54
+ try {
55
+ process . setuid ( parseInt ( process . env [ 'SUDO_UID' ] ) ) ;
56
+ } catch ( e ) {
57
+ // 这里catch error,处理系统不支持意外,以后权限的问题
58
+ logWarn ( '\u8BBE\u7F6Euid\u4E3A' + process . env [ 'SUDO_UID' ] + '\u53D1\u751F\u4E86\u95EE\u9898\u3002\u5982\u679C\u4E0D\u5F71\u54CD\u6700\u7EC8\u7684pack\u7ED3\u679C\uFF0C\u8BF7\u5FFD\u7565\u3002' ) ;
59
+ logWarn ( e ) ;
60
+ }
53
61
}
54
62
55
63
if ( ( 0 , _keys2 . default ) ( config . entry ) . length === 0 ) {
Original file line number Diff line number Diff line change @@ -46,8 +46,16 @@ exports.run = function (options) {
46
46
start . bind ( this . project ) ( ) . catch ( console . log . bind ( console ) ) ;
47
47
48
48
async function start ( ) {
49
+ // http://man7.org/linux/man-pages/man2/setuid.2.html
50
+ // 以sudo身份执行的时候,会自动设置此环境变量
49
51
if ( process . env [ 'SUDO_UID' ] ) {
50
- process . setuid ( parseInt ( process . env [ 'SUDO_UID' ] ) ) ;
52
+ try {
53
+ process . setuid ( parseInt ( process . env [ 'SUDO_UID' ] ) ) ;
54
+ } catch ( e ) {
55
+ // 这里catch error,处理系统不支持意外,以后权限的问题
56
+ logWarn ( `设置uid为${ process . env [ 'SUDO_UID' ] } 发生了问题。如果不影响最终的pack结果,请忽略。` ) ;
57
+ logWarn ( e ) ;
58
+ }
51
59
}
52
60
53
61
if ( Object . keys ( config . entry ) . length === 0 ) {
You can’t perform that action at this time.
0 commit comments