xref: /illumos-gate/usr/src/cmd/krb5/kadmin/cli/ss_wrapper.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 
55 extern ss_request_table kadmin_cmds;
56 extern int exit_status;
57 extern char *kadmin_startup();
58 extern char *whoami;
59 
60 int
61 main(argc, argv)
62 int argc;
63 char *argv[];
64 {
65 	char *request;
66 	krb5_error_code retval;
67 	int sci_idx, code = 0;
68 
69 	whoami = ((whoami = strrchr(argv[0], '/')) ? whoami + 1 : argv[0]);
70 
71 	(void) setlocale(LC_ALL, "");
72 
73 #if !defined(TEXT_DOMAIN)  /* Should be defined by cc -D */
74 #define	TEXT_DOMAIN	"SYS_TEST"	/* Use this only if it weren't */
75 #endif
76 
77 	(void) textdomain(TEXT_DOMAIN);
78 
79 	request = kadmin_startup(argc, argv);
80 	sci_idx = ss_create_invocation(whoami, "5.0", (char *) NULL,
81 	    &kadmin_cmds, &retval);
82 	if (retval) {
83 		ss_perror(sci_idx, retval, gettext("creating invocation"));
84 		exit(1);
85 	}
86 
87 	(void) setlocale(LC_ALL, "");
88 	(void) textdomain(TEXT_DOMAIN);
89 
90 	if (request) {
91 		code = ss_execute_line(sci_idx, request);
92 		if (code != 0) {
93 			ss_perror(sci_idx, code, request);
94 			exit_status++;
95 		}
96 	} else
97 		ss_listen(sci_idx, &retval);
98 	return (quit() ? 1 : exit_status);
99 }
100