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 |
virtual void | closeAndClearFileDescriptors(QVector<int> &fdList) = 0 |
virtual bool | hasRootPrivileges() = 0 |
virtual QStringList | substituteCommand(const QStringList &debugWrapperCommand, const QString &program, const QStringList &arguments) = 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 std::exceptions
on error and will simply return on successful completion.
[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 via sudo
or is setuid-root
and false
otherwise. Root privileges are required for certain operations, such as bindMountFileSystem.
[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.
© 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.