aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2024-01-02 21:36:01 +0100
committerDmitry V. Levin <ldv@strace.io>2024-01-03 17:16:02 +0000
commit5a0b61224f538d832d4f88b169524c138648b0c2 (patch)
tree0e034daf5225c457821a061cfe5cc6541d160858 /modules
parent1a2b73ac0befb25b4d297649a96636ca830a79f5 (diff)
downloadpam-5a0b61224f538d832d4f88b169524c138648b0c2.tar.gz
pam-5a0b61224f538d832d4f88b169524c138648b0c2.tar.bz2
pam-5a0b61224f538d832d4f88b169524c138648b0c2.zip
pam_unix: reduce variable visibility
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'modules')
-rw-r--r--modules/pam_unix/support.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/pam_unix/support.c b/modules/pam_unix/support.c
index df5044e9..a4e24210 100644
--- a/modules/pam_unix/support.c
+++ b/modules/pam_unix/support.c
@@ -346,13 +346,12 @@ static void _unix_cleanup(pam_handle_t *pamh UNUSED, void *data, int error_statu
int _unix_getpwnam(pam_handle_t *pamh, const char *name,
int files, int nis, struct passwd **ret)
{
- FILE *passwd;
char *buf = NULL;
int matched = 0;
- char *slogin, *spasswd, *suid, *sgid, *sgecos, *shome, *sshell, *p;
- size_t retlen;
if (!matched && files && strchr(name, ':') == NULL) {
+ FILE *passwd;
+
passwd = fopen("/etc/passwd", "r");
if (passwd != NULL) {
size_t n = 0, userlen;
@@ -363,6 +362,8 @@ int _unix_getpwnam(pam_handle_t *pamh, const char *name,
while ((r = getline(&buf, &n, passwd)) != -1) {
if ((size_t)r > userlen && (buf[userlen] == ':') &&
(strncmp(name, buf, userlen) == 0)) {
+ char *p;
+
p = buf + strlen(buf) - 1;
while (isspace((unsigned char)*p) && (p >= buf)) {
*p-- = '\0';
@@ -401,6 +402,9 @@ int _unix_getpwnam(pam_handle_t *pamh, const char *name,
#endif
if (matched && (ret != NULL)) {
+ char *slogin, *spasswd, *suid, *sgid, *sgecos, *shome, *sshell, *p;
+ size_t retlen;
+
*ret = NULL;
slogin = buf;