mirror of
https://github.com/javalsai/lidm.git
synced 2025-08-31 02:18:00 +02:00
fix: satify all clang code requirements
This commit is contained in:
4
Makefile
4
Makefile
@@ -138,8 +138,8 @@ pre-commit:
|
|||||||
prettier -c "**/*.md"
|
prettier -c "**/*.md"
|
||||||
git ls-files "*.sh" "*/PKGBUILD" | xargs shellcheck --shell=bash
|
git ls-files "*.sh" "*/PKGBUILD" | xargs shellcheck --shell=bash
|
||||||
clang-format -i $$(git ls-files "*.c" "*.h")
|
clang-format -i $$(git ls-files "*.c" "*.h")
|
||||||
git ls-files -z "*.h" | \
|
git ls-files -z "*.c" "*.h" | \
|
||||||
parallel -j$$(nproc) -q0 --no-notice --will-cite --tty clang-tidy --quiet |& \
|
parallel -j$$(nproc) -q0 --no-notice --will-cite --tty clang-tidy -warnings-as-errors=\* --quiet |& \
|
||||||
grep -v "warnings generated." || true
|
grep -v "warnings generated." || true
|
||||||
|
|
||||||
print-version:
|
print-version:
|
||||||
|
@@ -17,17 +17,17 @@
|
|||||||
struct pamh_getenv_status {
|
struct pamh_getenv_status {
|
||||||
char error_flag;
|
char error_flag;
|
||||||
union {
|
union {
|
||||||
char** envlist;
|
char* NULLABLE* NNULLABLE envlist;
|
||||||
const char* errfn;
|
const char* NNULLABLE errfn;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Doesn't include `source`s
|
// Doesn't include `source`s
|
||||||
struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* handle,
|
struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* NNULLABLE handle,
|
||||||
struct passwd* NNULLABLE pw,
|
struct passwd* NNULLABLE pw,
|
||||||
enum SessionType session_typ);
|
enum SessionType session_typ);
|
||||||
|
|
||||||
void free_envlist(char** NNULLABLE envlist);
|
void free_envlist(char* NULLABLE* NNULLABLE envlist);
|
||||||
pam_handle_t* NULLABLE get_pamh(char* NNULLABLE user, char* NNULLABLE passwd);
|
pam_handle_t* NULLABLE get_pamh(char* NNULLABLE user, char* NNULLABLE passwd);
|
||||||
|
|
||||||
#endif /* PAM_H */
|
#endif /* PAM_H */
|
||||||
|
@@ -19,6 +19,7 @@ char* trim_str(char* str) {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||||
int read_desktop(FILE* fd, void* ctx,
|
int read_desktop(FILE* fd, void* ctx,
|
||||||
struct status (*cb)(void* ctx, char* table, char* key,
|
struct status (*cb)(void* ctx, char* table, char* key,
|
||||||
char* value)) {
|
char* value)) {
|
||||||
|
31
src/pam.c
31
src/pam.c
@@ -76,24 +76,20 @@ char* NULLABLE xdg_ssession_type_str(enum SessionType typ) {
|
|||||||
return xdg_session_type;
|
return xdg_session_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FAIL_ALLOC(status) \
|
#define FAIL_ALLOC() \
|
||||||
{ \
|
{ \
|
||||||
(status).error_flag = PAMH_ERR_ALLOC; \
|
return (struct pamh_getenv_status){.error_flag = PAMH_ERR_ALLOC}; \
|
||||||
return (status); \
|
|
||||||
}
|
}
|
||||||
#define FAIL(status, ERR, ERRFN) \
|
#define FAIL(ERR, ERRFN) \
|
||||||
{ \
|
{ \
|
||||||
(status).error_flag = (ERR); \
|
return (struct pamh_getenv_status){.error_flag = (ERR), .errfn = (ERRFN)}; \
|
||||||
(status).errfn = (ERRFN); \
|
|
||||||
return (status); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* handle,
|
struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* handle,
|
||||||
struct passwd* NNULLABLE pw,
|
struct passwd* NNULLABLE pw,
|
||||||
enum SessionType session_typ) {
|
enum SessionType session_typ) {
|
||||||
struct pamh_getenv_status status;
|
char** raw_envlist = pam_getenvlist(handle);
|
||||||
char** envlist = pam_getenvlist(handle);
|
if (!raw_envlist) FAIL(PAMH_ERR_ERRNO, "pam_getenvlist");
|
||||||
if (!envlist) FAIL(status, PAMH_ERR_ERRNO, "pam_getenvlist");
|
|
||||||
|
|
||||||
struct envpair extra_env[] = {
|
struct envpair extra_env[] = {
|
||||||
{"TERM", getenv("TERM")},
|
{"TERM", getenv("TERM")},
|
||||||
@@ -104,11 +100,12 @@ struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* handle,
|
|||||||
{"LOGNAME", pw->pw_name},
|
{"LOGNAME", pw->pw_name},
|
||||||
{"XDG_SESSION_TYPE", xdg_ssession_type_str(session_typ)}};
|
{"XDG_SESSION_TYPE", xdg_ssession_type_str(session_typ)}};
|
||||||
|
|
||||||
status.error_flag = PAMH_ERR_NOERR;
|
char** envlist = merge_envlist(raw_envlist, extra_env, LEN(extra_env));
|
||||||
status.envlist = merge_envlist(envlist, extra_env, LEN(extra_env));
|
if (!envlist) FAIL_ALLOC();
|
||||||
if (!status.envlist) FAIL_ALLOC(status);
|
return (struct pamh_getenv_status){
|
||||||
|
.error_flag = PAMH_ERR_NOERR,
|
||||||
return status;
|
.envlist = envlist,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef FAIL
|
#undef FAIL
|
||||||
|
@@ -118,6 +118,7 @@ static int fn(const char* fpath, const struct stat* sb, int typeflag) {
|
|||||||
int parse_status = parse_exec_string(ctx.exec, &arg_count, &args);
|
int parse_status = parse_exec_string(ctx.exec, &arg_count, &args);
|
||||||
if (parse_status != 0 || arg_count == 0 || !args[0]) {
|
if (parse_status != 0 || arg_count == 0 || !args[0]) {
|
||||||
log_printf("[E] parsing exec string '%s': %d\n", ctx.exec, parse_status);
|
log_printf("[E] parsing exec string '%s': %d\n", ctx.exec, parse_status);
|
||||||
|
free(this_session);
|
||||||
goto err_parsing;
|
goto err_parsing;
|
||||||
}
|
}
|
||||||
free(ctx.exec);
|
free(ctx.exec);
|
||||||
|
Reference in New Issue
Block a user