17c478bd9Sstevel@tonic-gate /*
2*56a424ccSmp * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
37c478bd9Sstevel@tonic-gate * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate */
57c478bd9Sstevel@tonic-gate
67c478bd9Sstevel@tonic-gate /*
77c478bd9Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * Openvision retains the copyright to derivative works of
107c478bd9Sstevel@tonic-gate * this source code. Do *NOT* create a derivative of this
117c478bd9Sstevel@tonic-gate * source code before consulting with your legal department.
127c478bd9Sstevel@tonic-gate * Do *NOT* integrate *ANY* of this source code into another
137c478bd9Sstevel@tonic-gate * product before consulting with your legal department.
147c478bd9Sstevel@tonic-gate *
157c478bd9Sstevel@tonic-gate * For further information, read the top-level Openvision
167c478bd9Sstevel@tonic-gate * copyright which is contained in the top-level MIT Kerberos
177c478bd9Sstevel@tonic-gate * copyright.
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
207c478bd9Sstevel@tonic-gate *
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate
237c478bd9Sstevel@tonic-gate
247c478bd9Sstevel@tonic-gate /* ktutil_ct.c - automatically generated from ktutil_ct.ct */
257c478bd9Sstevel@tonic-gate /* Above no longer appears to be true */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate #include <libintl.h>
287c478bd9Sstevel@tonic-gate #include <ss/ss.h>
297c478bd9Sstevel@tonic-gate #include "k5-int.h"
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate * I18n hack. We sill define gettext(s) to be s here. That way the info_strings
337c478bd9Sstevel@tonic-gate * will be extracted to the .po file.
347c478bd9Sstevel@tonic-gate */
357c478bd9Sstevel@tonic-gate
367c478bd9Sstevel@tonic-gate #define gettext(s) s
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gate #ifndef __STDC__
39*56a424ccSmp #define const
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate
42*56a424ccSmp static char const * const ssu00001[] = {
43*56a424ccSmp "clear_list",
44*56a424ccSmp "clear",
45*56a424ccSmp (char const *)0
467c478bd9Sstevel@tonic-gate };
477c478bd9Sstevel@tonic-gate extern void ktutil_clear_list __SS_PROTO;
48*56a424ccSmp static char const * const ssu00002[] = {
49*56a424ccSmp "read_kt",
50*56a424ccSmp "rkt",
51*56a424ccSmp (char const *)0
527c478bd9Sstevel@tonic-gate };
537c478bd9Sstevel@tonic-gate extern void ktutil_read_v5 __SS_PROTO;
54*56a424ccSmp static char const * const ssu00003[] = {
55*56a424ccSmp "read_st",
56*56a424ccSmp "rst",
57*56a424ccSmp (char const *)0
587c478bd9Sstevel@tonic-gate };
597c478bd9Sstevel@tonic-gate extern void ktutil_read_v4 __SS_PROTO;
60*56a424ccSmp static char const * const ssu00004[] = {
61*56a424ccSmp "write_kt",
62*56a424ccSmp "wkt",
63*56a424ccSmp (char const *)0
647c478bd9Sstevel@tonic-gate };
657c478bd9Sstevel@tonic-gate extern void ktutil_write_v5 __SS_PROTO;
66*56a424ccSmp static char const * const ssu00005[] = {
67*56a424ccSmp "write_st",
68*56a424ccSmp "wst",
69*56a424ccSmp (char const *)0
707c478bd9Sstevel@tonic-gate };
717c478bd9Sstevel@tonic-gate extern void ktutil_write_v4 __SS_PROTO;
72*56a424ccSmp static char const * const ssu00006[] = {
73*56a424ccSmp "add_entry",
74*56a424ccSmp "addent",
75*56a424ccSmp (char const *)0
767c478bd9Sstevel@tonic-gate };
777c478bd9Sstevel@tonic-gate extern void ktutil_add_entry __SS_PROTO;
78*56a424ccSmp static char const * const ssu00007[] = {
79*56a424ccSmp "delete_entry",
80*56a424ccSmp "delent",
81*56a424ccSmp (char const *)0
827c478bd9Sstevel@tonic-gate };
837c478bd9Sstevel@tonic-gate extern void ktutil_delete_entry __SS_PROTO;
84*56a424ccSmp static char const * const ssu00008[] = {
85*56a424ccSmp "list",
86*56a424ccSmp "l",
87*56a424ccSmp (char const *)0
887c478bd9Sstevel@tonic-gate };
897c478bd9Sstevel@tonic-gate extern void ktutil_list __SS_PROTO;
90*56a424ccSmp static char const * const ssu00009[] = {
91*56a424ccSmp "list_requests",
92*56a424ccSmp "lr",
93*56a424ccSmp "?",
94*56a424ccSmp (char const *)0
957c478bd9Sstevel@tonic-gate };
967c478bd9Sstevel@tonic-gate extern void ss_list_requests __SS_PROTO;
97*56a424ccSmp static char const * const ssu00010[] = {
98*56a424ccSmp "quit",
99*56a424ccSmp "exit",
100*56a424ccSmp "q",
101*56a424ccSmp (char const *)0
1027c478bd9Sstevel@tonic-gate };
1037c478bd9Sstevel@tonic-gate extern void ss_quit __SS_PROTO;
1047c478bd9Sstevel@tonic-gate static ss_request_entry ssu00011[] = {
105*56a424ccSmp { ssu00001,
106*56a424ccSmp ktutil_clear_list,
1077c478bd9Sstevel@tonic-gate gettext("Clear the current keylist."),
108*56a424ccSmp 0 },
109*56a424ccSmp { ssu00002,
110*56a424ccSmp ktutil_read_v5,
1117c478bd9Sstevel@tonic-gate gettext("Read a krb5 keytab into the current keylist."),
112*56a424ccSmp 0 },
113*56a424ccSmp { ssu00003,
114*56a424ccSmp ktutil_read_v4,
1157c478bd9Sstevel@tonic-gate gettext("Read a krb4 srvtab into the current keylist."),
116*56a424ccSmp 0 },
117*56a424ccSmp { ssu00004,
118*56a424ccSmp ktutil_write_v5,
1197c478bd9Sstevel@tonic-gate gettext("Write the current keylist to a krb5 keytab."),
120*56a424ccSmp 0 },
121*56a424ccSmp { ssu00005,
122*56a424ccSmp ktutil_write_v4,
1237c478bd9Sstevel@tonic-gate gettext("Write the current keylist to a krb4 srvtab."),
124*56a424ccSmp 0 },
125*56a424ccSmp { ssu00006,
126*56a424ccSmp ktutil_add_entry,
1277c478bd9Sstevel@tonic-gate gettext("Add an entry to the current keylist."),
128*56a424ccSmp 0 },
129*56a424ccSmp { ssu00007,
130*56a424ccSmp ktutil_delete_entry,
1317c478bd9Sstevel@tonic-gate gettext("Delete an entry from the current keylist."),
132*56a424ccSmp 0 },
133*56a424ccSmp { ssu00008,
134*56a424ccSmp ktutil_list,
1357c478bd9Sstevel@tonic-gate gettext("List the current keylist."),
136*56a424ccSmp 0 },
137*56a424ccSmp { ssu00009,
138*56a424ccSmp ss_list_requests,
1397c478bd9Sstevel@tonic-gate gettext("List available requests."),
140*56a424ccSmp 0 },
141*56a424ccSmp { ssu00010,
142*56a424ccSmp ss_quit,
1437c478bd9Sstevel@tonic-gate gettext("Exit program."),
144*56a424ccSmp 0 },
145*56a424ccSmp { 0, 0, 0, 0 }
1467c478bd9Sstevel@tonic-gate };
1477c478bd9Sstevel@tonic-gate
148*56a424ccSmp ss_request_table ktutil_cmds = { 2, ssu00011 };
1497c478bd9Sstevel@tonic-gate
1507c478bd9Sstevel@tonic-gate #undef gettext
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gate /*
1537c478bd9Sstevel@tonic-gate * This routine is responsible for localizing all the displayable
1547c478bd9Sstevel@tonic-gate * messages in the table. This was necessary since ktutil will be
1557c478bd9Sstevel@tonic-gate * invoking library calls that need to be able to display the messages
1567c478bd9Sstevel@tonic-gate * in the correct text domain (which only ktutil knows).
1577c478bd9Sstevel@tonic-gate *
1587c478bd9Sstevel@tonic-gate * This function assumes that the US version of the messages are
1597c478bd9Sstevel@tonic-gate * pre-loaded in the table and will be used should gettext not be
1607c478bd9Sstevel@tonic-gate * successful. This routine does NOT free the replaced strings as
1617c478bd9Sstevel@tonic-gate * its expected they may be in the heap (as above) and not malloc'ed.
1627c478bd9Sstevel@tonic-gate * If the caller malloc'ed the strings, they should retain pointers
1637c478bd9Sstevel@tonic-gate * and free them if not matching the contents of the table.
1647c478bd9Sstevel@tonic-gate */
1657c478bd9Sstevel@tonic-gate krb5_error_code
ktutil_initialize_cmds_table(ss_request_table * ktutil_cmds)1667c478bd9Sstevel@tonic-gate ktutil_initialize_cmds_table(ss_request_table *ktutil_cmds)
1677c478bd9Sstevel@tonic-gate {
1687c478bd9Sstevel@tonic-gate char *localized_text;
1697c478bd9Sstevel@tonic-gate ss_request_entry *ss_cmd;
1707c478bd9Sstevel@tonic-gate krb5_error_code retval = 0;
1717c478bd9Sstevel@tonic-gate
1727c478bd9Sstevel@tonic-gate if (ktutil_cmds) {
1737c478bd9Sstevel@tonic-gate for (ss_cmd = ktutil_cmds->requests;
1747c478bd9Sstevel@tonic-gate ss_cmd->info_string && *(ss_cmd->info_string) != '\0';
1757c478bd9Sstevel@tonic-gate ++ss_cmd) {
1767c478bd9Sstevel@tonic-gate localized_text = gettext(ss_cmd->info_string);
1777c478bd9Sstevel@tonic-gate
1787c478bd9Sstevel@tonic-gate if ((strcmp(localized_text, ss_cmd->info_string))
1797c478bd9Sstevel@tonic-gate != 0) {
1807c478bd9Sstevel@tonic-gate ss_cmd->info_string = strdup(localized_text);
1817c478bd9Sstevel@tonic-gate }
1827c478bd9Sstevel@tonic-gate }
1837c478bd9Sstevel@tonic-gate }
1847c478bd9Sstevel@tonic-gate else
1857c478bd9Sstevel@tonic-gate retval = EINVAL;
1867c478bd9Sstevel@tonic-gate
1877c478bd9Sstevel@tonic-gate return (retval);
1887c478bd9Sstevel@tonic-gate }
189