4 #include "kdigest-commands.h"
7 digest_probe_wrap(int argc
, char **argv
)
9 struct digest_probe_options opt
;
12 struct getargs args
[] = {
13 { "realm", 0, arg_string
, NULL
, "Kerberos realm to communicate with", NULL
},
14 { "help", 'h', arg_flag
, NULL
, NULL
, NULL
}
17 opt
.realm_string
= NULL
;
18 args
[0].value
= &opt
.realm_string
;
19 args
[1].value
= &help_flag
;
20 if(getarg(args
, 2, argc
, argv
, &optidx
))
22 if(argc
- optidx
> 0) {
23 fprintf(stderr
, "Arguments given (%u) are more than expected (0).\n\n", argc
- optidx
);
28 ret
= digest_probe(&opt
, argc
- optidx
, argv
+ optidx
);
31 arg_printusage (args
, 2, "digest-probe", "");
36 digest_server_init_wrap(int argc
, char **argv
)
38 struct digest_server_init_options opt
;
41 struct getargs args
[] = {
42 { "type", 0, arg_string
, NULL
, "digest type", NULL
},
43 { "kerberos-realm", 0, arg_string
, NULL
, "", "realm" },
44 { "digest", 0, arg_string
, NULL
, "digest type to use in the algorithm", "digest-type" },
45 { "cb-type", 0, arg_string
, NULL
, "type of channel bindings", "type" },
46 { "cb-value", 0, arg_string
, NULL
, "value of channel bindings", "value" },
47 { "hostname", 0, arg_string
, NULL
, "hostname of the server", "hostname" },
48 { "realm", 0, arg_string
, NULL
, "Kerberos realm to communicate with", NULL
},
49 { "help", 'h', arg_flag
, NULL
, NULL
, NULL
}
52 opt
.type_string
= "sasl";
53 opt
.kerberos_realm_string
= NULL
;
54 opt
.digest_string
= NULL
;
55 opt
.cb_type_string
= NULL
;
56 opt
.cb_value_string
= NULL
;
57 opt
.hostname_string
= NULL
;
58 opt
.realm_string
= NULL
;
59 args
[0].value
= &opt
.type_string
;
60 args
[1].value
= &opt
.kerberos_realm_string
;
61 args
[2].value
= &opt
.digest_string
;
62 args
[3].value
= &opt
.cb_type_string
;
63 args
[4].value
= &opt
.cb_value_string
;
64 args
[5].value
= &opt
.hostname_string
;
65 args
[6].value
= &opt
.realm_string
;
66 args
[7].value
= &help_flag
;
67 if(getarg(args
, 8, argc
, argv
, &optidx
))
69 if(argc
- optidx
> 0) {
70 fprintf(stderr
, "Arguments given (%u) are more than expected (0).\n\n", argc
- optidx
);
75 ret
= digest_server_init(&opt
, argc
- optidx
, argv
+ optidx
);
78 arg_printusage (args
, 8, "digest-server-init", "");
83 digest_server_request_wrap(int argc
, char **argv
)
85 struct digest_server_request_options opt
;
88 struct getargs args
[] = {
89 { "type", 0, arg_string
, NULL
, "digest type", NULL
},
90 { "kerberos-realm", 0, arg_string
, NULL
, "", "realm" },
91 { "username", 0, arg_string
, NULL
, "digest type", "name" },
92 { "server-nonce", 0, arg_string
, NULL
, "", "nonce" },
93 { "server-identifier", 0, arg_string
, NULL
, "", "nonce" },
94 { "client-nonce", 0, arg_string
, NULL
, "", "nonce" },
95 { "client-response", 0, arg_string
, NULL
, "", "response" },
96 { "opaque", 0, arg_string
, NULL
, "", "string" },
97 { "authentication-name", 0, arg_string
, NULL
, "", "name" },
98 { "realm", 0, arg_string
, NULL
, "", "realm" },
99 { "method", 0, arg_string
, NULL
, "", "method" },
100 { "uri", 0, arg_string
, NULL
, "", "uri" },
101 { "nounce-count", 0, arg_string
, NULL
, "", "count" },
102 { "qop", 0, arg_string
, NULL
, "", "qop" },
103 { "ccache", 0, arg_string
, NULL
, "Where the the credential cache is created when the KDC returns tickets", "ccache" },
104 { "help", 'h', arg_flag
, NULL
, NULL
, NULL
}
107 opt
.type_string
= "sasl";
108 opt
.kerberos_realm_string
= NULL
;
109 opt
.username_string
= NULL
;
110 opt
.server_nonce_string
= NULL
;
111 opt
.server_identifier_string
= NULL
;
112 opt
.client_nonce_string
= NULL
;
113 opt
.client_response_string
= NULL
;
114 opt
.opaque_string
= NULL
;
115 opt
.authentication_name_string
= NULL
;
116 opt
.realm_string
= NULL
;
117 opt
.method_string
= NULL
;
118 opt
.uri_string
= NULL
;
119 opt
.nounce_count_string
= NULL
;
120 opt
.qop_string
= NULL
;
121 opt
.ccache_string
= NULL
;
122 args
[0].value
= &opt
.type_string
;
123 args
[1].value
= &opt
.kerberos_realm_string
;
124 args
[2].value
= &opt
.username_string
;
125 args
[3].value
= &opt
.server_nonce_string
;
126 args
[4].value
= &opt
.server_identifier_string
;
127 args
[5].value
= &opt
.client_nonce_string
;
128 args
[6].value
= &opt
.client_response_string
;
129 args
[7].value
= &opt
.opaque_string
;
130 args
[8].value
= &opt
.authentication_name_string
;
131 args
[9].value
= &opt
.realm_string
;
132 args
[10].value
= &opt
.method_string
;
133 args
[11].value
= &opt
.uri_string
;
134 args
[12].value
= &opt
.nounce_count_string
;
135 args
[13].value
= &opt
.qop_string
;
136 args
[14].value
= &opt
.ccache_string
;
137 args
[15].value
= &help_flag
;
138 if(getarg(args
, 16, argc
, argv
, &optidx
))
140 if(argc
- optidx
> 0) {
141 fprintf(stderr
, "Arguments given (%u) are more than expected (0).\n\n", argc
- optidx
);
146 ret
= digest_server_request(&opt
, argc
- optidx
, argv
+ optidx
);
149 arg_printusage (args
, 16, "digest-server-request", "");
154 digest_client_request_wrap(int argc
, char **argv
)
156 struct digest_client_request_options opt
;
159 struct getargs args
[] = {
160 { "type", 0, arg_string
, NULL
, "digest type", NULL
},
161 { "username", 0, arg_string
, NULL
, "digest type", "name" },
162 { "password", 0, arg_string
, NULL
, NULL
, "password" },
163 { "server-nonce", 0, arg_string
, NULL
, "", "nonce" },
164 { "server-identifier", 0, arg_string
, NULL
, "", "nonce" },
165 { "client-nonce", 0, arg_string
, NULL
, "", "nonce" },
166 { "opaque", 0, arg_string
, NULL
, "", "string" },
167 { "realm", 0, arg_string
, NULL
, "", "realm" },
168 { "method", 0, arg_string
, NULL
, "", "method" },
169 { "uri", 0, arg_string
, NULL
, "", "uri" },
170 { "nounce-count", 0, arg_string
, NULL
, "", "count" },
171 { "qop", 0, arg_string
, NULL
, "", "qop" },
172 { "help", 'h', arg_flag
, NULL
, NULL
, NULL
}
175 opt
.type_string
= "sasl";
176 opt
.username_string
= NULL
;
177 opt
.password_string
= NULL
;
178 opt
.server_nonce_string
= NULL
;
179 opt
.server_identifier_string
= NULL
;
180 opt
.client_nonce_string
= NULL
;
181 opt
.opaque_string
= NULL
;
182 opt
.realm_string
= NULL
;
183 opt
.method_string
= NULL
;
184 opt
.uri_string
= NULL
;
185 opt
.nounce_count_string
= NULL
;
186 opt
.qop_string
= NULL
;
187 args
[0].value
= &opt
.type_string
;
188 args
[1].value
= &opt
.username_string
;
189 args
[2].value
= &opt
.password_string
;
190 args
[3].value
= &opt
.server_nonce_string
;
191 args
[4].value
= &opt
.server_identifier_string
;
192 args
[5].value
= &opt
.client_nonce_string
;
193 args
[6].value
= &opt
.opaque_string
;
194 args
[7].value
= &opt
.realm_string
;
195 args
[8].value
= &opt
.method_string
;
196 args
[9].value
= &opt
.uri_string
;
197 args
[10].value
= &opt
.nounce_count_string
;
198 args
[11].value
= &opt
.qop_string
;
199 args
[12].value
= &help_flag
;
200 if(getarg(args
, 13, argc
, argv
, &optidx
))
202 if(argc
- optidx
> 0) {
203 fprintf(stderr
, "Arguments given (%u) are more than expected (0).\n\n", argc
- optidx
);
208 ret
= digest_client_request(&opt
, argc
- optidx
, argv
+ optidx
);
211 arg_printusage (args
, 13, "digest-client-request", "");
216 ntlm_server_init_wrap(int argc
, char **argv
)
218 struct ntlm_server_init_options opt
;
221 struct getargs args
[] = {
222 { "version", 0, arg_integer
, NULL
, "ntlm version", NULL
},
223 { "kerberos-realm", 0, arg_string
, NULL
, "Kerberos realm to communicate with", NULL
},
224 { "help", 'h', arg_flag
, NULL
, NULL
, NULL
}
227 opt
.version_integer
= 1;
228 opt
.kerberos_realm_string
= NULL
;
229 args
[0].value
= &opt
.version_integer
;
230 args
[1].value
= &opt
.kerberos_realm_string
;
231 args
[2].value
= &help_flag
;
232 if(getarg(args
, 3, argc
, argv
, &optidx
))
234 if(argc
- optidx
> 0) {
235 fprintf(stderr
, "Arguments given (%u) are more than expected (0).\n\n", argc
- optidx
);
240 ret
= ntlm_server_init(&opt
, argc
- optidx
, argv
+ optidx
);
243 arg_printusage (args
, 3, "ntlm-server-init", "");
248 help_wrap(int argc
, char **argv
)
252 struct getargs args
[] = {
253 { "help", 'h', arg_flag
, NULL
, NULL
, NULL
}
256 args
[0].value
= &help_flag
;
257 if(getarg(args
, 1, argc
, argv
, &optidx
))
259 if(argc
- optidx
> 1) {
260 fprintf(stderr
, "Arguments given (%u) are more than expected (1).\n\n", argc
- optidx
);
263 if(argc
- optidx
< 0) {
264 fprintf(stderr
, "Arguments given (%u) are less than expected (0).\n\n", argc
- optidx
);
269 ret
= help(NULL
, argc
- optidx
, argv
+ optidx
);
272 arg_printusage (args
, 1, "help", "[command]");
276 SL_cmd commands
[] = {
277 { "digest-probe", digest_probe_wrap
, "digest-probe", "probe what mech is allowed/supported for this server" },
279 { "digest-server-init", digest_server_init_wrap
, "digest-server-init", "Sets up a digest context and return initial parameters" },
281 { "digest-server-request", digest_server_request_wrap
, "digest-server-request", "Completes digest negotiation and return final parameters" },
283 { "digest-client-request", digest_client_request_wrap
, "digest-client-request", "Client part of a digest exchange" },
285 { "ntlm-server-init", ntlm_server_init_wrap
, "ntlm-server-init", "Sets up a digest context and return initial parameters" },
287 { "help", help_wrap
, "help [command]", "Help! I need somebody." },