ContainerHelperFunctions Class
A helper class for custom container solutions. More...
Header: | #include <ContainerHelperFunctions> |
Public Functions
virtual void | bindMountFileSystem(const QString &from, const QString &to, bool readOnly, quint64 namespacePid) = 0 |
(since 6.10) virtual QString | checkDBusSocketPath(const QString &dbusAddress, const QByteArray &typeHint) = 0 |
(since 6.10) virtual QString | checkWaylandSocketPath(const QString &xdgRuntimeDir, const QString &waylandDisplay) = 0 |
virtual void | closeAndClearFileDescriptors(QVector<int> &fdList) = 0 |
virtual bool | hasRootPrivileges() = 0 |
virtual QStringList | substituteCommand(const QStringList &debugWrapperCommand, const QString &program, const QStringList &arguments) = 0 |
(since 6.10) virtual int | watchdogSignal() = 0 |
Detailed Description
Your custom container implementation can use these functions to avoid code duplication. Keep in mind that your plugin cannot link to the static application manager libraries, as this would result in duplicate symbols.
A pointer to this interface is given to the plugin via ContainerManagerInterface::initialize(). The plugin does not own this pointer, it is owned by the application manager and valid during the lifetime of the plugin.
Member Function Documentation
[pure virtual]
void ContainerHelperFunctions::bindMountFileSystem(const QString &from, const QString &to, bool readOnly, quint64 namespacePid)
This function bind mounts the file system at from to the mountpoint to. If readOnly is true
, the bind mount will be read-only.
If namespacePid is non-zero, the bind mount will be done in the kernel mount namespace of the process with the given PID. This is useful to bind-mount the application directory into already started containers in case of quick-launching. If namespacePid is zero, the bind mount will be done in the application manager's mount namespace.
Note: This function needs root privileges.
Note: This functions will throw a std::exception
on error and will simply return on successful completion.
[pure virtual, since 6.10]
QString ContainerHelperFunctions::checkDBusSocketPath(const QString &dbusAddress, const QByteArray &typeHint)
This function parses the given dbusAddress to check if the referenced D-Bus socket exists. If it does, this function returns the absolute path to that socket. If the socket does not exist, it throws a std::exception
.
The typeHint is used to provide context for the exception's error message (e.g. "session"
or "p2p"
).
This function was introduced in Qt 6.10.
[pure virtual, since 6.10]
QString ContainerHelperFunctions::checkWaylandSocketPath(const QString &xdgRuntimeDir, const QString &waylandDisplay)
Checks if a Wayland socket exists in the given xdgRuntimeDir named waylandDisplay. If it does, this function returns the absolute path to that socket. If the socket does not exist, it throws a std::exception
.
This function was introduced in Qt 6.10.
[pure virtual]
void ContainerHelperFunctions::closeAndClearFileDescriptors(QVector<int> &fdList)
Convenience function that closes all the file descriptors in the fdList vector and also clears the vector afterwards. Used mainly when dealing with stdio redirections.
[pure virtual]
bool ContainerHelperFunctions::hasRootPrivileges()
Returns true
if the application manager process was started by the root user, and was able to fork off its sudo-helper process.
Root privileges are required for certain operations, such as bindMountFileSystem.
Please see the System Integration page for more information.
[pure virtual]
QStringList ContainerHelperFunctions::substituteCommand(const QStringList &debugWrapperCommand, const QString &program, const QStringList &arguments)
This function substitutes the %program%
and %arguments%
placeholders in the debugWrapperCommand with the actual values of program and arguments. The result is a QStringList that can be used to start the program with the debug-wrapper. If the debugWrapperCommand is empty, an empty QStringList is returned.
[pure virtual, since 6.10]
int ContainerHelperFunctions::watchdogSignal()
Returns the Unix signal that is registered as "killed by watchdog" in the application manager. If applicable, use this when the application manager requests stop with WatchdogExit via ContainerInterface.
This function was introduced in Qt 6.10.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.