| 1 |
/* |
| 2 |
* Test NSS Cache |
| 3 |
*/ |
| 4 |
|
| 5 |
#undef NDEBUG |
| 6 |
#include <c-list.h> |
| 7 |
#include <c-stdaux.h> |
| 8 |
#include <stdlib.h> |
| 9 |
#include "launch/nss-cache.h" |
| 10 |
|
| 11 |
static void test_nss_cache(void) { |
| 12 |
_c_cleanup_(nss_cache_deinit) NSSCache cache = NSS_CACHE_INIT; |
| 13 |
uint32_t uid, gid; |
| 14 |
int r; |
| 15 |
|
| 16 |
r = nss_cache_get_uid(&cache, NULL, NULL, "com.example.InvalidUser"); |
| 17 |
c_assert(r == NSS_CACHE_E_INVALID_NAME); |
| 18 |
|
| 19 |
r = nss_cache_get_gid(&cache, NULL, "com.example.InvalidGroup"); |
| 20 |
c_assert(r == NSS_CACHE_E_INVALID_NAME); |
| 21 |
|
| 22 |
r = nss_cache_get_uid(&cache, &uid, &gid, "root"); |
| 23 |
c_assert(!r); |
| 24 |
c_assert(uid == 0); |
| 25 |
c_assert(gid == 0); |
| 26 |
|
| 27 |
r = nss_cache_get_gid(&cache, &gid, "root"); |
| 28 |
c_assert(!r); |
| 29 |
c_assert(gid == 0); |
| 30 |
} |
| 31 |
|
| 32 |
int main(int argc, char **argv) { |
| 33 |
test_nss_cache(); |
| 34 |
return 0; |
| 35 |
} |