mirror of
https://github.com/javalsai/lidm.git
synced 2025-08-31 02:18: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
|
# Index
|
||||||
|
|
||||||
* [LiDM](#lidm)
|
- [LiDM](#lidm)
|
||||||
* [Features](#features)
|
- [Features](#features)
|
||||||
* [WIP](#wip)
|
- [Index](#index)
|
||||||
* [Index](#index)
|
- [Ideology](#ideology)
|
||||||
* [Ideology](#ideology)
|
- [Usage](#usage)
|
||||||
* [Usage](#usage)
|
- [Arguments](#arguments)
|
||||||
* [Arguments](#arguments)
|
- [Program](#program)
|
||||||
* [Program](#program)
|
- [Requirements](#requirements)
|
||||||
* [Requirements](#requirements)
|
- [Installation](#installation)
|
||||||
* [Installation](#installation)
|
- [Configuring](#configuring)
|
||||||
* [Configuring](#configuring)
|
- [PAM](#pam)
|
||||||
* [Contributing](#contributing)
|
- [Contributing](#contributing)
|
||||||
* [Inspiration](#inspiration)
|
- [Inspiration](#inspiration)
|
||||||
* [Contributors](#contributors)
|
- [Contributors](#contributors)
|
||||||
|
|
||||||
# Ideology
|
# Ideology
|
||||||
|
|
||||||
@@ -90,6 +90,12 @@ Colors are gonna be put inside `\x1b[...m`, if you don't know what this is check
|
|||||||
> [!TIP]
|
> [!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.
|
> 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
|
# Contributing
|
||||||
|
|
||||||
If you want to contribute check the [contribution guide](docs/CONTRIBUTING.md).
|
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:
|
Contributions are welcome! Here's how you can help:
|
||||||
|
|
||||||
* [Contributing code](#code)
|
- [Contributing](#contributing)
|
||||||
* [Reporting issues](#issues)
|
- [Code](#code)
|
||||||
* [Other](#other)
|
- [Issues](#issues)
|
||||||
|
- [Other](#other)
|
||||||
|
|
||||||
## Code
|
## Code
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ For small fixes or incremental improvements simply fork the repo and follow the
|
|||||||
* Check your code works as expected.
|
* Check your code works as expected.
|
||||||
* Run the code formatter: `clang-format -i $(git ls-files "*.c" "*.h")`
|
* 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.
|
* 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:
|
3. Commit your changes to a new branch (not `master`, one change per branch) and push it:
|
||||||
* Commit messages should:
|
* 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;
|
return PAM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PAM_SERVICE_FALLBACK
|
||||||
|
#define PAM_SERVICE_FALLBACK "login"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CHECK_PAM_RET(call) \
|
#define CHECK_PAM_RET(call) \
|
||||||
ret = (call); \
|
ret = (call); \
|
||||||
if (ret != PAM_SUCCESS) { \
|
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};
|
struct pam_conv pamc = {pam_conversation, (void*)passwd};
|
||||||
int ret;
|
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_authenticate(pamh, 0))
|
||||||
CHECK_PAM_RET(pam_acct_mgmt(pamh, 0))
|
CHECK_PAM_RET(pam_acct_mgmt(pamh, 0))
|
||||||
CHECK_PAM_RET(pam_setcred(pamh, PAM_ESTABLISH_CRED))
|
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
|
buf_start[eq_idx] = '\0'; // the equal
|
||||||
key = trim_str(key);
|
key = trim_str(key);
|
||||||
char* value = &buf_start[eq_idx + 1];
|
char* value = &buf_start[eq_idx + 1];
|
||||||
if(buf_start[read_size - 1] == '\n')
|
if (buf_start[read_size - 1] == '\n') buf_start[read_size - 1] = '\0';
|
||||||
buf_start[read_size - 1] = '\0';
|
|
||||||
value = trim_str(value);
|
value = trim_str(value);
|
||||||
|
|
||||||
// Callback
|
// Callback
|
||||||
|
Reference in New Issue
Block a user