mirror of
https://github.com/javalsai/lidm.git
synced 2025-08-30 09:58:00 +02:00
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:
34
README.md
34
README.md
@@ -23,20 +23,20 @@ LiDM is like any [Display Manager](https://en.wikipedia.org/wiki/X_display_manag
|
||||
|
||||
# Index
|
||||
|
||||
* [LiDM](#lidm)
|
||||
* [Features](#features)
|
||||
* [WIP](#wip)
|
||||
* [Index](#index)
|
||||
* [Ideology](#ideology)
|
||||
* [Usage](#usage)
|
||||
* [Arguments](#arguments)
|
||||
* [Program](#program)
|
||||
* [Requirements](#requirements)
|
||||
* [Installation](#installation)
|
||||
* [Configuring](#configuring)
|
||||
* [Contributing](#contributing)
|
||||
* [Inspiration](#inspiration)
|
||||
* [Contributors](#contributors)
|
||||
- [LiDM](#lidm)
|
||||
- [Features](#features)
|
||||
- [Index](#index)
|
||||
- [Ideology](#ideology)
|
||||
- [Usage](#usage)
|
||||
- [Arguments](#arguments)
|
||||
- [Program](#program)
|
||||
- [Requirements](#requirements)
|
||||
- [Installation](#installation)
|
||||
- [Configuring](#configuring)
|
||||
- [PAM](#pam)
|
||||
- [Contributing](#contributing)
|
||||
- [Inspiration](#inspiration)
|
||||
- [Contributors](#contributors)
|
||||
|
||||
# Ideology
|
||||
|
||||
@@ -90,6 +90,12 @@ Colors are gonna be put inside `\x1b[...m`, if you don't know what this is check
|
||||
> [!TIP]
|
||||
> If you don't like seeing an element, you can change the fg color of it to be the same as the bg, making it invisible.
|
||||
|
||||
# PAM
|
||||
|
||||
If your distribution does not use the standard PAM service name `login` (`/etc/pam.d/login`) for its PAM services or if you want to use another PAM file, simply set the `LIDM_PAM_SERVICE` env variable to your PAM service name.
|
||||
|
||||
When the env variable is empty it defaults to the `login` PAM service or whatever fallback your distribution packager has defined during compilation.
|
||||
|
||||
# Contributing
|
||||
|
||||
If you want to contribute check the [contribution guide](docs/CONTRIBUTING.md).
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
Contributions are welcome! Here's how you can help:
|
||||
|
||||
* [Contributing code](#code)
|
||||
* [Reporting issues](#issues)
|
||||
* [Other](#other)
|
||||
- [Contributing](#contributing)
|
||||
- [Code](#code)
|
||||
- [Issues](#issues)
|
||||
- [Other](#other)
|
||||
|
||||
## Code
|
||||
|
||||
@@ -18,7 +19,7 @@ For small fixes or incremental improvements simply fork the repo and follow the
|
||||
* Check your code works as expected.
|
||||
* Run the code formatter: `clang-format -i $(git ls-files "*.c" "*.h")`
|
||||
* Run the code linter: `clang-tidy -p . $(git ls-files "*.c" "*.h")`. Some checks are pretty pedantic, feel free to ignore or debate some of the rules.
|
||||
* If you prefer, you can run `make pre-commit` to run several code style checks like the avobe along a few extra stuff.
|
||||
* If you prefer, you can run `make pre-commit` to run several code style checks like the above along a few extra stuff.
|
||||
|
||||
3. Commit your changes to a new branch (not `master`, one change per branch) and push it:
|
||||
* Commit messages should:
|
||||
|
10
src/auth.c
10
src/auth.c
@@ -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))
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user