pam_limits: print line number in warning

The line itself is modified while parsing its content. Print the line
number and file name instead so an administrator can investigate it.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
This commit is contained in:
Tobias Stoeckmann 2024-02-07 19:16:03 +01:00
parent 9228077d76
commit 1e2c6cecf8

View File

@ -882,6 +882,7 @@ parse_config_file(pam_handle_t *pamh, const char *uname, uid_t uid, gid_t gid,
FILE *fil;
char *buf = NULL;
size_t n = 0;
unsigned long long lineno = 0;
/* check for the conf_file */
if (ctrl & PAM_DEBUG_ARG)
@ -905,6 +906,8 @@ parse_config_file(pam_handle_t *pamh, const char *uname, uid_t uid, gid_t gid,
size_t j;
uid_t min_uid = (uid_t)-1, max_uid = (uid_t)-1;
lineno++;
line = buf;
/* skip the leading white space */
while (*line && isspace((unsigned char)*line))
@ -1073,7 +1076,8 @@ parse_config_file(pam_handle_t *pamh, const char *uname, uid_t uid, gid_t gid,
fclose(fil);
return PAM_IGNORE;
} else {
pam_syslog(pamh, LOG_WARNING, "invalid line '%s' - skipped", line);
pam_syslog(pamh, LOG_WARNING, "invalid line %llu in '%s' - skipped",
lineno, pl->conf_file);
}
}
free(buf);