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