xref: /titanic_50/usr/src/cmd/krb5/kadmin/cli/ss_wrapper.c (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
1 #pragma ident	"%Z%%M%	%I%	%E% SMI"
2 
3 /*
4  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
5  *
6  *	Openvision retains the copyright to derivative works of
7  *	this source code.  Do *NOT* create a derivative of this
8  *	source code before consulting with your legal department.
9  *	Do *NOT* integrate *ANY* of this source code into another
10  *	product before consulting with your legal department.
11  *
12  *	For further information, read the top-level Openvision
13  *	copyright which is contained in the top-level MIT Kerberos
14  *	copyright.
15  *
16  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
17  *
18  */
19 
20 
21 /*
22  * Copyright 1994 by the Massachusetts Institute of Technology.
23  * All Rights Reserved.
24  *
25  * Export of this software from the United States of America may
26  *   require a specific license from the United States Government.
27  *   It is the responsibility of any person or organization contemplating
28  *   export to obtain such a license before exporting.
29  *
30  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
31  * distribute this software and its documentation for any purpose and
32  * without fee is hereby granted, provided that the above copyright
33  * notice appear in all copies and that both that copyright notice and
34  * this permission notice appear in supporting documentation, and that
35  * the name of M.I.T. not be used in advertising or publicity pertaining
36  * to distribution of the software without specific, written prior
37  * permission.  Furthermore if you modify this software you must label
38  * your software as modified software and not distribute it in such a
39  * fashion that it might be confused with the original M.I.T. software.
40  * M.I.T. makes no representations about the suitability of
41  * this software for any purpose.  It is provided "as is" without express
42  * or implied warranty.
43  *
44  *
45  * ss wrapper for kadmin
46  */
47 
48 #include <krb5.h>
49 #include <ss/ss.h>
50 #include <stdio.h>
51 #include <string.h>
52 #include <libintl.h>
53 #include <locale.h>
54 #include "kadmin.h"
55 
56 extern ss_request_table kadmin_cmds;
57 extern int exit_status;
58 extern char *whoami;
59 
60 int main(argc, argv)
61     int argc;
62     char *argv[];
63 {
64     char *request;
65     krb5_error_code retval;
66     int sci_idx, code = 0;
67 
68     whoami = ((whoami = strrchr(argv[0], '/')) ? whoami+1 : argv[0]);
69 
70 	(void) setlocale(LC_ALL, "");
71 
72 #if !defined(TEXT_DOMAIN)  /* Should be defined by cc -D */
73 #define	TEXT_DOMAIN	"SYS_TEST"	/* Use this only if it weren't */
74 #endif
75 
76 	(void) textdomain(TEXT_DOMAIN);
77 
78     request = kadmin_startup(argc, argv);
79     sci_idx = ss_create_invocation(whoami, "5.0", (char *) NULL,
80 				   &kadmin_cmds, &retval);
81     if (retval) {
82 	ss_perror(sci_idx, retval, gettext("creating invocation"));
83 	exit(1);
84     }
85 
86 	(void) setlocale(LC_ALL, "");
87 	(void) textdomain(TEXT_DOMAIN);
88 
89     if (request) {
90 	    code = ss_execute_line(sci_idx, request);
91 	    if (code != 0) {
92 		    ss_perror(sci_idx, code, request);
93 		    exit_status++;
94 	    }
95     } else
96             retval = ss_listen(sci_idx);
97     return quit() ? 1 : exit_status;
98 }
99