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 untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
10 changed files with 480 additions and 173 deletions

View file

@ -0,0 +1,31 @@
#pragma once
#include <iostream>
#include <security/pam_appl.h>
#include "ipc.hpp"
// endls are intentional as it makes debugging much easier when the buffer actually flushes.
// NOLINTBEGIN
#define logIf(log) \
if (log) std::cout << "quickshell.service.pam.subprocess: "
// NOLINTEND
class PamSubprocess {
public:
explicit PamSubprocess(bool log, int fdIn, int fdOut): log(log), pipes(fdIn, fdOut) {}
PamIpcExitCode exec(const char* configDir, const char* config, const char* user);
void sendCode(PamIpcExitCode code);
private:
static int conversation(
int msgCount,
const pam_message** msgArray,
pam_response** responseArray,
void* appdata
);
bool log;
PamIpcPipes pipes;
};