From: Paul Park Date: Fri, 28 Apr 1995 19:25:55 +0000 (+0000) Subject: Use new library libkadm. X-Git-Tag: krb5-1.0-beta5~128 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=77f7de1bdb0c3630bd10abe8db52ea6610ed3fbb;p=krb5.git Use new library libkadm. Cleanup some type conflicts. Allow for case-insensitivity for protocol commands. Cleanup some include files. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5624 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/v5server/ChangeLog b/src/kadmin/v5server/ChangeLog index f0937c47d..c25448af4 100644 --- a/src/kadmin/v5server/ChangeLog +++ b/src/kadmin/v5server/ChangeLog @@ -1,3 +1,17 @@ + +Fri Apr 28 10:13:21 EDT 1995 Paul Park (pjpark@mit.edu) + Add new library libkadm. + * configure.in - Check for presence of vsprintf. + * passwd.c - Use size_t for sizes. + * proto_serv.c - Allow for case-insensitivity of commands. + - Remove socket-dependent includes and add NEED_SOCKETS + * srv_key.c - Use size_t for sizes. + * srv_main.c - Check for presence of vsprintf. + * srv_net.c - Remove socket-dependent includes and add NEED_SOCKETS + - Use size_t for sizes. + - Return success if bind succeeds. + * srv_output.c - Add language name recoginition. + Fri Apr 28 13:06:18 1995 Theodore Y. Ts'o * srv_net.c: Linux doesn't have SOMAXCONN, assume 5 if not defined. diff --git a/src/kadmin/v5server/Makefile.in b/src/kadmin/v5server/Makefile.in index 5dd6822e7..d73336a54 100644 --- a/src/kadmin/v5server/Makefile.in +++ b/src/kadmin/v5server/Makefile.in @@ -4,12 +4,13 @@ LDFLAGS = -g COMERRLIB=$(BUILDTOP)/util/et/libcom_err.a SSLIB=$(BUILDTOP)/util/ss/libss.a DBMLIB= -KDBLIB=$(TOPLIBD)/libkdb5.a +KDBLIB=$(TOPLIBD)/libkdb5.a +KADMLIB=$(TOPLIBD)/libkadm.a all:: -KLIB = $(KDBLIB) $(TOPLIBD)/libkrb5.a $(TOPLIBD)/libcrypto.a $(SSLIB) $(COMERRLIB) $(DBMLIB) -DEPKLIB = $(TOPLIBD)/libkrb5.a $(TOPLIBD)/libcrypto.a $(SSLIB) $(COMERRLIB) $(DBMLIB) +KLIB = $(KADMLIB) $(KDBLIB) $(TOPLIBD)/libkrb5.a $(TOPLIBD)/libcrypto.a $(SSLIB) $(COMERRLIB) $(DBMLIB) +DEPKLIB = $(KADMLIB) $(TOPLIBD)/libkrb5.a $(TOPLIBD)/libcrypto.a $(SSLIB) $(COMERRLIB) $(DBMLIB) SRCS = \ $(srcdir)/srv_main.c $(srcdir)/srv_key.c \ diff --git a/src/kadmin/v5server/configure.in b/src/kadmin/v5server/configure.in index 96db24427..e5a097e0d 100644 --- a/src/kadmin/v5server/configure.in +++ b/src/kadmin/v5server/configure.in @@ -7,6 +7,7 @@ WITH_NETLIB AC_CHECK_LIB(ndbm,main) AC_CHECK_LIB(dbm,main) AC_FUNC_CHECK(waitpid,AC_DEFINE(HAVE_WAITPID)) +AC_FUNC_CHECK(vsprintf,AC_DEFINE(HAVE_VSPRINTF)) CHECK_WAIT_TYPE ET_RULES KRB_INCLUDE diff --git a/src/kadmin/v5server/passwd.c b/src/kadmin/v5server/passwd.c index 9013c3d84..2e5b498a5 100644 --- a/src/kadmin/v5server/passwd.c +++ b/src/kadmin/v5server/passwd.c @@ -161,19 +161,19 @@ passwd_check_opass_ok(kcontext, debug_level, princ, dbentp, pwdata) if (kret) pwret = 0; if (akey1.contents) { - memset((char *) akey1.contents, 0, akey1.length); + memset((char *) akey1.contents, 0, (size_t) akey1.length); krb5_xfree(akey1.contents); } if (pkey1.contents) { - memset((char *) pkey1.contents, 0, pkey1.length); + memset((char *) pkey1.contents, 0, (size_t) pkey1.length); krb5_xfree(pkey1.contents); } if (akey.contents) { - memset((char *) akey.contents, 0, akey.length); + memset((char *) akey.contents, 0, (size_t) akey.length); krb5_xfree(akey.contents); } if (pkey.contents) { - memset((char *) pkey.contents, 0, pkey.length); + memset((char *) pkey.contents, 0, (size_t) pkey.length); krb5_xfree(pkey.contents); } DPRINT(DEBUG_CALLS, debug_level, @@ -309,11 +309,11 @@ passwd_set_npass(kcontext, debug_level, princ, dbentp, pwdata) krb5_xfree(entry2write.alt_key.contents); } if (akey.contents) { - memset((char *) akey.contents, 0, akey.length); + memset((char *) akey.contents, 0, (size_t) akey.length); krb5_xfree(akey.contents); } if (pkey.contents) { - memset((char *) pkey.contents, 0, pkey.length); + memset((char *) pkey.contents, 0, (size_t) pkey.length); krb5_xfree(pkey.contents); } DPRINT(DEBUG_CALLS, debug_level, diff --git a/src/kadmin/v5server/proto_serv.c b/src/kadmin/v5server/proto_serv.c index a49e68956..f3dcc490b 100644 --- a/src/kadmin/v5server/proto_serv.c +++ b/src/kadmin/v5server/proto_serv.c @@ -27,15 +27,12 @@ * protocol as implemented in lib/krb5/os/adm_conn.c. Any changes * in one module must be reflected in the other. */ -#include -#include -#include -#include -#include +#define NEED_SOCKETS #include "k5-int.h" #include "com_err.h" #include "kadm5_defs.h" #include "adm.h" +#include static const char *proto_addrs_msg = "%d: cannot get memory for addresses"; static const char *proto_rcache_msg = "%d: cannot get replay cache"; @@ -298,7 +295,7 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) cmd_repl_complist = (krb5_data *) NULL; err_aux = 0; if (num_args > 0) { - if (!strcmp(arglist[0].data, KRB5_ADM_QUIT_CMD)) { + if (!strcasecmp(arglist[0].data, KRB5_ADM_QUIT_CMD)) { DPRINT(DEBUG_REQUESTS, proto_debug_level, ("> %d:QUIT command\n", my_id)); /* QUIT takes no arguments */ @@ -314,7 +311,7 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) err_aux = KRB5_ADM_BAD_ARGS; } } - else if (!strcmp(arglist[0].data, KRB5_ADM_CHECKPW_CMD)) { + else if (!strcasecmp(arglist[0].data, KRB5_ADM_CHECKPW_CMD)) { DPRINT(DEBUG_REQUESTS, proto_debug_level, ("> %d:CHECKPW command\n", my_id)); if (num_args == 2) { @@ -334,7 +331,7 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) err_aux = KRB5_ADM_BAD_ARGS; } } - else if (!strcmp(arglist[0].data, KRB5_ADM_CHANGEPW_CMD)) { + else if (!strcasecmp(arglist[0].data, KRB5_ADM_CHANGEPW_CMD)) { DPRINT(DEBUG_REQUESTS, proto_debug_level, ("> %d:CHANGEPW command\n", my_id)); if (num_args == 3) { @@ -355,7 +352,7 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) err_aux = KRB5_ADM_BAD_ARGS; } } - else if (!strcmp(arglist[0].data, KRB5_ADM_MOTD_CMD)) { + else if (!strcasecmp(arglist[0].data, KRB5_ADM_MOTD_CMD)) { DPRINT(DEBUG_REQUESTS, proto_debug_level, ("> %d:MOTD command\n", my_id)); if (num_args <= 2) { @@ -373,7 +370,7 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) err_aux = KRB5_ADM_BAD_ARGS; } } - else if (!strcmp(arglist[0].data, KRB5_ADM_MIME_CMD)) { + else if (!strcasecmp(arglist[0].data, KRB5_ADM_MIME_CMD)) { DPRINT(DEBUG_REQUESTS, proto_debug_level, ("> %d:MIME command\n", my_id)); if (num_args == 1) { @@ -388,7 +385,7 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) err_aux = KRB5_ADM_BAD_ARGS; } } - else if (!strcmp(arglist[0].data, KRB5_ADM_LANGUAGE_CMD)) { + else if (!strcasecmp(arglist[0].data, KRB5_ADM_LANGUAGE_CMD)) { DPRINT(DEBUG_REQUESTS, proto_debug_level, ("> %d:LANGUAGE command\n", my_id)); if (num_args == 2) { diff --git a/src/kadmin/v5server/srv_key.c b/src/kadmin/v5server/srv_key.c index 8a3055a9a..809c5d9d2 100644 --- a/src/kadmin/v5server/srv_key.c +++ b/src/kadmin/v5server/srv_key.c @@ -232,7 +232,8 @@ key_init(kcontext, debug_level, enc_type, key_type, master_key_name, manual, mencb_init = 0; } if (mkeyb_init) { - memset(master_keyblock.contents, 0, master_keyblock.length); + memset(master_keyblock.contents, 0, + (size_t) master_keyblock.length); krb5_xfree(master_keyblock.contents); mkeyb_init = 0; } @@ -368,20 +369,21 @@ key_string_to_keys(kcontext, principal, string, psalttype, asalttype, done: if (kret) { if (primary->contents) { - memset((char *) primary->contents, 0, primary->length); + memset((char *) primary->contents, 0, (size_t) primary->length); krb5_xfree(primary->contents); } if (alternate->contents) { - memset((char *) alternate->contents, 0, alternate->length); + memset((char *) alternate->contents, 0, + (size_t) alternate->length); krb5_xfree(alternate->contents); } } if (psalt_data.data) { - memset(psalt_data.data, 0, psalt_data.length); + memset(psalt_data.data, 0, (size_t) psalt_data.length); krb5_xfree(psalt_data.data); } if (asalt_data.data) { - memset(asalt_data.data, 0, asalt_data.length); + memset(asalt_data.data, 0, (size_t) asalt_data.length); krb5_xfree(asalt_data.data); } DPRINT(DEBUG_CALLS, key_debug_level, @@ -417,11 +419,12 @@ key_encrypt_keys(kcontext, principal, primary, alternate, eprimary, ealternate) done: if (kret) { if (eprimary->contents) { - memset((char *) eprimary->contents, 0, eprimary->length); + memset((char *) eprimary->contents, 0, (size_t) eprimary->length); krb5_xfree(eprimary->contents); } if (ealternate->contents) { - memset((char *) ealternate->contents, 0, ealternate->length); + memset((char *) ealternate->contents, 0, + (size_t) ealternate->length); krb5_xfree(ealternate->contents); } } @@ -458,11 +461,12 @@ key_decrypt_keys(kcontext, principal, eprimary, ealternate, primary, alternate) done: if (kret) { if (primary->contents) { - memset((char *) primary->contents, 0, primary->length); + memset((char *) primary->contents, 0, (size_t) primary->length); krb5_xfree(primary->contents); } if (alternate->contents) { - memset((char *) alternate->contents, 0, alternate->length); + memset((char *) alternate->contents, 0, + (size_t) alternate->length); krb5_xfree(alternate->contents); } } @@ -511,11 +515,12 @@ key_pwd_is_weak(kcontext, principal, string, psalttype, asalttype) mit_des_is_weak_key(alternate.contents)) weakness = 1; if (primary.contents) { - memset((char *) primary.contents, 0, primary.length); + memset((char *) primary.contents, 0, (size_t) primary.length); krb5_xfree(primary.contents); } if (alternate.contents) { - memset((char *) alternate.contents, 0, alternate.length); + memset((char *) alternate.contents, 0, + (size_t) alternate.length); krb5_xfree(alternate.contents); } } diff --git a/src/kadmin/v5server/srv_main.c b/src/kadmin/v5server/srv_main.c index ff1154501..248e82aba 100644 --- a/src/kadmin/v5server/srv_main.c +++ b/src/kadmin/v5server/srv_main.c @@ -102,7 +102,13 @@ kadm_com_err_proc(whoami, code, format, ap) strcat(outbuf, " - "); } cp = &outbuf[strlen(outbuf)]; +#if HAVE_VSPRINTF vsprintf(cp, format, ap); +#else /* HAVE_VSPRINTF */ + sprintf(cp, format, ((int *) ap)[0], ((int *) ap)[1], + ((int *) ap)[2], ((int *) ap)[3], + ((int *) ap)[4], ((int *) ap)[5]); +#endif /* HAVE_VSPRINTF */ #ifndef DEBUG syslog(LOG_AUTH|LOG_ERR, outbuf); #endif /* DEBUG */ diff --git a/src/kadmin/v5server/srv_net.c b/src/kadmin/v5server/srv_net.c index f07c36a41..534e57d29 100644 --- a/src/kadmin/v5server/srv_net.c +++ b/src/kadmin/v5server/srv_net.c @@ -25,11 +25,6 @@ /* * srv_net.c - handle networking functions of the administrative server. */ -#include -#include -#include -#include -#include #include #include #include @@ -37,6 +32,7 @@ #include #endif /* USE_PTHREADS */ +#define NEED_SOCKETS #include "k5-int.h" #include "com_err.h" #include "kadm5_defs.h" @@ -414,8 +410,8 @@ net_init(kcontext, debug_level) } /* Allocate the slave table */ - net_slave_table = (net_slave_info *) malloc(MAX_SLAVES * - sizeof(net_slave_info)); + net_slave_table = (net_slave_info *) + malloc((size_t) (MAX_SLAVES * sizeof(net_slave_info))); /* Make our service name */ net_service_name = (char *) malloc(strlen(local_realm) + strlen(KRB5_ADM_SERVICE_NAME) + 2); @@ -429,7 +425,8 @@ net_init(kcontext, debug_level) (void) sprintf(net_service_name, "%s%s%s", KRB5_ADM_SERVICE_NAME, "/", local_realm); krb5_xfree(local_realm); - memset((char *) net_slave_table, 0, MAX_SLAVES * sizeof(net_slave_info)); + memset((char *) net_slave_table, 0, + (size_t) (MAX_SLAVES * sizeof(net_slave_info))); net_max_slaves = MAX_SLAVES; DPRINT(DEBUG_HOST, net_debug_level, ("- name of service is %s\n", net_service_name)); @@ -513,6 +510,7 @@ net_init(kcontext, debug_level) else { DPRINT(DEBUG_HOST, net_debug_level, ("- bound socket %d on port\n", net_listen_socket)); + kret = 0; break; } } while (bind_tries < MAX_BIND_TRIES); diff --git a/src/kadmin/v5server/srv_output.c b/src/kadmin/v5server/srv_output.c index b1b72a346..bb99f0f28 100644 --- a/src/kadmin/v5server/srv_output.c +++ b/src/kadmin/v5server/srv_output.c @@ -47,7 +47,15 @@ static const char *out_adm_no_cmd = "No command in message."; static const char *out_adm_no_err = "Unknown error."; static int output_debug_level = 0; static int output_mime_enabled = 0; +static int output_lang_inited = 0; +static char **output_lang_list = (char **) NULL; +static char *output_langstring = (char *) NULL; +/* + * lang_error_message() - Return language-dependent Kerberos error message. + * + * This is just a hook. + */ static char * lang_error_message(lang, kval) char *lang; @@ -73,6 +81,11 @@ lang_error_message(lang, kval) return(ret); } +/* + * lang_adm_message() - Return language-dependent administrative message. + * + * This is just a hook. + */ static char * lang_adm_message(lang, ecode, aux, nargs, alist) char *lang; @@ -84,7 +97,7 @@ lang_adm_message(lang, ecode, aux, nargs, alist) char *ret; const char *ermsg; char *erarg; - int alen; + size_t alen; erarg = (char *) NULL; switch (ecode) { @@ -182,6 +195,11 @@ lang_adm_message(lang, ecode, aux, nargs, alist) return(ret); } +/* + * mimeify_text() - MIME encode text. + * + * This is just a hook. + */ static char * mimeify_text(msg) char *msg; @@ -203,6 +221,55 @@ mimeify_text(msg) return(ret); } +/* + * lang_init_slist() - Initialize list of supported languages. + */ +static int +lang_init_slist(llist) + char *llist; +{ + int ret; + + DPRINT(DEBUG_CALLS, output_debug_level, ("* lang_init_slist()\n")); + ret = 1; + if (llist) { + int nseps, i; + char *sepp; + + /* First count the number of commas. */ + sepp = llist; + for (nseps=1; + (sepp = strchr(sepp, (int) ',')) != (char *) NULL; + nseps++) + sepp++; + + output_langstring = + (char *) malloc((size_t) (strlen(llist)+1)); + output_lang_list = + (char **) malloc((size_t) ((nseps+1) * sizeof(char *))); + if (output_lang_list && output_langstring) { + strcpy(output_langstring, llist); + sepp = output_langstring; + for (i=0; i