From: Theodore Tso Date: Fri, 24 Dec 1993 22:24:32 +0000 (+0000) Subject: Fixed lots of bug; lots of cleanup.. X-Git-Tag: krb5-1.0-beta3~89 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cd54351f182758116041bbdb9f398d8606fc7027;p=krb5.git Fixed lots of bug; lots of cleanup.. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3259 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/server/Imakefile b/src/kadmin/server/Imakefile index 24d646528..61563d5b5 100644 --- a/src/kadmin/server/Imakefile +++ b/src/kadmin/server/Imakefile @@ -9,12 +9,6 @@ # # Imakefile for Kerberos admin server library. -#ifdef Krb4KDCCompat -K4LIB=-l$(KRB425LIB) -l$(DES425LIB) -#else -K4LIB= -#endif - SRCS = \ adm_server.c \ adm_parse.c \ @@ -28,7 +22,8 @@ SRCS = \ adm_adm_func.c \ adm_funcs.c \ adm_check.c \ - adm_extern.c + adm_extern.c \ + adm_msgs.c OBJS = \ adm_server.o \ @@ -43,7 +38,8 @@ OBJS = \ adm_adm_func.o \ adm_funcs.o \ adm_check.o \ - adm_extern.o + adm_extern.o \ + adm_msgs.o ErrorTableObjectRule() diff --git a/src/kadmin/server/adm_extern.h b/src/kadmin/server/adm_extern.h index d8408ec86..498df1ffe 100644 --- a/src/kadmin/server/adm_extern.h +++ b/src/kadmin/server/adm_extern.h @@ -71,6 +71,8 @@ extern int *pidarray; extern char *adm5_ver_str; extern int adm5_ver_len; +extern int adm_debug_flag; + extern int send_seqno; extern int recv_seqno; @@ -79,4 +81,12 @@ extern int exit_now; extern krb5_data inbuf; extern krb5_data msg_data; +extern char *oper_type[]; +extern char *ksrvutil_message[]; +extern char *kadmind_general_response[]; +extern char *kadmind_kpasswd_response[]; +extern char *kadmind_ksrvutil_response[]; +extern char *kadmind_kadmin_response[]; + + #endif /* __ADM_EXTERN__ */ diff --git a/src/kadmin/server/adm_funcs.c b/src/kadmin/server/adm_funcs.c index f36233825..99e1aecdc 100644 --- a/src/kadmin/server/adm_funcs.c +++ b/src/kadmin/server/adm_funcs.c @@ -193,7 +193,7 @@ OLDDECLARG(krb5_db_entry *, entry) } if (!req_type) { /* New entry - initialize */ - memset((char *) &entry, 0, sizeof(entry)); + memset((char *) entry, 0, sizeof(*entry)); entry->principal = (krb5_principal) principal; entry->kvno = KDB5_VERSION_NUM; entry->max_life = KDB5_MAX_TKT_LIFE; diff --git a/src/kadmin/server/adm_listen.c b/src/kadmin/server/adm_listen.c index cb344285a..f38e1a0c0 100644 --- a/src/kadmin/server/adm_listen.c +++ b/src/kadmin/server/adm_listen.c @@ -47,6 +47,8 @@ static char rcsid_adm_listen[] = #include "adm_extern.h" +int adm_debug_flag = 0; + void kill_children() { @@ -118,7 +120,12 @@ const char *prog; error_message(errno)); continue; } -#ifndef DEBUG + + if (adm_debug_flag) { + retval = process_client("adm5_listen_and_process"); + exit(retval); + } + /* if you want a sep daemon for each server */ if (!(pid = fork())) { /* child */ @@ -150,12 +157,6 @@ const char *prog; pidarray[0] = pid; } } -#else - /* do stuff */ - - retval = process_client("adm5_listen_and_process"); - exit(retval); -#endif /* DEBUG */ } else { syslog(LOG_AUTH | LOG_INFO, "%s: something else woke me up!", "adm5_listen_and_process"); diff --git a/src/kadmin/server/adm_process.c b/src/kadmin/server/adm_process.c index e64044258..98b98bafe 100644 --- a/src/kadmin/server/adm_process.c +++ b/src/kadmin/server/adm_process.c @@ -277,57 +277,56 @@ char *prog; error_message(retval)); (void) sprintf(retbuf, "kadmind error during recvauth: %s\n", error_message(retval)); - } else { - /* Check if ticket was issued using password (and not tgt) - within the last 5 minutes */ + exit(1); + } + + /* Check if ticket was issued using password (and not tgt) + * within the last 5 minutes + */ - if (!(client_creds->enc_part2->flags & TKT_FLG_INITIAL)) { - syslog(LOG_ERR, - "Client ticket not initial"); - close(client_server_info.client_socket); - exit(0); - } + if (!(client_creds->enc_part2->flags & TKT_FLG_INITIAL)) { + syslog(LOG_ERR, "Client ticket not initial"); + close(client_server_info.client_socket); + exit(0); + } - if (retval = krb5_timeofday(&adm_time)) { - syslog(LOG_ERR, - "Can't get time of day"); - close(client_server_info.client_socket); - exit(0); - } + if (retval = krb5_timeofday(&adm_time)) { + syslog(LOG_ERR, "Can't get time of day"); + close(client_server_info.client_socket); + exit(0); + } - if ((client_creds->enc_part2->times.authtime - adm_time) > 60*5) { - syslog(LOG_ERR, - "Client ticket not recent"); - close(client_server_info.client_socket); - exit(0); - } + if ((adm_time - client_creds->enc_part2->times.authtime) > 60*5) { + syslog(LOG_ERR, "Client ticket not recent"); + close(client_server_info.client_socket); + exit(0); + } - recv_seqno = client_auth_data->seq_number; + recv_seqno = client_auth_data->seq_number; - if ((client_server_info.name_of_client = - (char *) calloc (1, 3 * 255)) == (char *) 0) { - syslog(LOG_ERR, "kadmind error: No Memory for name_of_client"); - close(client_server_info.client_socket); - exit(0); - } + if ((client_server_info.name_of_client = + (char *) calloc (1, 3 * 255)) == (char *) 0) { + syslog(LOG_ERR, "kadmind error: No Memory for name_of_client"); + close(client_server_info.client_socket); + exit(0); + } - if ((retval = krb5_unparse_name(client_server_info.client, - &client_server_info.name_of_client))) { - syslog(LOG_ERR, "kadmind error: unparse failed.", - error_message(retval)); - goto finish; - } + if ((retval = krb5_unparse_name(client_server_info.client, + &client_server_info.name_of_client))) { + syslog(LOG_ERR, "kadmind error: unparse failed.", + error_message(retval)); + goto finish; + } - syslog(LOG_AUTH | LOG_INFO, - "Request for Administrative Service Received from %s at %s.", - client_server_info.name_of_client, - inet_ntoa( client_server_info.client_name.sin_addr )); + syslog(LOG_AUTH | LOG_INFO, + "Request for Administrative Service Received from %s at %s.", + client_server_info.name_of_client, + inet_ntoa( client_server_info.client_name.sin_addr )); - /* compose the reply */ - outbuf.data[0] = KADMIND; - outbuf.data[1] = KADMSAG; - outbuf.length = 2; - } + /* compose the reply */ + outbuf.data[0] = KADMIND; + outbuf.data[1] = KADMSAG; + outbuf.length = 2; /* write back the response */ if ((retval = krb5_write_message(&client_server_info.client_socket, @@ -387,6 +386,7 @@ char *prog; otype = 0; break; + default: retbuf[0] = KUNKNOWNAPPL; retbuf[1] = '\0'; diff --git a/src/kadmin/server/adm_server.c b/src/kadmin/server/adm_server.c index d71429683..3d21de8b7 100644 --- a/src/kadmin/server/adm_server.c +++ b/src/kadmin/server/adm_server.c @@ -56,9 +56,22 @@ static char rcsid_adm_server_c[] = #include #include -#include "adm_server.h" #include "adm_extern.h" +char prog[32]; +char *progname = prog; +char *acl_file_name = DEFAULT_ADMIN_ACL; +char *adm5_ver_str = ADM5_VERSTR; +int adm5_ver_len; + +char *adm5_tcp_portname = ADM5_PORTNAME; +int adm5_tcp_port_fd = -1; + +unsigned pidarraysize = 0; +int *pidarray = (int *) 0; + +int exit_now = 0; + global_client_server_info client_server_info; #ifdef SANDIA @@ -142,7 +155,7 @@ char **argv; fclose(startup_file); } #endif - while ((c = getopt(argc, argv, "hmMa:d:k:r:")) != EOF) { + while ((c = getopt(argc, argv, "hmMa:d:k:r:D")) != EOF) { switch(c) { case 'a': /* new acl directory */ acl_file_name = optarg; @@ -175,6 +188,10 @@ char **argv; db_realm = optarg; break; + case 'D': + adm_debug_flag = 1; + break; + case 'h': /* get help on using adm_server */ default: usage(argv[0]); diff --git a/src/kadmin/server/adm_server.h b/src/kadmin/server/adm_server.h deleted file mode 100644 index 7b1fed83c..000000000 --- a/src/kadmin/server/adm_server.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * $Source$ - * $Author$ - * $Id$ - * - * Copyright 1990 by the Massachusetts Institute of Technology. - * - * 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. 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. - * - * Sandia National Laboratories also makes no representations about the - * suitability of the modifications, or additions to this software for - * any purpose. It is provided "as is" without express or implied warranty. - * - * <<< Description >>> - */ - -char prog[32]; -char *progname = prog; -char *acl_file_name = DEFAULT_ADMIN_ACL; -char *adm5_ver_str = ADM5_VERSTR; -int adm5_ver_len; - -char *adm5_tcp_portname = ADM5_PORTNAME; -int adm5_tcp_port_fd = -1; - -unsigned pidarraysize = 0; -int *pidarray = (int *) 0; - -int exit_now = 0;