aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/kadmin/cli/ChangeLog15
-rw-r--r--src/kadmin/cli/getdate.y4
-rw-r--r--src/kadmin/cli/kadmin.c90
-rw-r--r--src/kadmin/cli/kadmin.h58
-rw-r--r--src/kadmin/cli/keytab.c54
-rw-r--r--src/kadmin/cli/ss_wrapper.c2
6 files changed, 154 insertions, 69 deletions
diff --git a/src/kadmin/cli/ChangeLog b/src/kadmin/cli/ChangeLog
index 0ad1e07..74563c6 100644
--- a/src/kadmin/cli/ChangeLog
+++ b/src/kadmin/cli/ChangeLog
@@ -1,3 +1,18 @@
+Mon Feb 26 13:25:50 2001 Ezra Peisach <epeisach@mit.edu>
+
+ * ss_wrapper.c: Include kadmin.h.
+
+ * kadmin.c, keytab.c: Warning cleanup of shadowing variables,
+ missing prototypes, assignments within conditionals. variables
+ type mismatches.
+
+ * getdate.y: Prototypes in file are for getdate_yylex() and
+ getdaye_yyerror() and not yylex()/yyerror().
+
+ * kadmin.h: New header file with ss callback prototypes and global
+ variables.
+
+
2000-10-17 Ezra Peisach <epeisach@mit.edu>
* kadmin.c (kadmin_cpw): Argument to krb5_read_password changed to
diff --git a/src/kadmin/cli/getdate.y b/src/kadmin/cli/getdate.y
index 6de1f7e..1b4613c 100644
--- a/src/kadmin/cli/getdate.y
+++ b/src/kadmin/cli/getdate.y
@@ -119,8 +119,8 @@ extern struct tm *localtime();
#define yylex getdate_yylex
#define yyerror getdate_yyerror
-static int yylex ();
-static int yyerror ();
+static int getdate_yylex ();
+static int getdate_yyerror ();
#if !defined(lint) && !defined(SABER) && !defined(_LINT)
static char RCS[] =
diff --git a/src/kadmin/cli/kadmin.c b/src/kadmin/cli/kadmin.c
index 87feb9a..0c223e0 100644
--- a/src/kadmin/cli/kadmin.c
+++ b/src/kadmin/cli/kadmin.c
@@ -28,6 +28,7 @@
#include <krb5.h>
#include <k5-int.h>
#include <kadm5/admin.h>
+#include <krb5/adm_proto.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
@@ -36,6 +37,7 @@
#include <pwd.h>
/* #include <sys/timeb.h> */
#include <time.h>
+#include "kadmin.h"
/* special struct to convert flag names for principals
to actual krb5_flags for a principal */
@@ -91,7 +93,7 @@ void *handle = NULL;
krb5_context context;
char *ccache_name = NULL;
-void usage()
+static void usage()
{
fprintf(stderr,
"Usage: %s [-r realm] [-p principal] [-q query] [clnt|local args]\n"
@@ -100,7 +102,7 @@ void usage()
exit(1);
}
-char *strdur(duration)
+static char *strdur(duration)
time_t duration;
{
static char out[50];
@@ -124,7 +126,7 @@ char *strdur(duration)
return out;
}
-char *strdate(when)
+static char *strdate(when)
krb5_timestamp when;
{
struct tm *tm;
@@ -138,7 +140,8 @@ char *strdate(when)
/* this is a wrapper to go around krb5_parse_principal so we can set
the default realm up properly */
-krb5_error_code kadmin_parse_name(name, principal)
+static krb5_error_code
+kadmin_parse_name(name, principal)
char *name;
krb5_principal *principal;
{
@@ -184,7 +187,8 @@ char *kadmin_startup(argc, argv)
memset((char *) &params, 0, sizeof(params));
- if (retval = krb5_init_context(&context)) {
+ retval = krb5_init_context(&context);
+ if (retval) {
com_err(whoami, retval, "while initializing krb5 library");
exit(1);
}
@@ -260,13 +264,13 @@ char *kadmin_startup(argc, argv)
* argument or the default.
*/
if (ccache_name == NULL) {
- if (retval = krb5_cc_default(context, &cc)) {
+ if ((retval = krb5_cc_default(context, &cc))) {
com_err(whoami, retval,
"while opening default credentials cache");
exit(1);
}
} else {
- if (retval = krb5_cc_resolve(context, ccache_name, &cc)) {
+ if ((retval = krb5_cc_resolve(context, ccache_name, &cc))) {
com_err(whoami, retval,
"while opening credentials cache %s", ccache_name);
exit(1);
@@ -287,7 +291,7 @@ char *kadmin_startup(argc, argv)
if (princstr == NULL) {
if (ccache_name != NULL &&
!krb5_cc_get_principal(context, cc, &princ)) {
- if (retval = krb5_unparse_name(context, princ, &princstr)) {
+ if ((retval = krb5_unparse_name(context, princ, &princstr))) {
com_err(whoami, retval,
"while canonicalizing principal name");
krb5_free_principal(context, princ);
@@ -296,16 +300,16 @@ char *kadmin_startup(argc, argv)
krb5_free_principal(context, princ);
freeprinc++;
} else if (use_keytab != 0) {
- if (retval = krb5_sname_to_principal(context, NULL,
- "host",
- KRB5_NT_SRV_HST,
- &princ)) {
+ if ((retval = krb5_sname_to_principal(context, NULL,
+ "host",
+ KRB5_NT_SRV_HST,
+ &princ))) {
com_err(whoami, retval,
"creating host service principal");
exit(1);
}
- if (retval = krb5_unparse_name(context, princ, &princstr)) {
- com_err(whoami, retval,
+ if ((retval = krb5_unparse_name(context, princ, &princstr))) {
+ com_err(whoami, retval,
"while canonicalizing principal name");
krb5_free_principal(context, princ);
exit(1);
@@ -354,7 +358,7 @@ char *kadmin_startup(argc, argv)
free(canon);
krb5_free_principal(context, princ);
freeprinc++;
- } else if (luser = getenv("USER")) {
+ } else if ((luser = getenv("USER"))) {
princstr = (char *) malloc(strlen(luser) + 7 /* "/admin@" */
+ strlen(def_realm) + 1);
if (princstr == NULL) {
@@ -366,7 +370,7 @@ char *kadmin_startup(argc, argv)
strcat(princstr, "@");
strcat(princstr, def_realm);
freeprinc++;
- } else if (pw = getpwuid(getuid())) {
+ } else if ((pw = getpwuid(getuid()))) {
princstr = (char *) malloc(strlen(pw->pw_name) + 7 /* "/admin@" */
+ strlen(def_realm) + 1);
if (princstr == NULL) {
@@ -436,14 +440,14 @@ char *kadmin_startup(argc, argv)
if (freeprinc)
free(princstr);
- if (retval = krb5_cc_close(context, cc)) {
+ if ((retval = krb5_cc_close(context, cc))) {
com_err(whoami, retval, "while closing ccache %s",
ccache_name);
exit(1);
}
/* register the WRFILE keytab type and set it as the default */
- if (retval = krb5_kt_register(context, &krb5_ktf_writable_ops)) {
+ if ((retval = krb5_kt_register(context, &krb5_ktf_writable_ops))) {
com_err(whoami, retval,
"while registering writable key table functions");
exit(1);
@@ -531,7 +535,8 @@ void kadmin_cpw(argc, argv)
static char prompt1[1024], prompt2[1024];
char *canon;
char *pwarg = NULL;
- int n_ks_tuple = 0, keepold = 0, randkey = 0;
+ int n_ks_tuple = 0, randkey = 0;
+ krb5_boolean keepold = FALSE;
krb5_key_salt_tuple *ks_tuple = NULL;
krb5_principal princ;
@@ -553,7 +558,7 @@ void kadmin_cpw(argc, argv)
continue;
}
if (!strcmp("-keepold", *argv)) {
- keepold++;
+ keepold = TRUE;
continue;
}
if (!strcmp("-e", *argv)) {
@@ -681,8 +686,9 @@ void kadmin_cpw(argc, argv)
}
}
-int kadmin_parse_princ_args(argc, argv, oprinc, mask, pass, randkey,
- ks_tuple, n_ks_tuple, caller)
+static int
+kadmin_parse_princ_args(argc, argv, oprinc, mask, pass, randkey,
+ ks_tuple, n_ks_tuple, caller)
int argc;
char *argv[];
kadm5_principal_ent_t oprinc;
@@ -828,14 +834,14 @@ int kadmin_parse_princ_args(argc, argv, oprinc, mask, pass, randkey,
if (strlen(argv[i]) == flags[j].flaglen + 1 &&
!strcmp(flags[j].flagname,
&argv[i][1] /* strip off leading + or - */)) {
- if (flags[j].set && argv[i][0] == '-' ||
- !flags[j].set && argv[i][0] == '+') {
+ if ((flags[j].set && argv[i][0] == '-') ||
+ (!flags[j].set && argv[i][0] == '+')) {
oprinc->attributes |= flags[j].theflag;
*mask |= KADM5_ATTRIBUTES;
attrib_set++;
break;
- } else if (flags[j].set && argv[i][0] == '+' ||
- !flags[j].set && argv[i][0] == '-') {
+ } else if ((flags[j].set && argv[i][0] == '+') ||
+ (!flags[j].set && argv[i][0] == '-')) {
oprinc->attributes &= ~flags[j].theflag;
*mask |= KADM5_ATTRIBUTES;
attrib_set++;
@@ -859,7 +865,8 @@ int kadmin_parse_princ_args(argc, argv, oprinc, mask, pass, randkey,
return 0;
}
-void kadmin_addprinc_usage(func)
+static void
+kadmin_addprinc_usage(func)
char *func;
{
fprintf(stderr, "usage: %s [options] principal\n", func);
@@ -872,7 +879,8 @@ void kadmin_addprinc_usage(func)
"\t\trequires_hwauth needchange allow_svr password_changing_service\n");
}
-void kadmin_modprinc_usage(func)
+static void
+kadmin_modprinc_usage(func)
char *func;
{
fprintf(stderr, "usage: %s [options] principal\n", func);
@@ -954,7 +962,7 @@ void kadmin_addprinc(argc, argv)
mask |= KADM5_ATTRIBUTES;
pass = dummybuf;
} else if (pass == NULL) {
- unsigned int i = sizeof (newpw) - 1;
+ unsigned int sz = sizeof (newpw) - 1;
sprintf(prompt1, "Enter password for principal \"%.900s\": ",
canon);
@@ -962,7 +970,7 @@ void kadmin_addprinc(argc, argv)
"Re-enter password for principal \"%.900s\": ",
canon);
retval = krb5_read_password(context, prompt1, prompt2,
- newpw, &i);
+ newpw, &sz);
if (retval) {
com_err("add_principal", retval,
"while reading password for \"%s\".", canon);
@@ -1233,15 +1241,15 @@ void kadmin_getprincs(argc, argv)
char *argv[];
{
krb5_error_code retval;
- char *exp, **names;
+ char *expr, **names;
int i, count;
- exp = NULL;
- if (! (argc == 1 || (argc == 2 && (exp = argv[1])))) {
+ expr = NULL;
+ if (! (argc == 1 || (argc == 2 && (expr = argv[1])))) {
fprintf(stderr, "usage: get_principals [expression]\n");
return;
}
- retval = kadm5_get_principals(handle, exp, &names, &count);
+ retval = kadm5_get_principals(handle, expr, &names, &count);
if (retval) {
com_err("get_principals", retval, "while retrieving list.");
return;
@@ -1251,7 +1259,8 @@ void kadmin_getprincs(argc, argv)
kadm5_free_name_list(handle, names, count);
}
-int kadmin_parse_policy_args(argc, argv, policy, mask, caller)
+static int
+kadmin_parse_policy_args(argc, argv, policy, mask, caller)
int argc;
char *argv[];
kadm5_policy_ent_t policy;
@@ -1332,7 +1341,8 @@ int kadmin_parse_policy_args(argc, argv, policy, mask, caller)
return 0;
}
-void kadmin_addmodpol_usage(func)
+static void
+kadmin_addmodpol_usage(func)
char *func;
{
fprintf(stderr, "usage; %s [options] policy\n", func);
@@ -1461,15 +1471,15 @@ void kadmin_getpols(argc, argv)
char *argv[];
{
krb5_error_code retval;
- char *exp, **names;
+ char *expr, **names;
int i, count;
- exp = NULL;
- if (! (argc == 1 || (argc == 2 && (exp = argv[1])))) {
+ expr = NULL;
+ if (! (argc == 1 || (argc == 2 && (expr = argv[1])))) {
fprintf(stderr, "usage: get_policies [expression]\n");
return;
}
- retval = kadm5_get_policies(handle, exp, &names, &count);
+ retval = kadm5_get_policies(handle, expr, &names, &count);
if (retval) {
com_err("get_policies", retval, "while retrieving list.");
return;
diff --git a/src/kadmin/cli/kadmin.h b/src/kadmin/cli/kadmin.h
new file mode 100644
index 0000000..4255e0c
--- /dev/null
+++ b/src/kadmin/cli/kadmin.h
@@ -0,0 +1,58 @@
+/*
+ * kadmin/cli/kadmin.h
+ *
+ * Copyright 2001 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ *
+ * Prototypes for kadmin functions called from SS library.
+ */
+
+#ifndef __KADMIN_H__
+#define __KADMIN_H__
+
+/* It would be nice if ss produced a header file we could reference */
+extern char *kadmin_startup(int argc, char *argv[]);
+extern int quit (void);
+extern void kadmin_delprinc(int argc, char *argv[]);
+extern void kadmin_cpw(int argc, char *argv[]);
+extern void kadmin_addprinc(int argc, char *argv[]);
+extern void kadmin_modprinc(int argc, char *argv[]);
+extern void kadmin_getprinc(int argc, char *argv[]);
+extern void kadmin_getprincs(int argc, char *argv[]);
+extern void kadmin_addpol(int argc, char *argv[]);
+extern void kadmin_modpol(int argc, char *argv[]);
+extern void kadmin_delpol(int argc, char *argv[]);
+extern void kadmin_getpol(int argc, char *argv[]);
+extern void kadmin_getpols(int argc, char *argv[]);
+extern void kadmin_getprivs(int argc, char *argv[]);
+extern void kadmin_keytab_add(int argc, char *argv[]);
+extern void kadmin_keytab_remove(int argc, char *argv[]);
+
+/* Yucky global variables */
+extern krb5_context context;
+extern char *krb5_defkeyname;
+extern char *whoami;
+extern void *handle;
+
+#endif /* __KADMIN_H__ */
+
diff --git a/src/kadmin/cli/keytab.c b/src/kadmin/cli/keytab.c
index 832628e..3d25b95 100644
--- a/src/kadmin/cli/keytab.c
+++ b/src/kadmin/cli/keytab.c
@@ -42,32 +42,30 @@ static char *rcsid = "$Header$";
#include <krb5.h>
#include <k5-int.h>
#include <kadm5/admin.h>
+#include <krb5/adm_proto.h>
+#include "kadmin.h"
-static int add_principal(void *handle, char *keytab_str, krb5_keytab keytab,
- int keepold,
+static int add_principal(void *lhandle, char *keytab_str, krb5_keytab keytab,
+ krb5_boolean keepold,
int n_ks_tuple, krb5_key_salt_tuple *ks_tuple,
char *princ_str);
static int remove_principal(char *keytab_str, krb5_keytab keytab, char
*princ_str, char *kvno_str);
static char *etype_string(krb5_enctype enctype);
-extern char *krb5_defkeyname;
-extern char *whoami;
-extern krb5_context context;
-extern void *handle;
static int quiet;
-void add_usage()
+static void add_usage()
{
fprintf(stderr, "Usage: ktadd [-k[eytab] keytab] [-q] [-e keysaltlist] [principal | -glob princ-exp] [...]\n");
}
-void rem_usage()
+static void rem_usage()
{
fprintf(stderr, "Usage: ktremove [-k[eytab] keytab] [-q] principal [kvno|\"all\"|\"old\"]\n");
}
-int process_keytab(krb5_context context, char **keytab_str,
+static int process_keytab(krb5_context my_context, char **keytab_str,
krb5_keytab *keytab)
{
int code;
@@ -79,7 +77,7 @@ int process_keytab(krb5_context context, char **keytab_str,
com_err(whoami, ENOMEM, "while creating keytab name");
return 1;
}
- code = krb5_kt_default(context, keytab);
+ code = krb5_kt_default(my_context, keytab);
if (code != 0) {
com_err(whoami, code, "while opening default keytab");
free(*keytab_str);
@@ -104,7 +102,7 @@ int process_keytab(krb5_context context, char **keytab_str,
sprintf(*keytab_str, "WRFILE:%s", tmp);
}
- code = krb5_kt_resolve(context, *keytab_str, keytab);
+ code = krb5_kt_resolve(my_context, *keytab_str, keytab);
if (code != 0) {
com_err(whoami, code, "while resolving keytab %s", *keytab_str);
free(keytab_str);
@@ -119,10 +117,11 @@ int process_keytab(krb5_context context, char **keytab_str,
void kadmin_keytab_add(int argc, char **argv)
{
krb5_keytab keytab = 0;
- char *princ_str, *keytab_str = NULL, **princs;
+ char *keytab_str = NULL, **princs;
int code, num, i;
krb5_error_code retval;
- int keepold = 0, n_ks_tuple = 0;
+ int n_ks_tuple = 0;
+ krb5_boolean keepold = FALSE;
krb5_key_salt_tuple *ks_tuple = NULL;
argc--; argv++;
@@ -171,7 +170,8 @@ void kadmin_keytab_add(int argc, char **argv)
break;
}
- if (code = kadm5_get_principals(handle, *argv, &princs, &num)) {
+ code = kadm5_get_principals(handle, *argv, &princs, &num);
+ if (code) {
com_err(whoami, code, "while expanding expression \"%s\".",
*argv);
argv++;
@@ -200,7 +200,7 @@ void kadmin_keytab_add(int argc, char **argv)
void kadmin_keytab_remove(int argc, char **argv)
{
krb5_keytab keytab = 0;
- char *princ_str, *keytab_str = NULL;
+ char *keytab_str = NULL;
int code;
argc--; argv++;
@@ -236,8 +236,9 @@ void kadmin_keytab_remove(int argc, char **argv)
free(keytab_str);
}
-int add_principal(void *handle, char *keytab_str, krb5_keytab keytab,
- int keepold, int n_ks_tuple,
+static
+int add_principal(void *lhandle, char *keytab_str, krb5_keytab keytab,
+ krb5_boolean keepold, int n_ks_tuple,
krb5_key_salt_tuple *ks_tuple,
char *princ_str)
{
@@ -245,7 +246,7 @@ int add_principal(void *handle, char *keytab_str, krb5_keytab keytab,
krb5_principal princ;
krb5_keytab_entry new_entry;
krb5_keyblock *keys;
- int code, code2, mask, nkeys, i;
+ int code, nkeys, i;
(void) memset((char *)&princ_rec, 0, sizeof(princ_rec));
@@ -261,11 +262,11 @@ int add_principal(void *handle, char *keytab_str, krb5_keytab keytab,
}
if (keepold || ks_tuple != NULL) {
- code = kadm5_randkey_principal_3(handle, princ,
+ code = kadm5_randkey_principal_3(lhandle, princ,
keepold, n_ks_tuple, ks_tuple,
&keys, &nkeys);
} else {
- code = kadm5_randkey_principal(handle, princ, &keys, &nkeys);
+ code = kadm5_randkey_principal(lhandle, princ, &keys, &nkeys);
}
if (code != 0) {
if (code == KADM5_UNK_PRINC) {
@@ -277,7 +278,7 @@ int add_principal(void *handle, char *keytab_str, krb5_keytab keytab,
goto cleanup;
}
- code = kadm5_get_principal(handle, princ, &princ_rec,
+ code = kadm5_get_principal(lhandle, princ, &princ_rec,
KADM5_PRINCIPAL_NORMAL_MASK);
if (code != 0) {
com_err(whoami, code, "while retrieving principal");
@@ -293,7 +294,7 @@ int add_principal(void *handle, char *keytab_str, krb5_keytab keytab,
code = krb5_kt_add_entry(context, keytab, &new_entry);
if (code != 0) {
com_err(whoami, code, "while adding key to keytab");
- (void) kadm5_free_principal_ent(handle, &princ_rec);
+ (void) kadm5_free_principal_ent(lhandle, &princ_rec);
goto cleanup;
}
@@ -304,7 +305,7 @@ int add_principal(void *handle, char *keytab_str, krb5_keytab keytab,
etype_string(keys[i].enctype), keytab_str);
}
- code = kadm5_free_principal_ent(handle, &princ_rec);
+ code = kadm5_free_principal_ent(lhandle, &princ_rec);
if (code != 0) {
com_err(whoami, code, "while freeing principal entry");
goto cleanup;
@@ -329,7 +330,8 @@ int remove_principal(char *keytab_str, krb5_keytab keytab, char
krb5_keytab_entry entry;
krb5_kt_cursor cursor;
enum { UNDEF, SPEC, HIGH, ALL, OLD } mode;
- int code, kvno, did_something;
+ int code, did_something;
+ krb5_kvno kvno;
code = krb5_parse_name(context, princ_str, &princ);
if (code != 0) {
@@ -428,7 +430,7 @@ int remove_principal(char *keytab_str, krb5_keytab keytab, char
com_err(whoami, code, "while scanning keytab");
return code;
}
- if (code = krb5_kt_end_seq_get(context, keytab, &cursor)) {
+ if ((code = krb5_kt_end_seq_get(context, keytab, &cursor))) {
com_err(whoami, code, "while ending keytab scan");
return code;
}
@@ -458,7 +460,7 @@ static char *etype_string(enctype)
static char buf[100];
krb5_error_code ret;
- if (ret = krb5_enctype_to_string(enctype, buf, sizeof(buf)))
+ if ((ret = krb5_enctype_to_string(enctype, buf, sizeof(buf))))
sprintf(buf, "etype %d", enctype);
return buf;
diff --git a/src/kadmin/cli/ss_wrapper.c b/src/kadmin/cli/ss_wrapper.c
index c8d10ac..f73ba82 100644
--- a/src/kadmin/cli/ss_wrapper.c
+++ b/src/kadmin/cli/ss_wrapper.c
@@ -29,10 +29,10 @@
#include <ss/ss.h>
#include <stdio.h>
#include <string.h>
+#include "kadmin.h"
extern ss_request_table kadmin_cmds;
extern int exit_status;
-extern char *kadmin_startup();
extern char *whoami;
int main(argc, argv)