From cc434a644aefe9bacdde1044288e3b7522cd7969 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Sat, 21 Sep 2024 16:24:01 +0800 Subject: [PATCH] fix auto grant --- src/main/core/manager.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/main/core/manager.ts b/src/main/core/manager.ts index 49841ee..e7e08d7 100644 --- a/src/main/core/manager.ts +++ b/src/main/core/manager.ts @@ -226,24 +226,19 @@ export async function autoGrantCorePermition(corePath: string): Promise { 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 } } }