mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
fix: remove core privilege check on non-windows
This commit is contained in:
parent
d8d79f7b7d
commit
4997e098ba
@ -487,22 +487,8 @@ export async function checkHighPrivilegeCore(): Promise<boolean> {
|
||||
}
|
||||
|
||||
if (process.platform === 'darwin' || process.platform === 'linux') {
|
||||
const { stat, existsSync } = await import('fs')
|
||||
const { promisify } = await import('util')
|
||||
const statAsync = promisify(stat)
|
||||
|
||||
if (!existsSync(corePath)) {
|
||||
await managerLogger.info('Core file does not exist')
|
||||
return false
|
||||
}
|
||||
|
||||
const stats = await statAsync(corePath)
|
||||
const hasSetuid = (stats.mode & 0o4000) !== 0
|
||||
const isOwnedByRoot = stats.uid === 0
|
||||
|
||||
await managerLogger.info(`Core file stats - setuid: ${hasSetuid}, owned by root: ${isOwnedByRoot}, mode: ${stats.mode.toString(8)}`)
|
||||
|
||||
return hasSetuid && isOwnedByRoot
|
||||
await managerLogger.info('Non-Windows platform, skipping high privilege core check')
|
||||
return false
|
||||
}
|
||||
} catch (error) {
|
||||
await managerLogger.error('Failed to check high privilege core', error)
|
||||
|
||||
@ -113,25 +113,21 @@ if (process.platform === 'win32' && !exePath().startsWith('C')) {
|
||||
app.commandLine.appendSwitch('in-process-gpu')
|
||||
}
|
||||
|
||||
// 内核检测
|
||||
// 运行内核检测
|
||||
async function checkHighPrivilegeCoreEarly(): Promise<void> {
|
||||
if (process.platform !== 'win32') {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await initBasic()
|
||||
|
||||
// 应用管理员权限运行,跳过检测
|
||||
if (process.platform === 'win32') {
|
||||
const { checkAdminPrivileges } = await import('./core/manager')
|
||||
const isCurrentAppAdmin = await checkAdminPrivileges()
|
||||
const { checkAdminPrivileges } = await import('./core/manager')
|
||||
const isCurrentAppAdmin = await checkAdminPrivileges()
|
||||
|
||||
if (isCurrentAppAdmin) {
|
||||
console.log('Current app is running as administrator, skipping privilege check')
|
||||
return
|
||||
}
|
||||
} else if (process.platform === 'darwin' || process.platform === 'linux') {
|
||||
if (process.getuid && process.getuid() === 0) {
|
||||
console.log('Current app is running as root, skipping privilege check')
|
||||
return
|
||||
}
|
||||
if (isCurrentAppAdmin) {
|
||||
console.log('Current app is running as administrator, skipping privilege check')
|
||||
return
|
||||
}
|
||||
|
||||
const hasHighPrivilegeCore = await checkHighPrivilegeCore()
|
||||
@ -155,7 +151,7 @@ async function checkHighPrivilegeCoreEarly(): Promise<void> {
|
||||
|
||||
if (choice === 0) {
|
||||
try {
|
||||
// 非TUN重启
|
||||
// Windows 平台重启应用获取管理员权限
|
||||
await restartAsAdmin(false)
|
||||
process.exit(0)
|
||||
} catch (error) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user