2021-05-19 12:08:57 +02:00
|
|
|
#ifndef RUNNER_H
|
|
|
|
|
#define RUNNER_H
|
|
|
|
|
|
|
|
|
|
#include "Message.h"
|
|
|
|
|
|
2024-02-20 21:56:45 +01:00
|
|
|
#include <deque>
|
2024-02-16 16:54:09 +01:00
|
|
|
#include <filesystem>
|
|
|
|
|
|
2024-02-20 22:15:20 +01:00
|
|
|
void renameThisProcess(char *nameBlob, int blobSize, const char *newName);
|
|
|
|
|
|
2021-05-19 12:08:57 +02:00
|
|
|
class Runner
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-05-20 19:08:42 +02:00
|
|
|
Runner(const Message &message, int errorFile);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The user Id that owns the security manager.
|
|
|
|
|
*/
|
|
|
|
|
void setOwnerUserId(uint32_t uid);
|
2024-02-20 22:15:20 +01:00
|
|
|
void setProcessName(char *name, int allocatedSize);
|
2021-05-19 12:08:57 +02:00
|
|
|
|
2024-02-20 21:56:45 +01:00
|
|
|
void addPipe(int fd) {
|
|
|
|
|
m_pipes.push_back(fd);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-19 12:08:57 +02:00
|
|
|
void run();
|
|
|
|
|
|
|
|
|
|
private:
|
2024-02-25 19:22:08 +01:00
|
|
|
void sendUpstream(const char *errorMessage);
|
2024-02-16 16:54:09 +01:00
|
|
|
bool runCopy(const std::string &from, const std::filesystem::path &to) const;
|
|
|
|
|
bool copySingle(const std::filesystem::path &from, const std::filesystem::path &to) const;
|
2024-02-17 01:03:43 +01:00
|
|
|
// copy env, but filter by the details from m_message
|
|
|
|
|
void copyFilteredEnv(char **from, char **target);
|
2024-02-19 12:07:37 +01:00
|
|
|
void mkdirs(const std::filesystem::path &dir) const;
|
2024-02-24 11:40:42 +01:00
|
|
|
int runInitScript();
|
2021-05-19 12:08:57 +02:00
|
|
|
|
2024-05-17 11:39:44 +02:00
|
|
|
int runEncFs(const char *password, int strlen) const;
|
|
|
|
|
|
2024-02-25 19:22:08 +01:00
|
|
|
const int m_outputFD;
|
2021-05-20 19:08:42 +02:00
|
|
|
uint32_t m_ownerUid = 0;
|
2024-05-17 11:39:44 +02:00
|
|
|
uint32_t m_jailId = 0;
|
2021-05-19 12:08:57 +02:00
|
|
|
Message m_message;
|
2021-05-25 14:24:44 +02:00
|
|
|
|
2026-04-11 14:54:32 +02:00
|
|
|
// vpn stuff
|
|
|
|
|
std::string m_vpnBasePath;
|
|
|
|
|
bool m_vpnHasPwdFile = false;
|
|
|
|
|
std::string m_netNsName;
|
|
|
|
|
|
2021-05-25 14:24:44 +02:00
|
|
|
char *m_processName = nullptr;
|
2024-02-20 22:15:20 +01:00
|
|
|
int m_processNameSize = 0; // the amount of bytes allocated to it.
|
2024-02-20 21:56:45 +01:00
|
|
|
std::deque<int> m_pipes;
|
2021-05-19 12:08:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|