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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
* t_walk_rtree.c --- test krb5_walk_realm_tree
*/
#include "k5-int.h"
#include <stdio.h>
#include "com_err.h"
main(argc, argv)
int argc;
char **argv;
{
krb5_data client, server;
char realm_branch_char = '.';
krb5_principal *tree, *p;
char *name;
krb5_error_code retval;
krb5_context context;
krb5_init_context(&context);
if (argc < 3 || argc > 4) {
fprintf(stderr,
"Usage: %s client-realm server-realm [sep_char]\n",
argv[0]);
exit(99);
}
client.data = argv[1];
client.length = strlen(client.data);
server.data = argv[2];
server.length = strlen(server.data);
if (argc == 4)
realm_branch_char = argv[3][0];
retval = krb5_walk_realm_tree(context, &client, &server, &tree,
realm_branch_char);
if (retval) {
com_err("krb5_walk_realm_tree", retval, "");
exit(1);
}
for (p = tree; *p; p++) {
retval = krb5_unparse_name(context, *p, &name);
if (retval) {
com_err("krb5_unprase_name", retval, "");
exit(2);
}
printf("%s\n", name);
free(name);
}
krb5_free_realm_tree(context, tree);
exit(0);
}
|