feat(PAM service configuration) (#62)

* docs(typo): fix typo in Contributing.md

* add optional PAM service name

* feat(PAM service name): Add ENV variable configuration for the PAM service name

* feat(PAM service name): Implement suggested changes + update README instructions

* docs(remove segment)
This commit is contained in:
SpamixOfficial
2025-07-16 14:53:23 +02:00
committed by GitHub
parent 8fc6bff60f
commit 589f33ffec
4 changed files with 35 additions and 21 deletions

View File

@@ -35,6 +35,10 @@ int pam_conversation(int num_msg, const struct pam_message** msg,
return PAM_SUCCESS;
}
#ifndef PAM_SERVICE_FALLBACK
#define PAM_SERVICE_FALLBACK "login"
#endif
#define CHECK_PAM_RET(call) \
ret = (call); \
if (ret != PAM_SUCCESS) { \
@@ -51,7 +55,11 @@ pam_handle_t* get_pamh(char* user, char* passwd) {
struct pam_conv pamc = {pam_conversation, (void*)passwd};
int ret;
CHECK_PAM_RET(pam_start("login", user, &pamc, &pamh))
char* pam_service_override = getenv("LIDM_PAM_SERVICE");
char* pam_service_name =
pam_service_override ? pam_service_override : PAM_SERVICE_FALLBACK;
CHECK_PAM_RET(pam_start(pam_service_name, user, &pamc, &pamh))
CHECK_PAM_RET(pam_authenticate(pamh, 0))
CHECK_PAM_RET(pam_acct_mgmt(pamh, 0))
CHECK_PAM_RET(pam_setcred(pamh, PAM_ESTABLISH_CRED))

View File

@@ -66,8 +66,7 @@ int read_desktop(FILE* fd, void* ctx,
buf_start[eq_idx] = '\0'; // the equal
key = trim_str(key);
char* value = &buf_start[eq_idx + 1];
if(buf_start[read_size - 1] == '\n')
buf_start[read_size - 1] = '\0';
if (buf_start[read_size - 1] == '\n') buf_start[read_size - 1] = '\0';
value = trim_str(value);
// Callback