1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 3*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 4*7c478bd9Sstevel@tonic-gate */ 5*7c478bd9Sstevel@tonic-gate 6*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 7*7c478bd9Sstevel@tonic-gate 8*7c478bd9Sstevel@tonic-gate /* 9*7c478bd9Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 10*7c478bd9Sstevel@tonic-gate * 11*7c478bd9Sstevel@tonic-gate * Openvision retains the copyright to derivative works of 12*7c478bd9Sstevel@tonic-gate * this source code. Do *NOT* create a derivative of this 13*7c478bd9Sstevel@tonic-gate * source code before consulting with your legal department. 14*7c478bd9Sstevel@tonic-gate * Do *NOT* integrate *ANY* of this source code into another 15*7c478bd9Sstevel@tonic-gate * product before consulting with your legal department. 16*7c478bd9Sstevel@tonic-gate * 17*7c478bd9Sstevel@tonic-gate * For further information, read the top-level Openvision 18*7c478bd9Sstevel@tonic-gate * copyright which is contained in the top-level MIT Kerberos 19*7c478bd9Sstevel@tonic-gate * copyright. 20*7c478bd9Sstevel@tonic-gate * 21*7c478bd9Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 22*7c478bd9Sstevel@tonic-gate * 23*7c478bd9Sstevel@tonic-gate */ 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate /* ktutil_ct.c - automatically generated from ktutil_ct.ct */ 27*7c478bd9Sstevel@tonic-gate /* Above no longer appears to be true */ 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #include <libintl.h> 30*7c478bd9Sstevel@tonic-gate #include <ss/ss.h> 31*7c478bd9Sstevel@tonic-gate #include "k5-int.h" 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate /* 34*7c478bd9Sstevel@tonic-gate * I18n hack. We sill define gettext(s) to be s here. That way the info_strings 35*7c478bd9Sstevel@tonic-gate * will be extracted to the .po file. 36*7c478bd9Sstevel@tonic-gate */ 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #define gettext(s) s 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #ifndef __STDC__ 41*7c478bd9Sstevel@tonic-gate #define const 42*7c478bd9Sstevel@tonic-gate #endif 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate static char const *const ssu00001[] = { 45*7c478bd9Sstevel@tonic-gate "clear_list", 46*7c478bd9Sstevel@tonic-gate "clear", 47*7c478bd9Sstevel@tonic-gate (char const *) 0 48*7c478bd9Sstevel@tonic-gate }; 49*7c478bd9Sstevel@tonic-gate extern void ktutil_clear_list __SS_PROTO; 50*7c478bd9Sstevel@tonic-gate static char const *const ssu00002[] = { 51*7c478bd9Sstevel@tonic-gate "read_kt", 52*7c478bd9Sstevel@tonic-gate "rkt", 53*7c478bd9Sstevel@tonic-gate (char const *) 0 54*7c478bd9Sstevel@tonic-gate }; 55*7c478bd9Sstevel@tonic-gate extern void ktutil_read_v5 __SS_PROTO; 56*7c478bd9Sstevel@tonic-gate static char const *const ssu00003[] = { 57*7c478bd9Sstevel@tonic-gate "read_st", 58*7c478bd9Sstevel@tonic-gate "rst", 59*7c478bd9Sstevel@tonic-gate (char const *) 0 60*7c478bd9Sstevel@tonic-gate }; 61*7c478bd9Sstevel@tonic-gate extern void ktutil_read_v4 __SS_PROTO; 62*7c478bd9Sstevel@tonic-gate static char const *const ssu00004[] = { 63*7c478bd9Sstevel@tonic-gate "write_kt", 64*7c478bd9Sstevel@tonic-gate "wkt", 65*7c478bd9Sstevel@tonic-gate (char const *) 0 66*7c478bd9Sstevel@tonic-gate }; 67*7c478bd9Sstevel@tonic-gate extern void ktutil_write_v5 __SS_PROTO; 68*7c478bd9Sstevel@tonic-gate static char const *const ssu00005[] = { 69*7c478bd9Sstevel@tonic-gate "write_st", 70*7c478bd9Sstevel@tonic-gate "wst", 71*7c478bd9Sstevel@tonic-gate (char const *) 0 72*7c478bd9Sstevel@tonic-gate }; 73*7c478bd9Sstevel@tonic-gate extern void ktutil_write_v4 __SS_PROTO; 74*7c478bd9Sstevel@tonic-gate static char const *const ssu00006[] = { 75*7c478bd9Sstevel@tonic-gate "add_entry", 76*7c478bd9Sstevel@tonic-gate "addent", 77*7c478bd9Sstevel@tonic-gate (char const *) 0 78*7c478bd9Sstevel@tonic-gate }; 79*7c478bd9Sstevel@tonic-gate extern void ktutil_add_entry __SS_PROTO; 80*7c478bd9Sstevel@tonic-gate static char const *const ssu00007[] = { 81*7c478bd9Sstevel@tonic-gate "delete_entry", 82*7c478bd9Sstevel@tonic-gate "delent", 83*7c478bd9Sstevel@tonic-gate (char const *) 0 84*7c478bd9Sstevel@tonic-gate }; 85*7c478bd9Sstevel@tonic-gate extern void ktutil_delete_entry __SS_PROTO; 86*7c478bd9Sstevel@tonic-gate static char const *const ssu00008[] = { 87*7c478bd9Sstevel@tonic-gate "list", 88*7c478bd9Sstevel@tonic-gate "l", 89*7c478bd9Sstevel@tonic-gate (char const *) 0 90*7c478bd9Sstevel@tonic-gate }; 91*7c478bd9Sstevel@tonic-gate extern void ktutil_list __SS_PROTO; 92*7c478bd9Sstevel@tonic-gate static char const *const ssu00009[] = { 93*7c478bd9Sstevel@tonic-gate "list_requests", 94*7c478bd9Sstevel@tonic-gate "lr", 95*7c478bd9Sstevel@tonic-gate "?", 96*7c478bd9Sstevel@tonic-gate (char const *) 0 97*7c478bd9Sstevel@tonic-gate }; 98*7c478bd9Sstevel@tonic-gate extern void ss_list_requests __SS_PROTO; 99*7c478bd9Sstevel@tonic-gate static char const *const ssu00010[] = { 100*7c478bd9Sstevel@tonic-gate "quit", 101*7c478bd9Sstevel@tonic-gate "exit", 102*7c478bd9Sstevel@tonic-gate "q", 103*7c478bd9Sstevel@tonic-gate (char const *) 0 104*7c478bd9Sstevel@tonic-gate }; 105*7c478bd9Sstevel@tonic-gate extern void ss_quit __SS_PROTO; 106*7c478bd9Sstevel@tonic-gate static ss_request_entry ssu00011[] = { 107*7c478bd9Sstevel@tonic-gate {ssu00001, 108*7c478bd9Sstevel@tonic-gate ktutil_clear_list, 109*7c478bd9Sstevel@tonic-gate gettext("Clear the current keylist."), 110*7c478bd9Sstevel@tonic-gate 0}, 111*7c478bd9Sstevel@tonic-gate {ssu00002, 112*7c478bd9Sstevel@tonic-gate ktutil_read_v5, 113*7c478bd9Sstevel@tonic-gate gettext("Read a krb5 keytab into the current keylist."), 114*7c478bd9Sstevel@tonic-gate 0}, 115*7c478bd9Sstevel@tonic-gate {ssu00003, 116*7c478bd9Sstevel@tonic-gate ktutil_read_v4, 117*7c478bd9Sstevel@tonic-gate gettext("Read a krb4 srvtab into the current keylist."), 118*7c478bd9Sstevel@tonic-gate 0}, 119*7c478bd9Sstevel@tonic-gate {ssu00004, 120*7c478bd9Sstevel@tonic-gate ktutil_write_v5, 121*7c478bd9Sstevel@tonic-gate gettext("Write the current keylist to a krb5 keytab."), 122*7c478bd9Sstevel@tonic-gate 0}, 123*7c478bd9Sstevel@tonic-gate {ssu00005, 124*7c478bd9Sstevel@tonic-gate ktutil_write_v4, 125*7c478bd9Sstevel@tonic-gate gettext("Write the current keylist to a krb4 srvtab."), 126*7c478bd9Sstevel@tonic-gate 0}, 127*7c478bd9Sstevel@tonic-gate {ssu00006, 128*7c478bd9Sstevel@tonic-gate ktutil_add_entry, 129*7c478bd9Sstevel@tonic-gate gettext("Add an entry to the current keylist."), 130*7c478bd9Sstevel@tonic-gate 0}, 131*7c478bd9Sstevel@tonic-gate {ssu00007, 132*7c478bd9Sstevel@tonic-gate ktutil_delete_entry, 133*7c478bd9Sstevel@tonic-gate gettext("Delete an entry from the current keylist."), 134*7c478bd9Sstevel@tonic-gate 0}, 135*7c478bd9Sstevel@tonic-gate {ssu00008, 136*7c478bd9Sstevel@tonic-gate ktutil_list, 137*7c478bd9Sstevel@tonic-gate gettext("List the current keylist."), 138*7c478bd9Sstevel@tonic-gate 0}, 139*7c478bd9Sstevel@tonic-gate {ssu00009, 140*7c478bd9Sstevel@tonic-gate ss_list_requests, 141*7c478bd9Sstevel@tonic-gate gettext("List available requests."), 142*7c478bd9Sstevel@tonic-gate 0}, 143*7c478bd9Sstevel@tonic-gate {ssu00010, 144*7c478bd9Sstevel@tonic-gate ss_quit, 145*7c478bd9Sstevel@tonic-gate gettext("Exit program."), 146*7c478bd9Sstevel@tonic-gate 0}, 147*7c478bd9Sstevel@tonic-gate {0, 0, 0, 0} 148*7c478bd9Sstevel@tonic-gate }; 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate ss_request_table ktutil_cmds = {2, ssu00011}; 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate #undef gettext 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate /* 155*7c478bd9Sstevel@tonic-gate * This routine is responsible for localizing all the displayable 156*7c478bd9Sstevel@tonic-gate * messages in the table. This was necessary since ktutil will be 157*7c478bd9Sstevel@tonic-gate * invoking library calls that need to be able to display the messages 158*7c478bd9Sstevel@tonic-gate * in the correct text domain (which only ktutil knows). 159*7c478bd9Sstevel@tonic-gate * 160*7c478bd9Sstevel@tonic-gate * This function assumes that the US version of the messages are 161*7c478bd9Sstevel@tonic-gate * pre-loaded in the table and will be used should gettext not be 162*7c478bd9Sstevel@tonic-gate * successful. This routine does NOT free the replaced strings as 163*7c478bd9Sstevel@tonic-gate * its expected they may be in the heap (as above) and not malloc'ed. 164*7c478bd9Sstevel@tonic-gate * If the caller malloc'ed the strings, they should retain pointers 165*7c478bd9Sstevel@tonic-gate * and free them if not matching the contents of the table. 166*7c478bd9Sstevel@tonic-gate */ 167*7c478bd9Sstevel@tonic-gate krb5_error_code 168*7c478bd9Sstevel@tonic-gate ktutil_initialize_cmds_table(ss_request_table *ktutil_cmds) 169*7c478bd9Sstevel@tonic-gate { 170*7c478bd9Sstevel@tonic-gate char *localized_text; 171*7c478bd9Sstevel@tonic-gate ss_request_entry *ss_cmd; 172*7c478bd9Sstevel@tonic-gate krb5_error_code retval = 0; 173*7c478bd9Sstevel@tonic-gate 174*7c478bd9Sstevel@tonic-gate if (ktutil_cmds) { 175*7c478bd9Sstevel@tonic-gate for (ss_cmd = ktutil_cmds->requests; 176*7c478bd9Sstevel@tonic-gate ss_cmd->info_string && *(ss_cmd->info_string) != '\0'; 177*7c478bd9Sstevel@tonic-gate ++ss_cmd) { 178*7c478bd9Sstevel@tonic-gate localized_text = gettext(ss_cmd->info_string); 179*7c478bd9Sstevel@tonic-gate 180*7c478bd9Sstevel@tonic-gate if ((strcmp(localized_text, ss_cmd->info_string)) 181*7c478bd9Sstevel@tonic-gate != 0) { 182*7c478bd9Sstevel@tonic-gate ss_cmd->info_string = strdup(localized_text); 183*7c478bd9Sstevel@tonic-gate } 184*7c478bd9Sstevel@tonic-gate } 185*7c478bd9Sstevel@tonic-gate } 186*7c478bd9Sstevel@tonic-gate else 187*7c478bd9Sstevel@tonic-gate retval = EINVAL; 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate return (retval); 190*7c478bd9Sstevel@tonic-gate } 191