s3-schannel: add simple wrappers to fetch and store schannel auth info.
authorGünther Deschner <gd@samba.org>
Tue, 25 Aug 2009 22:31:27 +0000 (00:31 +0200)
committerGünther Deschner <gd@samba.org>
Thu, 27 Aug 2009 13:55:19 +0000 (15:55 +0200)
Guenther

source3/Makefile.in
source3/include/proto.h
source3/passdb/secrets.c
source3/passdb/secrets_schannel.c [new file with mode: 0644]

index 765250595d1287242decdf72d35db2ad1211dd77..3af97db96758fa743e8bd56a6e7be7f3e41bc1b4 100644 (file)
@@ -492,7 +492,8 @@ TLDAP_OBJ = lib/tldap.o lib/tldap_util.o lib/util_tsock.o
 SCHANNEL_OBJ = libsmb/credentials.o \
               ../libcli/auth/credentials.o \
               ../libcli/auth/schannel_state_tdb.o \
-              ../librpc/gen_ndr/ndr_schannel.o
+              ../librpc/gen_ndr/ndr_schannel.o \
+              passdb/secrets_schannel.o
 
 LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
             libsmb/clikrb5.o libsmb/clispnego.o ../lib/util/asn1.o \
index d6ee5ed65fb2e7c075e275795babbb79fb0d3573..bed592c6cba26fe758c315905d315d8b56d3c574 100644 (file)
@@ -4744,6 +4744,14 @@ char *secrets_fetch_generic(const char *owner, const char *key);
 bool secrets_store_local_schannel_key(uint8_t schannel_key[16]);
 bool secrets_fetch_local_schannel_key(uint8_t schannel_key[16]);
 
+/* The following definitions come from passdb/secrets_schannel.c  */
+
+NTSTATUS schannel_fetch_session_key(TALLOC_CTX *mem_ctx,
+                                   const char *computer_name,
+                                   struct netlogon_creds_CredentialState **pcreds);
+NTSTATUS schannel_store_session_key(TALLOC_CTX *mem_ctx,
+                                   struct netlogon_creds_CredentialState *creds);
+
 /* The following definitions come from passdb/util_builtin.c  */
 
 bool lookup_builtin_rid(TALLOC_CTX *mem_ctx, uint32 rid, const char **name);
index ee0dcaf42cc79c651c1f3d2313afaa3284ba059b..0a3871e6201b8728cc9e52d7cdde96e5e04e7d8d 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "includes.h"
 #include "../libcli/auth/libcli_auth.h"
+
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_PASSDB
 
diff --git a/source3/passdb/secrets_schannel.c b/source3/passdb/secrets_schannel.c
new file mode 100644 (file)
index 0000000..84a860e
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+   Unix SMB/CIFS implementation.
+   Copyright (C) Guenther Deschner    2009
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "../libcli/auth/libcli_auth.h"
+#include "../libcli/auth/schannel_state.h"
+
+/******************************************************************************
+ Wrapper around schannel_fetch_session_key_tdb()
+ Note we must be root here.
+*******************************************************************************/
+
+NTSTATUS schannel_fetch_session_key(TALLOC_CTX *mem_ctx,
+                                   const char *computer_name,
+                                   struct netlogon_creds_CredentialState **pcreds)
+{
+       struct tdb_context *tdb;
+       NTSTATUS status;
+
+       tdb = open_schannel_session_store(mem_ctx);
+       if (!tdb) {
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       status = schannel_fetch_session_key_tdb(tdb, mem_ctx, computer_name, pcreds);
+
+       tdb_close(tdb);
+
+       return status;
+}
+
+/******************************************************************************
+ Wrapper around schannel_store_session_key_tdb()
+ Note we must be root here.
+*******************************************************************************/
+
+NTSTATUS schannel_store_session_key(TALLOC_CTX *mem_ctx,
+                                   struct netlogon_creds_CredentialState *creds)
+{
+       struct tdb_context *tdb;
+       NTSTATUS status;
+
+       tdb = open_schannel_session_store(mem_ctx);
+       if (!tdb) {
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       status = schannel_store_session_key_tdb(tdb, mem_ctx, creds);
+
+       tdb_close(tdb);
+
+       return status;
+}