diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2018-07-02 12:38:33 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2018-07-02 12:38:33 +0000 |
commit | 3cb4106b13aa883f3b704aa4026b78fd36db3756 (patch) | |
tree | 7909fa214055aa344a71b515c8781c03db32ab79 /src/tests/test-all-fallback.c | |
parent | 42c3adc8841167026bb8409cb5e4390a32bff49a (diff) | |
download | nsss-3cb4106b13aa883f3b704aa4026b78fd36db3756.tar.gz nsss-3cb4106b13aa883f3b704aa4026b78fd36db3756.tar.xz nsss-3cb4106b13aa883f3b704aa4026b78fd36db3756.zip |
Add test framework, fix some bugs
Diffstat (limited to 'src/tests/test-all-fallback.c')
-rw-r--r-- | src/tests/test-all-fallback.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/tests/test-all-fallback.c b/src/tests/test-all-fallback.c new file mode 100644 index 0000000..666d2f7 --- /dev/null +++ b/src/tests/test-all-fallback.c @@ -0,0 +1,53 @@ +/* ISC license. */ + +#include <errno.h> +#include <skalibs/buffer.h> +#include <skalibs/strerr2.h> +#include <skalibs/lolstdio.h> +#include <nsss/pwd-def.h> +#include <nsss/grp-def.h> +#include <nsss/nsss-all.h> + +int main (void) +{ + PROG = "test-all-fallback" ; + for (;;) + { + struct passwd *pw ; + errno = 0 ; + pw = nsss_all_getpwent() ; + if (!pw) break ; + lolprintf("%s:%s:%d:%d:%s:%s:%s\n", pw->pw_name, pw->pw_passwd, (int)pw->pw_uid, (int)pw->pw_gid, pw->pw_gecos, pw->pw_dir, pw->pw_shell) ; + } + if (errno) + strerr_diefu1sys(111, "nsss_all_getpwent") ; + nsss_all_endpwent() ; + lolprintf("\n") ; + + { + struct passwd *pw = nsss_all_getpwnam("root") ; + lolprintf("%u\n\n", (unsigned int)pw->pw_uid) ; + } + + for (;;) + { + struct group *gr ; + char **p ; + errno = 0 ; + gr = nsss_all_getgrent() ; + if (!gr) break ; + p = gr->gr_mem ; + lolprintf("%s:%s:%d:", gr->gr_name, gr->gr_passwd, (int)gr->gr_gid) ; + if (*p) + { + while (*p) lolprintf("%s,", *p++) ; + buffer_unput(buffer_1, 1) ; + } + buffer_put(buffer_1, "\n", 1) ; + } + if (errno) + strerr_diefu1sys(111, "nsss_all_getgrent") ; + nsss_all_endgrent() ; + buffer_flush(buffer_1) ; + return 0 ; +} |