From 3937fbe25f37d22a77d0f4fe5a266376bc0fa34a Mon Sep 17 00:00:00 2001 From: Etaash Mathamsetty Date: Mon, 27 Nov 2023 15:20:50 -0500 Subject: [PATCH 1/2] [FIX] Mark wineprefixes starting with XDG_RUNTIME_DIR as invalid --- src/backend/api/misc.ts | 2 ++ src/backend/main.ts | 10 +++++++++ src/common/typedefs/ipcBridge.d.ts | 1 + .../InstallModal/DownloadDialog/index.tsx | 7 +++++-- .../InstallModal/SideloadDialog/index.tsx | 11 ++++++++-- .../InstallModal/WineSelector/index.tsx | 21 +++++++++++++++++-- .../Library/components/InstallModal/index.tsx | 7 +++++++ 7 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/backend/api/misc.ts b/src/backend/api/misc.ts index 95d01404ae..38b492f887 100644 --- a/src/backend/api/misc.ts +++ b/src/backend/api/misc.ts @@ -103,6 +103,8 @@ export const getFonts = async (reload: boolean) => ipcRenderer.invoke('getFonts', reload) export const checkDiskSpace = async (installPath: string) => ipcRenderer.invoke('checkDiskSpace', installPath) +export const checkWinePrefix = async (prefix: string) => + ipcRenderer.invoke('checkWinePrefix', prefix) export const getGOGLinuxInstallersLangs = async (appName: string) => ipcRenderer.invoke('getGOGLinuxInstallersLangs', appName) export const getAlternativeWine = async () => diff --git a/src/backend/main.ts b/src/backend/main.ts index 020a689eeb..cd2afd072f 100644 --- a/src/backend/main.ts +++ b/src/backend/main.ts @@ -600,6 +600,16 @@ ipcMain.handle('checkDiskSpace', async (event, folder) => { }) }) +ipcMain.handle('checkWinePrefix', async (event, prefix) => { + const isValidFlatpakPath = !( + isFlatpak && prefix.startsWith(process.env.XDG_RUNTIME_DIR || '/run/user/') + ) + + logDebug(`Checking wine prefix ${prefix}`, LogPrefix.Backend) + + return isValidFlatpakPath +}) + ipcMain.handle('isFrameless', () => isFrameless()) ipcMain.handle('isMinimized', () => !!getMainWindow()?.isMinimized()) ipcMain.handle('isMaximized', () => !!getMainWindow()?.isMaximized()) diff --git a/src/common/typedefs/ipcBridge.d.ts b/src/common/typedefs/ipcBridge.d.ts index 7c917db4e1..a83b2c0b0b 100644 --- a/src/common/typedefs/ipcBridge.d.ts +++ b/src/common/typedefs/ipcBridge.d.ts @@ -122,6 +122,7 @@ interface AsyncIPCFunctions { addToDMQueue: (element: DMQueueElement) => Promise kill: (appName: string, runner: Runner) => Promise checkDiskSpace: (folder: string) => Promise + checkWinePrefix: (prefix: string) => Promise callTool: (args: Tools) => Promise runWineCommand: ( args: WineCommandArgs diff --git a/src/frontend/screens/Library/components/InstallModal/DownloadDialog/index.tsx b/src/frontend/screens/Library/components/InstallModal/DownloadDialog/index.tsx index f6cb87d901..317a0af08c 100644 --- a/src/frontend/screens/Library/components/InstallModal/DownloadDialog/index.tsx +++ b/src/frontend/screens/Library/components/InstallModal/DownloadDialog/index.tsx @@ -60,6 +60,7 @@ interface Props { wineVersion: WineInstallation | undefined children: React.ReactNode gameInfo: GameInfo + validWinePrefix: boolean } type DiskSpaceInfo = { @@ -116,7 +117,8 @@ export default function DownloadDialog({ wineVersion, children, gameInfo, - crossoverBottle + crossoverBottle, + validWinePrefix }: Props) { const previousProgress = JSON.parse( storage.getItem(appName) || '{}' @@ -422,7 +424,8 @@ export default function DownloadDialog({ installPath && gameInstallInfo?.manifest?.download_size && !gettingInstallInfo && - validFlatpakPath + validFlatpakPath && + validWinePrefix const showDlcSelector = runner === 'legendary' && DLCList && DLCList?.length > 0 diff --git a/src/frontend/screens/Library/components/InstallModal/SideloadDialog/index.tsx b/src/frontend/screens/Library/components/InstallModal/SideloadDialog/index.tsx index 8824b4035d..7fe436d1ac 100644 --- a/src/frontend/screens/Library/components/InstallModal/SideloadDialog/index.tsx +++ b/src/frontend/screens/Library/components/InstallModal/SideloadDialog/index.tsx @@ -34,6 +34,7 @@ type Props = { platformToInstall: InstallPlatform backdropClick: () => void appName?: string + validWinePrefix: boolean } export default function SideloadDialog({ @@ -45,7 +46,8 @@ export default function SideloadDialog({ platformToInstall, setWinePrefix, children, - appName + appName, + validWinePrefix }: Props) { const { t } = useTranslation('gamepage') const [title, setTitle] = useState( @@ -389,7 +391,12 @@ export default function SideloadDialog({