svn commit: samba r6340 - in branches/SAMBA_4_0/source: auth/gensec lib

tridge at samba.org tridge at samba.org
Thu Apr 14 08:24:36 GMT 2005


Author: tridge
Date: 2005-04-14 08:24:36 +0000 (Thu, 14 Apr 2005)
New Revision: 6340

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6340

Log:
- added an easy to use function to initialise a temporary ldb with some ldif

- init the schannel.ldb with some CASE_INSENSITIVE attributes


Modified:
   branches/SAMBA_4_0/source/auth/gensec/schannel_state.c
   branches/SAMBA_4_0/source/lib/gendb.c
   branches/SAMBA_4_0/source/lib/util_file.c


Changeset:
Modified: branches/SAMBA_4_0/source/auth/gensec/schannel_state.c
===================================================================
--- branches/SAMBA_4_0/source/auth/gensec/schannel_state.c	2005-04-14 08:00:45 UTC (rev 6339)
+++ branches/SAMBA_4_0/source/auth/gensec/schannel_state.c	2005-04-14 08:24:36 UTC (rev 6340)
@@ -36,17 +36,28 @@
 {
 	char *path;
 	struct ldb_context *ldb;
+	BOOL existed;
+	const char *init_ldif = 
+		"dn: @ATTRIBUTES\n" \
+		"computerName: CASE_INSENSITIVE\n" \
+		"flatname: CASE_INSENSITIVE\n";
 
 	path = smbd_tmp_path(mem_ctx, "schannel.ldb");
 	if (!path) {
 		return NULL;
 	}
+
+	existed = file_exists(path);
 	
 	ldb = ldb_wrap_connect(mem_ctx, path, 0, NULL);
 	talloc_free(path);
 	if (!ldb) {
 		return NULL;
 	}
+	
+	if (!existed) {
+		gendb_add_ldif(ldb, init_ldif);
+	}
 
 	return ldb;
 }

Modified: branches/SAMBA_4_0/source/lib/gendb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/gendb.c	2005-04-14 08:00:45 UTC (rev 6339)
+++ branches/SAMBA_4_0/source/lib/gendb.c	2005-04-14 08:24:36 UTC (rev 6340)
@@ -78,3 +78,16 @@
 	return count;
 }
 
+/*
+  setup some initial ldif in a ldb
+*/
+int gendb_add_ldif(struct ldb_context *ldb, const char *ldif_string)
+{
+	struct ldb_ldif *ldif;
+	int ret;
+	ldif = ldb_ldif_read_string(ldb, ldif_string);
+	if (ldif == NULL) return -1;
+	ret = ldb_add(ldb, ldif->msg);
+	talloc_free(ldif);
+	return ret;
+}

Modified: branches/SAMBA_4_0/source/lib/util_file.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util_file.c	2005-04-14 08:00:45 UTC (rev 6339)
+++ branches/SAMBA_4_0/source/lib/util_file.c	2005-04-14 08:24:36 UTC (rev 6340)
@@ -386,3 +386,12 @@
 	close(fd);
 	return True;
 }
+
+/*
+  see if a file exists
+*/
+BOOL file_exists(const char *path)
+{
+	struct stat st;
+	return (stat(path, &st) == 0);
+}



More information about the samba-cvs mailing list