fix auto grant

This commit is contained in:
pompurin404 2024-09-21 16:24:01 +08:00
parent ca42519e85
commit cc434a644a
No known key found for this signature in database

View File

@ -226,24 +226,19 @@ export async function autoGrantCorePermition(corePath: string): Promise<void> {
const { encryptedPassword } = await getAppConfig()
const execPromise = promisify(exec)
if (encryptedPassword && isEncryptionAvailable()) {
const password = safeStorage.decryptString(Buffer.from(encryptedPassword))
if (process.platform === 'linux') {
try {
try {
const password = safeStorage.decryptString(Buffer.from(encryptedPassword))
if (process.platform === 'linux') {
await execPromise(`echo "${password}" | sudo -S chown root:root "${corePath}"`)
await execPromise(`echo "${password}" | sudo -S chmod +sx "${corePath}"`)
} catch (error) {
patchAppConfig({ encryptedPassword: undefined })
throw error
}
}
if (process.platform === 'darwin') {
try {
if (process.platform === 'darwin') {
await execPromise(`echo "${password}" | sudo -S chown root:admin "${corePath}"`)
await execPromise(`echo "${password}" | sudo -S chmod +sx "${corePath}"`)
} catch (error) {
patchAppConfig({ encryptedPassword: undefined })
throw error
}
} catch (error) {
patchAppConfig({ encryptedPassword: undefined })
throw error
}
}
}