mit_samba: Initial samba kdb plugin
authorSimo Sorce <idra@samba.org>
Mon, 4 Jan 2010 21:02:55 +0000 (16:02 -0500)
committerSimo Sorce <idra@samba.org>
Tue, 1 Feb 2011 15:25:34 +0000 (10:25 -0500)
src/plugins/kdb/samba/kdb_samba.c [new file with mode: 0644]

diff --git a/src/plugins/kdb/samba/kdb_samba.c b/src/plugins/kdb/samba/kdb_samba.c
new file mode 100644 (file)
index 0000000..e26d06f
--- /dev/null
@@ -0,0 +1,345 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * plugins/kdb/kdbs4/kdb_kdbs4.c
+ *
+ * Copyright (c) 2009, Simo Sorce <idra@samba.org>
+ * 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.
+ *
+ */
+
+#include "k5-int.h"
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <db.h>
+#include <stdio.h>
+#include <errno.h>
+#include <utime.h>
+#include "kdb5.h"
+#include "kdb_samba.h"
+
+#define KDC_SAMBA_LIBRARY "mit-samba4.so"
+
+struct kdbs4_context {
+    struct mits4_context *mits4;
+    int mode;
+};
+
+static krb5_error_code
+kdbs4_init(void)
+{
+    return 0;
+}
+
+static krb5_error_code
+kdbs4_fini(void)
+{
+    return 0;
+}
+
+static krb5_error_code
+kdbs4_load_mits4_module(krb5_context context,
+                        kdbs4_context *kdbs4_ctx,
+                        const char *libdir)
+{
+
+}
+
+static krb5_error_code
+kdbs4_init_module(krb5_context context,
+                  char *conf_section,
+                  char **db_args,
+                  int mode)
+{
+    kdb5_dal_handle *dal_handle = context->dal_handle;
+    krb5_error_code code;
+    kdbs4_context *s4ctx;
+
+    if (dal_handle->db_context != NULL) {
+        s4ctx = (kdbs4_context *)dal_handle->db_context;
+        mits4_context_free(s4ctx->mits4);
+        free(dal_handle->db_context);
+        dal_handle->db_context = NULL;
+    }
+
+    s4ctx = k5alloc(sizeof(kdbs4_context), &code);
+    if (code != 0) {
+        s4ctx = NULL;
+        goto done;
+    }
+    s4ctx->mits4 = NULL;
+
+    if (mode & KRB5_KDB_OPEN_RO) {
+        s4ctx->mode = O_RDONLY;
+    } else {
+        s4ctx->mode = O_RDWR;
+    }
+
+    code = mits4_context_init(&s4ctx->mits4);
+    if (code != 0) {
+        goto done;
+    }
+
+    dal_handle->db_context = s4ctx;
+
+done:
+    if (code != 0 && s4ctx != NULL) {
+        mits4_context_free(s4ctx->mits4);
+        free(s4ctx);
+    }
+    return code;
+}
+
+static krb5_error_code
+kdbs4_fini_module(krb5_context context)
+{
+    kdb5_dal_handle *dal_handle = context->dal_handle;
+
+    mits4_context_free((mits4_context *)dal_handle->db_context);
+    dal_handle->db_context = NULL;
+
+    return 0;
+}
+
+static krb5_error_code
+kdbs4_db_create(krb5_context context,
+                char *conf_section,
+                char **db_args)
+{
+
+}
+
+static krb5_error_code
+kdbs4_db_destroy(krb5_context context,
+                 char *conf_section,
+                 char **db_args)
+{
+    return KRB5_KDB_DBTYPE_NOSUP;
+}
+
+static krb5_error_code
+kdbs4_db_get_age(krb5_context context,
+                 char *db_name,
+                 time_t *age)
+{
+    return KRB5_KDB_DBTYPE_NOSUP;
+}
+
+static krb5_error_code
+kdbs4_db_set_option(krb5_context context,
+                    int option,
+                    void *value)
+{
+    return KRB5_KDB_DBTYPE_NOSUP;
+}
+
+static krb5_error_code
+kdbs4_db_lock(krb5_context context, int kmode)
+{
+
+}
+
+static krb5_error_code
+kdbs4_db_unlock(krb5_context context)
+{
+
+}
+
+static krb5_error_code
+kdbs4_db_get_principal(krb5_context context,
+                       krb5_const_principal princ,
+                       unsigned int kflags,
+                       krb5_db_entry *kentry,
+                       int *nentries,
+                       krb5_boolean *more)
+{
+
+}
+
+static krb5_error_code
+kdbs4_db_free_principal(krb5_context context,
+                        krb5_db_entry *entry,
+                        int count)
+{
+
+}
+
+static krb5_error_code
+kdbs4_db_put_principal(krb5_context context,
+                       krb5_db_entry *entries,
+                       int *nentries,
+                       char **db_args)
+{
+
+}
+
+static krb5_error_code
+kdbs4_delete_principal(krb5_context context,
+                       kh_db_context *kh,
+                       krb5_const_principal princ)
+{
+
+}
+
+static krb5_error_code
+kdbs4_db_iterate(krb5_context context,
+                 char *match_entry,
+                 int (*func)(krb5_pointer, krb5_db_entry *),
+                 krb5_pointer func_arg)
+{
+
+}
+
+static void *
+kdbs4_db_alloc(krb5_context context, void *ptr, size_t size)
+{
+    return realloc(ptr, size);
+}
+
+static void
+kdbs4_db_free(krb5_context context, void *ptr)
+{
+    free(ptr);
+}
+
+static krb5_error_code
+kdbs4_set_master_key(krb5_context context,
+                     char *pwd,
+                     krb5_keyblock *kkey)
+{
+
+}
+
+static krb5_error_code
+kdbs4_get_master_key(krb5_context context,
+                     krb5_keyblock **pkey)
+{
+
+}
+
+static krb5_error_code
+kdbs4_fetch_master_key(krb5_context context,
+                       krb5_principal name,
+                       krb5_keyblock *key,
+                       krb5_kvno *kvno,
+                       char *db_args)
+{
+    return 0;
+}
+
+static krb5_error_code
+kdbs4_fetch_master_key_list(krb5_context context,
+                            krb5_principal mname,
+                            const krb5_keyblock *key,
+                            krb5_kvno kvno,
+                            krb5_keylist_node **mkeys_list)
+{
+
+}
+
+static krb5_error_code
+kdbs4_promote_db(krb5_context context,
+                 char *conf_section,
+                 char **db_args)
+{
+
+}
+
+static krb5_error_code
+kdbs4_dbekd_decrypt_key_data(krb5_context context,
+                             const krb5_keyblock *mkey,
+                             const krb5_key_data *key_data,
+                             krb5_keyblock *kkey,
+                             krb5_keysalt *keysalt)
+{
+
+}
+
+static krb5_error_code
+kdbs4_dbekd_encrypt_key_data(krb5_context context,
+                             const krb5_keyblock *mkey,
+                             const krb5_keyblock *kkey,
+                             const krb5_keysalt *keysalt,
+                             int keyver,
+                             krb5_key_data *key_data)
+{
+
+}
+
+static krb5_error_code
+kdbs4_db_invoke(krb5_context context,
+                unsigned int method,
+                const krb5_data *req,
+                krb5_data *rep)
+{
+
+}
+
+kdb_vftabl kdb_function_table = {
+    1,
+    0,
+    kdbs4_init,
+    kdbs4_fini,
+    kdbs4_init_module,
+    kdbs4_fini_module,
+    kdbs4_db_create,
+    kdbs4_db_destroy,
+    kdbs4_db_get_age,
+    kdbs4_db_set_option,
+    kdbs4_db_lock,
+    kdbs4_db_unlock,
+    kdbs4_db_get_principal,
+    kdbs4_db_free_principal,
+    kdbs4_db_put_principal,
+    kdbs4_db_delete_principal,
+    kdbs4_db_iterate,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    kdbs4_db_alloc,
+    kdbs4_db_free,
+    kdbs4_set_master_key,
+    kdbs4_get_master_key,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    kdbs4_fetch_master_key,
+    NULL,
+    kdbs4_fetch_master_key_list,
+    NULL,
+    NULL,
+    NULL,
+    kdbs4_promote_db,
+    kdbs4_dbekd_decrypt_key_data,
+    kdbs4_dbekd_encrypt_key_data,
+    kdbs4_db_invoke,
+};