mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
fix path with spaces
This commit is contained in:
parent
74fa513f83
commit
d87fa750c3
@ -167,7 +167,7 @@ export async function autoGrantCorePermition(corePath: string): Promise<void> {
|
|||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
try {
|
try {
|
||||||
await execPromise(
|
await execPromise(
|
||||||
`echo "${password}" | sudo -S setcap cap_net_bind_service,cap_net_admin,cap_sys_ptrace,cap_dac_read_search,cap_dac_override,cap_net_raw=+ep ${corePath}`
|
`echo "${password}" | sudo -S setcap cap_net_bind_service,cap_net_admin,cap_sys_ptrace,cap_dac_read_search,cap_dac_override,cap_net_raw=+ep "${corePath}"`
|
||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
patchAppConfig({ encryptedPassword: undefined })
|
patchAppConfig({ encryptedPassword: undefined })
|
||||||
@ -176,8 +176,8 @@ export async function autoGrantCorePermition(corePath: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
try {
|
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
|
||||||
@ -191,13 +191,13 @@ export async function manualGrantCorePermition(password?: string): Promise<void>
|
|||||||
const corePath = mihomoCorePath(core)
|
const corePath = mihomoCorePath(core)
|
||||||
const execPromise = promisify(exec)
|
const execPromise = promisify(exec)
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
const shell = `chown root:admin ${corePath}\nchmod +sx ${corePath}`
|
const shell = `chown root:admin ${corePath.replace(' ', '\\\\ ')}\nchmod +sx ${corePath.replace(' ', '\\\\ ')}`
|
||||||
const command = `do shell script "${shell}" with administrator privileges`
|
const command = `do shell script "${shell}" with administrator privileges`
|
||||||
await execPromise(`osascript -e '${command}'`)
|
await execPromise(`osascript -e '${command}'`)
|
||||||
}
|
}
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
await execPromise(
|
await execPromise(
|
||||||
`echo "${password}" | sudo -S setcap cap_net_bind_service,cap_net_admin,cap_sys_ptrace,cap_dac_read_search,cap_dac_override,cap_net_raw=+ep ${corePath}`
|
`echo "${password}" | sudo -S setcap cap_net_bind_service,cap_net_admin,cap_sys_ptrace,cap_dac_read_search,cap_dac_override,cap_net_raw=+ep "${corePath}"`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user