File indexing completed on 2025-02-02 04:53:18
0001 /* 0002 SPDX-FileCopyrightText: 2023 Thomas Baumgart tbaumgart @kde.org 0003 0004 This file is part of libalkimia. 0005 0006 SPDX-License-Identifier: LGPL-2.1-or-later 0007 */ 0008 0009 #ifndef ALKENVIRONMENT_H 0010 #define ALKENVIRONMENT_H 0011 0012 #include <alkimia/alk_export.h> 0013 0014 class QProcess; 0015 0016 class ALK_EXPORT AlkEnvironment 0017 { 0018 public: 0019 /** 0020 * Check if @a applicationPath (usually argv[0]) is pointing to an application 0021 * inside an AppImage container and setting up certain environment variables 0022 * 0023 * For AppImages we need to set the LD_LIBRARY_PATH to have 0024 * $APPDIR/usr/lib/ as the first entry. We set this up here. 0025 * For security reasons, we extract the directory from argv[0] 0026 * and don't use APPDIR directly. It would otherwise allow to 0027 * add a different library path for non AppImage versions. 0028 * 0029 * Has no function if not running inside AppImage container or 0030 * Q_OS_UNIX is not defined 0031 */ 0032 static void checkForAppImageEnvironment(const char* applicationPath); 0033 0034 /** 0035 * Check if the current application is running inside an AppImage 0036 * container. 0037 * 0038 * @return true Running inside AppImage container 0039 * @return false otherwise 0040 * 0041 * @note Requires checkForAppImageEnvironment() to be run before 0042 */ 0043 static bool isRunningAsAppImage(); 0044 0045 /** 0046 * Adjust the LD_LIBRARY_PATH environment variable to exclude 0047 * the AppImage mount point so that external tools do not try 0048 * to use libs contained inside the AppImage for the @a process 0049 * pointed to by the argument. 0050 * 0051 * Has no function if not running inside AppImage container, 0052 * Q_OS_UNIX is not defined or @a process is @c nullptr 0053 * 0054 * @note Requires checkForAppImageEnvironment() to be run before 0055 */ 0056 static void removeAppImagePathFromLinkLoaderLibPath(QProcess* process); 0057 0058 }; 0059 #endif // ALKENVIRONMENT_H