xref: /titanic_51/usr/src/cmd/krb5/kadmin/ktutil/ktutil_ct.c (revision 56a424cca6b3f91f31bdab72a4626c48c779fe8b)
17c478bd9Sstevel@tonic-gate /*
2*56a424ccSmp153739  * 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
77c478bd9Sstevel@tonic-gate 
87c478bd9Sstevel@tonic-gate /*
97c478bd9Sstevel@tonic-gate  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
107c478bd9Sstevel@tonic-gate  *
117c478bd9Sstevel@tonic-gate  *	Openvision retains the copyright to derivative works of
127c478bd9Sstevel@tonic-gate  *	this source code.  Do *NOT* create a derivative of this
137c478bd9Sstevel@tonic-gate  *	source code before consulting with your legal department.
147c478bd9Sstevel@tonic-gate  *	Do *NOT* integrate *ANY* of this source code into another
157c478bd9Sstevel@tonic-gate  *	product before consulting with your legal department.
167c478bd9Sstevel@tonic-gate  *
177c478bd9Sstevel@tonic-gate  *	For further information, read the top-level Openvision
187c478bd9Sstevel@tonic-gate  *	copyright which is contained in the top-level MIT Kerberos
197c478bd9Sstevel@tonic-gate  *	copyright.
207c478bd9Sstevel@tonic-gate  *
217c478bd9Sstevel@tonic-gate  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
227c478bd9Sstevel@tonic-gate  *
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /* ktutil_ct.c - automatically generated from ktutil_ct.ct */
277c478bd9Sstevel@tonic-gate /* Above no longer appears to be true */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <libintl.h>
307c478bd9Sstevel@tonic-gate #include <ss/ss.h>
317c478bd9Sstevel@tonic-gate #include "k5-int.h"
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate  * I18n hack. We sill define gettext(s) to be s here. That way the info_strings
357c478bd9Sstevel@tonic-gate  * will be extracted to the .po file.
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #define	gettext(s) s
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #ifndef __STDC__
417c478bd9Sstevel@tonic-gate #define const
427c478bd9Sstevel@tonic-gate #endif
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate static char const * const ssu00001[] = {
457c478bd9Sstevel@tonic-gate "clear_list",
467c478bd9Sstevel@tonic-gate     "clear",
477c478bd9Sstevel@tonic-gate     (char const *)0
487c478bd9Sstevel@tonic-gate };
497c478bd9Sstevel@tonic-gate extern void ktutil_clear_list __SS_PROTO;
507c478bd9Sstevel@tonic-gate static char const * const ssu00002[] = {
517c478bd9Sstevel@tonic-gate "read_kt",
527c478bd9Sstevel@tonic-gate     "rkt",
537c478bd9Sstevel@tonic-gate     (char const *)0
547c478bd9Sstevel@tonic-gate };
557c478bd9Sstevel@tonic-gate extern void ktutil_read_v5 __SS_PROTO;
567c478bd9Sstevel@tonic-gate static char const * const ssu00003[] = {
577c478bd9Sstevel@tonic-gate "read_st",
587c478bd9Sstevel@tonic-gate     "rst",
597c478bd9Sstevel@tonic-gate     (char const *)0
607c478bd9Sstevel@tonic-gate };
617c478bd9Sstevel@tonic-gate extern void ktutil_read_v4 __SS_PROTO;
627c478bd9Sstevel@tonic-gate static char const * const ssu00004[] = {
637c478bd9Sstevel@tonic-gate "write_kt",
647c478bd9Sstevel@tonic-gate     "wkt",
657c478bd9Sstevel@tonic-gate     (char const *)0
667c478bd9Sstevel@tonic-gate };
677c478bd9Sstevel@tonic-gate extern void ktutil_write_v5 __SS_PROTO;
687c478bd9Sstevel@tonic-gate static char const * const ssu00005[] = {
697c478bd9Sstevel@tonic-gate "write_st",
707c478bd9Sstevel@tonic-gate     "wst",
717c478bd9Sstevel@tonic-gate     (char const *)0
727c478bd9Sstevel@tonic-gate };
737c478bd9Sstevel@tonic-gate extern void ktutil_write_v4 __SS_PROTO;
747c478bd9Sstevel@tonic-gate static char const * const ssu00006[] = {
757c478bd9Sstevel@tonic-gate "add_entry",
767c478bd9Sstevel@tonic-gate     "addent",
777c478bd9Sstevel@tonic-gate     (char const *)0
787c478bd9Sstevel@tonic-gate };
797c478bd9Sstevel@tonic-gate extern void ktutil_add_entry __SS_PROTO;
807c478bd9Sstevel@tonic-gate static char const * const ssu00007[] = {
817c478bd9Sstevel@tonic-gate "delete_entry",
827c478bd9Sstevel@tonic-gate     "delent",
837c478bd9Sstevel@tonic-gate     (char const *)0
847c478bd9Sstevel@tonic-gate };
857c478bd9Sstevel@tonic-gate extern void ktutil_delete_entry __SS_PROTO;
867c478bd9Sstevel@tonic-gate static char const * const ssu00008[] = {
877c478bd9Sstevel@tonic-gate "list",
887c478bd9Sstevel@tonic-gate     "l",
897c478bd9Sstevel@tonic-gate     (char const *)0
907c478bd9Sstevel@tonic-gate };
917c478bd9Sstevel@tonic-gate extern void ktutil_list __SS_PROTO;
927c478bd9Sstevel@tonic-gate static char const * const ssu00009[] = {
937c478bd9Sstevel@tonic-gate "list_requests",
947c478bd9Sstevel@tonic-gate     "lr",
957c478bd9Sstevel@tonic-gate     "?",
967c478bd9Sstevel@tonic-gate     (char const *)0
977c478bd9Sstevel@tonic-gate };
987c478bd9Sstevel@tonic-gate extern void ss_list_requests __SS_PROTO;
997c478bd9Sstevel@tonic-gate static char const * const ssu00010[] = {
1007c478bd9Sstevel@tonic-gate "quit",
1017c478bd9Sstevel@tonic-gate     "exit",
1027c478bd9Sstevel@tonic-gate     "q",
1037c478bd9Sstevel@tonic-gate     (char const *)0
1047c478bd9Sstevel@tonic-gate };
1057c478bd9Sstevel@tonic-gate extern void ss_quit __SS_PROTO;
1067c478bd9Sstevel@tonic-gate static ss_request_entry ssu00011[] = {
1077c478bd9Sstevel@tonic-gate     { ssu00001,
1087c478bd9Sstevel@tonic-gate       ktutil_clear_list,
1097c478bd9Sstevel@tonic-gate 		gettext("Clear the current keylist."),
1107c478bd9Sstevel@tonic-gate       0 },
1117c478bd9Sstevel@tonic-gate     { ssu00002,
1127c478bd9Sstevel@tonic-gate       ktutil_read_v5,
1137c478bd9Sstevel@tonic-gate 		gettext("Read a krb5 keytab into the current keylist."),
1147c478bd9Sstevel@tonic-gate       0 },
1157c478bd9Sstevel@tonic-gate     { ssu00003,
1167c478bd9Sstevel@tonic-gate       ktutil_read_v4,
1177c478bd9Sstevel@tonic-gate 		gettext("Read a krb4 srvtab into the current keylist."),
1187c478bd9Sstevel@tonic-gate       0 },
1197c478bd9Sstevel@tonic-gate     { ssu00004,
1207c478bd9Sstevel@tonic-gate       ktutil_write_v5,
1217c478bd9Sstevel@tonic-gate 		gettext("Write the current keylist to a krb5 keytab."),
1227c478bd9Sstevel@tonic-gate       0 },
1237c478bd9Sstevel@tonic-gate     { ssu00005,
1247c478bd9Sstevel@tonic-gate       ktutil_write_v4,
1257c478bd9Sstevel@tonic-gate 		gettext("Write the current keylist to a krb4 srvtab."),
1267c478bd9Sstevel@tonic-gate       0 },
1277c478bd9Sstevel@tonic-gate     { ssu00006,
1287c478bd9Sstevel@tonic-gate       ktutil_add_entry,
1297c478bd9Sstevel@tonic-gate 		gettext("Add an entry to the current keylist."),
1307c478bd9Sstevel@tonic-gate       0 },
1317c478bd9Sstevel@tonic-gate     { ssu00007,
1327c478bd9Sstevel@tonic-gate       ktutil_delete_entry,
1337c478bd9Sstevel@tonic-gate 		gettext("Delete an entry from the current keylist."),
1347c478bd9Sstevel@tonic-gate       0 },
1357c478bd9Sstevel@tonic-gate     { ssu00008,
1367c478bd9Sstevel@tonic-gate       ktutil_list,
1377c478bd9Sstevel@tonic-gate 		gettext("List the current keylist."),
1387c478bd9Sstevel@tonic-gate       0 },
1397c478bd9Sstevel@tonic-gate     { ssu00009,
1407c478bd9Sstevel@tonic-gate       ss_list_requests,
1417c478bd9Sstevel@tonic-gate 		gettext("List available requests."),
1427c478bd9Sstevel@tonic-gate       0 },
1437c478bd9Sstevel@tonic-gate     { ssu00010,
1447c478bd9Sstevel@tonic-gate       ss_quit,
1457c478bd9Sstevel@tonic-gate 		gettext("Exit program."),
1467c478bd9Sstevel@tonic-gate       0 },
1477c478bd9Sstevel@tonic-gate     { 0, 0, 0, 0 }
1487c478bd9Sstevel@tonic-gate };
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate ss_request_table ktutil_cmds = { 2, ssu00011 };
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate #undef gettext
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate /*
1557c478bd9Sstevel@tonic-gate  * This routine is responsible for localizing all the displayable
1567c478bd9Sstevel@tonic-gate  * messages in the table.  This was necessary since ktutil will be
1577c478bd9Sstevel@tonic-gate  * invoking library calls that need to be able to display the messages
1587c478bd9Sstevel@tonic-gate  * in the correct text domain (which only ktutil knows).
1597c478bd9Sstevel@tonic-gate  *
1607c478bd9Sstevel@tonic-gate  * This function assumes that the US version of the messages are
1617c478bd9Sstevel@tonic-gate  * pre-loaded in the table and will be used should gettext not be
1627c478bd9Sstevel@tonic-gate  * successful.  This routine does NOT free the replaced strings as
1637c478bd9Sstevel@tonic-gate  * its expected they may be in the heap (as above) and not malloc'ed.
1647c478bd9Sstevel@tonic-gate  * If the caller malloc'ed the strings, they should retain pointers
1657c478bd9Sstevel@tonic-gate  * and free them if not matching the contents of the table.
1667c478bd9Sstevel@tonic-gate  */
1677c478bd9Sstevel@tonic-gate krb5_error_code
1687c478bd9Sstevel@tonic-gate ktutil_initialize_cmds_table(ss_request_table *ktutil_cmds)
1697c478bd9Sstevel@tonic-gate {
1707c478bd9Sstevel@tonic-gate 	char *localized_text;
1717c478bd9Sstevel@tonic-gate 	ss_request_entry *ss_cmd;
1727c478bd9Sstevel@tonic-gate 	krb5_error_code retval = 0;
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate 	if (ktutil_cmds) {
1757c478bd9Sstevel@tonic-gate 		for (ss_cmd = ktutil_cmds->requests;
1767c478bd9Sstevel@tonic-gate 		ss_cmd->info_string && *(ss_cmd->info_string) != '\0';
1777c478bd9Sstevel@tonic-gate 		++ss_cmd) {
1787c478bd9Sstevel@tonic-gate 			localized_text = gettext(ss_cmd->info_string);
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate 			if ((strcmp(localized_text, ss_cmd->info_string))
1817c478bd9Sstevel@tonic-gate 				!= 0) {
1827c478bd9Sstevel@tonic-gate 				ss_cmd->info_string = strdup(localized_text);
1837c478bd9Sstevel@tonic-gate 			}
1847c478bd9Sstevel@tonic-gate 		}
1857c478bd9Sstevel@tonic-gate 	}
1867c478bd9Sstevel@tonic-gate 	else
1877c478bd9Sstevel@tonic-gate 		retval = EINVAL;
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate 	return (retval);
1907c478bd9Sstevel@tonic-gate }
191