service/pam: move pam execution to subprocess to allow killing it

Many pam modules can't be aborted well without this.
This commit is contained in:
outfoxxed 2024-06-18 03:29:25 -07:00
parent b5c8774a79
commit e89035b18c
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
10 changed files with 480 additions and 173 deletions

43
src/services/pam/ipc.hpp Normal file
View file

@ -0,0 +1,43 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <string>
#include <qtclasshelpermacros.h>
enum class PamIpcEvent : uint8_t {
Request,
Exit,
};
enum class PamIpcExitCode : uint8_t {
Success,
StartFailed,
AuthFailed,
MaxTries,
PamError,
OtherError,
};
struct PamIpcRequestFlags {
bool echo;
bool error;
bool responseRequired;
};
class PamIpcPipes {
public:
explicit PamIpcPipes() = default;
explicit PamIpcPipes(int fdIn, int fdOut): fdIn(fdIn), fdOut(fdOut) {}
~PamIpcPipes();
Q_DISABLE_COPY_MOVE(PamIpcPipes);
[[nodiscard]] bool readBytes(char* buffer, size_t length) const;
[[nodiscard]] bool writeBytes(const char* buffer, size_t length) const;
[[nodiscard]] std::string readString(bool* ok) const;
[[nodiscard]] bool writeString(const std::string& string) const;
int fdIn = 0;
int fdOut = 0;
};