*** empty log message ***
authorJohn Kohl <jtkohl@mit.edu>
Wed, 25 Apr 1990 16:52:06 +0000 (16:52 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Wed, 25 Apr 1990 16:52:06 +0000 (16:52 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@579 dc483132-0cff-0310-8789-dd5450dbe970

13 files changed:
src/lib/krb5/keytab/file/ktf_close.c [new file with mode: 0644]
src/lib/krb5/keytab/file/ktf_get_en.c [new file with mode: 0644]
src/lib/krb5/keytab/file/ktf_get_na.c [new file with mode: 0644]
src/lib/krb5/keytab/file/ktf_ops.c [new file with mode: 0644]
src/lib/krb5/keytab/file/ktf_resolv.c [new file with mode: 0644]
src/lib/krb5/keytab/file/ktf_util.c [new file with mode: 0644]
src/lib/krb5/keytab/file/ktf_wops.c [new file with mode: 0644]
src/lib/krb5/keytab/file/ktfile.h [new file with mode: 0644]
src/lib/krb5/keytab/ktadd.c [new file with mode: 0644]
src/lib/krb5/keytab/ktdefault.c [new file with mode: 0644]
src/lib/krb5/keytab/ktfr_entry.c [new file with mode: 0644]
src/lib/krb5/keytab/ktremove.c [new file with mode: 0644]
src/lib/krb5/keytab/read_servi.c [new file with mode: 0644]

diff --git a/src/lib/krb5/keytab/file/ktf_close.c b/src/lib/krb5/keytab/file/ktf_close.c
new file mode 100644 (file)
index 0000000..c961e5b
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * "Close" a file-based keytab and invalidate the id.  This means
+ * free memory hidden in the structures.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_krb5_ktfile_close_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "ktfile.h"
+
+krb5_error_code 
+krb5_ktfile_close(id)
+  krb5_keytab *id;
+  /*
+   * This routine is responsible for freeing all memory allocated 
+   * for this keytab.  There are no system resources that need
+   * to be freed nor are there any open files.
+   *
+   * This routine should undo anything done by krb5_ktfile_resolve().
+   */
+{
+    (void) free(KTFILENAME(*id));
+    (void) free((krb5_pointer)(*id)->data);
+    *id = NULL;
+    return (0); /* XXX */
+}
diff --git a/src/lib/krb5/keytab/file/ktf_get_en.c b/src/lib/krb5/keytab/file/ktf_get_en.c
new file mode 100644 (file)
index 0000000..069bc67
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * This is the get_entry routine for the file based keytab implementation.
+ * It opens the keytab file, and either retrieves the entry or returns
+ * an error.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_krb5_ktfile_get_entry_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+
+#include "ktfile.h"
+
+krb5_error_code
+krb5_ktfile_get_entry(id, principal, kvno, entry)
+  krb5_keytab id;
+  krb5_principal principal;
+  krb5_kvno kvno;
+  krb5_keytab_entry *entry;
+{
+    krb5_keytab_entry cur_entry;
+    krb5_error_code kerror = 0; /* XXX */
+
+    bzero((char *)&cur_entry, sizeof(krb5_keytab_entry));
+
+    /* Open the keyfile for reading */
+    if (kerror = krb5_ktfileint_openr(id))
+       return(kerror); /* XXX */
+    
+    /* 
+     * For efficiency and simplicity, we'll use a while true that 
+     * is exited with a break statement.
+     */
+    while (TRUE) {
+       if (kerror = krb5_ktfileint_read_entry(id, &entry))
+           break;
+
+       if (((kvno == IGNORE_VNO) || (kvno == entry.kvno)) &&
+           (principal  XXXXX here XXXXX
diff --git a/src/lib/krb5/keytab/file/ktf_get_na.c b/src/lib/krb5/keytab/file/ktf_get_na.c
new file mode 100644 (file)
index 0000000..156e9c3
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * Get the name of the file containing a file-based keytab.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char krb5_ktfile_get_name_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+
+#include "ktfile.h"
+
+krb5_error_code
+krb5_ktfile_get_name(id, name, len)
+  krb5_keytab id;
+  char *name;
+  int len;
+  /* 
+   * This routine returns the name of the name of the file associated with
+   * this file-based keytab.  name is zeroed and the filename is truncated
+   * to fit in name if necessary.
+   */
+{
+    bzero(name, len);
+    strncpy(name, KTFILENAME(id), len);
+    return(0); /* XXX */
+}
diff --git a/src/lib/krb5/keytab/file/ktf_ops.c b/src/lib/krb5/keytab/file/ktf_ops.c
new file mode 100644 (file)
index 0000000..e637382
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/copyright.h>.
+ *
+ * krb5_ktf_ops
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_ktf_ops_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+
+#include "ktfile.h"
+
+struct _krb5_kt_ops krb5_ktf_ops = {
+    "FILE",    /* Prefix -- this string should not appear anywhere else! */
+    krb5_ktfile_resolve,
+    krb5_ktfile_get_name, 
+    krb5_ktfile_close,
+    krb5_ktfile_get,
+    krb5_ktfile_start_seq_get,
+    krb5_ktfile_get_next,
+    krb5_ktfile_end_get,
+    0,
+    0,
+};
diff --git a/src/lib/krb5/keytab/file/ktf_resolv.c b/src/lib/krb5/keytab/file/ktf_resolv.c
new file mode 100644 (file)
index 0000000..956133a
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * This is an implementation specific resolver.  It returns a keytab id 
+ * initialized with file keytab routines.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char krb5_ktfile_resolve_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+
+#include "ktfile.h"
+
+krb5_error_code
+krb5_ktfile_resolve(name, id)
+  char *name;
+  krb5_keytab *id;
+{
+    krb5_ktfile_data *data;
+
+    if ((*id = malloc(sizeof(struct _krb5_kt))) == NULL)
+       return(KRB5_NO_MEMORY); /* XXX */
+    
+    (*id)->ops = &krb5_ktf_ops;
+    if ((data = (krb5_ktfile_data *)malloc(sizeof(krb5_ktfile_data))) == NULL)
+       return(KRB5_NO_MEMORY); /* XXX */
+
+    if ((data->name = (char *)calloc(strlen(name) + 1, sizeof(char))) == NULL)
+       return(KRB5_NO_MEMORY); /* XXX */
+
+    (void) strcpy(data->name, name);
+
+    id->data = (krb5_pointer)data;
+
+    return(0); /* XXX */
+}
+
diff --git a/src/lib/krb5/keytab/file/ktf_util.c b/src/lib/krb5/keytab/file/ktf_util.c
new file mode 100644 (file)
index 0000000..aa615f5
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * This function contains utilities for the file based implementation of 
+ * the keytab.  There are no public functions in this file.
+ *
+ * This file is the only one that has knowledge of the format of a
+ * keytab file.
+ *
+ * The format is as follows:
+ * 
+ * principal vno key
+ * principal vno key
+ * ....
+ *
+ * There are no separators between fields of an entry or between entries.
+ * A principal is a length-encoded array of length-encoded strings.  The
+ * length is a krb5_length XXX in each case.  The specific format, then, is 
+ * multiple entries concatinated with no separators.  An entry has this 
+ * exact format:
+ *
+ * sizeof(krb5_length) bytes for number of components in the principal; 
+ * then, each component listed in ordser.
+ * For each component, sizeof(krb5_length) bytes for the number of bytes
+ * in the component, followed by the component.
+ * sizeof(krb5_kvno) bytes for the key version number
+ * sizeof(krb5_key_block) bytes for the key
+ *
+ * Extra garbage at the end of a keytab will be not be searched for, but
+ * 
+ * 
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_ktf_util_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+
+#include "ktfile.h"
+
diff --git a/src/lib/krb5/keytab/file/ktf_wops.c b/src/lib/krb5/keytab/file/ktf_wops.c
new file mode 100644 (file)
index 0000000..3f657f8
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/copyright.h>.
+ *
+ * krb5_ktf_writable_ops
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_ktf_wops_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+
+#include "ktfile.h"
+
+struct _krb5_kt_ops krb5_ktf_writable_ops = {
+    "WRFILE",  /* Prefix -- this string should not appear anywhere else! */
+    krb5_ktfile_resolve,
+    krb5_ktfile_get_name, 
+    krb5_ktfile_close,
+    krb5_ktfile_get,
+    krb5_ktfile_start_seq_get,
+    krb5_ktfile_get_next,
+    krb5_ktfile_end_get,
+    krb5_ktfile_add,
+    krb5_ktfile_remove,
+};
diff --git a/src/lib/krb5/keytab/file/ktfile.h b/src/lib/krb5/keytab/file/ktfile.h
new file mode 100644 (file)
index 0000000..09cf3c7
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * $Source$
+ * $Author$
+ * $Id$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * This header file contains information needed by internal routines
+ * of the file-based ticket cache implementation.
+ */
+
+#include <krb5/copyright.h>
+
+#ifndef __KTFILE__
+#define __KTFILE__
+
+/*
+ * Constants
+ */
+#define IGNORE_VNO 0
+
+
+/* 
+ * Types
+ */
+typedef struct _krb5_ktfile_data {
+    char *name;                        /* Name of the file */
+} krb5_ktfile_data;
+
+/*
+ * Macros
+ */
+#define KTFILENAME(id) (((krb5_ktfile_data *)(id)->data)->name)
+
+extern struct _krb5_kt_ops krb5_ktf_ops;
+krb5_error_code krb5_ktfile_resolve PROTOTYPE((char *,
+                                              krb5_keytab *));
+krb5_error_code krb5_ktfile_get_name PROTOTYPE((krb5_keytab,
+                                               char *,
+                                               int));
+krb5_error_code krb5_ktfile_close PROTOTYPE((krb5_keytab));
+krb5_error_code krb5_ktfile_get PROTOTYPE((krb5_keytab,
+                                          krb5_principal,
+                                          krb5_kvno,
+                                          krb5_keytab_entry *));
+krb5_error_code krb5_ktfile_start_seq_get PROTOTYPE((krb5_keytab,
+                                                    krb5_kt_cursor *));
+krb5_error_code krb5_ktfile_get_next PROTOTYPE((krb5_keytab,
+                                               krb5_keytab_entry *,
+                                               krb5_kt_cursor));
+krb5_error_code krb5_ktfile_end_get PROTOTYPE((krb5_keytab,
+                                              krb5_kt_cursor));
+/* routines to be included on extended version (write routines) */
+krb5_error_code krb5_ktfile_add PROTOTYPE((krb5_keytab,
+                                          krb5_keytab_entry *));
+krb5_error_code krb5_ktfile_remove PROTOTYPE((krb5_keytab,
+                                             krb5_keytab_entry *));
+
+#endif /* __KTFILE__ */
diff --git a/src/lib/krb5/keytab/ktadd.c b/src/lib/krb5/keytab/ktadd.c
new file mode 100644 (file)
index 0000000..89e9ce6
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/copyright.h>.
+ *
+ * krb5_kt_add_entry()
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_ktadd_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+#include <krb5/krb5_err.h>
+
+krb5_error_code
+krb5_kt_add_entry (id, entry)
+krb5_keytab id;
+krb5_keytab_entry *entry;
+{
+    if (id->ops->add)
+       return (*id->ops->add)(id, entry);
+    else
+       return KRB5_KT_NOWRITE;
+}
diff --git a/src/lib/krb5/keytab/ktdefault.c b/src/lib/krb5/keytab/ktdefault.c
new file mode 100644 (file)
index 0000000..be38f24
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/copyright.h>.
+ *
+ * Get a default keytab.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_ktdefault_c [] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+#include <errno.h>
+
+krb5_error_code krb5_kt_default(id)
+krb5_keytab *id;
+{
+    return EOPNOTSUPP;
+}
+
+
+
diff --git a/src/lib/krb5/keytab/ktfr_entry.c b/src/lib/krb5/keytab/ktfr_entry.c
new file mode 100644 (file)
index 0000000..a5bb1de
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/copyright.h>.
+ *
+ * krb5_kt_free_entry()
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_ktfr_entry_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+
+krb5_error_code
+krb5_kt_free_entry (entry)
+krb5_keytab_entry *entry;
+{
+    krb5_free_principal(entry->principal);
+    krb5_free_keyblock(entry->key);
+    return 0;
+}
diff --git a/src/lib/krb5/keytab/ktremove.c b/src/lib/krb5/keytab/ktremove.c
new file mode 100644 (file)
index 0000000..b8c0fd5
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/copyright.h>.
+ *
+ * krb5_kt_remove_entry()
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_ktremove_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+#include <krb5/krb5_err.h>
+
+krb5_error_code
+krb5_kt_remove_entry (id, entry)
+krb5_keytab id;
+krb5_keytab_entry *entry;
+{
+    if (id->ops->remove)
+       return (*id->ops->remove)(id, entry);
+    else
+       return KRB5_KT_NOWRITE;
+}
diff --git a/src/lib/krb5/keytab/read_servi.c b/src/lib/krb5/keytab/read_servi.c
new file mode 100644 (file)
index 0000000..8ecbae9
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * This routine is designed to be passed to krb5_rd_req.  
+ * It is a convenience function that reads a key out of a keytab.
+ * It handles all of the opening and closing of the keytab 
+ * internally. 
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_krb5_kt_read_service_key_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+
+#include <krb5/ext-proto.h>
+#include <errno.h>
+#include <stdio.h>
+
+/* XXX  Things that I need and don't know where to get yet */
+#define KSUCCESS 0
+
+krb5_error_code 
+krb5_kt_read_service_key(DECLARG(krb5_pointer, keyprocarg),
+                        DECLARG(krb5_principal, principal),
+                        DECLARG(krb5_kvno, vno),
+                        DECLARG(krb5_keyblock **, key))
+OLDDECLARG(krb5_pointer, keyprocarg)
+OLDDECLARG(krb5_principal, principal)
+OLDDECLARG(krb5_kvno, vno)
+OLDDECLARG(krb5_keyblock **, key)
+/*
+       effects: If keyprocarg is not NULL, it is taken to be 
+               the name of a keytab.  Otherwise, the default
+               keytab will be used.  This routine opens the
+               keytab and finds the principal associated with
+               principal and vno, returning the resulting key
+               in *key or returning an error code if it is not
+               found. 
+       returns: nothing
+       errors: error code if not found
+*/
+{
+    krb5_error_code kerror = KSUCCESS;
+    char keytabname[MAX_KEYTAB_NAME_LEN + 1]; /* + 1 for NULL termination */
+    krb5_keytab id;
+    krb5_keytab_entry entry;
+        
+    /*
+     * Get the name of the file that we should use. 
+     */
+    if (keyprocarg == NULL)
+       if ((kerror = krb5_kt_default_name((char *)keytabname, 
+                                          sizeof(keytabname) - 1))!= KSUCCESS)
+           return (kerror);
+    else {
+       bzero(keytabname, sizeof(keytabname));
+       (void) strncpy(keytabname, (char *)keyprocarg, 
+                      sizeof(keytabname) - 1);
+    }
+
+    if (kerror = krb5_kt_resolve((char *)keytabname, &id))
+       return (kerror);
+
+    kerror = krb5_kt_get_entry(id, principal, vno, &entry);
+    krb5_kt_close(id);
+
+    if (kerror)
+       return(kerror);
+
+    /* 
+     * This routine takes a krb5_keyblock **.   Should it?  I assume this
+     * means that it is supposed allocate the key and return it...
+     * XXX
+     */
+
+    if ((*key = (krb5_keyblock *)malloc(sizeof(krb5_keyblock))) == NULL)
+       return (ENOMEM);        /* XXX */
+
+    krb5_copy_keyblock(entry.key, *key);
+
+    /* Zero the memory containing the key */
+    bzero((char *)&entry, sizeof(krb5_keytab_entry));
+
+    return (KSUCCESS);
+}