Fixed lots of bug; lots of cleanup..
authorTheodore Tso <tytso@mit.edu>
Fri, 24 Dec 1993 22:24:32 +0000 (22:24 +0000)
committerTheodore Tso <tytso@mit.edu>
Fri, 24 Dec 1993 22:24:32 +0000 (22:24 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3259 dc483132-0cff-0310-8789-dd5450dbe970

src/kadmin/server/Imakefile
src/kadmin/server/adm_extern.h
src/kadmin/server/adm_funcs.c
src/kadmin/server/adm_listen.c
src/kadmin/server/adm_process.c
src/kadmin/server/adm_server.c
src/kadmin/server/adm_server.h [deleted file]

index 24d6465284f761f69f9431a95c5fa165937028e9..61563d5b56cbd0f385b23903e52e5973b4d7315f 100644 (file)
@@ -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()
 
index d8408ec86b9ffb4f9c78e42f71fec27305590562..498df1ffefc7e524ab78aa847caa2136f1534fe8 100644 (file)
@@ -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__ */
index f36233825c56def6436dc437d49f1c6e8fc1f635..99e1aecdc89bcfdf18c64052a69bdc3123a516c6 100644 (file)
@@ -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;
index cb344285a184a0d272939f26f92c966835e56d8d..f38e1a0c051ec3e74d93b086a4a260821278efcb 100644 (file)
@@ -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");
index e6404425835f55c6c8ac9ae2944eb0bd46c0993f..98b98bafedb26d1d308dbf86d10374f8fe8548a7 100644 (file)
@@ -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';
index d71429683f90cd0c3b3611733cd79497c90207f7..3d21de8b750dc01166f6adcfcf53e2411d7e94bf 100644 (file)
@@ -56,9 +56,22 @@ static char rcsid_adm_server_c[] =
 #include <krb5/kdb_dbm.h>
 
 #include <krb5/adm_defs.h>
-#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 (file)
index 7b1fed8..0000000
+++ /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;