acl/0001-acl-2.3.2-tests-fix-getpwnam-and-getgrnam.patch
2024-07-19 15:40:56 +02:00

63 lines
2.0 KiB
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 99ed23222f315d1a6efbc240db3ff4ed04db99c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= <lzaoral@redhat.com>
Date: Mon, 10 Jun 2024 16:28:22 +0200
Subject: [PATCH] tests: fix getpwnam and getgrnam
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The calls to these functions would always fail because the size of the buffer
was smaller than the minimum (170000) specified in the test implementations
of getgrnam_r and getpwnam_r. Use test_get*_match directly because getpwnam
and getgrnam should never fail on ERANGE.
This commit fixes the following failure in the test/root/restore.test test:
[21] $ chown bin passwd -- failed
chown: invalid user: bin != ~
Fixes: 3737f000d3f17cd283f51eeacac21a71a3472053 ("use thread-safe getpwnam_r and getgrnam_r")
---
test/test_group.c | 2 +-
test/test_passwd.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/test_group.c b/test/test_group.c
index 96dd612..42d6b07 100644
--- a/test/test_group.c
+++ b/test/test_group.c
@@ -136,7 +136,7 @@ struct group *getgrnam(const char *name)
static struct group grp;
struct group *result;
- (void) getgrnam_r(name, &grp, buf, sizeof(buf), &result);
+ (void) test_getgr_match(&grp, buf, sizeof buf, &result, match_name, name);
return result;
}
diff --git a/test/test_passwd.c b/test/test_passwd.c
index b88ea45..ebe9dce 100644
--- a/test/test_passwd.c
+++ b/test/test_passwd.c
@@ -117,7 +117,7 @@ int getpwnam_r(const char *name, struct passwd *pwd, char *buf, size_t buflen,
*result = NULL;
return ERANGE;
}
- last_buflen =- 1;
+ last_buflen = -1;
return test_getpw_match(pwd, buf, buflen, result, match_name, name);
}
@@ -129,7 +129,7 @@ struct passwd *getpwnam(const char *name)
static struct passwd pwd;
struct passwd *result;
- (void) getpwnam_r(name, &pwd, buf, sizeof(buf), &result);
+ (void) test_getpw_match(&pwd, buf, sizeof(buf), &result, match_name, name);
return result;
}
--
2.45.2