1 /*
2  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 /*
9  * Contains remote client specific code.
10  */
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <libintl.h>
15 #include <krb5.h>
16 #include <k5-int.h>
17 
18 extern void *handle;
19 
20 void
21 usage(char *whoami)
22 {
23 	fprintf(stderr,
24 	    "%s: %s [-r realm] [-p principal] [-q query] "
25 	    "[-s admin_server[:port]] [[-c ccache]|[-k [-t keytab]]]\n",
26 	    gettext("Usage"), whoami);
27 	exit(1);
28 }
29 
30 
31 /*
32  * Debugging function - for remote admin client
33  */
34 /* ARGSUSED */
35 void
36 debugEnable(int displayMsgs)
37 {
38 
39 #ifdef DEBUG
40 	debugDisplaySS(displayMsgs);
41 #endif
42 }
43 
44 void kadmin_getprivs(argc, argv)
45     int argc;
46     char *argv[];
47 {
48     static char *privs[] = {"GET", "ADD", "MODIFY", "DELETE", "LIST", "CHANGE"};
49     krb5_error_code retval;
50     int i;
51     long plist;
52 
53     if (argc != 1) {
54 	fprintf(stderr, "%s: get_privs\n", gettext("usage"));
55 	return;
56     }
57     retval = kadm5_get_privs(handle, &plist);
58     if (retval) {
59 	com_err("get_privs", retval,
60 		    gettext("while retrieving privileges"));
61 	return;
62     }
63     printf(gettext("current privileges:"));
64     for (i = 0; i < sizeof (privs) / sizeof (char *); i++) {
65 	if (plist & 1 << i)
66 	    printf(" %s", gettext(privs[i]));
67     }
68     printf("\n");
69     return;
70 }
71