10Sstevel@tonic-gate /*
2*2881Smp153739 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
30Sstevel@tonic-gate * Use is subject to license terms.
40Sstevel@tonic-gate */
50Sstevel@tonic-gate
60Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
70Sstevel@tonic-gate
80Sstevel@tonic-gate /*
90Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
100Sstevel@tonic-gate *
110Sstevel@tonic-gate * Openvision retains the copyright to derivative works of
120Sstevel@tonic-gate * this source code. Do *NOT* create a derivative of this
130Sstevel@tonic-gate * source code before consulting with your legal department.
140Sstevel@tonic-gate * Do *NOT* integrate *ANY* of this source code into another
150Sstevel@tonic-gate * product before consulting with your legal department.
160Sstevel@tonic-gate *
170Sstevel@tonic-gate * For further information, read the top-level Openvision
180Sstevel@tonic-gate * copyright which is contained in the top-level MIT Kerberos
190Sstevel@tonic-gate * copyright.
200Sstevel@tonic-gate *
210Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
220Sstevel@tonic-gate *
230Sstevel@tonic-gate */
240Sstevel@tonic-gate
250Sstevel@tonic-gate
260Sstevel@tonic-gate /* ktutil_ct.c - automatically generated from ktutil_ct.ct */
270Sstevel@tonic-gate /* Above no longer appears to be true */
280Sstevel@tonic-gate
290Sstevel@tonic-gate #include <libintl.h>
300Sstevel@tonic-gate #include <ss/ss.h>
310Sstevel@tonic-gate #include "k5-int.h"
320Sstevel@tonic-gate
330Sstevel@tonic-gate /*
340Sstevel@tonic-gate * I18n hack. We sill define gettext(s) to be s here. That way the info_strings
350Sstevel@tonic-gate * will be extracted to the .po file.
360Sstevel@tonic-gate */
370Sstevel@tonic-gate
380Sstevel@tonic-gate #define gettext(s) s
390Sstevel@tonic-gate
400Sstevel@tonic-gate #ifndef __STDC__
41*2881Smp153739 #define const
420Sstevel@tonic-gate #endif
430Sstevel@tonic-gate
44*2881Smp153739 static char const * const ssu00001[] = {
45*2881Smp153739 "clear_list",
46*2881Smp153739 "clear",
47*2881Smp153739 (char const *)0
480Sstevel@tonic-gate };
490Sstevel@tonic-gate extern void ktutil_clear_list __SS_PROTO;
50*2881Smp153739 static char const * const ssu00002[] = {
51*2881Smp153739 "read_kt",
52*2881Smp153739 "rkt",
53*2881Smp153739 (char const *)0
540Sstevel@tonic-gate };
550Sstevel@tonic-gate extern void ktutil_read_v5 __SS_PROTO;
56*2881Smp153739 static char const * const ssu00003[] = {
57*2881Smp153739 "read_st",
58*2881Smp153739 "rst",
59*2881Smp153739 (char const *)0
600Sstevel@tonic-gate };
610Sstevel@tonic-gate extern void ktutil_read_v4 __SS_PROTO;
62*2881Smp153739 static char const * const ssu00004[] = {
63*2881Smp153739 "write_kt",
64*2881Smp153739 "wkt",
65*2881Smp153739 (char const *)0
660Sstevel@tonic-gate };
670Sstevel@tonic-gate extern void ktutil_write_v5 __SS_PROTO;
68*2881Smp153739 static char const * const ssu00005[] = {
69*2881Smp153739 "write_st",
70*2881Smp153739 "wst",
71*2881Smp153739 (char const *)0
720Sstevel@tonic-gate };
730Sstevel@tonic-gate extern void ktutil_write_v4 __SS_PROTO;
74*2881Smp153739 static char const * const ssu00006[] = {
75*2881Smp153739 "add_entry",
76*2881Smp153739 "addent",
77*2881Smp153739 (char const *)0
780Sstevel@tonic-gate };
790Sstevel@tonic-gate extern void ktutil_add_entry __SS_PROTO;
80*2881Smp153739 static char const * const ssu00007[] = {
81*2881Smp153739 "delete_entry",
82*2881Smp153739 "delent",
83*2881Smp153739 (char const *)0
840Sstevel@tonic-gate };
850Sstevel@tonic-gate extern void ktutil_delete_entry __SS_PROTO;
86*2881Smp153739 static char const * const ssu00008[] = {
87*2881Smp153739 "list",
88*2881Smp153739 "l",
89*2881Smp153739 (char const *)0
900Sstevel@tonic-gate };
910Sstevel@tonic-gate extern void ktutil_list __SS_PROTO;
92*2881Smp153739 static char const * const ssu00009[] = {
93*2881Smp153739 "list_requests",
94*2881Smp153739 "lr",
95*2881Smp153739 "?",
96*2881Smp153739 (char const *)0
970Sstevel@tonic-gate };
980Sstevel@tonic-gate extern void ss_list_requests __SS_PROTO;
99*2881Smp153739 static char const * const ssu00010[] = {
100*2881Smp153739 "quit",
101*2881Smp153739 "exit",
102*2881Smp153739 "q",
103*2881Smp153739 (char const *)0
1040Sstevel@tonic-gate };
1050Sstevel@tonic-gate extern void ss_quit __SS_PROTO;
1060Sstevel@tonic-gate static ss_request_entry ssu00011[] = {
107*2881Smp153739 { ssu00001,
108*2881Smp153739 ktutil_clear_list,
1090Sstevel@tonic-gate gettext("Clear the current keylist."),
110*2881Smp153739 0 },
111*2881Smp153739 { ssu00002,
112*2881Smp153739 ktutil_read_v5,
1130Sstevel@tonic-gate gettext("Read a krb5 keytab into the current keylist."),
114*2881Smp153739 0 },
115*2881Smp153739 { ssu00003,
116*2881Smp153739 ktutil_read_v4,
1170Sstevel@tonic-gate gettext("Read a krb4 srvtab into the current keylist."),
118*2881Smp153739 0 },
119*2881Smp153739 { ssu00004,
120*2881Smp153739 ktutil_write_v5,
1210Sstevel@tonic-gate gettext("Write the current keylist to a krb5 keytab."),
122*2881Smp153739 0 },
123*2881Smp153739 { ssu00005,
124*2881Smp153739 ktutil_write_v4,
1250Sstevel@tonic-gate gettext("Write the current keylist to a krb4 srvtab."),
126*2881Smp153739 0 },
127*2881Smp153739 { ssu00006,
128*2881Smp153739 ktutil_add_entry,
1290Sstevel@tonic-gate gettext("Add an entry to the current keylist."),
130*2881Smp153739 0 },
131*2881Smp153739 { ssu00007,
132*2881Smp153739 ktutil_delete_entry,
1330Sstevel@tonic-gate gettext("Delete an entry from the current keylist."),
134*2881Smp153739 0 },
135*2881Smp153739 { ssu00008,
136*2881Smp153739 ktutil_list,
1370Sstevel@tonic-gate gettext("List the current keylist."),
138*2881Smp153739 0 },
139*2881Smp153739 { ssu00009,
140*2881Smp153739 ss_list_requests,
1410Sstevel@tonic-gate gettext("List available requests."),
142*2881Smp153739 0 },
143*2881Smp153739 { ssu00010,
144*2881Smp153739 ss_quit,
1450Sstevel@tonic-gate gettext("Exit program."),
146*2881Smp153739 0 },
147*2881Smp153739 { 0, 0, 0, 0 }
1480Sstevel@tonic-gate };
1490Sstevel@tonic-gate
150*2881Smp153739 ss_request_table ktutil_cmds = { 2, ssu00011 };
1510Sstevel@tonic-gate
1520Sstevel@tonic-gate #undef gettext
1530Sstevel@tonic-gate
1540Sstevel@tonic-gate /*
1550Sstevel@tonic-gate * This routine is responsible for localizing all the displayable
1560Sstevel@tonic-gate * messages in the table. This was necessary since ktutil will be
1570Sstevel@tonic-gate * invoking library calls that need to be able to display the messages
1580Sstevel@tonic-gate * in the correct text domain (which only ktutil knows).
1590Sstevel@tonic-gate *
1600Sstevel@tonic-gate * This function assumes that the US version of the messages are
1610Sstevel@tonic-gate * pre-loaded in the table and will be used should gettext not be
1620Sstevel@tonic-gate * successful. This routine does NOT free the replaced strings as
1630Sstevel@tonic-gate * its expected they may be in the heap (as above) and not malloc'ed.
1640Sstevel@tonic-gate * If the caller malloc'ed the strings, they should retain pointers
1650Sstevel@tonic-gate * and free them if not matching the contents of the table.
1660Sstevel@tonic-gate */
1670Sstevel@tonic-gate krb5_error_code
ktutil_initialize_cmds_table(ss_request_table * ktutil_cmds)1680Sstevel@tonic-gate ktutil_initialize_cmds_table(ss_request_table *ktutil_cmds)
1690Sstevel@tonic-gate {
1700Sstevel@tonic-gate char *localized_text;
1710Sstevel@tonic-gate ss_request_entry *ss_cmd;
1720Sstevel@tonic-gate krb5_error_code retval = 0;
1730Sstevel@tonic-gate
1740Sstevel@tonic-gate if (ktutil_cmds) {
1750Sstevel@tonic-gate for (ss_cmd = ktutil_cmds->requests;
1760Sstevel@tonic-gate ss_cmd->info_string && *(ss_cmd->info_string) != '\0';
1770Sstevel@tonic-gate ++ss_cmd) {
1780Sstevel@tonic-gate localized_text = gettext(ss_cmd->info_string);
1790Sstevel@tonic-gate
1800Sstevel@tonic-gate if ((strcmp(localized_text, ss_cmd->info_string))
1810Sstevel@tonic-gate != 0) {
1820Sstevel@tonic-gate ss_cmd->info_string = strdup(localized_text);
1830Sstevel@tonic-gate }
1840Sstevel@tonic-gate }
1850Sstevel@tonic-gate }
1860Sstevel@tonic-gate else
1870Sstevel@tonic-gate retval = EINVAL;
1880Sstevel@tonic-gate
1890Sstevel@tonic-gate return (retval);
1900Sstevel@tonic-gate }
191