2 * Copyright (c) 2006 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of KTH nor the names of its contributors may be
18 * used to endorse or promote products derived from this software without
19 * specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY
22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 #include <gss-commands.h>
47 RCSID("$Id: gss.c 19922 2007-01-16 09:32:03Z lha $");
49 static int version_flag = 0;
50 static int help_flag = 0;
52 static struct getargs args[] = {
53 {"version", 0, arg_flag, &version_flag, "print version", NULL },
54 {"help", 0, arg_flag, &help_flag, NULL, NULL }
60 arg_printusage (args, sizeof(args)/sizeof(*args),
61 NULL, "service@host");
66 #define COL_NAME "Name"
69 supported_mechanisms(void *argptr, int argc, char **argv)
71 OM_uint32 maj_stat, min_stat;
76 maj_stat = gss_indicate_mechs(&min_stat, &mechs);
77 if (maj_stat != GSS_S_COMPLETE)
78 errx(1, "gss_indicate_mechs failed");
80 printf("Supported mechanisms:\n");
84 errx(1, "rtbl_create");
86 rtbl_set_separator(ct, " ");
87 rtbl_add_column(ct, COL_OID, 0);
88 rtbl_add_column(ct, COL_NAME, 0);
90 for (i = 0; i < mechs->count; i++) {
93 maj_stat = gss_oid_to_str(&min_stat, &mechs->elements[i], &name);
94 if (maj_stat != GSS_S_COMPLETE)
95 errx(1, "gss_oid_to_str failed");
97 rtbl_add_column_entryv(ct, COL_OID, "%.*s",
98 (int)name.length, (char *)name.value);
99 gss_release_buffer(&min_stat, &name);
101 if (gss_oid_equal(&mechs->elements[i], GSS_KRB5_MECHANISM))
102 rtbl_add_column_entry(ct, COL_NAME, "Kerberos 5");
103 else if (gss_oid_equal(&mechs->elements[i], GSS_SPNEGO_MECHANISM))
104 rtbl_add_column_entry(ct, COL_NAME, "SPNEGO");
105 else if (gss_oid_equal(&mechs->elements[i], GSS_NTLM_MECHANISM))
106 rtbl_add_column_entry(ct, COL_NAME, "NTLM");
108 gss_release_oid_set(&min_stat, &mechs);
110 rtbl_format(ct, stdout);
121 #define DOVEDOT_MAJOR_VERSION 1
122 #define DOVEDOT_MINOR_VERSION 0
125 S: MECH mech mech-parameters
126 S: MECH mech mech-parameters
127 S: VERSION major minor
132 C: VERSION major minor
135 C: AUTH id method service= resp=
140 S: CONTINUE id message
144 dovecot_server(void *argptr, int argc, char **argv)
149 sp = krb5_storage_from_fd(fd);
151 errx(1, "krb5_storage_from_fd");
153 krb5_store_stringnl(sp, "MECH\tGSSAPI");
154 krb5_store_stringnl(sp, "VERSION\t1\t0");
155 krb5_store_stringnl(sp, "DONE");
159 if (krb5_ret_stringnl(sp, &cmd) != 0)
161 printf("cmd: %s\n", cmd);
173 help(void *opt, int argc, char **argv)
175 sl_slc_help(commands, argc, argv);
180 main(int argc, char **argv)
184 setprogname(argv[0]);
185 if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optidx))
200 help(NULL, argc, argv);
204 return sl_command (commands, argc, argv);