mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 13:10:30 +08:00
fix auto grant
This commit is contained in:
parent
ca42519e85
commit
cc434a644a
@ -226,27 +226,22 @@ export async function autoGrantCorePermition(corePath: string): Promise<void> {
|
|||||||
const { encryptedPassword } = await getAppConfig()
|
const { encryptedPassword } = await getAppConfig()
|
||||||
const execPromise = promisify(exec)
|
const execPromise = promisify(exec)
|
||||||
if (encryptedPassword && isEncryptionAvailable()) {
|
if (encryptedPassword && isEncryptionAvailable()) {
|
||||||
|
try {
|
||||||
const password = safeStorage.decryptString(Buffer.from(encryptedPassword))
|
const password = safeStorage.decryptString(Buffer.from(encryptedPassword))
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
try {
|
|
||||||
await execPromise(`echo "${password}" | sudo -S chown root:root "${corePath}"`)
|
await execPromise(`echo "${password}" | sudo -S chown root:root "${corePath}"`)
|
||||||
await execPromise(`echo "${password}" | sudo -S chmod +sx "${corePath}"`)
|
await execPromise(`echo "${password}" | sudo -S chmod +sx "${corePath}"`)
|
||||||
} catch (error) {
|
|
||||||
patchAppConfig({ encryptedPassword: undefined })
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
try {
|
|
||||||
await execPromise(`echo "${password}" | sudo -S chown root:admin "${corePath}"`)
|
await execPromise(`echo "${password}" | sudo -S chown root:admin "${corePath}"`)
|
||||||
await execPromise(`echo "${password}" | sudo -S chmod +sx "${corePath}"`)
|
await execPromise(`echo "${password}" | sudo -S chmod +sx "${corePath}"`)
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
patchAppConfig({ encryptedPassword: undefined })
|
patchAppConfig({ encryptedPassword: undefined })
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export async function manualGrantCorePermition(password?: string): Promise<void> {
|
export async function manualGrantCorePermition(password?: string): Promise<void> {
|
||||||
const { core = 'mihomo' } = await getAppConfig()
|
const { core = 'mihomo' } = await getAppConfig()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user