-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.c
33 lines (28 loc) · 734 Bytes
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//#include "headers.h"
#include <pwd.h>
/**
* test iam users retrieve
*/
#ifdef TEST
#include <string.h>
#include <stdio.h>
#include "headers.h"
#include "libnss_iam.h"
#include "pam.h"
int main(int argc, char** argv) {
char buffer[1024];
struct passwd p;
memset(buffer, '0', 1024);
if (argc > 1)
strcpy(buffer, argv[1]);
if (get_posix_iam_user(buffer, 1024, &p)) {
printf("%s (%d)\n", p.pw_name, p.pw_uid);
if (get_posix_iam_user_by_uid(p.pw_uid, buffer, 1024, &p))
printf("%s (%d)\n", p.pw_name, p.pw_uid);
}
if (argc > 2) {
int ret = iam_authenticate(argv[1], argv[2], argc > 2 ? argv[3] : NULL);
printf("Ret: %d\n", ret);
}
}
#endif