1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* 3 * Copyright 1994 by the Massachusetts Institute of Technology. 4 * All Rights Reserved. 5 * 6 * Export of this software from the United States of America may 7 * require a specific license from the United States Government. 8 * It is the responsibility of any person or organization contemplating 9 * export to obtain such a license before exporting. 10 * 11 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 12 * distribute this software and its documentation for any purpose and 13 * without fee is hereby granted, provided that the above copyright 14 * notice appear in all copies and that both that copyright notice and 15 * this permission notice appear in supporting documentation, and that 16 * the name of M.I.T. not be used in advertising or publicity pertaining 17 * to distribution of the software without specific, written prior 18 * permission. Furthermore if you modify this software you must label 19 * your software as modified software and not distribute it in such a 20 * fashion that it might be confused with the original M.I.T. software. 21 * M.I.T. makes no representations about the suitability of 22 * this software for any purpose. It is provided "as is" without express 23 * or implied warranty. 24 */ 25 26 #include <k5-platform.h> 27 #include <krb5.h> 28 #include <locale.h> 29 #include <ss/ss.h> 30 #include "kadmin.h" 31 32 #ifdef NEED_SS_EXECUTE_COMMAND_PROTO 33 int ss_execute_command(int, char **); 34 #endif 35 36 extern ss_request_table kadmin_cmds; 37 extern int exit_status; 38 extern char *whoami; 39 40 int 41 main(int argc, char *argv[]) 42 { 43 char *request, **args; 44 krb5_error_code retval; 45 int sci_idx, code = 0; 46 47 setlocale(LC_ALL, ""); 48 whoami = ((whoami = strrchr(argv[0], '/')) ? whoami+1 : argv[0]); 49 50 kadmin_startup(argc, argv, &request, &args); 51 sci_idx = ss_create_invocation(whoami, "5.0", NULL, &kadmin_cmds, &retval); 52 if (retval) { 53 ss_perror(sci_idx, retval, _("creating invocation")); 54 exit(1); 55 } 56 57 if (*args != NULL) { 58 /* Execute post-option arguments as a single script-mode command. */ 59 code = ss_execute_command(sci_idx, args); 60 if (code) { 61 ss_perror(sci_idx, code, *args); 62 exit_status = 1; 63 } 64 } else if (request != NULL) { 65 /* Execute the -q option as a single interactive command. */ 66 code = ss_execute_line(sci_idx, request); 67 if (code != 0) { 68 ss_perror(sci_idx, code, request); 69 exit_status = 1; 70 } 71 } else { 72 /* Prompt for commands. */ 73 (void)ss_listen(sci_idx); 74 } 75 76 return quit() ? 1 : exit_status; 77 } 78