svn commit: samba r17663 - in branches/SOC/mkhl/ejs-map: .

2006-08-21 Thread mkhl
Author: mkhl
Date: 2006-08-21 14:32:59 + (Mon, 21 Aug 2006)
New Revision: 17663

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17663

Log:

This patch takes a first semi-serious stab at implementing the ejs_map
module, which is supposed to support defining ldb_map mappings in EJS.

To do this, it
1) modifies the ldb_map module so mapping structures contain a pointer
   to additional private data, and passes the mapping structure to
   each contained conversion/generation function.  This is done so the
   EJS mapping object can be stored in private data and used to call
   the right EJS function to perform conversions.
   The samba3sam and entryUUID modules are adapted to this change.
2) extends the smbcalls modules with additional handling for GUID
   structures, ldb values and ldb attribute handlers.  These are all a
   bit rough and unfinished but should prove useful.

A few things that are still missing (among many others) are:
1) an EJS exception handler
2) sane handling of ldb objects in EJS (creation from an ldb_context
   struct in C and passing it to the EJS conversion functions in C).
3) support for reading an EJS script and executing it
4) a sanity check of my memory handling
5) a clean way of iterating EJS arrays in C
6) a clean way of calling EJS functions from C (it currently uses
   `ejsRunFunction', which expects an `MprArray' for its arguments,
   which don't seem to be used anywhere else...)

As of revision 17662, the modules involved with this patch compile,
but the ejs_map module cannot be linked yet.

Martin
Modified:
   branches/SOC/mkhl/ejs-map/ejs.patch


Changeset:
Sorry, the patch is too large (897 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17663


svn commit: samba r17664 - in branches/SOC/mkhl/ejs-map: .

2006-08-21 Thread mkhl
Author: mkhl
Date: 2006-08-21 14:35:04 + (Mon, 21 Aug 2006)
New Revision: 17664

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17664

Log:

Remove files that were obsoleted by ejs.patch.

Martin
Removed:
   branches/SOC/mkhl/ejs-map/entryUUID_support.c
   branches/SOC/mkhl/ejs-map/ldb_map.c-privdat.patch
   branches/SOC/mkhl/ejs-map/ldb_map.h-privdat.patch
   branches/SOC/mkhl/ejs-map/samba3sam.c-privdat.patch


Changeset:
Deleted: branches/SOC/mkhl/ejs-map/entryUUID_support.c
===
--- branches/SOC/mkhl/ejs-map/entryUUID_support.c   2006-08-21 14:32:59 UTC 
(rev 17663)
+++ branches/SOC/mkhl/ejs-map/entryUUID_support.c   2006-08-21 14:35:04 UTC 
(rev 17664)
@@ -1,72 +0,0 @@
-static int ejs_encodeGuid(MprHandle eid, int argc, struct MprVar **argv)
-{
-   struct GUID *guid;
-   struct ldb_val val;
-   NTSTATUS status;
-
-   if (argc != 1) {
-   ejsSetErrorMsg(eid, encodeGuid invalid argument count);
-   return -1;
-   }
-
-   val = data_blob(NULL, 0);
-
-   guid = mprToGuid(mprMemCtx(), argv[0]);
-   if (guid == NULL) {
-   ejsSetErrorMsg(eid, encodeGuid invalid GUID string);
-   return -1;
-   }
-
-   status = ndr_push_struct_blob(val, mprMemCtx(), guid,
- (ndr_push_flags_fn_t)ndr_push_GUID);
-   if (NT_STATUS_IS_OK(status)) {
-   talloc_free(guid);
-   ejsSetErrorMsg(eid, encodeGuid failed to encode GUID);
-   return -1;
-   }
-
-   talloc_free(guid);
-   mpr_Return(mprData(val.data, val.length));
-   return 0;
-}
-
-static int ejs_decodeGuid(MprHandle eid, int argc, struct MprVar **argv)
-{
-   struct GUID *guid;
-   struct ldb_val val;
-   NTSTATUS status;
-
-   if (argc != 1) {
-   ejsSetErrorMsg(eid, decodeGuid invalid argument count);
-   return -1;
-   }
-
-   guid = talloc(mprMemCtx(), struct GUID);
-   if (guid == NULL) {
-   ejsSetErrorMsg(eid, decodeGuid Out of Memory);
-   return -1;
-   }
-
-   val.data = (uint8_t *)mprToString(argv[0]);
-   val.length = strlen((char *)val.data);
-
-   status = ndr_pull_struct_blob(in, guid, guid,
- (ndr_pull_flags_fn_t)ndr_pull_GUID);
-   if (!NT_STATUS_IS_OK(status)) {
-   talloc_free(guid);
-   ejsSetErrorMsg(eid, decodeGuid failed to decode GUID);
-   return -1;
-   }
-
-   mpr_Return(mprGuid(guid));
-   talloc_free(guid);
-   return 0;
-}
-
-NTSTATUS smb_setup_ejs_guid(void)
-{
-   ejsDefineCFunction(-1, encodeGuid, ejs_encodeGuid, NULL, 
MPR_VAR_SCRIPT_HANDLE);
-   ejsDefineCFunction(-1, decodeGuid, ejs_decodeGuid, NULL, 
MPR_VAR_SCRIPT_HANDLE);
-   return NT_STATUS_OK;
-}
-

Deleted: branches/SOC/mkhl/ejs-map/ldb_map.c-privdat.patch
===
--- branches/SOC/mkhl/ejs-map/ldb_map.c-privdat.patch   2006-08-21 14:32:59 UTC 
(rev 17663)
+++ branches/SOC/mkhl/ejs-map/ldb_map.c-privdat.patch   2006-08-21 14:35:04 UTC 
(rev 17664)
@@ -1,85 +0,0 @@
-Index: lib/ldb/modules/ldb_map.c
-===
 lib/ldb/modules/ldb_map.c  (revision 17506)
-+++ lib/ldb/modules/ldb_map.c  (working copy)
-@@ -637,7 +637,7 @@
- static struct ldb_val ldb_val_map_local(struct ldb_module *module, void 
*mem_ctx, const struct ldb_map_attribute *map, struct ldb_val val)
- {
-   if (map  (map-type == MAP_CONVERT)  
(map-u.convert.convert_local)) {
--  return map-u.convert.convert_local(module, mem_ctx, val);
-+  return map-u.convert.convert_local(module, mem_ctx, map, val);
-   }
- 
-   return ldb_val_dup(mem_ctx, val);
-@@ -647,7 +647,7 @@
- static struct ldb_val ldb_val_map_remote(struct ldb_module *module, void 
*mem_ctx, const struct ldb_map_attribute *map, struct ldb_val val)
- {
-   if (map  (map-type == MAP_CONVERT)  
(map-u.convert.convert_remote)) {
--  return map-u.convert.convert_remote(module, mem_ctx, val);
-+  return map-u.convert.convert_remote(module, mem_ctx, map, 
val);
-   }
- 
-   return ldb_val_dup(mem_ctx, val);
-@@ -968,7 +968,7 @@
-   return 0;
-   }
- 
--  el = map-u.generate.generate_local(module, local, old-name, 
remote);
-+  el = map-u.generate.generate_local(module, local, map, 
old-name, remote);
-   break;
-   }
- 
-@@ -1028,7 +1028,7 @@
-*   maybe postpone generation until they have been mapped?
-*/
- 
--  map-u.generate.generate_remote(module, map-local_name, msg, 
remote, local);
-+  map-u.generate.generate_remote(module, map, map-local_name, 
msg, remote, local

svn commit: samba r17635 - in branches/SOC/mkhl/ejs-map: .

2006-08-20 Thread mkhl
Author: mkhl
Date: 2006-08-20 23:07:36 + (Sun, 20 Aug 2006)
New Revision: 17635

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17635

Log:
Sketch out the ejs mapping module a little further.
Martin
Modified:
   branches/SOC/mkhl/ejs-map/ejs_map.c
   branches/SOC/mkhl/ejs-map/entryUUID.js


Changeset:
Modified: branches/SOC/mkhl/ejs-map/ejs_map.c
===
--- branches/SOC/mkhl/ejs-map/ejs_map.c 2006-08-20 21:58:02 UTC (rev 17634)
+++ branches/SOC/mkhl/ejs-map/ejs_map.c 2006-08-20 23:07:36 UTC (rev 17635)
@@ -41,43 +41,50 @@
 
/* validate arguments */
if (argc  2) {
-   ejsSetErrorMsg(eid, ldbMap invalid number of arguments);
-   goto failed;
+   ejsSetErrorMsg(eid, ldbMap too few arguments);
+   return -1;
}
-
if (!mprVarIsNumber(argv[0]) || !mprVarIsString(argv[1])) {
ejsSetErrorMsg(eid, ldbMap invalid arguments);
-   goto failed;
+   return -1;
}
-
/* validate more arguments */
ret = ejs_map_check_argc(mprToInt(argv[0]), argc);
if (ret) {
-   goto failed;
+   return ret;
}
 
/* create object */
-   this = mprObject(mprToString(argv[1]));
-   mprSetVar(this, type, argv[0]);
-   mprSetVar(this, local, argv[1]);
+   this = mprInitObject(eid, mprToString(argv[1]), 0, NULL);
 
+   /* create attributes */
+   mprSetProperty(this, type, argv[0]);
+   mprSetProperty(this, local, argv[1]);
if (argc  2) {
-   mprSetVar(this, remote, argv[2]);
+   mprSetProperty(this, remote, argv[2]);
}
if (argc  3) {
-   mprSetVar(this, to_local, argv[4]);
-   mprSetVar(this, to_remote, argv[5]);
-   mprSetVar(this, to_tree, argv[6]);
+   mprSetProperty(this, to_local, argv[4]);
+   mprSetProperty(this, to_remote, argv[5]);
+   mprSetProperty(this, to_tree, argv[6]);
}
 
-   mprReturn(eid, this);
return 0;
+}
 
-failed:
-   return -1;
+static int ejs_map_set_ldb(MprVarHandle eid, struct ldb_context *ldb)
+{
+   struct MprVar *var;
+
+   ejs_ldb_init(eid, 0, NULL);
+   var = ejsGetReturnValue(eid);
+   mprSetPtrChild(var, db, ldb);
+
+   return 0;
 }
 
-static struct ldb_parse_tree *ejs_map_convert_operator(const struct ldb_module 
*module, void *mem_ctx, const struct ldb_map_attribute *map, const struct 
ldb_parse_tree *tree)
+/* TODO:
+static int ejs_map_convert_operator(struct ldb_module *module, void *mem_ctx, 
const struct ldb_map_attribute *map, struct ldb_parse_tree **new, const struct 
ldb_parse_tree *tree)
 {
struct MprVar *this, ejs_tree;
struct MprArray *args;
@@ -85,39 +92,44 @@
int ret;
 
this = (struct MprVar *)map-private_data;
+   mprSetProperty(ejsGetLocalObject(eid), this, this);
 
ejs_tree = mprLdbParseTree(module-ldb, tree);
args = mprCreateArray();
-   mprAddToArray(args, (void *)ejs_tree);
+   mprAddToArray(args, (void *)ejs_tree);
 
ret = ejsRunFunction(eid, this, to_tree, args);
if (ret) {
+   ldb_debug(module-ldb, LDB_DEBUG_ERROR, ldbMap: conversion of 
parse tree failed!);
return NULL;
-   // XXX: Scream and yell!
}
 
result = mprToLdbParseTree(mem_ctx, ejsGetReturnValue(eid));
 
return result;
 }
+*/
 
 static struct ldb_val ejs_map_convert_local(struct ldb_module *module, void 
*mem_ctx, const struct ldb_map_attribute *map, const struct ldb_val *val)
 {
+   /* XXX: eid must be stored in context or something... */
struct MprVar *this, ejs_val;
struct MprArray *args;
struct ldb_val result;
int ret;
 
this = (struct MprVar *)map-private_data;
+   mprSetProperty(ejsGetLocalObject(eid), this, this);
+   ejs_map_set_ldb(eid, module-ldb);
 
-   ejs_val = mprData(val-data, val-length);
+   ejs_val = mprLdbVal(val);
args = mprCreateArray();
-   mprAddToArray(args, (void *)ejs_val);
+   mprAddToArray(args, (void *)ejs_val);
 
ret = ejsRunFunction(eid, this, to_remote, args);
if (ret) {
+   ldb_debug(module-ldb, LDB_DEBUG_ERROR, ldbMap: conversion to 
remote value failed!);
return NULL;
-   // XXX: Scream and yell!
}
 
result = mprToLdbVal(ejsGetReturnValue(eid));
@@ -127,21 +139,24 @@
 
 static struct ldb_val ejs_map_convert_remote(struct ldb_module *module, void 
*mem_ctx, const struct ldb_map_attribute *map, const struct ldb_val *val)
 {
+   /* XXX: eid must be stored in context or something... */
struct MprVar *this, ejs_val;
struct MprArray *args;
struct ldb_val result;
int ret;
 
this = (struct MprVar *)map

svn commit: samba r17636 - in branches/SOC/mkhl/ejs-map: .

2006-08-20 Thread mkhl
Author: mkhl
Date: 2006-08-20 23:14:12 + (Sun, 20 Aug 2006)
New Revision: 17636

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17636

Log:
Update set of changes to smbcalls_* and mprutil to facilitate ldb
operations from ejs.

Martin 

Modified:
   branches/SOC/mkhl/ejs-map/ejs.patch


Changeset:
Modified: branches/SOC/mkhl/ejs-map/ejs.patch
===
--- branches/SOC/mkhl/ejs-map/ejs.patch 2006-08-20 23:07:36 UTC (rev 17635)
+++ branches/SOC/mkhl/ejs-map/ejs.patch 2006-08-20 23:14:12 UTC (rev 17636)
@@ -1,13 +1,128 @@
 Add access to the ldb_attrib_handler to smbcalls_ldb.
 These don't really belong in the smbcalls files, they aren't usually
 accessed from ejs client scripts.
-Add GUID handling to mprutils.
+Add ldb_val handling to mprutil.
+Add GUID handling to mprutil.
+Add more GUID handling to smbcalls_guid.
 
+Index: scripting/ejs/smbcalls.h
+===
+--- scripting/ejs/smbcalls.h   (revision 17618)
 scripting/ejs/smbcalls.h   (working copy)
+@@ -29,6 +29,9 @@
+ void mprSetCFunction(struct MprVar *obj, const char *name, MprCFunction fn);
+ void mprSetStringCFunction(struct MprVar *obj, const char *name, 
MprStringCFunction fn);
+ 
++struct MprVar mprLdbVal(const struct ldb_val val);
++struct ldb_val mprToLdbVal(struct MprVar *var);
++
+ struct smbcalls_context {
+   struct event_context *event_ctx;
+   struct messaging_context *msg_ctx;
+@@ -36,6 +39,7 @@
+ 
+ struct ldb_context;
+ struct ldb_message;
++struct ldb_attrib_handler;
+ struct cli_credentials;
+ 
+ #include scripting/ejs/proto.h
+Index: scripting/ejs/smbcalls_guid.c
+===
+--- scripting/ejs/smbcalls_guid.c  (revision 0)
 scripting/ejs/smbcalls_guid.c  (revision 0)
+@@ -0,0 +1,78 @@
++#include includes.h
++#include scripting/ejs/smbcalls.h
++#include lib/appweb/ejs/ejs.h
++#include lib/ldb/include/ldb.h
++#include librpc/gen_ndr/ndr_misc.h
++#include librpc/ndr/libndr.h
++
++static int ejs_encodeGuid(MprVarHandle eid, int argc, struct MprVar **argv)
++{
++  struct GUID *guid;
++  struct ldb_val val;
++  NTSTATUS status;
++
++  if (argc != 1) {
++  ejsSetErrorMsg(eid, encodeGuid invalid argument count);
++  return -1;
++  }
++
++  val = data_blob(NULL, 0);
++
++  guid = mprToGuid(mprMemCtx(), argv[0]);
++  if (guid == NULL) {
++  ejsSetErrorMsg(eid, encodeGuid invalid GUID string);
++  return -1;
++  }
++
++  status = ndr_push_struct_blob(val, mprMemCtx(), guid,
++(ndr_push_flags_fn_t)ndr_push_GUID);
++  if (NT_STATUS_IS_OK(status)) {
++  talloc_free(guid);
++  ejsSetErrorMsg(eid, encodeGuid failed to encode GUID);
++  return -1;
++  }
++
++  talloc_free(guid);
++  mpr_Return(eid, mprLdbVal(val));
++  return 0;
++}
++
++static int ejs_decodeGuid(MprVarHandle eid, int argc, struct MprVar **argv)
++{
++  struct GUID *guid;
++  struct ldb_val val;
++  NTSTATUS status;
++
++  if (argc != 1) {
++  ejsSetErrorMsg(eid, decodeGuid invalid argument count);
++  return -1;
++  }
++
++  guid = talloc(mprMemCtx(), struct GUID);
++  if (guid == NULL) {
++  ejsSetErrorMsg(eid, decodeGuid Out of Memory);
++  return -1;
++  }
++
++  val = mprToLdbVal(argv[0]);
++
++  status = ndr_pull_struct_blob(val, guid, guid,
++(ndr_pull_flags_fn_t)ndr_pull_GUID);
++  if (!NT_STATUS_IS_OK(status)) {
++  talloc_free(guid);
++  ejsSetErrorMsg(eid, decodeGuid failed to decode GUID);
++  return -1;
++  }
++
++  mpr_Return(eid, mprGuid(guid));
++  talloc_free(guid);
++  return 0;
++}
++
++NTSTATUS smb_setup_ejs_guid(void)
++{
++  ejsDefineCFunction(-1, encodeGuid, ejs_encodeGuid, NULL, 
MPR_VAR_SCRIPT_HANDLE);
++  ejsDefineCFunction(-1, decodeGuid, ejs_decodeGuid, NULL, 
MPR_VAR_SCRIPT_HANDLE);
++  return NT_STATUS_OK;
++}
++
 Index: scripting/ejs/smbcalls_ldb.c
 ===
 scripting/ejs/smbcalls_ldb.c   (Revision 17553)
-+++ scripting/ejs/smbcalls_ldb.c   (Arbeitskopie)
-@@ -524,6 +524,67 @@
+--- scripting/ejs/smbcalls_ldb.c   (revision 17618)
 scripting/ejs/smbcalls_ldb.c   (working copy)
+@@ -26,6 +26,7 @@
+ #include lib/appweb/ejs/ejs.h
+ #include lib/ldb/include/ldb.h
+ #include lib/ldb/include/ldb_errors.h
++#include lib/ldb/include/ldb_private.h
+ #include db_wrap.h
+ 
+ /*
+@@ -524,6 +525,68 @@
  }
  
  /*
@@ -27,19 +142,19 @@
 +  }
 +
 +  ldb = ejs_get_ldb_context(eid);
-+  if (ldb = NULL) {
++  if (ldb == NULL) {
 +  return -1;
 +  }
 +
-+  val.data

svn commit: samba r17637 - in branches/SOC/mkhl/testprogs-map/ejs: .

2006-08-20 Thread mkhl
Author: mkhl
Date: 2006-08-20 23:20:44 + (Sun, 20 Aug 2006)
New Revision: 17637

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17637

Log:
Merge from mainline, r17636
Added:
   branches/SOC/mkhl/testprogs-map/ejs/base.js
   branches/SOC/mkhl/testprogs-map/ejs/samba3sam.js
Modified:
   branches/SOC/mkhl/testprogs-map/ejs/ldb.js
   branches/SOC/mkhl/testprogs-map/ejs/samba3sam


Changeset:
Copied: branches/SOC/mkhl/testprogs-map/ejs/base.js (from rev 17636, 
branches/SAMBA_4_0/testprogs/ejs/base.js)

Modified: branches/SOC/mkhl/testprogs-map/ejs/ldb.js
===
--- branches/SOC/mkhl/testprogs-map/ejs/ldb.js  2006-08-20 23:14:12 UTC (rev 
17636)
+++ branches/SOC/mkhl/testprogs-map/ejs/ldb.js  2006-08-20 23:20:44 UTC (rev 
17637)
@@ -18,7 +18,7 @@
 libinclude(base.js);
 
 if (options.ARGV.length != 1) {
-   println(Usage: ldap.js HOST);
+   println(Usage: ldb.js prefix);
return -1;
 }
 
@@ -82,19 +82,20 @@
 {
ok = ldb.add(
 dn: @MODULES
[EMAIL PROTECTED]: rootdse,operational,objectguid,rdn_name,partition
[EMAIL PROTECTED]: rootdse,operational,rdn_name,partition
 
 dn: cn=ROOTDSE
 defaultNamingContext: cn=Test
 
 dn: @PARTITION
-partition: cn=SideTest: + prefix +  testside.ldb
-partition: cn=Sub,cn=PartTest: + prefix +  testsub.ldb
-partition: cn=PartTest: + prefix +  testpartition.ldb
-partition: cn=Sub,cn=Sub,cn=PartTest: + prefix +  testsubsub.ldb
+partition: cn=SideTest: + prefix + / + testside.ldb
+partition: cn=Sub,cn=PartTest: + prefix + / + testsub.ldb
+partition: cn=PartTest: + prefix + / + testpartition.ldb
+partition: cn=Sub,cn=Sub,cn=PartTest: + prefix + / + testsubsub.ldb
 replicateEntries: @SUBCLASSES
 replicateEntries: @ATTRIBUTES
 replicateEntries: @INDEXLIST
+modules: cn=PartTest:objectguid
 );
 }
 
@@ -238,9 +239,9 @@
assert(res7.length == 0);
 
var res8 = ldb.search(x=11, cn=sub,cn=parttest, ldb.SCOPE_DEFAULT, 
attrs);
-   assert(res8[0].objectGUID != undefined);
-   assert(res8[0].createTimestamp != undefined);
-   assert(res8[0].whenCreated != undefined);
+   
+   assert(res8[0].objectGUID == undefined); /* The objectGUID module is 
not loaded here */
+   assert(res8[0].uSNCreated != undefined);
assert(res8[0].name == x11);
assert(res8[0].cn == x11);
 
@@ -348,31 +349,31 @@
 sys = sys_init();
 var dbfile = test.ldb;
 
-sys.unlink(prefix + dbfile);
-sys.unlink(prefix + testpartition.ldb);
-sys.unlink(prefix + testsub.ldb);
-sys.unlink(prefix + testsubsub.ldb);
-sys.unlink(prefix + testside.ldb);
+sys.unlink(prefix + / + dbfile);
+sys.unlink(prefix + / + testpartition.ldb);
+sys.unlink(prefix + / + testsub.ldb);
+sys.unlink(prefix + / + testsubsub.ldb);
+sys.unlink(prefix + / + testside.ldb);
 
-var ok = ldb.connect(tdb:// + prefix + dbfile);
+var ok = ldb.connect(tdb:// + prefix + / + dbfile);
 assert(ok);
 
 basic_tests(ldb);
 
 setup_modules(ldb);
 ldb = ldb_init();
-var ok = ldb.connect(tdb:// + prefix + dbfile);
+var ok = ldb.connect(tdb:// + prefix + / + dbfile);
 assert(ok);
 
 parttestldb = ldb_init();
-var ok = parttestldb.connect(tdb:// + prefix + testpartition.ldb);
+var ok = parttestldb.connect(tdb:// + prefix + / + testpartition.ldb);
 assert(ok);
 
 modules_test(ldb, parttestldb);
 
-sys.unlink(prefix + dbfile);
-sys.unlink(prefix + testpartition.ldb);
-sys.unlink(prefix + testsub.ldb);
-sys.unlink(prefix + testsubsub.ldb);
-sys.unlink(prefix + testside.ldb);
+sys.unlink(prefix + / + dbfile);
+sys.unlink(prefix + / + testpartition.ldb);
+sys.unlink(prefix + / + testsub.ldb);
+sys.unlink(prefix + / + testsubsub.ldb);
+sys.unlink(prefix + / + testside.ldb);
 return 0;

Modified: branches/SOC/mkhl/testprogs-map/ejs/samba3sam
===
--- branches/SOC/mkhl/testprogs-map/ejs/samba3sam   2006-08-20 23:14:12 UTC 
(rev 17636)
+++ branches/SOC/mkhl/testprogs-map/ejs/samba3sam   2006-08-20 23:20:44 UTC 
(rev 17637)
@@ -48,20 +48,13 @@
 assert(ok);
 
 println(Initial samba4 LDIF...);
-var path = ../../source/setup/provision_init.ldif;
+var path = ../../testdata/samba3/provision_samba3sam.ldif
 var ldif = sys.file_load(mypath + path);
 ldif = substitute_var(ldif, local);
 assert(ldif != undefined);
 ok = s4.add(ldif);
 assert(ok);
 
-var path = ../../source/setup/provision_templates.ldif;
-var ldif = sys.file_load(mypath + path);
-ldif = substitute_var(ldif, local);
-assert(ldif != undefined);
-ok = s4.add(ldif);
-assert(ok);
-
 println(Registering partitions...);
 var ldif = substitute_var(prt_ldif, local);
 assert(ldif != undefined);
@@ -112,6 +105,24 @@
assert(oc[i] == posixGroup || oc[i] == group);
 }
 
+println(Looking up by objectClass);
+msg = s4.search((|(objectClass=user)(cn=Administrator)));
+assert(msg != undefined);
+assert(msg.length == 2);
+for (var i = 0; i  msg.length; i++) {
+assert((msg[i].dn == 
unixName=Administrator,ou=Users

svn commit: samba r17638 - in branches/SOC/mkhl/testprogs-map/ejs: .

2006-08-20 Thread mkhl
Author: mkhl
Date: 2006-08-20 23:22:33 + (Sun, 20 Aug 2006)
New Revision: 17638

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17638

Log:
Commit patch that completes the samba3sam test suite but isn't yet
merged into mainline.

Martin

Modified:
   branches/SOC/mkhl/testprogs-map/ejs/samba3sam.js


Changeset:
Sorry, the patch is too large (874 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17638


svn commit: samba r17563 - in branches/SOC/mkhl: . ejs-map

2006-08-15 Thread mkhl
Author: mkhl
Date: 2006-08-15 23:18:20 + (Tue, 15 Aug 2006)
New Revision: 17563

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17563

Log:
Add a subtree for adding support for ldb_map mappings in ejs.
Currently contains incoherent sketches how it might maybe work, someday.

Martin

Added:
   branches/SOC/mkhl/ejs-map/
   branches/SOC/mkhl/ejs-map/ejs.patch
   branches/SOC/mkhl/ejs-map/ejs_map.c
   branches/SOC/mkhl/ejs-map/entryUUID.js
   branches/SOC/mkhl/ejs-map/entryUUID_support.c
   branches/SOC/mkhl/ejs-map/ldbMap.js
   branches/SOC/mkhl/ejs-map/ldb_map.c-privdat.patch
   branches/SOC/mkhl/ejs-map/ldb_map.h-privdat.patch
   branches/SOC/mkhl/ejs-map/samba3sam.c-privdat.patch


Changeset:
Sorry, the patch is too large (892 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17563


svn commit: samba r17518 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-13 Thread mkhl
Author: mkhl
Date: 2006-08-13 10:21:37 + (Sun, 13 Aug 2006)
New Revision: 17518

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17518

Log:
The license change in r17512 was not valid, revert it.
The license change in r16505 was valid, stick to that.

Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c
   branches/SOC/mkhl/ldb-map/modules/ldb_map_inbound.c
   branches/SOC/mkhl/ldb-map/modules/ldb_map_outbound.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-13 10:20:21 UTC (rev 
17517)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-13 10:21:37 UTC (rev 
17518)
@@ -4,23 +4,23 @@
Copyright (C) Jelmer Vernooij 2005
Copyright (C) Martin Kuehl [EMAIL PROTECTED] 2006
 
- ** NOTE! The following LGPL license applies to the ldb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
+   * NOTICE: this module is NOT released under the GNU LGPL license as
+   * other ldb code. This module is release under the GNU GPL v2 or
+   * later license.
+
+   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 2 of the License, or
+   (at your option) any later version.

-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
+   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
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+   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, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /* 

Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map_inbound.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map_inbound.c 2006-08-13 10:20:21 UTC 
(rev 17517)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map_inbound.c 2006-08-13 10:21:37 UTC 
(rev 17518)
@@ -15,7 +15,7 @@

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
+   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

Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map_outbound.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map_outbound.c2006-08-13 
10:20:21 UTC (rev 17517)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map_outbound.c2006-08-13 
10:21:37 UTC (rev 17518)
@@ -15,7 +15,7 @@

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
+   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



svn commit: samba r17519 - in branches/SOC/mkhl: ldb-map/common ldb-map/include ldb-map/ldb_ildap ldb-map/ldb_ldap ldb-map/ldb_sqlite3 ldb-map/ldb_tdb ldb-map/modules ldb-map/samba samdb-map samdb-map

2006-08-13 Thread mkhl
Author: mkhl
Date: 2006-08-13 11:00:56 + (Sun, 13 Aug 2006)
New Revision: 17519

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17519

Log:
Merge from mainline, r17518
Modified:
   branches/SOC/mkhl/ldb-map/common/ldb.c
   branches/SOC/mkhl/ldb-map/common/ldb_debug.c
   branches/SOC/mkhl/ldb-map/common/ldb_modules.c
   branches/SOC/mkhl/ldb-map/common/ldb_msg.c
   branches/SOC/mkhl/ldb-map/include/ldb.h
   branches/SOC/mkhl/ldb-map/include/ldb_private.h
   branches/SOC/mkhl/ldb-map/ldb_ildap/ldb_ildap.c
   branches/SOC/mkhl/ldb-map/ldb_ldap/ldb_ldap.c
   branches/SOC/mkhl/ldb-map/ldb_sqlite3/ldb_sqlite3.c
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_cache.c
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_search.c
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.c
   branches/SOC/mkhl/ldb-map/modules/asq.c
   branches/SOC/mkhl/ldb-map/modules/objectclass.c
   branches/SOC/mkhl/ldb-map/modules/operational.c
   branches/SOC/mkhl/ldb-map/modules/paged_results.c
   branches/SOC/mkhl/ldb-map/modules/sort.c
   branches/SOC/mkhl/ldb-map/samba/ldif_handlers.c
   branches/SOC/mkhl/samdb-map/ldb_modules/extended_dn.c
   branches/SOC/mkhl/samdb-map/ldb_modules/kludge_acl.c
   branches/SOC/mkhl/samdb-map/ldb_modules/local_password.c
   branches/SOC/mkhl/samdb-map/ldb_modules/partition.c
   branches/SOC/mkhl/samdb-map/ldb_modules/password_hash.c
   branches/SOC/mkhl/samdb-map/ldb_modules/proxy.c
   branches/SOC/mkhl/samdb-map/ldb_modules/rootdse.c
   branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c
   branches/SOC/mkhl/samdb-map/ldb_modules/samldb.c
   branches/SOC/mkhl/samdb-map/samdb.c


Changeset:
Sorry, the patch is too large (2149 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17519


svn commit: samba r17521 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-13 Thread mkhl
Author: mkhl
Date: 2006-08-13 11:57:34 + (Sun, 13 Aug 2006)
New Revision: 17521

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17521

Log:
Use `ldb_msg_find_attr_as_dn' where appropriate.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-13 11:55:13 UTC (rev 
17520)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-13 11:57:34 UTC (rev 
17521)
@@ -1195,8 +1195,8 @@
}
 
msg = res-msgs[0];
-   data-local_base_dn = ldb_dn_explode(data, ldb_msg_find_string(msg, 
MAP_DN_FROM, NULL));
-   data-remote_base_dn = ldb_dn_explode(data, ldb_msg_find_string(msg, 
MAP_DN_TO, NULL));
+   data-local_base_dn = ldb_msg_find_attr_as_dn(data, msg, MAP_DN_FROM);
+   data-remote_base_dn = ldb_msg_find_attr_as_dn(data, msg, MAP_DN_TO);
talloc_free(res);
 
return LDB_SUCCESS;



svn commit: samba r17502 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-12 Thread mkhl
Author: mkhl
Date: 2006-08-12 10:42:17 + (Sat, 12 Aug 2006)
New Revision: 17502

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17502

Log:
Reformat function headers.
Tabify.
Remove trailing whitespace.

Martin


Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Sorry, the patch is too large (1520 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17502


svn commit: samba r17506 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-12 Thread mkhl
Author: mkhl
Date: 2006-08-12 15:52:56 + (Sat, 12 Aug 2006)
New Revision: 17506

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17506

Log:
Reformat function prototypes.
Tabify.

Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.h


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.h
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.h 2006-08-12 15:22:58 UTC (rev 
17505)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.h 2006-08-12 15:52:56 UTC (rev 
17506)
@@ -68,10 +68,7 @@
} type;

/* if set, will be called for search expressions that contain this 
attribute */
-   struct ldb_parse_tree *(*convert_operator) (
-   const struct ldb_map_context *,
-   TALLOC_CTX *ctx,
-   const struct ldb_parse_tree *); 
+   struct ldb_parse_tree *(*convert_operator)(const struct ldb_map_context 
*, TALLOC_CTX *ctx, const struct ldb_parse_tree *);
 
union { 
struct {
@@ -82,29 +79,20 @@
const char *remote_name;
 
/* Convert local to remote data */
-ldb_map_convert_func convert_local;
+   ldb_map_convert_func convert_local;
 
/* Convert remote to local data */
/* an entry can have convert_remote set to NULL, as 
long as there as an entry with the same local_name 
 * that is non-NULL before it. */
-ldb_map_convert_func convert_remote;
+   ldb_map_convert_func convert_remote;
} convert;

struct {
/* Generate the local attribute from remote message */
-   struct ldb_message_element *(*generate_local) (
-   struct ldb_module *,
-   TALLOC_CTX *mem_ctx,
-   const char *remote_attr,
-   const struct ldb_message *remote);
+   struct ldb_message_element *(*generate_local)(struct 
ldb_module *, TALLOC_CTX *mem_ctx, const char *remote_attr, const struct 
ldb_message *remote);
 
/* Update remote message with information from local 
message */
-   void (*generate_remote) (
-   struct ldb_module *,
-   const char *local_attr,
-   const struct ldb_message *old,
-   struct ldb_message *remote,
-   struct ldb_message *local);
+   void (*generate_remote)(struct ldb_module *, const char 
*local_attr, const struct ldb_message *old, struct ldb_message *remote, struct 
ldb_message *local);
 
/* Name(s) for this attribute on the remote server. 
This is an array since 
 * one local attribute's data can be split up into 
several attributes 



svn commit: samba r17510 - in branches/SOC/mkhl/ldb-map: . modules

2006-08-12 Thread mkhl
Author: mkhl
Date: 2006-08-12 23:56:53 + (Sat, 12 Aug 2006)
New Revision: 17510

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17510

Log:

Split the ldb_map module into three files:
- ldb_map.c: common operations, asynchronism and initialization
- ldb_map_inbound: inbound operations, i.e. add/modify/rename/delete
- ldb_map_outbound: outbound operations, i.e. search

Remove `static' declaration from shared functions.  Move common
function prototypes and data structures into the `ldb_map_private.h'
header.  Update build configuration.

Martin
Added:
   branches/SOC/mkhl/ldb-map/modules/ldb_map_inbound.c
   branches/SOC/mkhl/ldb-map/modules/ldb_map_outbound.c
   branches/SOC/mkhl/ldb-map/modules/ldb_map_private.h
Modified:
   branches/SOC/mkhl/ldb-map/config.mk
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Sorry, the patch is too large (4087 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17510


svn commit: samba r17511 - in branches/SOC/mkhl: ldb-map/common ldb-map/include ldb-map/tests/schema-tests samdb-map/ldb_modules

2006-08-12 Thread mkhl
Author: mkhl
Date: 2006-08-13 00:01:26 + (Sun, 13 Aug 2006)
New Revision: 17511

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17511

Log:
Merge from mainline, r17510
Modified:
   branches/SOC/mkhl/ldb-map/common/ldb_msg.c
   branches/SOC/mkhl/ldb-map/include/ldb.h
   branches/SOC/mkhl/ldb-map/tests/schema-tests/schema.ldif
   branches/SOC/mkhl/samdb-map/ldb_modules/password_hash.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/common/ldb_msg.c
===
--- branches/SOC/mkhl/ldb-map/common/ldb_msg.c  2006-08-12 23:56:53 UTC (rev 
17510)
+++ branches/SOC/mkhl/ldb-map/common/ldb_msg.c  2006-08-13 00:01:26 UTC (rev 
17511)
@@ -377,6 +377,19 @@
return (const char *)v-data;
 }
 
+struct ldb_dn *ldb_msg_find_dn(void *mem_ctx,
+   const struct ldb_message *msg,
+   const char *attr_name)
+{
+   const struct ldb_val *v;
+
+   v = ldb_msg_find_ldb_val(msg, attr_name);
+   if (!v || !v-data) {
+   return NULL;
+   }
+   return ldb_dn_explode(mem_ctx, (const char *)v-data);
+}
+
 /*
   sort the elements of a message by name
 */

Modified: branches/SOC/mkhl/ldb-map/include/ldb.h
===
--- branches/SOC/mkhl/ldb-map/include/ldb.h 2006-08-12 23:56:53 UTC (rev 
17510)
+++ branches/SOC/mkhl/ldb-map/include/ldb.h 2006-08-13 00:01:26 UTC (rev 
17511)
@@ -1269,6 +1269,10 @@
const char *attr_name,
const char *default_value);
 
+struct ldb_dn *ldb_msg_find_dn(void *mem_ctx,
+  const struct ldb_message *msg,
+  const char *attr_name);
+
 void ldb_msg_sort_elements(struct ldb_message *msg);
 
 struct ldb_message *ldb_msg_copy_shallow(void *mem_ctx, 

Modified: branches/SOC/mkhl/ldb-map/tests/schema-tests/schema.ldif
===
--- branches/SOC/mkhl/ldb-map/tests/schema-tests/schema.ldif2006-08-12 
23:56:53 UTC (rev 17510)
+++ branches/SOC/mkhl/ldb-map/tests/schema-tests/schema.ldif2006-08-13 
00:01:26 UTC (rev 17511)
@@ -4,7 +4,8 @@
 @IDXATTR: objectSid
 @IDXATTR: objectClass
 @IDXATTR: member
[EMAIL PROTECTED]: unixID
[EMAIL PROTECTED]: uidNumber
[EMAIL PROTECTED]: gidNumber
 @IDXATTR: unixName
 @IDXATTR: privilege
 @IDXATTR: lDAPDisplayName

Modified: branches/SOC/mkhl/samdb-map/ldb_modules/password_hash.c
===
--- branches/SOC/mkhl/samdb-map/ldb_modules/password_hash.c 2006-08-12 
23:56:53 UTC (rev 17510)
+++ branches/SOC/mkhl/samdb-map/ldb_modules/password_hash.c 2006-08-13 
00:01:26 UTC (rev 17511)
@@ -512,7 +512,6 @@
ac-dom_req-controls = NULL;
ac-dom_req-context = ac;
ac-dom_req-callback = get_domain_data_callback;
-   ac-dom_req-timeout = ac-orig_req-timeout;
ldb_set_timeout_from_prev_req(ac-module-ldb, ac-orig_req, 
ac-dom_req);
 
return LDB_SUCCESS;



svn commit: samba r17512 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-12 Thread mkhl
Author: mkhl
Date: 2006-08-13 00:22:52 + (Sun, 13 Aug 2006)
New Revision: 17512

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17512

Log:
Bring the copyleft header in line with mainline and the other modules.

Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-13 00:01:26 UTC (rev 
17511)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-13 00:22:52 UTC (rev 
17512)
@@ -4,23 +4,23 @@
Copyright (C) Jelmer Vernooij 2005
Copyright (C) Martin Kuehl [EMAIL PROTECTED] 2006
 
-   * NOTICE: this module is NOT released under the GNU LGPL license as
-   * other ldb code. This module is release under the GNU GPL v2 or
-   * later license.
+ ** NOTE! The following LGPL license applies to the ldb
+ ** library. This does NOT imply that all of Samba is released
+ ** under the LGPL
+   
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
 
-   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 2 of the License, or
-   (at your option) any later version.
-   
-   This program is distributed in the hope that it will be useful,
+   This library 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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 /* 



svn commit: samba r17500 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-11 Thread mkhl
Author: mkhl
Date: 2006-08-11 22:36:53 + (Fri, 11 Aug 2006)
New Revision: 17500

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17500

Log:
Add function to check whether we are supposed to use a local partition at all.
Skip requests targeted at the local db if we aren't supposed to use it.

Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-11 22:11:29 UTC (rev 
17499)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-11 22:36:53 UTC (rev 
17500)
@@ -228,6 +228,20 @@
 /* Dealing with DNs for different partitions
  * = */
 
+/* Check whether any data should be stored in the local partition. */
+static
+BOOL
+map_check_local_db(struct ldb_module *module)
+{
+   const struct ldb_map_context *data = map_get_context(module);
+
+   if (!data-remote_base_dn || !data-local_base_dn) {
+   return False;
+   }
+
+   return True;
+}
+
 /* WARK: verbatim copy from ldb_dn.c */
 static
 struct ldb_dn_component
@@ -2334,6 +2348,11 @@
return LDB_ERR_OPERATIONS_ERROR;
}
 
+   /* There is no local db, stop searching */
+   if (!map_check_local_db(ac-module)) {
+   return map_up_callback(ldb, ac-orig_req, ares);
+   }
+
/* Prepare local search context */
sc = map_init_search_context(ac, ares);
if (sc == NULL) {
@@ -2598,8 +2617,8 @@
ac-local_req-op.add.message = local;
ac-remote_req-op.add.message = remote;

-   if (local-num_elements == 0) {
-   /* No local data, just run the remote request */
+   if ((local-num_elements == 0) || (!map_check_local_db(ac-module))) {
+   /* No local data or db, just run the remote request */
talloc_free(ac-local_req);
req-handle = h;/* return our own handle to deal with 
this call */
return map_add_do_remote(h);
@@ -2761,8 +2780,8 @@
ac-local_req-op.mod.message = local;
ac-remote_req-op.mod.message = remote;

-   if (local-num_elements == 0) {
-   /* No local data, just run the remote request */
+   if ((local-num_elements == 0) || (!map_check_local_db(ac-module))) {
+   /* No local data or db, just run the remote request */
talloc_free(ac-local_req);
req-handle = h;/* return our own handle to deal with 
this call */
return map_modify_do_remote(h);
@@ -2877,16 +2896,11 @@
*(ac-remote_req) = *req;   /* copy the request */
ac-remote_req-op.del.dn = ldb_dn_map_local(module, ac-remote_req, 
req-op.del.dn);
 
-   /* The DN didn't change, so just pretend we were never here */
-   /* TODO:: It's actually quite common for DNs not to change
-*until the remote one is rebased, so we need a
-*different way to test here.
-   if (ldb_dn_compare(module-ldb, ac-remote_req-op.del.dn,
-  req-op.del.dn) == 0) {
-   talloc_free(h);
-   return ldb_next_request(module, req);   
+   /* No local db, just run the remote request */
+   if (!map_check_local_db(ac-module)) {
+   req-handle = h;/* return our own handle to deal with 
this call */
+   return map_delete_do_remote(h);
}
-   */
 
ac-remote_req-context = NULL;
ac-remote_req-callback = NULL;
@@ -3032,6 +3046,12 @@
ac-remote_req-context = NULL;
ac-remote_req-callback = NULL;
 
+   /* No local db, just run the remote request */
+   if (!map_check_local_db(ac-module)) {
+   req-handle = h;/* return our own handle to deal with 
this call */
+   return map_rename_do_remote(h);
+   }
+
/* Prepare the fixup operation */
/* TODO: use GUIDs here instead -- or skip it when GUIDs are used. */
ac-down_req = map_build_fixup_req(ac, req-op.rename.newdn, 
ac-remote_req-op.rename.newdn);



svn commit: samba r17479 - in branches/SOC/mkhl: ldb-map/common ldb-map/include ldb-map/samba ldb-map/tools samdb-map/ldb_modules

2006-08-10 Thread mkhl
Author: mkhl
Date: 2006-08-10 15:07:55 + (Thu, 10 Aug 2006)
New Revision: 17479

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17479

Log:
Merge from mainline, r17478
Modified:
   branches/SOC/mkhl/ldb-map/common/ldb_modules.c
   branches/SOC/mkhl/ldb-map/include/ldb.h
   branches/SOC/mkhl/ldb-map/include/ldb_private.h
   branches/SOC/mkhl/ldb-map/samba/ldif_handlers.c
   branches/SOC/mkhl/ldb-map/tools/cmdline.c
   branches/SOC/mkhl/samdb-map/ldb_modules/partition.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/common/ldb_modules.c
===
--- branches/SOC/mkhl/ldb-map/common/ldb_modules.c  2006-08-10 11:51:43 UTC 
(rev 17478)
+++ branches/SOC/mkhl/ldb-map/common/ldb_modules.c  2006-08-10 15:07:55 UTC 
(rev 17479)
@@ -73,7 +73,7 @@
 /* modules are called in inverse order on the stack.
Lets place them as an admin would think the right order is.
Modules order is important */
-static const char **ldb_modules_list_from_string(struct ldb_context *ldb, 
TALLOC_CTX *mem_ctx, const char *string)
+const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX 
*mem_ctx, const char *string)
 {
char **modules = NULL;
const char **m;
@@ -95,6 +95,7 @@
talloc_steal(modules, modstr);
 
i = 0;
+   /* The str*r*chr walks backwards:  This is how we get the inverse order 
mentioned above */
while ((p = strrchr(modstr, ',')) != NULL) {
*p = '\0';
p++;
@@ -236,11 +237,63 @@
 #endif
 }
 
+int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, 
struct ldb_module *backend, struct ldb_module **out)
+{
+   struct ldb_module *module;
+   int i;
+   
+   module = backend;
+
+   for (i = 0; module_list[i] != NULL; i++) {
+   struct ldb_module *current;
+   const struct ldb_module_ops *ops;
+   
+   ops = ldb_find_module_ops(module_list[i]);
+   if (ops == NULL) {
+   if (ldb_try_load_dso(ldb, module_list[i]) == 0) {
+   ops = ldb_find_module_ops(module_list[i]);
+   }
+   }
+   
+   if (ops == NULL) {
+   ldb_debug(ldb, LDB_DEBUG_WARNING, WARNING: Module [%s] 
not found\n, 
+ module_list[i]);
+   continue;
+   }
+   
+   current = talloc_zero(ldb, struct ldb_module);
+   if (current == NULL) {
+   return LDB_ERR_OPERATIONS_ERROR;
+   }
+   
+   current-ldb = ldb;
+   current-ops = ops;
+   
+   DLIST_ADD(module, current);
+   }
+   *out = module;
+   return LDB_SUCCESS;
+}
+
+int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module) 
+{
+   while (module  module-ops-init_context == NULL) 
+   module = module-next;
+
+   if (module  module-ops-init_context 
+   module-ops-init_context(module) != LDB_SUCCESS) {
+   ldb_debug(ldb, LDB_DEBUG_FATAL, module initialization 
failed\n);
+   return LDB_ERR_OPERATIONS_ERROR;
+   }
+
+   return LDB_SUCCESS;
+}
+
 int ldb_load_modules(struct ldb_context *ldb, const char *options[])
 {
const char **modules = NULL;
-   struct ldb_module *module;
int i;
+   int ret;
TALLOC_CTX *mem_ctx = talloc_new(ldb);
if (!mem_ctx) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -259,7 +312,6 @@
 
/* if not overloaded by options and the backend is not ldap try to load 
the modules list from ldb */
if ((modules == NULL)  (strcmp(ldap, ldb-modules-ops-name) != 
0)) { 
-   int ret;
const char * const attrs[] = { @LIST , NULL};
struct ldb_result *res = NULL;
struct ldb_dn *mods_dn;
@@ -295,51 +347,16 @@
}
 
if (modules != NULL) {
-   for (i = 0; modules[i] != NULL; i++) {
-   struct ldb_module *current;
-   const struct ldb_module_ops *ops;
-   
-   ops = ldb_find_module_ops(modules[i]);
-   if (ops == NULL) {
-   if (ldb_try_load_dso(ldb, modules[i]) == 0) {
-   ops = ldb_find_module_ops(modules[i]);
-   }
-   }
-   
-   if (ops == NULL) {
-   ldb_debug(ldb, LDB_DEBUG_WARNING, WARNING: 
Module [%s] not found\n, 
- modules[i]);
-   continue;
-   }
-
-   current = talloc_zero

svn commit: samba r17480 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-10 Thread mkhl
Author: mkhl
Date: 2006-08-10 15:25:52 + (Thu, 10 Aug 2006)
New Revision: 17480

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17480

Log:
Update initial description of search request handling.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-10 15:07:55 UTC (rev 
17479)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-10 15:25:52 UTC (rev 
17480)
@@ -1,5 +1,5 @@
 /*
-   Mapping ldb module
+   ldb database mapping module
 
Copyright (C) Jelmer Vernooij 2005
Copyright (C) Martin Kuehl [EMAIL PROTECTED] 2006
@@ -43,13 +43,18 @@
  - special attribute 'isMapped'
 
  - search:
- - search local records w/ isMapped
-   use local attrs and a local parse_tree
- - for each local result
- - if isMapped
-- search remote record
-  use remote attrs and remote parse tree
-- merge remote into local result
+ - if parse tree can be split
+ - search remote records w/ remote attrs and parse tree
+ - otherwise
+ - enumerate all remote records
+ - for each remote result
+ - map remote result to local message
+- search local result
+- is present
+- merge local into remote result
+- run callback on merged result
+- otherwise
+- run callback on remote result
 
  - add:
  - split message into local and remote part



svn commit: samba r17481 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-10 Thread mkhl
Author: mkhl
Date: 2006-08-10 15:29:15 + (Thu, 10 Aug 2006)
New Revision: 17481

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17481

Log:
Add copyright info.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.h


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.h
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.h 2006-08-10 15:25:52 UTC (rev 
17480)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.h 2006-08-10 15:29:15 UTC (rev 
17481)
@@ -2,6 +2,7 @@
ldb database library - map backend
 
Copyright (C) Jelmer Vernooij 2005
+   Copyright (C) Martin Kuehl [EMAIL PROTECTED] 2006
Development sponsored by the Google Summer of Code program
 
  ** NOTE! The following LGPL license applies to the ldb



svn commit: samba r17482 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-10 Thread mkhl
Author: mkhl
Date: 2006-08-10 16:24:12 + (Thu, 10 Aug 2006)
New Revision: 17482

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17482

Log:
Add missing comments, rename the `map_flarp' function.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-10 15:29:15 UTC (rev 
17481)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-10 16:24:12 UTC (rev 
17482)
@@ -648,7 +648,6 @@
 
 /* Split attributes that stay in the local partition from those that
  * are mapped into the remote partition. */
-/* TODO: map_search doesn't use this function currently... */
 static
 int
 map_attrs_partition(struct ldb_module *module,
@@ -664,7 +663,7 @@
return 0;
 }
 
-/* TODO: comment me! */
+/* Merge two lists of attributes into a single one. */
 static
 int
 map_attrs_merge(struct ldb_module *module,
@@ -1290,7 +1289,7 @@
return True;/* no parse tree */
 }
 
-/* TODO: Comment me! */
+/* Collect a list of attributes required to match a given parse tree. */
 static
 int
 ldb_parse_tree_collect_attrs(struct ldb_module *module,
@@ -1710,17 +1709,18 @@
return 0;
 }
 
-/* TODO: Comment me! */
-/* TODO: Rename me! */
+/* Collect a list of attributes required either explicitly from a
+ * given list or implicitly  from a given parse tree; split the
+ * collected list into local and remote parts. */
 static
 int
-map_flarp(struct ldb_module *module,
- void *local_ctx,
- void *remote_ctx,
- const char ***local_attrs,
- const char ***remote_attrs,
- const char * const *search_attrs,
- const struct ldb_parse_tree *tree)
+map_attrs_collect_and_partition(struct ldb_module *module,
+   void *local_ctx,
+   void *remote_ctx,
+   const char ***local_attrs,
+   const char ***remote_attrs,
+   const char * const *search_attrs,
+   const struct ldb_parse_tree *tree)
 {
void *tmp_ctx;
const char **tree_attrs;
@@ -2417,7 +2417,7 @@
ac-search_reqs[0]-callback = map_remote_search_callback;
 
/* Split local from remote attrs */
-   ret = map_flarp(module, ac, ac-search_reqs[0], local_attrs, 
remote_attrs, req-op.search.attrs, req-op.search.tree);
+   ret = map_attrs_collect_and_partition(module, ac, ac-search_reqs[0], 
local_attrs, remote_attrs, req-op.search.attrs, req-op.search.tree);
if (ret) {
goto failed;
}



svn commit: samba r17421 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-05 Thread mkhl
Author: mkhl
Date: 2006-08-05 12:46:42 + (Sat, 05 Aug 2006)
New Revision: 17421

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17421

Log:
Comment loops with noops.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-05 11:38:50 UTC (rev 
17420)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-05 12:46:42 UTC (rev 
17421)
@@ -3053,9 +3053,9 @@
last = 0;
 
/* Count specified attribute maps */
-   for (i = 0; attrs[i].local_name; i++);
+   for (i = 0; attrs[i].local_name; i++) /* noop */ ;
/* Count built-in attribute maps */
-   for (j = 0; builtin_attribute_maps[j].local_name; j++);
+   for (j = 0; builtin_attribute_maps[j].local_name; j++) /* noop */ ;
 
/* Store list of attribute maps */
data-attribute_maps = talloc_array(data, struct ldb_map_attribute, 
i+j+1);



svn commit: samba r17422 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-05 Thread mkhl
Author: mkhl
Date: 2006-08-05 12:50:41 + (Sat, 05 Aug 2006)
New Revision: 17422

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17422

Log:
Add logic to generate a list of attributes a parse tree requires from
that parse tree.
Use that logic to reenable partitioning attributes of a search request.
(No comments w.r.t. the function name, please...)c

Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-05 12:46:42 UTC (rev 
17421)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-05 12:50:41 UTC (rev 
17422)
@@ -655,7 +655,34 @@
return 0;
 }
 
+/* TODO: comment me! */
+static
+int
+map_attrs_merge(struct ldb_module *module,
+   void *mem_ctx,
+   const char ***attrs,
+   const char * const *more_attrs)
+{
+   int i, j, k;
 
+   for (i = 0; (*attrs)[i]; i++) /* noop */ ;
+   for (j = 0; more_attrs[j]; j++) /* noop */ ;
+
+   *attrs = talloc_realloc(mem_ctx, *attrs, const char *, i+j+1);
+   if (*attrs == NULL) {
+   map_oom(module);
+   return -1;
+   }
+
+   for (k = 0; k  j; k++) {
+   (*attrs)[i+k] = more_attrs[k];
+   }
+
+   (*attrs)[i+k] = NULL;
+
+   return 0;
+}
+
 /* Mapping ldb values
  * == */
 
@@ -1254,6 +1281,45 @@
return True;/* no parse tree */
 }
 
+/* TODO: Comment me! */
+static
+int
+ldb_parse_tree_collect_attrs(struct ldb_module *module,
+void *mem_ctx,
+const char ***attrs,
+const struct ldb_parse_tree *tree)
+{
+   const char **new_attrs;
+   int i, ret;
+
+   if (tree == NULL) {
+   return 0;
+   }
+
+   switch (tree-operation) {
+   case LDB_OP_OR:
+   case LDB_OP_AND:/* attributes stored in list of 
subtrees */
+   for (i = 0; i  tree-u.list.num_elements; i++) {
+   ret = ldb_parse_tree_collect_attrs(module, mem_ctx, 
attrs, tree-u.list.elements[i]);
+   if (ret) {
+   return ret;
+   }
+   }
+   return 0;
+
+   case LDB_OP_NOT:/* attributes stored in single subtree 
*/
+   return ldb_parse_tree_collect_attrs(module, mem_ctx, attrs, 
tree-u.isnot.child);
+
+   default:/* single attribute in tree */
+   new_attrs = ldb_attr_list_copy_add(mem_ctx, *attrs, 
tree-u.equality.attr);
+   talloc_free(*attrs);
+   *attrs = new_attrs;
+   return 0;
+   }
+
+   return -1;
+}
+
 static int map_subtree_select_local(struct ldb_module *module, void *mem_ctx, 
struct ldb_parse_tree **new, const struct ldb_parse_tree *tree);
 
 /* Select a negated subtree that queries attributes in the local partition */
@@ -1635,7 +1701,75 @@
return 0;
 }
 
+/* TODO: Comment me! */
+/* TODO: Rename me! */
+static
+int
+map_flarp(struct ldb_module *module,
+ void *local_ctx,
+ void *remote_ctx,
+ const char ***local_attrs,
+ const char ***remote_attrs,
+ const char * const *search_attrs,
+ const struct ldb_parse_tree *tree)
+{
+   void *tmp_ctx;
+   const char **tree_attrs;
+   int ret;
 
+   /* Clear initial lists of partitioned attributes */
+   *local_attrs = NULL;
+   *remote_attrs = NULL;
+
+   /* There are no searched attributes, just stick to that */
+   if (search_attrs == NULL) {
+   return 0;
+   }
+
+   /* There is no tree, just partition the searched attributes */
+   if (tree == NULL) {
+   return map_attrs_partition(module, local_ctx, remote_ctx, 
local_attrs, remote_attrs, search_attrs);
+   }
+
+   /* Create context for temporary memory */
+   tmp_ctx = talloc_new(local_ctx);
+   if (tmp_ctx == NULL) {
+   goto oom;
+   }
+
+   /* Prepare list of attributes from tree */
+   tree_attrs = talloc_array(tmp_ctx, const char *, 1);
+   if (tree_attrs == NULL) {
+   talloc_free(tmp_ctx);
+   goto oom;
+   }
+   tree_attrs[0] = NULL;
+
+   /* Collect attributes from tree */
+   ret = ldb_parse_tree_collect_attrs(module, tmp_ctx, tree_attrs, tree);
+   if (ret) {
+   goto done;
+   }
+
+   /* Merge attributes from search operation */
+   ret = map_attrs_merge(module, tmp_ctx, tree_attrs, search_attrs);
+   if (ret) {
+   goto done;
+   }
+
+   /* Split local from remote attributes */
+   ret = map_attrs_partition(module, local_ctx, remote_ctx, local_attrs, 
remote_attrs, tree_attrs

svn commit: samba r17424 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-05 Thread mkhl
Author: mkhl
Date: 2006-08-05 17:17:38 + (Sat, 05 Aug 2006)
New Revision: 17424

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17424

Log:
Fix typo in check for splittable parse trees.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-05 17:16:10 UTC (rev 
17423)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-05 17:17:38 UTC (rev 
17424)
@@ -2284,7 +2284,7 @@
}
 
if (((local_tree == NULL) ^ (remote_tree == NULL)) 
-   (ldb_parse_tree_check_splittable(req-op.search.tree))) {
+   (!ldb_parse_tree_check_splittable(req-op.search.tree))) {
/* The query can't safely be split, enumerate the remote 
partition */
local_tree = NULL;
remote_tree = NULL;



svn commit: samba r17426 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-05 Thread mkhl
Author: mkhl
Date: 2006-08-05 17:52:23 + (Sat, 05 Aug 2006)
New Revision: 17426

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17426

Log:
Make parameter names for `generate' mappings clearer.

Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.h


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.h
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.h 2006-08-05 17:49:35 UTC (rev 
17425)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.h 2006-08-05 17:52:23 UTC (rev 
17426)
@@ -93,17 +93,17 @@
/* Generate the local attribute from remote message */
struct ldb_message_element *(*generate_local) (
struct ldb_module *,
-   TALLOC_CTX *ctx,
-   const char *attr,
+   TALLOC_CTX *mem_ctx,
+   const char *remote_attr,
const struct ldb_message *remote);
 
/* Update remote message with information from local 
message */
void (*generate_remote) (
struct ldb_module *,
const char *local_attr,
-   const struct ldb_message *local,
-   struct ldb_message *remote_mp,
-   struct ldb_message *remote_fb);
+   const struct ldb_message *old,
+   struct ldb_message *remote,
+   struct ldb_message *local);
 
/* Name(s) for this attribute on the remote server. 
This is an array since 
 * one local attribute's data can be split up into 
several attributes 



svn commit: samba r17427 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-05 Thread mkhl
Author: mkhl
Date: 2006-08-05 17:54:52 + (Sat, 05 Aug 2006)
New Revision: 17427

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17427

Log:
Change mapping type for objectClass into `generate'.
Add generator functions for objectClass elements, converting their
values as before but adding an objectClass of extensibleObject in
the remote partition.

Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-05 17:52:23 UTC (rev 
17426)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-05 17:54:52 UTC (rev 
17427)
@@ -1890,10 +1890,62 @@
return ldb_val_dup(mem_ctx, val);
 }
 
+/* Generate a remote message with a mapped objectClass. */
+static
+void
+map_objectclass_generate_remote(struct ldb_module *module,
+   const char *local_attr,
+   const struct ldb_message *old,
+   struct ldb_message *remote,
+   struct ldb_message *local)
+{
+   struct ldb_message_element *el, *oc;
+   struct ldb_val val;
+   int i;
+
+   /* Find old local objectClass */
+   oc = ldb_msg_find_element(old, local_attr);
+   if (oc == NULL) {
+   return;
+   }
+
+   /* Prepare new element */
+   el = talloc_zero(remote, struct ldb_message_element);
+   if (el == NULL) {
+   ldb_oom(module-ldb);
+   return; /* TODO: fail? */
+   }
+
+   /* Copy local objectClass element, reverse space for an extra value */
+   el-num_values = oc-num_values + 1;
+   el-values = talloc_array(el, struct ldb_val, el-num_values);
+   if (el-values == NULL) {
+   talloc_free(el);
+   ldb_oom(module-ldb);
+   return; /* TODO: fail? */
+   }
+
+   /* Copy local element name objectClass */
+   el-name = talloc_strdup(el, local_attr);
+
+   /* Convert all local objectClasses */
+   for (i = 0; i  el-num_values - 1; i++) {
+   el-values[i] = map_objectclass_convert_local(module, 
el-values, oc-values[i]);
+   }
+
+   val.data = (uint8_t *)talloc_strdup(el-values, extensibleObject);
+   val.length = strlen((char *)val.data);
+
+   /* Append additional objectClass extensibleObject */
+   el-values[i] = val;
+
+   /* Add new objectClass to remote message */
+   ldb_msg_add(remote, el, 0);
+}
+
 /* Map an objectClass into the local partition. */
 static
-struct
-ldb_val
+struct ldb_val
 map_objectclass_convert_remote(struct ldb_module *module,
   void *mem_ctx,
   const struct ldb_val *val)
@@ -1912,7 +1964,67 @@
return ldb_val_dup(mem_ctx, val); 
 }
 
+/* Generate a local message with a mapped objectClass. */
+static
+struct ldb_message_element *
+map_objectclass_generate_local(struct ldb_module *module,
+  void *mem_ctx,
+  const char *remote_attr,
+  const struct ldb_message *remote)
+{
+   struct ldb_message_element *el, *oc;
+   struct ldb_val val;
+   int i;
 
+   /* Find old remote objectClass */
+   oc = ldb_msg_find_element(remote, remote_attr);
+   if (oc == NULL) {
+   return NULL;
+   }
+
+   /* Prepare new element */
+   el = talloc_zero(mem_ctx, struct ldb_message_element);
+   if (el == NULL) {
+   ldb_oom(module-ldb);
+   return NULL;
+   }
+
+   /* Copy remote objectClass element */
+   el-num_values = oc-num_values;
+   el-values = talloc_array(el, struct ldb_val, el-num_values);
+   if (el-values == NULL) {
+   talloc_free(el);
+   ldb_oom(module-ldb);
+   return NULL;
+   }
+
+   /* Copy remote element name objectClass */
+   el-name = talloc_strdup(el, remote_attr);
+
+   /* Convert all remote objectClasses */
+   for (i = 0; i  el-num_values; i++) {
+   el-values[i] = map_objectclass_convert_remote(module, 
el-values, oc-values[i]);
+   }
+
+   val.data = (uint8_t *)talloc_strdup(el-values, extensibleObject);
+   val.length = strlen((char *)val.data);
+
+   /* Remove last value if it was extensibleObject */
+   if (ldb_val_equal_exact(val, el-values[i-1])) {
+   el-num_values--;
+   el-values = talloc_realloc(el, el-values, struct ldb_val, 
el-num_values);
+   if (el-values == NULL) {
+   talloc_free(el);
+   ldb_oom(module-ldb);
+   return NULL;
+   }
+   }
+
+   return el;
+}
+
+
+
 /* Auxiliary request construction

svn commit: samba r17428 - in branches/SOC/mkhl/testprogs-map/ejs: .

2006-08-05 Thread mkhl
Author: mkhl
Date: 2006-08-05 17:56:59 + (Sat, 05 Aug 2006)
New Revision: 17428

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17428

Log:
Fix typo in the `objectClass' member of the search result used for
checking objectClasses.
Fix spelling in the corresponding comment.
Add assertion that the `objectClass' member in fact exists before
running tests on it.

Martin
Modified:
   branches/SOC/mkhl/testprogs-map/ejs/samba3sam


Changeset:
Modified: branches/SOC/mkhl/testprogs-map/ejs/samba3sam
===
--- branches/SOC/mkhl/testprogs-map/ejs/samba3sam   2006-08-05 17:54:52 UTC 
(rev 17427)
+++ branches/SOC/mkhl/testprogs-map/ejs/samba3sam   2006-08-05 17:56:59 UTC 
(rev 17428)
@@ -105,8 +105,9 @@
 assert(msg[0].dn == 
cn=Replicator,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl);
 assert(msg[0].objectSid == S-1-5-21-4231626423-2410014848-2360679739-552);
 
-println(Checking mapping of objectclass);
-var oc = msg[0].objectclass;
+println(Checking mapping of objectClass);
+var oc = msg[0].objectClass;
+assert(oc != undefined);
 for (var i in oc) {
assert(oc[i] == posixGroup || oc[i] == group);
 }



svn commit: samba r17409 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-04 Thread mkhl
Author: mkhl
Date: 2006-08-04 23:29:06 + (Fri, 04 Aug 2006)
New Revision: 17409

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17409

Log:
Keep the name of a keep attribute, make sure it isn't replaced with the 
wildcard.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-04 22:18:02 UTC (rev 
17408)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-04 23:29:06 UTC (rev 
17409)
@@ -503,6 +503,10 @@
return talloc_strdup(mem_ctx, attr);
}
 
+   if (map-type == MAP_KEEP) {
+   return talloc_strdup(mem_ctx, attr);
+   }
+
return talloc_strdup(mem_ctx, map-local_name);
 }
 



svn commit: samba r17410 - in branches/SOC/mkhl/ldb-map/modules: .

2006-08-04 Thread mkhl
Author: mkhl
Date: 2006-08-04 23:30:10 + (Fri, 04 Aug 2006)
New Revision: 17410

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17410

Log:
Fix swapped talloc contexts for local/remote parts of search requests.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-04 23:29:06 UTC (rev 
17409)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-08-04 23:30:10 UTC (rev 
17410)
@@ -2138,7 +2138,7 @@
/* TODO: To check merged results against the original query,
 *   we need to have all their attributes available. */
/* That's why this code is disabled:
-   ret = map_attrs_partition(module, ac-remote_req, ac, local_attrs, 
remote_attrs, req-op.search.attrs);
+   ret = map_attrs_partition(module, ac, ac-remote_req, local_attrs, 
remote_attrs, req-op.search.attrs);
if (ret) {
ret = LDB_ERR_OPERATIONS_ERROR;
goto failed;
@@ -2151,7 +2151,7 @@
ac-remote_req-op.search.attrs = remote_attrs;
 
/* Split local from remote tree */
-   ret = ldb_parse_tree_partition(module, ac-remote_req, ac, local_tree, 
remote_tree, req-op.search.tree);
+   ret = ldb_parse_tree_partition(module, ac, ac-remote_req, local_tree, 
remote_tree, req-op.search.tree);
if (ret) {
goto failed;
}



svn commit: samba r17387 - in branches/SOC/mkhl: ldb-map/modules testprogs-map/ejs

2006-08-03 Thread mkhl
Author: mkhl
Date: 2006-08-03 16:43:26 + (Thu, 03 Aug 2006)
New Revision: 17387

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17387

Log:

Rename functions based on which data type they operate on and reorganize them
into sections.
Reformulate comments for every function.
Lots fo reformatting (less inconsistent tries at 80-column-lines, braces after
ifs, less gotos).

Reformulate filtering of attributes (in `map_up_callback') to use
`ldb_msg_remove_attr'.
Add logic to check whether a parse tree can safely be split and to enumerate
the remote partition in case it can't.
Enable searching the local partition for search requests.

Enable tests that require the local partition to be searched.
Add tests that query using an unsafe parse tree.
Adapt test initialization to the new privision.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c
   branches/SOC/mkhl/testprogs-map/ejs/samba3sam


Changeset:
Sorry, the patch is too large (4470 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17387


svn commit: samba r17389 - in branches/SOC/mkhl/testprogs-map/ejs: .

2006-08-03 Thread mkhl
Author: mkhl
Date: 2006-08-03 21:51:14 + (Thu, 03 Aug 2006)
New Revision: 17389

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17389

Log:
Merge from mainline, r17388.
Modified:
   branches/SOC/mkhl/testprogs-map/ejs/ldap.js


Changeset:
Modified: branches/SOC/mkhl/testprogs-map/ejs/ldap.js
===
--- branches/SOC/mkhl/testprogs-map/ejs/ldap.js 2006-08-03 19:07:12 UTC (rev 
17388)
+++ branches/SOC/mkhl/testprogs-map/ejs/ldap.js 2006-08-03 21:51:14 UTC (rev 
17389)
@@ -5,6 +5,7 @@
 */
 
 var ldb = ldb_init();
+var gc_ldb = ldb_init();
 
 var options = GetOptions(ARGV, 
POPT_AUTOHELP,
@@ -24,7 +25,7 @@
 
 var host = options.ARGV[0];
 
-function basic_tests(ldb, base_dn)
+function basic_tests(ldb, gc_ldb, base_dn, configuration_dn)
 {
println(Running basic tests);
 
@@ -195,13 +196,22 @@
 
println(Testing ldb.search for 
((cn=ldaptestuser)(objectCategory=PerSon)));
var res3 = ldb.search(((cn=ldaptestuser)(objectCategory=PerSon)));
-   if (res.length != 1) {
+   if (res3.length != 1) {
println(Could not find 
((cn=ldaptestuser)(objectCategory=PerSon)));
-   assert(res.length == 1);
+   assert(res3.length == 1);
}
 
assert(res[0].dn == res3[0].dn);
 
+   println(Testing ldb.search for 
((cn=ldaptestuser)(objectCategory=PerSon)) in Global Catalog);
+   var res3gc = 
gc_ldb.search(((cn=ldaptestuser)(objectCategory=PerSon)));
+   if (res3gc.length != 1) {
+   println(Could not find 
((cn=ldaptestuser)(objectCategory=PerSon)) in Global Catalog);
+   assert(res3gc.length == 1);
+   }
+
+   assert(res[0].dn == res3gc[0].dn);
+
ok = ldb.del(res[0].dn);
if (!ok) {
println(ldb.errstring());
@@ -238,6 +248,15 @@
 
assert(res[0].dn == res2[0].dn);
 
+   println(Testing ldb.search for 
((cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration, 
+ base_dn + )) in Global Catlog);
+   var res2gc = 
gc_ldb.search(((cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration,
 + base_dn + )));
+   if (res2gc.length != 1) {
+   println(Could not find 
((cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration, 
+ base_dn + )) in Global Catlog);
+   assert(res2gc.length == 1);
+   }
+
+   assert(res[0].dn == res2[0].dn);
+
println(Testing ldb.search for 
((cn=ldaptestcomputer)(objectCategory=compuTER)));
var res3 = 
ldb.search(((cn=ldaptestcomputer)(objectCategory=compuTER)));
if (res3.length != 1) {
@@ -247,6 +266,15 @@
 
assert(res[0].dn == res3[0].dn);
 
+   println(Testing ldb.search for 
((cn=ldaptestcomputer)(objectCategory=compuTER)) in Global Catalog);
+   var res3gc = 
gc_ldb.search(((cn=ldaptestcomputer)(objectCategory=compuTER)));
+   if (res3gc.length != 1) {
+   println(Could not find 
((cn=ldaptestcomputer)(objectCategory=compuTER)) in Global Catalog);
+   assert(res3gc.length == 1);
+   }
+
+   assert(res[0].dn == res3gc[0].dn);
+
println(Testing ldb.search for 
((cn=ldaptestcomp*r)(objectCategory=compuTER)));
var res4 = 
ldb.search(((cn=ldaptestcomp*r)(objectCategory=compuTER)));
if (res4.length != 1) {
@@ -366,6 +394,31 @@
assert(res[0].highestCommittedUSN != undefined);
assert(res[0].highestCommittedUSN != 0);
 
+   println(Testing that we can't get at the configuration DN from the 
main search base);
+   var attrs = new Array(cn);
+   var res = ldb.search(objectClass=crossRef, base_dn, 
ldb.SCOPE_SUBTREE, attrs);
+   assert (res.length == 0);
+
+   println(Testing that we do find configuration elements in the global 
catlog);
+   var attrs = new Array(cn);
+   var res = gc_ldb.search(objectClass=crossRef, base_dn, 
ldb.SCOPE_SUBTREE, attrs);
+   assert (res.length  0);
+
+   println(Testing that we do find configuration elements and user 
elements at the same time);
+   var attrs = new Array(cn);
+   var res = 
gc_ldb.search((|(objectClass=crossRef)(objectClass=person)), base_dn, 
ldb.SCOPE_SUBTREE, attrs);
+   assert (res.length  0);
+
+   println(Testing that we do find configuration elements in the global 
catlog, with the configuration basedn);
+   var attrs = new Array(cn);
+   var res = gc_ldb.search(objectClass=crossRef, configuration_dn, 
ldb.SCOPE_SUBTREE, attrs);
+   assert (res.length  0);
+
+   println(Testing that we can get at the configuration DN on the main 
LDAP port);
+   var attrs = new Array(cn);
+   var res = ldb.search(objectClass=crossRef, configuration_dn, 
ldb.SCOPE_SUBTREE, attrs);
+   assert (res.length  0);
+
 }
 
 function find_basedn(ldb)
@@ -376,14 +429,26 @@
 return res[0].defaultNamingContext;
 }
 
+function

svn commit: samba r17369 - in branches/SOC/mkhl: ldb-map/common ldb-map/include ldb-map/ldb_ildap ldb-map/ldb_tdb samdb-map/ldb_modules

2006-08-01 Thread mkhl
Author: mkhl
Date: 2006-08-01 22:59:36 + (Tue, 01 Aug 2006)
New Revision: 17369

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17369

Log:
Merge from mainline, r17368.

Removed:
   branches/SOC/mkhl/samdb-map/ldb_modules/password_sync.c
Modified:
   branches/SOC/mkhl/ldb-map/common/ldb_match.c
   branches/SOC/mkhl/ldb-map/include/ldb.h
   branches/SOC/mkhl/ldb-map/include/ldb_private.h
   branches/SOC/mkhl/ldb-map/ldb_ildap/ldb_ildap.c
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/common/ldb_match.c
===
--- branches/SOC/mkhl/ldb-map/common/ldb_match.c2006-08-01 22:46:49 UTC 
(rev 17368)
+++ branches/SOC/mkhl/ldb-map/common/ldb_match.c2006-08-01 22:59:36 UTC 
(rev 17369)
@@ -81,9 +81,9 @@
   match if node is present
 */
 static int ldb_match_present(struct ldb_context *ldb, 
-   struct ldb_message *msg,
-   struct ldb_parse_tree *tree,
-   enum ldb_scope scope)
+const struct ldb_message *msg,
+const struct ldb_parse_tree *tree,
+enum ldb_scope scope)
 {
if (ldb_attr_dn(tree-u.present.attr) == 0) {
return 1;
@@ -97,8 +97,8 @@
 }
 
 static int ldb_match_comparison(struct ldb_context *ldb, 
-   struct ldb_message *msg,
-   struct ldb_parse_tree *tree,
+   const struct ldb_message *msg,
+   const struct ldb_parse_tree *tree,
enum ldb_scope scope,
enum ldb_parse_op comp_op)
 {
@@ -138,8 +138,8 @@
   match a simple leaf node
 */
 static int ldb_match_equality(struct ldb_context *ldb, 
- struct ldb_message *msg,
- struct ldb_parse_tree *tree,
+ const struct ldb_message *msg,
+ const struct ldb_parse_tree *tree,
  enum ldb_scope scope)
 {
unsigned int i;
@@ -183,7 +183,7 @@
 }
 
 static int ldb_wildcard_compare(struct ldb_context *ldb,
-   struct ldb_parse_tree *tree,
+   const struct ldb_parse_tree *tree,
const struct ldb_val value)
 {
const struct ldb_attrib_handler *h;
@@ -254,8 +254,8 @@
   match a simple leaf node
 */
 static int ldb_match_substring(struct ldb_context *ldb, 
-  struct ldb_message *msg,
-  struct ldb_parse_tree *tree,
+  const struct ldb_message *msg,
+  const struct ldb_parse_tree *tree,
   enum ldb_scope scope)
 {
unsigned int i;
@@ -279,7 +279,7 @@
 /*
   bitwise-and comparator
 */
-static int ldb_comparator_and(struct ldb_val *v1, struct ldb_val *v2)
+static int ldb_comparator_and(const struct ldb_val *v1, const struct ldb_val 
*v2)
 {
uint64_t i1, i2;
i1 = strtoull((char *)v1-data, NULL, 0);
@@ -290,7 +290,7 @@
 /*
   bitwise-or comparator
 */
-static int ldb_comparator_or(struct ldb_val *v1, struct ldb_val *v2)
+static int ldb_comparator_or(const struct ldb_val *v1, const struct ldb_val 
*v2)
 {
uint64_t i1, i2;
i1 = strtoull((char *)v1-data, NULL, 0);
@@ -303,19 +303,19 @@
   extended match, handles things like bitops
 */
 static int ldb_match_extended(struct ldb_context *ldb, 
- struct ldb_message *msg,
- struct ldb_parse_tree *tree,
+ const struct ldb_message *msg,
+ const struct ldb_parse_tree *tree,
  enum ldb_scope scope)
 {
int i;
const struct {
const char *oid;
-   int (*comparator)(struct ldb_val *, struct ldb_val *);
+   int (*comparator)(const struct ldb_val *, const struct ldb_val 
*);
} rules[] = {
{ LDB_OID_COMPARATOR_AND, ldb_comparator_and},
{ LDB_OID_COMPARATOR_OR, ldb_comparator_or}
};
-   int (*comp)(struct ldb_val *, struct ldb_val *) = NULL;
+   int (*comp)(const struct ldb_val *, const struct ldb_val *) = NULL;
struct ldb_message_element *el;
 
if (tree-u.extended.dnAttributes) {
@@ -366,8 +366,8 @@
   this is a recursive function, and does short-circuit evaluation
  */
 static int ldb_match_message(struct ldb_context *ldb, 
-struct ldb_message *msg,
-struct ldb_parse_tree *tree,
+const struct ldb_message *msg,
+const struct ldb_parse_tree *tree

svn commit: samba r17371 - in branches/SOC/mkhl/ldb-map/ldb_tdb: .

2006-08-01 Thread mkhl
Author: mkhl
Date: 2006-08-02 01:25:05 + (Wed, 02 Aug 2006)
New Revision: 17371

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17371

Log:
Merge from mainline, r17370.
Modified:
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_search.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_search.c
===
--- branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_search.c  2006-08-02 00:01:09 UTC 
(rev 17370)
+++ branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_search.c  2006-08-02 01:25:05 UTC 
(rev 17371)
@@ -478,6 +478,7 @@
 {
struct ltdb_private *ltdb = talloc_get_type(module-private_data, 
struct ltdb_private);
struct ltdb_context *ltdb_ac;
+   struct ldb_reply *ares;
int ret;
 
if ((req-op.search.base == NULL || req-op.search.base-comp_num == 0) 

@@ -521,6 +522,20 @@
req-handle-status = ret;
}
 
+   /* Finally send an LDB_REPLY_DONE packet when searching is finished */
+
+   ares = talloc_zero(req, struct ldb_reply);
+   if (!ares) {
+   ltdb_unlock_read(module);
+   return LDB_ERR_OPERATIONS_ERROR;
+   }
+
+   req-handle-state = LDB_ASYNC_DONE;
+   ares-type = LDB_REPLY_DONE;
+
+   ret = req-callback(module-ldb, req-context, ares);
+   req-handle-status = ret;
+
ltdb_unlock_read(module);
 
return LDB_SUCCESS;



svn commit: samba r17309 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-29 Thread mkhl
Author: mkhl
Date: 2006-07-29 14:01:34 + (Sat, 29 Jul 2006)
New Revision: 17309

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17309

Log:
Get rid of the macro changing a DNs base, replace it with functions.
Provide a function to remap and rebase a remote DN.

Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-29 12:23:26 UTC (rev 
17308)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-29 14:01:34 UTC (rev 
17309)
@@ -229,8 +229,28 @@
 return new;
 }
 
-#define MAP_DN_REBASE(dn) dn = ldb_dn_rebase(request, dn, data-local_base_dn, 
data-remote_base_dn)
+/* copy DN with the baseDN of the local partition */
+static
+struct ldb_dn *
+ldb_dn_rebase_local(void *mem_ctx,
+   const struct ldb_map_context *data,
+   const struct ldb_dn *dn)
+{
+   return ldb_dn_rebase(mem_ctx, dn,
+data-remote_base_dn, data-local_base_dn);
+}
 
+/* copy DN with the baseDN of the remote partition */
+static
+struct ldb_dn *
+ldb_dn_rebase_remote(void *mem_ctx,
+const struct ldb_map_context *data,
+const struct ldb_dn *dn)
+{
+   return ldb_dn_rebase(mem_ctx, dn,
+data-local_base_dn, data-remote_base_dn);
+}
+
 /* run request in the remote partition */
 static
 int
@@ -244,33 +264,39 @@
case LDB_SEARCH:
/* make sure the request targets the remote partition */
if (request-op.search.base) {
-   MAP_DN_REBASE(request-op.search.base);
+   request-op.search.base
+   = ldb_dn_rebase_remote(request, data,
+  request-op.search.base);
} else {
request-op.search.base = data-remote_base_dn;
-   /* TODO: reference/steal? */
/* TODO: adjust scope? */
}
 break;
 
case LDB_ADD:
 msg = ldb_msg_copy_shallow(request, request-op.add.message);
-MAP_DN_REBASE(msg-dn);
+msg-dn = ldb_dn_rebase_remote(msg, data, msg-dn);
 request-op.add.message = msg;
 break;
 
case LDB_MODIFY:
 msg = ldb_msg_copy_shallow(request, request-op.mod.message);
-MAP_DN_REBASE(msg-dn);
+msg-dn = ldb_dn_rebase_remote(msg, data, msg-dn);
 request-op.mod.message = msg;
 break;
 
case LDB_DELETE:
-MAP_DN_REBASE(request-op.del.dn);
+   request-op.del.dn = ldb_dn_rebase_remote(request, data,
+ request-op.del.dn);
 break;
 
case LDB_RENAME:
-MAP_DN_REBASE(request-op.rename.olddn);
-MAP_DN_REBASE(request-op.rename.newdn);
+   request-op.rename.olddn
+   = ldb_dn_rebase_remote(request, data,
+  request-op.rename.olddn);
+   request-op.rename.newdn
+   = ldb_dn_rebase_remote(request, data,
+  request-op.rename.newdn);
 break;
 
 default:
@@ -962,19 +988,6 @@
 /* TODO: these functions move a DN from the remote into the local partition.
The first one keeps the remote schema, the second one uses the local one.
Neither should be necessary with GUIDs. */
-/* rebased DN - DN */
-static
-struct ldb_dn *
-map_unrebase_dn(struct ldb_module *module,
- void *mem_ctx,
- const struct ldb_dn *dn)
-{
-   const struct ldb_map_context *data = map_get_context(module);
-
-   return ldb_dn_rebase(mem_ctx, dn,
-data-remote_base_dn, data-local_base_dn);
-}
-
 /* remote rebased DN - local DN */
 static
 struct ldb_dn *
@@ -982,9 +995,10 @@
   void *mem_ctx,
   const struct ldb_dn *dn)
 {
+   const struct ldb_map_context *data = map_get_context(module);
struct ldb_dn *dn1, *dn2;
 
-   dn1 = map_unrebase_dn(module, mem_ctx, dn);
+   dn1 = ldb_dn_rebase_local(mem_ctx, data, dn);
dn2 = map_remote_dn(module, mem_ctx, dn1);
 
talloc_free(dn1);



svn commit: samba r17310 - in branches/SOC/mkhl: ldb-map/modules testprogs-map/ejs

2006-07-29 Thread mkhl
Author: mkhl
Date: 2006-07-29 14:11:48 + (Sat, 29 Jul 2006)
New Revision: 17310

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17310

Log:

Let search requests target the remote database first and the local
database afterwards.
Local searching isn't actually enabled yet, as the callback is never
called in absence of local search results.

Because of unreliable splitting of parse-trees, the merged result is
checked against the original parse-tree and attribute list before
passing it to the original callback.

Add a few kludges related to split attrs and parse-trees that let more
tests pass.

Enable tests that now pass.  Add one more (disabled) test that
requires merging the remote with the local search result.

Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c
   branches/SOC/mkhl/testprogs-map/ejs/samba3sam


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-29 14:01:34 UTC (rev 
17309)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-29 14:11:48 UTC (rev 
17310)
@@ -104,7 +104,7 @@
 /* async context data */
 struct map_async_context {
enum map_step {
-   MAP_SEARCH_LOCAL,
+   MAP_SEARCH_REMOTE,
MAP_ADD_REMOTE,
MAP_ADD_LOCAL,
MAP_SEARCH_SELF_MODIFY,
@@ -1862,7 +1862,50 @@
 
  */
 
+/* remote reply - local reply */
+static
+int
+map_remote_reply(struct ldb_module *module,
+struct ldb_reply *ares)
+{
+   struct ldb_message *msg;
+   struct ldb_dn *dn;
+   int ret;
 
+   /* there is no remote message, skip */
+   if (ares-type != LDB_REPLY_ENTRY)
+   return LDB_SUCCESS;
+
+   /* create a new result message */
+   msg = ldb_msg_new(ares);
+   if (msg == NULL) {
+   map_oom(module);
+   return LDB_ERR_OPERATIONS_ERROR;
+   }
+
+   /* merge remote message into new message */
+   ret = merge_msg(module, msg, ares-message);
+   if (ret != LDB_SUCCESS) {
+   talloc_free(msg);
+   return ret;
+   }
+
+   /* create corresponding local DN */
+   dn = map_unrebase_remote_dn(module, msg, ares-message-dn);
+   if (dn == NULL) {
+   talloc_free(msg);
+   return LDB_ERR_OPERATIONS_ERROR;
+   }
+
+   /* store new message with new DN as the result */
+   talloc_free(ares-message);
+   msg-dn = dn;
+   ares-message = msg;
+
+   return LDB_SUCCESS;
+}
+
+
 typedef int (*ldb_search_callback)(struct ldb_context *, void *, struct 
ldb_reply *);
 
 /* store single search result in async context */
@@ -1969,6 +2012,51 @@
return search_base_req(ac, dn, attrs, tree, search_self_callback);
 }
 
+static
+int
+up_callback(struct ldb_context *ldb,
+   const struct ldb_request *req,
+   struct ldb_reply *ares)
+{
+   int i;
+
+   if (ares-type != LDB_REPLY_ENTRY)
+   goto callback;
+
+   /* the merged result doesn't match the original tree, skip it */
+   /* TODO: silence warning about tree being `const' */
+   if (!ldb_match_msg(ldb, ares-message, req-op.search.tree,
+  req-op.search.base, req-op.search.scope)) {
+   ldb_debug(ldb, LDB_DEBUG_TRACE, ldb_map: 
+ Skipping record '%s': 
+ doesn't match original search\n,
+ ldb_dn_linearize(ldb, ares-message-dn));
+   return LDB_SUCCESS;
+   }
+
+   /* XXX: ugly kludge: pass only requested attrs */
+   if (req-op.search.attrs) {
+   struct ldb_message *msg = ldb_msg_new(ares);
+   if (msg == NULL)
+   goto error;
+
+   for (i = 0; req-op.search.attrs[i]; i++) {
+   struct ldb_message_element *el = 
ldb_msg_find_element(ares-message, req-op.search.attrs[i]);
+   if (el)
+   ldb_msg_add(msg, el, 0);
+   }
+
+   talloc_free(ares-message);
+   ares-message = msg;
+   }
+
+callback:
+   return req-callback(ldb, req-context, ares);
+
+error:
+   return LDB_ERR_OPERATIONS_ERROR;
+}
+
 /* merge remote record with associated local record */
 static
 int
@@ -1977,7 +2065,6 @@
 struct ldb_reply *ares)
 {
struct map_async_search_context *sc;
-   const struct ldb_request *req;
int ret;
 
if (context == NULL || ares == NULL) {
@@ -1989,47 +2076,45 @@
 
switch (ares-type) {
case LDB_REPLY_ENTRY:
-   /* we have already found a remote record */
-   if (sc-remote_res) {
-   ldb_set_errstring(ldb, talloc_asprintf(ldb, Too many 
results to base search for mapped entry

svn commit: samba r17311 - in branches/SOC/mkhl: ldb-map/common ldb-map/ldb_ildap ldb-map/ldb_tdb samdb-map/ldb_modules testprogs-map/ejs

2006-07-29 Thread mkhl
Author: mkhl
Date: 2006-07-29 14:29:27 + (Sat, 29 Jul 2006)
New Revision: 17311

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17311

Log:
Merge from mainline, r17310.

Added:
   branches/SOC/mkhl/samdb-map/ldb_modules/local_password.c
   branches/SOC/mkhl/samdb-map/ldb_modules/password_modules.h
   branches/SOC/mkhl/samdb-map/ldb_modules/password_sync.c
Modified:
   branches/SOC/mkhl/ldb-map/common/ldb_msg.c
   branches/SOC/mkhl/ldb-map/ldb_ildap/ldb_ildap.c
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.c
   branches/SOC/mkhl/samdb-map/ldb_modules/config.mk
   branches/SOC/mkhl/samdb-map/ldb_modules/partition.c
   branches/SOC/mkhl/samdb-map/ldb_modules/password_hash.c
   branches/SOC/mkhl/testprogs-map/ejs/ldb.js


Changeset:
Sorry, the patch is too large (933 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17311


svn commit: samba r17235 - in branches/SOC/mkhl/ldb-map/include: .

2006-07-25 Thread mkhl
Author: mkhl
Date: 2006-07-25 18:22:03 + (Tue, 25 Jul 2006)
New Revision: 17235

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17235

Log:
Merge from mainline, r17234.
Modified:
   branches/SOC/mkhl/ldb-map/include/ldb.h


Changeset:
Modified: branches/SOC/mkhl/ldb-map/include/ldb.h
===
--- branches/SOC/mkhl/ldb-map/include/ldb.h 2006-07-25 16:48:08 UTC (rev 
17234)
+++ branches/SOC/mkhl/ldb-map/include/ldb.h 2006-07-25 18:22:03 UTC (rev 
17235)
@@ -500,7 +500,7 @@
This Extended operation is used to start a new TLS
channel on top of a clear text channel.
 */
-#define LDB_EXTENDED_STATRT_TLS_OID1.3.6.1.4.1.1466.20037
+#define LDB_EXTENDED_START_TLS_OID 1.3.6.1.4.1.1466.20037
 
 struct ldb_paged_control {
int size;



svn commit: samba r17236 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-25 Thread mkhl
Author: mkhl
Date: 2006-07-25 18:42:26 + (Tue, 25 Jul 2006)
New Revision: 17236

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17236

Log:
Even more const declarations for `ldb_map_context's.

Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c
   branches/SOC/mkhl/ldb-map/modules/ldb_map.h


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-25 18:22:03 UTC (rev 
17235)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-25 18:42:26 UTC (rev 
17236)
@@ -92,7 +92,7 @@
 
 /* extract private data */
 static
-struct ldb_map_context *
+const struct ldb_map_context *
 map_get_context(struct ldb_module *module)
 {
struct map_private *data = talloc_get_type(module-private_data,
@@ -1446,7 +1446,7 @@
  struct ldb_parse_tree **new,
  const struct ldb_parse_tree *tree)
 {
-   struct ldb_map_context *data = map_get_context(module);
+   const struct ldb_map_context *data = map_get_context(module);
const struct ldb_map_attribute *map;
 
if (tree == NULL)
@@ -2984,10 +2984,10 @@
 static
 int
 map_init_dns(struct ldb_module *module,
+struct ldb_map_context *data,
 const char *name)
 {
static const char *const attrs[] = { MAP_DN_FROM, MAP_DN_TO, NULL};
-   struct ldb_map_context *data = map_get_context(module);
struct ldb_dn *dn;
struct ldb_message *msg;
struct ldb_result *res;
@@ -3034,10 +3034,10 @@
 static
 void
 map_init_maps(struct ldb_module *module,
+ struct ldb_map_context *data,
  const struct ldb_map_attribute *attrs,
  const struct ldb_map_objectclass *ocls)
 {
-   struct ldb_map_context *data = map_get_context(module);
int i, last;
 
last = 0;
@@ -3092,7 +3092,7 @@
int ret;
 
/* prepare private data */
-   data = talloc(module, struct map_private);
+   data = talloc_zero(module, struct map_private);
if (data == NULL) {
ldb_oom(module-ldb);
 goto failed;
@@ -3101,12 +3101,12 @@
module-private_data = data;
 
/* store local and remote baseDNs */
-   ret = map_init_dns(module, name);
+   ret = map_init_dns(module, (data-context), name);
if (ret != LDB_SUCCESS)
goto failed;
 
/* store list of attribute and objectClass maps */
-   map_init_maps(module, attrs, ocls);
+   map_init_maps(module, (data-context), attrs, ocls);
 
return LDB_SUCCESS;
 

Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.h
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.h 2006-07-25 18:22:03 UTC (rev 
17235)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.h 2006-07-25 18:42:26 UTC (rev 
17236)
@@ -68,7 +68,7 @@

/* if set, will be called for search expressions that contain this 
attribute */
struct ldb_parse_tree *(*convert_operator) (
-   struct ldb_map_context *,
+   const struct ldb_map_context *,
TALLOC_CTX *ctx,
const struct ldb_parse_tree *); 
 



svn commit: samba r17200 - in branches/SOC/mkhl: ldb-map ldb-map/common ldb-map/include ldb-map/ldb_ildap ldb-map/ldb_ldap ldb-map/ldb_sqlite3 ldb-map/ldb_tdb ldb-map/modules ldb-map/samba ldb-map/too

2006-07-23 Thread mkhl
Author: mkhl
Date: 2006-07-23 09:50:04 + (Sun, 23 Jul 2006)
New Revision: 17200

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17200

Log:
Merge from mainline, r17199.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/common/ldb.c
   branches/SOC/mkhl/ldb-map/common/ldb_dn.c
   branches/SOC/mkhl/ldb-map/common/ldb_modules.c
   branches/SOC/mkhl/ldb-map/configure.in
   branches/SOC/mkhl/ldb-map/include/ldb.h
   branches/SOC/mkhl/ldb-map/include/ldb_private.h
   branches/SOC/mkhl/ldb-map/ldb_ildap/ldb_ildap.c
   branches/SOC/mkhl/ldb-map/ldb_ldap/ldb_ldap.c
   branches/SOC/mkhl/ldb-map/ldb_sqlite3/ldb_sqlite3.c
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_index.c
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_search.c
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.c
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.h
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb_wrap.c
   branches/SOC/mkhl/ldb-map/modules/asq.c
   branches/SOC/mkhl/ldb-map/modules/objectclass.c
   branches/SOC/mkhl/ldb-map/modules/operational.c
   branches/SOC/mkhl/ldb-map/modules/paged_results.c
   branches/SOC/mkhl/ldb-map/modules/rdn_name.c
   branches/SOC/mkhl/ldb-map/modules/sort.c
   branches/SOC/mkhl/ldb-map/samba/ldif_handlers.c
   branches/SOC/mkhl/ldb-map/tools/ldbsearch.c
   branches/SOC/mkhl/samdb-map/ldb_modules/extended_dn.c
   branches/SOC/mkhl/samdb-map/ldb_modules/kludge_acl.c
   branches/SOC/mkhl/samdb-map/ldb_modules/objectguid.c
   branches/SOC/mkhl/samdb-map/ldb_modules/partition.c
   branches/SOC/mkhl/samdb-map/ldb_modules/password_hash.c
   branches/SOC/mkhl/samdb-map/ldb_modules/rootdse.c
   branches/SOC/mkhl/samdb-map/ldb_modules/samldb.c


Changeset:
Sorry, the patch is too large (5238 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17200


svn commit: samba r17201 - in branches/SOC/mkhl/ldb-map: common include ldb_tdb modules

2006-07-23 Thread mkhl
Author: mkhl
Date: 2006-07-23 10:54:06 + (Sun, 23 Jul 2006)
New Revision: 17201

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17201

Log:
Fetch missing updates from mainline (missed them while merging...).

Martin

Modified:
   branches/SOC/mkhl/ldb-map/common/ldb.c
   branches/SOC/mkhl/ldb-map/common/ldb_dn.c
   branches/SOC/mkhl/ldb-map/common/ldb_msg.c
   branches/SOC/mkhl/ldb-map/include/ldb.h
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.c
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.h
   branches/SOC/mkhl/ldb-map/modules/objectclass.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/common/ldb.c
===
--- branches/SOC/mkhl/ldb-map/common/ldb.c  2006-07-23 09:50:04 UTC (rev 
17200)
+++ branches/SOC/mkhl/ldb-map/common/ldb.c  2006-07-23 10:54:06 UTC (rev 
17201)
@@ -296,7 +296,7 @@
return ldb_transaction_cancel_internal(ldb);
 }
 
-int ldb_autotransaction_start(struct ldb_context *ldb)
+static int ldb_autotransaction_start(struct ldb_context *ldb)
 {
/* explicit transaction active, ignore autotransaction request */
if (ldb-transaction_active)
@@ -305,7 +305,7 @@
return ldb_transaction_start_internal(ldb);
 }
 
-int ldb_autotransaction_commit(struct ldb_context *ldb)
+static int ldb_autotransaction_commit(struct ldb_context *ldb)
 {
/* explicit transaction active, ignore autotransaction request */
if (ldb-transaction_active)
@@ -314,7 +314,7 @@
return ldb_transaction_commit_internal(ldb);
 }
 
-int ldb_autotransaction_cancel(struct ldb_context *ldb)
+static int ldb_autotransaction_cancel(struct ldb_context *ldb)
 {
/* explicit transaction active, ignore autotransaction request */
if (ldb-transaction_active)
@@ -529,11 +529,8 @@
struct ldb_request *req;
int ret;
 
-   *res = talloc_zero(ldb, struct ldb_result);
-   if (! *res) {
-   return LDB_ERR_OPERATIONS_ERROR;
-   }
-
+   *res = NULL;
+   
req = talloc(ldb, struct ldb_request);
if (req == NULL) {
ldb_set_errstring(ldb, talloc_strdup(ldb, Out of memory!));
@@ -551,6 +548,12 @@
return LDB_ERR_OPERATIONS_ERROR;
}
 
+   *res = talloc_zero(ldb, struct ldb_result);
+   if (! *res) {
+   talloc_free(req);
+   return LDB_ERR_OPERATIONS_ERROR;
+   }
+
req-op.search.attrs = attrs;
req-controls = NULL;
req-context = res;
@@ -583,9 +586,11 @@
struct ldb_request *req;
int ret;
 
-   ret = ldb_msg_sanity_check(message);
-   if (ret != LDB_SUCCESS) return ret;
-
+   ret = ldb_msg_sanity_check(ldb, message);
+   if (ret != LDB_SUCCESS) {
+   return ret;
+   }
+   
req = talloc(ldb, struct ldb_request);
if (req == NULL) {
ldb_set_errstring(ldb, talloc_strdup(ldb, Out of memory!));
@@ -615,7 +620,7 @@
struct ldb_request *req;
int ret;
 
-   ret = ldb_msg_sanity_check(message);
+   ret = ldb_msg_sanity_check(ldb, message);
if (ret != LDB_SUCCESS) return ret;
 
req = talloc(ldb, struct ldb_request);

Modified: branches/SOC/mkhl/ldb-map/common/ldb_dn.c
===
--- branches/SOC/mkhl/ldb-map/common/ldb_dn.c   2006-07-23 09:50:04 UTC (rev 
17200)
+++ branches/SOC/mkhl/ldb-map/common/ldb_dn.c   2006-07-23 10:54:06 UTC (rev 
17201)
@@ -578,32 +578,37 @@
if (edn == NULL) return NULL;
 
cedn = ldb_dn_new(ldb);
-   LDB_DN_NULL_FAILED(cedn);
+   if (!cedn) {
+   return NULL;
+   }
 
cedn-comp_num = edn-comp_num;
cedn-components = talloc_array(cedn, struct ldb_dn_component, 
edn-comp_num);
-   LDB_DN_NULL_FAILED(cedn-components);
+   if (!cedn-components) {
+   talloc_free(cedn);
+   return NULL;
+   }
 
for (i = 0; i  edn-comp_num; i++) {
struct ldb_dn_component dc;
const struct ldb_attrib_handler *h;
 
dc.name = ldb_attr_casefold(cedn, edn-components[i].name);
-   LDB_DN_NULL_FAILED(dc.name);
+   if (!dc.name) {
+   talloc_free(cedn);
+   return NULL;
+   }
 
h = ldb_attrib_handler(ldb, dc.name);
if (h-canonicalise_fn(ldb, cedn, (edn-components[i].value), 
(dc.value)) != 0) {
-   goto failed;
+   talloc_free(cedn);
+   return NULL;
}
 
cedn-components[i] = dc;
}
 
return cedn;
-
-failed:
-   talloc_free(cedn);
-   return NULL;
 }
 
 struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char *dn)

Modified: branches/SOC/mkhl/ldb-map/common/ldb_msg.c

svn commit: samba r17202 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-23 Thread mkhl
Author: mkhl
Date: 2006-07-23 10:58:05 + (Sun, 23 Jul 2006)
New Revision: 17202

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17202

Log:
Adapt ldb_map module to the new async naming.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Sorry, the patch is too large (605 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17202


svn commit: samba r17203 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-23 Thread mkhl
Author: mkhl
Date: 2006-07-23 12:53:33 + (Sun, 23 Jul 2006)
New Revision: 17203

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17203

Log:
Oops, forgot two ldb_replies.

Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-23 10:58:05 UTC (rev 
17202)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-23 12:53:33 UTC (rev 
17203)
@@ -1799,14 +1799,14 @@
  */
 
 
-typedef int (*ldb_search_callback)(struct ldb_context *, void *, struct 
ldb_async_result *);
+typedef int (*ldb_search_callback)(struct ldb_context *, void *, struct 
ldb_reply *);
 
 /* store single search result in async context */
 static
 int
 search_self_callback(struct ldb_context *ldb,
 void *context,
-struct ldb_async_result *ares)
+struct ldb_reply *ares)
 {
struct map_async_context *ac;
const char *dn;



svn commit: samba r17204 - in branches/SOC/mkhl/samdb-map/ldb_modules: .

2006-07-23 Thread mkhl
Author: mkhl
Date: 2006-07-23 13:30:25 + (Sun, 23 Jul 2006)
New Revision: 17204

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17204

Log:
Adapt samba3sam as well.
Martin
Modified:
   branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c


Changeset:
Modified: branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c
===
--- branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c 2006-07-23 12:53:33 UTC 
(rev 17203)
+++ branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c 2006-07-23 13:30:25 UTC 
(rev 17204)
@@ -881,13 +881,13 @@
 /* the init function */
 int ldb_samba3sam_module_init(void)
 {
-struct ldb_module_ops ops = ldb_map_get_ops();
-   samba3sam_ops.add= ops.add;
-   samba3sam_ops.modify = ops.modify;
-   samba3sam_ops.del= ops.del;
-   samba3sam_ops.rename = ops.rename;
-   samba3sam_ops.search = ops.search;
-   samba3sam_ops.async_wait = ops.async_wait;
+   struct ldb_module_ops ops = ldb_map_get_ops();
+   samba3sam_ops.add   = ops.add;
+   samba3sam_ops.modify= ops.modify;
+   samba3sam_ops.del   = ops.del;
+   samba3sam_ops.rename= ops.rename;
+   samba3sam_ops.search= ops.search;
+   samba3sam_ops.wait  = ops.wait;
 
-return ldb_register_module(samba3sam_ops);
+   return ldb_register_module(samba3sam_ops);
 }



svn commit: samba r17211 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-23 Thread mkhl
Author: mkhl
Date: 2006-07-23 21:27:44 + (Sun, 23 Jul 2006)
New Revision: 17211

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17211

Log:
More const declarations for map_context structures.
Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-23 20:04:42 UTC (rev 
17210)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-23 21:27:44 UTC (rev 
17211)
@@ -237,7 +237,7 @@
 ldb_next_remote_request(struct ldb_module *module,
struct ldb_request *request)
 {
-   struct ldb_map_context *data = map_get_context(module);
+   const struct ldb_map_context *data = map_get_context(module);
 struct ldb_message *msg;
 
 switch (request-operation) {
@@ -281,7 +281,7 @@
 /* Find an objectClass by the local name. */
 static
 const struct ldb_map_objectclass *
-find_local_oc(struct ldb_map_context *data,
+find_local_oc(const struct ldb_map_context *data,
  const char *name)
 {
int i;
@@ -296,7 +296,7 @@
 
 static
 const struct ldb_map_objectclass *
-find_remote_oc(struct ldb_map_context *data,
+find_remote_oc(const struct ldb_map_context *data,
   const char *name)
 {
int i;
@@ -312,7 +312,7 @@
 /* Find an attribute by the local name. */
 static
 const struct ldb_map_attribute *
-find_local_attr(struct ldb_map_context *data,
+find_local_attr(const struct ldb_map_context *data,
const char *name)
 {
int i;
@@ -328,7 +328,7 @@
 /* Find an attribute by the remote name. */
 static
 const struct ldb_map_attribute *
-find_remote_attr(struct ldb_map_context *data,
+find_remote_attr(const struct ldb_map_context *data,
 const char *name)
 {
int i, j;
@@ -369,7 +369,7 @@
 check_dn_local(struct ldb_module *module,
   const struct ldb_dn *dn)
 {
-   struct ldb_map_context *data = map_get_context(module);
+   const struct ldb_map_context *data = map_get_context(module);
 
return ldb_dn_compare_base(module-ldb, data-local_base_dn, dn) == 0;
 }
@@ -377,7 +377,7 @@
 /* True if attr has an associated mapping that does not ignore it */
 static
 BOOL
-check_attr_mapped(struct ldb_map_context *data,
+check_attr_mapped(const struct ldb_map_context *data,
  const char* attr)
 {
const struct ldb_map_attribute *map;
@@ -396,7 +396,7 @@
 check_attrs_mapped(struct ldb_module *module,
   const char * const *attrs)
 {
-   struct ldb_map_context *data = map_get_context(module);
+   const struct ldb_map_context *data = map_get_context(module);
BOOL ret;
int i;
 
@@ -415,7 +415,7 @@
 check_msg_mapped(struct ldb_module *module,
 const struct ldb_message *msg)
 {
-   struct ldb_map_context *data = map_get_context(module);
+   const struct ldb_map_context *data = map_get_context(module);
BOOL ret;
int i;
 
@@ -435,7 +435,7 @@
   const struct ldb_message *msg,
   const char *attr)
 {
-   struct ldb_map_context *data = map_get_context(module);
+   const struct ldb_map_context *data = map_get_context(module);
const struct ldb_map_attribute *map;
 
map = find_remote_attr(data, attr);
@@ -459,7 +459,7 @@
  void *mem_ctx,
  const char * const *attrs)
 {
-   struct ldb_map_context *data = map_get_context(module);
+   const struct ldb_map_context *data = map_get_context(module);
const char **result;
int i, last;
 
@@ -501,7 +501,7 @@
void *mem_ctx,
const char * const *attrs)
 {
-   struct ldb_map_context *data = map_get_context(module);
+   const struct ldb_map_context *data = map_get_context(module);
const struct ldb_map_attribute *map;
const char *name;
const char **result;
@@ -578,7 +578,7 @@
void *mem_ctx,
const struct ldb_message *msg)
 {
-   struct ldb_map_context *data = map_get_context(module);
+   const struct ldb_map_context *data = map_get_context(module);
const struct ldb_map_attribute *map;
const char **result;
int i, j, last;
@@ -665,7 +665,7 @@
  const struct ldb_message *msg,
  const char *name)
 {
-   struct ldb_map_context *map = map_get_context(module);
+   const struct ldb_map_context *map = map_get_context(module);
const struct ldb_message_element *oc;
const struct ldb_map_objectclass *class;
int i, j;
@@ -794,7 +794,7 @@
 void *mem_ctx,
 const struct ldb_dn *dn)
 {  
-   struct ldb_map_context *data = map_get_context(module);
+   const struct

svn commit: samba r17212 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-23 Thread mkhl
Author: mkhl
Date: 2006-07-23 21:51:59 + (Sun, 23 Jul 2006)
New Revision: 17212

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17212

Log:
Comment out a few unused functions.
Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-23 21:27:44 UTC (rev 
17211)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-23 21:51:59 UTC (rev 
17212)
@@ -391,6 +391,7 @@
 }
 
 /* True if any of attrs is mapped */
+/*
 static
 BOOL
 check_attrs_mapped(struct ldb_module *module,
@@ -408,8 +409,10 @@
 
return False;
 }
+*/
 
 /* True if any of the message elements is mapped */
+/*
 static
 BOOL
 check_msg_mapped(struct ldb_module *module,
@@ -427,8 +430,10 @@
 
return False;
 }
+*/
 
 /* True if remote attribute attr can be created from msg */
+/*
 static
 BOOL
 check_msg_can_map_attr(struct ldb_module *module,
@@ -445,12 +450,13 @@
if (ldb_msg_find_element(msg, map-local_name) == NULL)
return False;
 
-   /* TODO: if this attr requires context:
+   /\* TODO: if this attr requires context:
   make sure all context attrs are mappable from msg
-  prevent unsolvable attr chases ... somehow */
+  prevent unsolvable attr chases ... somehow *\/
 
return True;
 }
+*/
 
 /* select only attrs that are not mapped */
 static
@@ -572,6 +578,7 @@
 }
 
 /* select only local attrs that can be unmapped from msg */
+/*
 static
 const char **
 select_unmappable_msg_attrs(struct ldb_module *module,
@@ -592,9 +599,9 @@
return NULL;
result[0] = NULL;
 
-   /* for each mapping, check if all remote attributes are present
-  if they are, add the local one to the result */
-   /* TODO: Alternatively, walk over msg-elements and use 
find_remote_attr. */
+   /\* for each mapping, check if all remote attributes are present
+  if they are, add the local one to the result *\/
+   /\* TODO: Alternatively, walk over msg-elements and use 
find_remote_attr. *\/
for (i = 0; data-attribute_maps[i].local_name; i++) {
BOOL avail = False;
map = data-attribute_maps[i];
@@ -613,7 +620,7 @@
break;
 
case MAP_GENERATE:
-   /* look for *all* remote names */
+   /\* look for *all* remote names *\/
avail = True;
for (j = 0; map-u.generate.remote_names[j]; j++)
avail = (ldb_msg_find_element(msg, 
map-u.generate.remote_names[j]) != NULL);
@@ -631,8 +638,8 @@
 
return result;
 }
+*/
 
-
 /* Check whether the given objectClass is contained in the specified
  * message */
 /*



svn commit: samba r17213 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-23 Thread mkhl
Author: mkhl
Date: 2006-07-23 23:59:31 + (Sun, 23 Jul 2006)
New Revision: 17213

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17213

Log:
Imcomplete stab at fetching data from the remote partition first.
Add/Modify/Rename/Delete work okay for basic cases, need to test complex ones.
Search is currently restricted to remote data only.
Still uses DNs for record identification.

Martin
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Sorry, the patch is too large (1171 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17213


svn commit: samba r17048 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 08:46:27 + (Sat, 15 Jul 2006)
New Revision: 17048

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17048

Log:
Remove unused async step from map_step.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 08:36:44 UTC (rev 
17047)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 08:46:27 UTC (rev 
17048)
@@ -105,7 +105,6 @@
 struct map_async_context {
enum map_step {
MAP_SEARCH_LOCAL,
-   MAP_SEARCH_REMOTE,
MAP_DO_ADD_REMOTE,
MAP_DO_ADD_LOCAL,
MAP_SEARCH_SELF_MODIFY,



svn commit: samba r17049 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 08:56:19 + (Sat, 15 Jul 2006)
New Revision: 17049

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17049

Log:
Insert missing braces.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 08:46:27 UTC (rev 
17048)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 08:56:19 UTC (rev 
17049)
@@ -1547,12 +1547,13 @@
break;
 
case MAP_CONVERT:
-   if (map-u.convert.convert_local == NULL)
+   if (map-u.convert.convert_local == NULL) {
ldb_debug(module-ldb, LDB_DEBUG_ERROR, ldb_map: 
  Skipping attribute '%s': 
  'convert_local' not set\n,
  map-local_name);
-   goto failed;
+   goto failed;
+   }
 
el = copy_conv_msg_el(module, remote, old,
  map-u.convert.remote_name,



svn commit: samba r17050 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 09:01:20 + (Sat, 15 Jul 2006)
New Revision: 17050

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17050

Log:
Copy (don't steal) the old msg element when adding to the local
message.  The old elements are accessed from an array and usually
haven't been tallocced themselves.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 08:56:19 UTC (rev 
17049)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:01:20 UTC (rev 
17050)
@@ -1586,9 +1586,17 @@
return ldb_msg_add(remote, el, old-flags);
 
 local:
-   /* TODO: do we need a copy or can we just steal it? */
-   return ldb_msg_add(local, talloc_steal(local, old), old-flags);
+   /* copy the message element */
+   el = talloc(local, struct ldb_message_element);
+   if (el == NULL) {
+   ldb_oom(module-ldb);
+   goto failed;
+   }
 
+   *el = *old; /* copy the old element */
+
+   return ldb_msg_add(local, el, old-flags);
+
 failed:
return -1;
 }



svn commit: samba r17051 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 09:04:28 + (Sat, 15 Jul 2006)
New Revision: 17051

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17051

Log:
Reset the async handle status before running additional down requests.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:01:20 UTC (rev 
17050)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:04:28 UTC (rev 
17051)
@@ -2100,6 +2100,9 @@
 
ac-step = MAP_DO_ADD_LOCAL;
 
+   handle-state = LDB_ASYNC_INIT;
+   handle-status = LDB_SUCCESS;
+
return ldb_next_request(ac-module, ac-local_req);
 }
 
@@ -2218,6 +2221,9 @@
 
ac-step = MAP_DO_MODIFY_LOCAL;
 
+   handle-state = LDB_ASYNC_INIT;
+   handle-status = LDB_SUCCESS;
+
return ldb_next_request(ac-module, ac-local_req);
 }
 
@@ -2257,6 +2263,9 @@
 
ac-step = MAP_DO_MODIFY_REMOTE;
 
+   handle-state = LDB_ASYNC_INIT;
+   handle-status = LDB_SUCCESS;
+
return ldb_next_remote_request(ac-module, ac-remote_req);
 }
 
@@ -2382,6 +2391,9 @@
 
ac-step = MAP_DO_DELETE_LOCAL;
 
+   handle-state = LDB_ASYNC_INIT;
+   handle-status = LDB_SUCCESS;
+
return ldb_next_request(ac-module, ac-local_req);
 }
 
@@ -2417,6 +2429,9 @@
 
ac-step = MAP_DO_DELETE_REMOTE;
 
+   handle-state = LDB_ASYNC_INIT;
+   handle-status = LDB_SUCCESS;
+
return ldb_next_remote_request(ac-module, ac-remote_req);
 }
 
@@ -2483,6 +2498,9 @@
 
ac-step = MAP_DO_RENAME_LOCAL;
 
+   handle-state = LDB_ASYNC_INIT;
+   handle-status = LDB_SUCCESS;
+
return ldb_next_request(ac-module, ac-local_req);
 }
 
@@ -2531,6 +2549,9 @@
 
ac-step = MAP_DO_RENAME_FIXUP;
 
+   handle-state = LDB_ASYNC_INIT;
+   handle-status = LDB_SUCCESS;
+
return ldb_next_request(ac-module, ac-down_req);
 
 failed:
@@ -2573,6 +2594,9 @@
 
ac-step = MAP_DO_RENAME_REMOTE;
 
+   handle-state = LDB_ASYNC_INIT;
+   handle-status = LDB_SUCCESS;
+
return ldb_next_remote_request(ac-module, ac-remote_req);
 }
 



svn commit: samba r17052 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 09:07:24 + (Sat, 15 Jul 2006)
New Revision: 17052

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17052

Log:
Don't declare variables in the middle of a function.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:04:28 UTC (rev 
17051)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:07:24 UTC (rev 
17052)
@@ -2116,6 +2116,7 @@
struct ldb_async_handle *h;
struct map_async_context *ac;
struct ldb_message *local, *remote;
+   const char *dn;
 
/* do not manipulate our control entries */
if (ldb_dn_is_special(msg-dn))
@@ -2188,7 +2189,7 @@
return map_add_do_local(h);
 
/* store the remote DN in 'IS_MAPPED' */
-   const char *dn = ldb_dn_linearize(local, remote-dn);
+   dn = ldb_dn_linearize(local, remote-dn);
if (ldb_msg_add_string(local, IS_MAPPED, dn) != 0)
goto failed;
 



svn commit: samba r17053 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 09:11:02 + (Sat, 15 Jul 2006)
New Revision: 17053

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17053

Log:
Handle missing async step.
Don't include a default case when switching ac-step, that suppresses
the wrong warnings.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:07:24 UTC (rev 
17052)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:11:02 UTC (rev 
17053)
@@ -2662,15 +2662,15 @@
case MAP_DO_RENAME_FIXUP:
return ac-down_req;
 
+   case MAP_SEARCH_LOCAL:
case MAP_DO_ADD_LOCAL:
case MAP_DO_MODIFY_LOCAL:
case MAP_DO_DELETE_LOCAL:
case MAP_DO_RENAME_LOCAL:
return ac-local_req;
+   }
 
-default:
-return NULL;
-   }
+   return NULL;/* unreachable; silences a warning */
 }
 
 typedef int (*map_next_function)(struct ldb_async_handle *handle);
@@ -2681,6 +2681,9 @@
 map_async_get_next(struct map_async_context *ac)
 {
switch (ac-step) {
+   case MAP_SEARCH_LOCAL:
+   return NULL;
+
case MAP_DO_ADD_REMOTE:
return map_add_do_local;
 
@@ -2716,10 +2719,9 @@
 
case MAP_DO_RENAME_LOCAL:
return NULL;
-   
-   default:
-   return NULL;
}
+
+   return NULL;/* unreachable; silences a warning */
 }
 
 /* Async trampoline */



svn commit: samba r17054 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 09:13:29 + (Sat, 15 Jul 2006)
New Revision: 17054

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17054

Log:
When renaming, skip requests if neither DN is in the local partition.
Fail if either is but the other isn't.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:11:02 UTC (rev 
17053)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:13:29 UTC (rev 
17054)
@@ -2615,11 +2615,15 @@
return ldb_next_request(module, req);
 
/* no mapping requested, skip to next module */
-   /* TODO: both? either? neither? what to do in each case? */
-   if (!check_dn_local(module, req-op.rename.olddn) ||
+   if (!check_dn_local(module, req-op.rename.olddn) 
!check_dn_local(module, req-op.rename.newdn))
return ldb_next_request(module, req);
 
+   /* rename into/out of the mapped partition requested, bail out */
+   if (!check_dn_local(module, req-op.rename.olddn) ||
+   !check_dn_local(module, req-op.rename.newdn))
+   return LDB_ERR_AFFECTS_MULTIPLE_DSAS;
+
/* prepare async context and handle */
h = map_init_handle(req, module);
if (h == NULL)



svn commit: samba r17055 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 09:16:41 + (Sat, 15 Jul 2006)
New Revision: 17055

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17055

Log:
Don't talloc_zero structures whose contents will be completely
overwritten anyway.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:13:29 UTC (rev 
17054)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:16:41 UTC (rev 
17055)
@@ -2140,7 +2140,7 @@
req-async.handle = h;
 
/* prepare the local operation */
-   ac-local_req = talloc_zero(ac, struct ldb_request);
+   ac-local_req = talloc(ac, struct ldb_request);
if (ac-local_req == NULL) {
map_oom(module);
return LDB_ERR_OPERATIONS_ERROR;
@@ -2152,7 +2152,7 @@
ac-local_req-async.callback = NULL;
 
/* prepare the remote operation */
-   ac-remote_req = talloc_zero(ac, struct ldb_request);
+   ac-remote_req = talloc(ac, struct ldb_request);
if (ac-remote_req == NULL) {
talloc_free(ac-local_req);
map_oom(module);
@@ -2303,7 +2303,7 @@
req-async.handle = h;
 
/* prepare the local operation */
-   ac-local_req = talloc_zero(ac, struct ldb_request);
+   ac-local_req = talloc(ac, struct ldb_request);
if (ac-local_req == NULL) {
map_oom(module);
return LDB_ERR_OPERATIONS_ERROR;
@@ -2315,7 +2315,7 @@
ac-local_req-async.callback = NULL;
 
/* prepare the remote operation */
-   ac-remote_req = talloc_zero(ac, struct ldb_request);
+   ac-remote_req = talloc(ac, struct ldb_request);
if (ac-remote_req == NULL) {
talloc_free(ac-local_req);
map_oom(module);
@@ -2377,7 +2377,7 @@
ac = talloc_get_type(handle-private_data, struct map_async_context);
 
/* prepare the local operation */
-   ac-local_req = talloc_zero(ac, struct ldb_request);
+   ac-local_req = talloc(ac, struct ldb_request);
if (ac-local_req == NULL) {
ldb_oom(ac-module-ldb);
return LDB_ERR_OPERATIONS_ERROR;
@@ -2412,7 +2412,7 @@
return map_delete_do_local(handle);
 
/* prepare the remote operation */
-   ac-remote_req = talloc_zero(ac, struct ldb_request);
+   ac-remote_req = talloc(ac, struct ldb_request);
if (ac-remote_req == NULL) {
ldb_oom(ac-module-ldb);
return LDB_ERR_OPERATIONS_ERROR;
@@ -2484,7 +2484,7 @@
ac = talloc_get_type(handle-private_data, struct map_async_context);
 
/* prepare the local operation */
-   ac-local_req = talloc_zero(ac, struct ldb_request);
+   ac-local_req = talloc(ac, struct ldb_request);
if (ac-local_req == NULL) {
ldb_oom(ac-module-ldb);
return LDB_ERR_OPERATIONS_ERROR;
@@ -2574,7 +2574,7 @@
return map_rename_do_local(handle);
 
/* prepare the remote operation */
-   ac-remote_req = talloc_zero(ac, struct ldb_request);
+   ac-remote_req = talloc(ac, struct ldb_request);
if (ac-remote_req == NULL) {
ldb_oom(ac-module-ldb);
return LDB_ERR_OPERATIONS_ERROR;



svn commit: samba r17056 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 09:22:24 + (Sat, 15 Jul 2006)
New Revision: 17056

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17056

Log:
Defer setting async handled until *after* the up request was copied.
When an async handle is likely to still have been copied, reset to NULL.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:16:41 UTC (rev 
17055)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:22:24 UTC (rev 
17056)
@@ -2136,9 +2136,6 @@
return LDB_ERR_OPERATIONS_ERROR;
ac = talloc_get_type(h-private_data, struct map_async_context);
 
-   /* return or own handle to deal with this call */
-   req-async.handle = h;
-
/* prepare the local operation */
ac-local_req = talloc(ac, struct ldb_request);
if (ac-local_req == NULL) {
@@ -2193,6 +2190,9 @@
if (ldb_msg_add_string(local, IS_MAPPED, dn) != 0)
goto failed;
 
+   /* return or own handle to deal with this call */
+   req-async.handle = h;
+
ldb_set_timeout_from_prev_req(module-ldb, req, ac-remote_req);
 
/* continue with the remote request */
@@ -2299,9 +2299,6 @@
return LDB_ERR_OPERATIONS_ERROR;
ac = talloc_get_type(h-private_data, struct map_async_context);
 
-   /* return or own handle to deal with this call */
-   req-async.handle = h;
-
/* prepare the local operation */
ac-local_req = talloc(ac, struct ldb_request);
if (ac-local_req == NULL) {
@@ -2358,6 +2355,9 @@
 
ac-step = MAP_SEARCH_SELF_MODIFY;
 
+   /* return or own handle to deal with this call */
+   req-async.handle = h;
+
return ldb_next_request(module, ac-search_req);
 
 failed:
@@ -2385,8 +2385,10 @@
 
*(ac-local_req) = *(ac-orig_req); /* copy the request */
 
+   ac-local_req-async.handle = NULL;
ac-local_req-async.context = NULL;
ac-local_req-async.callback = NULL;
+
ldb_set_timeout_from_prev_req(ac-module-ldb,
  ac-orig_req, ac-local_req);
 
@@ -2420,8 +2422,10 @@
 
*(ac-remote_req) = *(ac-orig_req); /* copy the request */
 
+   ac-remote_req-async.handle = NULL;
ac-remote_req-async.context = NULL;
ac-remote_req-async.callback = NULL;
+
ldb_set_timeout_from_prev_req(ac-module-ldb,
  ac-orig_req, ac-remote_req);
 
@@ -2460,14 +2464,14 @@
return LDB_ERR_OPERATIONS_ERROR;
ac = talloc_get_type(h-private_data, struct map_async_context);
 
-   /* return or own handle to deal with this call */
-   req-async.handle = h;
-
/* prepare the search operation */
ac-search_req = search_self_req(ac, req-op.del.dn);
if (ac-search_req == NULL)
return LDB_ERR_OPERATIONS_ERROR;
 
+   /* return or own handle to deal with this call */
+   req-async.handle = h;
+
ac-step = MAP_SEARCH_SELF_DELETE;
 
return ldb_next_request(module, ac-search_req);
@@ -2492,8 +2496,10 @@
 
*(ac-local_req) = *(ac-orig_req); /* copy the request */
 
+   ac-local_req-async.handle = NULL;
ac-local_req-async.context = NULL;
ac-local_req-async.callback = NULL;
+
ldb_set_timeout_from_prev_req(ac-module-ldb,
  ac-orig_req, ac-local_req);
 
@@ -2543,8 +2549,10 @@
ac-down_req-operation = LDB_MODIFY;
ac-down_req-op.mod.message = msg;
ac-down_req-controls = NULL;
+   ac-down_req-async.handle = NULL;
ac-down_req-async.context = NULL;
ac-down_req-async.callback = NULL;
+
ldb_set_timeout_from_prev_req(ac-module-ldb,
  ac-orig_req, ac-down_req);
 
@@ -2582,8 +2590,10 @@
 
*(ac-remote_req) = *(ac-orig_req); /* copy the request */
 
+   ac-remote_req-async.handle = NULL;
ac-remote_req-async.context = NULL;
ac-remote_req-async.callback = NULL;
+
ldb_set_timeout_from_prev_req(ac-module-ldb,
  ac-orig_req, ac-remote_req);
 
@@ -2630,14 +2640,14 @@
return LDB_ERR_OPERATIONS_ERROR;
ac = talloc_get_type(h-private_data, struct map_async_context);
 
-   /* return or own handle to deal with this call */
-   req-async.handle = h;
-
/* prepare the search operation */
ac-search_req = search_self_req(ac, req-op.rename.olddn);
if (ac-search_req == NULL)
return LDB_ERR_OPERATIONS_ERROR;
 
+   /* return or own handle to deal with this call */
+   req-async.handle = h;
+
ac-step = MAP_SEARCH_SELF_RENAME;
 
return ldb_next_request(module, ac-search_req);



svn commit: samba r17057 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 09:27:07 + (Sat, 15 Jul 2006)
New Revision: 17057

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17057

Log:
When failing before the async handle was set in the up request, free
the complete async handle.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:22:24 UTC (rev 
17056)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:27:07 UTC (rev 
17057)
@@ -2140,7 +2140,7 @@
ac-local_req = talloc(ac, struct ldb_request);
if (ac-local_req == NULL) {
map_oom(module);
-   return LDB_ERR_OPERATIONS_ERROR;
+   goto failed;
}
 
*(ac-local_req) = *req; /* copy the request */
@@ -2151,9 +2151,8 @@
/* prepare the remote operation */
ac-remote_req = talloc(ac, struct ldb_request);
if (ac-remote_req == NULL) {
-   talloc_free(ac-local_req);
map_oom(module);
-   return LDB_ERR_OPERATIONS_ERROR;
+   goto failed;
}
 
*(ac-remote_req) = *req; /* copy the request */
@@ -2201,8 +2200,7 @@
return ldb_next_remote_request(module, ac-remote_req);
 
 failed:
-   talloc_free(ac-local_req);
-   talloc_free(ac-remote_req);
+   talloc_free(h);
return LDB_ERR_OPERATIONS_ERROR;
 }
 
@@ -2303,7 +2301,7 @@
ac-local_req = talloc(ac, struct ldb_request);
if (ac-local_req == NULL) {
map_oom(module);
-   return LDB_ERR_OPERATIONS_ERROR;
+   goto failed;
}
 
*(ac-local_req) = *req; /* copy the request */
@@ -2314,9 +2312,8 @@
/* prepare the remote operation */
ac-remote_req = talloc(ac, struct ldb_request);
if (ac-remote_req == NULL) {
-   talloc_free(ac-local_req);
map_oom(module);
-   return LDB_ERR_OPERATIONS_ERROR;
+   goto failed;
}
 
*(ac-remote_req) = *req; /* copy the request */
@@ -2361,8 +2358,7 @@
return ldb_next_request(module, ac-search_req);
 
 failed:
-   talloc_free(ac-local_req);
-   talloc_free(ac-remote_req);
+   talloc_free(h);
return LDB_ERR_OPERATIONS_ERROR;
 }
 



svn commit: samba r17058 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 09:32:17 + (Sat, 15 Jul 2006)
New Revision: 17058

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17058

Log:
When fixing the 'isMapped' attribute after renaming the remote record,
don't reuse the DN from the last down request but calculate it freshly.

The old 'newdn' was modified to point into the remote partition, but
the 'isMapped' attribute is expected to keep pointing into the local
partition.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:27:07 UTC (rev 
17057)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:32:17 UTC (rev 
17058)
@@ -2534,7 +2534,7 @@
/* update 'IS_MAPPED' with the new remote DN */
msg-dn = discard_const_p(struct ldb_dn,
  ac-orig_req-op.rename.olddn);
-   dn = ldb_dn_linearize(msg, ac-remote_req-op.rename.newdn);
+   dn = map_local_dn(ac-module, msg, ac-orig_req-op.rename.newdn);
if (dn == NULL)
goto failed;
if (ldb_msg_add_empty(msg, IS_MAPPED, LDB_FLAG_MOD_REPLACE) != 0)



svn commit: samba r17059 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 09:35:21 + (Sat, 15 Jul 2006)
New Revision: 17059

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17059

Log:
If no remote addition/modification is neccessary, just free the async
handle and run the original request.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:32:17 UTC (rev 
17058)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 09:35:21 UTC (rev 
17059)
@@ -2181,8 +2181,10 @@
ac-local_req-op.add.message = local;
ac-remote_req-op.add.message = remote;

-   if (remote-num_elements == 0) /* no remote data */
-   return map_add_do_local(h);
+   if (remote-num_elements == 0) { /* no remote data */
+   talloc_free(h);
+   return ldb_next_request(module, req);
+   }
 
/* store the remote DN in 'IS_MAPPED' */
dn = ldb_dn_linearize(local, remote-dn);
@@ -2342,8 +2344,10 @@
ac-local_req-op.mod.message = local;
ac-remote_req-op.mod.message = remote;

-   if (remote-num_elements == 0) /* no remote data */
-   return map_modify_do_local(h);
+   if (remote-num_elements == 0) { /* no remote data */
+   talloc_free(h);
+   return ldb_next_request(module, req);
+   }
 
/* prepare the search operation */
ac-search_req = search_self_req(ac, msg-dn);



svn commit: samba r17066 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 18:26:12 + (Sat, 15 Jul 2006)
New Revision: 17066

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17066

Log:
Add missing `break's to switches...

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:20:13 UTC (rev 
17065)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:26:12 UTC (rev 
17066)
@@ -338,16 +338,19 @@
case MAP_KEEP:
if (ldb_attr_cmp(data-attribute_maps[i] .local_name, 
name) == 0)
return data-attribute_maps[i];
+   break;
 
case MAP_RENAME:
case MAP_CONVERT:
if (ldb_attr_cmp(data-attribute_maps[i] 
.u.rename.remote_name, name) == 0)
return data-attribute_maps[i];
+   break;
 
case MAP_GENERATE:
for (j = 0; 
data-attribute_maps[i].u.generate.remote_names[j]; j++)
if 
(ldb_attr_cmp(data-attribute_maps[i].u.generate.remote_names[j], name) == 0)
return data-attribute_maps[i];
+   break;
 
default:
break;
@@ -1204,12 +1207,15 @@
switch (tree-operation) {
case LDB_OP_EQUALITY:
val = tree-u.equality.value;
+   break;
case LDB_OP_LESS:
case LDB_OP_GREATER:
case LDB_OP_APPROX:
val = tree-u.comparison.value;
+   break;
case LDB_OP_EXTENDED:
val = tree-u.extended.value;
+   break;
default:
return val;
}



svn commit: samba r17067 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 18:28:27 + (Sat, 15 Jul 2006)
New Revision: 17067

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17067

Log:
When merging search results and the remote result contains an unmapped
attribute, assume it was auto-generated and skip it.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:26:12 UTC (rev 
17066)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:28:27 UTC (rev 
17067)
@@ -1687,12 +1687,13 @@
 {
struct ldb_message_element *el;
 
-   /* no mapping: fail */
+   /* unmapped attribute in remote message:
+  skip, attribute was probably auto-generated */
if (map == NULL) {
ldb_debug(module-ldb, LDB_DEBUG_WARNING, ldb_map: 
  Not mapping attribute '%s': no mapping found\n,
  old-name);
-   goto failed;
+   goto unmapped;
}
 
switch (map-type) {



svn commit: samba r17068 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 18:30:29 + (Sat, 15 Jul 2006)
New Revision: 17068

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17068

Log:
Fix a pointer to inaccessible memory.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:28:27 UTC (rev 
17067)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:30:29 UTC (rev 
17068)
@@ -1217,7 +1217,7 @@
val = tree-u.extended.value;
break;
default:
-   return val;
+   return ldb_val_dup(new, val);
}
 
/* convert to the new value */



svn commit: samba r17070 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 18:32:37 + (Sat, 15 Jul 2006)
New Revision: 17070

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17070

Log:
Skip mapped search if search base *exists* and is outside the local partition.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:31:51 UTC (rev 
17069)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:32:37 UTC (rev 
17070)
@@ -2019,7 +2019,8 @@
return ldb_next_request(module, req);
 
/* no mapping requested, skip to next module */
-   if (!check_dn_local(module, req-op.search.base))
+   if (req-op.search.base 
+   !check_dn_local(module, req-op.search.base))
return ldb_next_request(module, req);
 
/* no mapping needed, skip to next module */



svn commit: samba r17071 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 18:33:32 + (Sat, 15 Jul 2006)
New Revision: 17071

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17071

Log:
Set the correct async handles for searches.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:32:37 UTC (rev 
17070)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:33:32 UTC (rev 
17071)
@@ -1988,6 +1988,9 @@
if (req == NULL)
goto error;
 
+   /* use search context to merge results */
+   req-async.context = sc;
+
return ldb_next_remote_request(ac-module, req);
 
 callback:
@@ -2038,9 +2041,6 @@
return LDB_ERR_OPERATIONS_ERROR;
ac = talloc_get_type(h-private_data, struct map_async_context);
 
-   /* return or own handle to deal with this call */
-   /* req-async.handle = h; */
-
/* prepare the local operation */
ac-local_req = talloc_zero(ac, struct ldb_request);
if (ac-local_req == NULL) {



svn commit: samba r17072 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 18:35:26 + (Sat, 15 Jul 2006)
New Revision: 17072

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17072

Log:
When a parse-tree contains only remote parts, use a new parse-tree
that searches records pointing to remote parts for the local search.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:33:32 UTC (rev 
17071)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:35:26 UTC (rev 
17072)
@@ -2073,6 +2073,19 @@
if (ret != LDB_SUCCESS)
goto failed;
 
+   /* if there is no local tree, search for records with remote parts */
+   if (remote_tree  !local_tree) {
+   local_tree = talloc_zero(ac-local_req, struct ldb_parse_tree);
+   if (local_tree == NULL) {
+   map_oom(module);
+   goto failed;
+   }
+
+   local_tree-operation = LDB_OP_PRESENT;
+   local_tree-u.present.attr
+   = talloc_strdup(local_tree, IS_MAPPED);
+   }
+
ac-local_req-op.search.tree = local_tree;
ac-remote_tree = remote_tree;
 



svn commit: samba r17073 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-15 18:38:57 + (Sat, 15 Jul 2006)
New Revision: 17073

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17073

Log:
Convert remote new DN to string before stuffing it into the fixup message.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:35:26 UTC (rev 
17072)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 18:38:57 UTC (rev 
17073)
@@ -2539,6 +2539,7 @@
 {
struct map_async_context *ac;
struct ldb_message *msg;
+   const struct ldb_dn *newdn;
const char *dn;
 
ac = talloc_get_type(handle-private_data, struct map_async_context);
@@ -2559,7 +2560,8 @@
/* update 'IS_MAPPED' with the new remote DN */
msg-dn = discard_const_p(struct ldb_dn,
  ac-orig_req-op.rename.olddn);
-   dn = map_local_dn(ac-module, msg, ac-orig_req-op.rename.newdn);
+   newdn = map_local_dn(ac-module, msg, ac-orig_req-op.rename.newdn);
+   dn = ldb_dn_linearize(msg, newdn);
if (dn == NULL)
goto failed;
if (ldb_msg_add_empty(msg, IS_MAPPED, LDB_FLAG_MOD_REPLACE) != 0)



svn commit: samba r17076 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-15 Thread mkhl
Author: mkhl
Date: 2006-07-16 00:29:35 + (Sun, 16 Jul 2006)
New Revision: 17076

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=17076

Log:
When searching for specific local attributes, always search for the
IS_MAPPED attribute as well so we can include data from the remote
partition.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-15 20:39:00 UTC (rev 
17075)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-16 00:29:35 UTC (rev 
17076)
@@ -1510,9 +1510,27 @@
const char ***remote_attrs,
const char * const *attrs)
 {
-   
+   int last;
+
*local_attrs = select_unmapped_attrs(module, local_ctx, attrs);
*remote_attrs = select_mapped_attrs(module, remote_ctx, attrs);
+
+   if (*local_attrs == NULL)
+   return LDB_SUCCESS;
+
+   /* if specific local attrs were requested */
+   /* find last local attribute */
+   for (last = 0; (*local_attrs)[last]; last++);
+
+   /* add IS_MAPPED behind it */
+   *local_attrs = talloc_realloc(local_ctx, *local_attrs,
+ const char *, last+2);
+   if (*local_attrs == NULL)
+   return LDB_ERR_OPERATIONS_ERROR;
+
+   (*local_attrs)[last] = talloc_strdup(*local_attrs, IS_MAPPED);
+   (*local_attrs)[last+1] = NULL;
+
return LDB_SUCCESS;
 }
 



svn commit: samba r16878 - in branches/SOC/mkhl/samdb-map: . ldb_modules

2006-07-08 Thread mkhl
Author: mkhl
Date: 2006-07-08 17:30:58 + (Sat, 08 Jul 2006)
New Revision: 16878

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16878

Log:

Merge from mainline, r16877.

Martin

Modified:
   branches/SOC/mkhl/samdb-map/ldb_modules/password_hash.c
   branches/SOC/mkhl/samdb-map/ldb_modules/samldb.c
   branches/SOC/mkhl/samdb-map/samdb.c


Changeset:
Sorry, the patch is too large (574 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16878


svn commit: samba r16880 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-08 Thread mkhl
Author: mkhl
Date: 2006-07-08 17:37:13 + (Sat, 08 Jul 2006)
New Revision: 16880

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16880

Log:

Fix assignment of mapped subtrees to wrong places.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-08 17:33:19 UTC (rev 
16879)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-08 17:37:13 UTC (rev 
16880)
@@ -1094,7 +1094,7 @@
   struct ldb_parse_tree **new,
   const struct ldb_parse_tree *tree)
 {
-   int i, ret;
+   int i, j, ret;
 
/* prepare new tree */
*new = talloc_memdup(mem_ctx, tree, sizeof(struct ldb_parse_tree));
@@ -1113,6 +1113,7 @@
}
 
/* generate list of local subtrees */
+   j = 0;
for (i = 0; i  tree-u.list.num_elements; i++) {
struct ldb_parse_tree *child;
ret = keep_local_subtree(module, *new, child,
@@ -1121,16 +1122,17 @@
goto failed;
 
if (child) {
-   (*new)-u.list.elements[i] = child;
-   (*new)-u.list.num_elements++;
+   (*new)-u.list.elements[j] = child;
+   j++;
}
}
 
/* prune tree without subtrees */
-   if ((*new)-u.list.num_elements == 0)
+   if (j == 0)
goto prune;
 
/* fix subtree list size */
+   (*new)-u.list.num_elements = j;
(*new)-u.list.elements = talloc_realloc(*new, (*new)-u.list.elements,
 struct ldb_parse_tree *,
 (*new)-u.list.num_elements);
@@ -1266,7 +1268,7 @@
   struct ldb_parse_tree **new,
   const struct ldb_parse_tree *tree)
 {
-   int i, ret;
+   int i, j, ret;
 
/* prepare new tree */
*new = talloc_memdup(mem_ctx, tree, sizeof(struct ldb_parse_tree));
@@ -1285,6 +1287,7 @@
}
 
/* generate list of remote subtrees */
+   j = 0;
for (i = 0; i  tree-u.list.num_elements; i++) {
struct ldb_parse_tree *child;
ret = map_local_subtree(module, *new, child,
@@ -1293,16 +1296,17 @@
goto failed;
 
if (child) {
-   (*new)-u.list.elements[i] = child;
-   (*new)-u.list.num_elements++;
+   (*new)-u.list.elements[j] = child;
+   j++;
}
}
 
/* prune tree without subtrees */
-   if ((*new)-u.list.num_elements == 0)
+   if (j == 0)
goto prune;
 
/* fix subtree list size */
+   (*new)-u.list.num_elements = j;
(*new)-u.list.elements = talloc_realloc(*new, (*new)-u.list.elements,
 struct ldb_parse_tree *,
 (*new)-u.list.num_elements);



svn commit: samba r16818 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-05 Thread mkhl
Author: mkhl
Date: 2006-07-05 12:24:27 + (Wed, 05 Jul 2006)
New Revision: 16818

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16818

Log:
Add more `const' declarations.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-05 11:43:49 UTC (rev 
16817)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-07-05 12:24:27 UTC (rev 
16818)
@@ -312,7 +312,7 @@
 
 /* Find an attribute by the local name. */
 static
-struct ldb_map_attribute *
+const struct ldb_map_attribute *
 find_local_attr(struct ldb_map_context *data,
const char *name)
 {
@@ -378,7 +378,7 @@
 check_attr_mapped(struct ldb_map_context *data,
  const char* attr)
 {
-   struct ldb_map_attribute *map;
+   const struct ldb_map_attribute *map;
 
map = find_local_attr(data, attr);
if (map == NULL)
@@ -500,7 +500,7 @@
const char * const *attrs)
 {
struct ldb_map_context *data = map_get_context(module);
-   struct ldb_map_attribute *map;
+   const struct ldb_map_attribute *map;
const char *name;
const char **result;
int i, j, last;
@@ -1601,7 +1601,7 @@
struct ldb_map_context *data = map_get_context(module);
/* names of remote attributes the original message can map */
/* const char * const names[]; */
-   struct ldb_map_attribute *map;
+   const struct ldb_map_attribute *map;
int i, ret;
 
/* try to map each attribute;



svn commit: samba r16819 - in branches/SOC/mkhl/testprogs-map/ejs: .

2006-07-05 Thread mkhl
Author: mkhl
Date: 2006-07-05 12:32:09 + (Wed, 05 Jul 2006)
New Revision: 16819

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16819

Log:
Update samba3sam test script to
- disallow passing a different samba3 URL (that should go in a different test)
- update the list of used modules
- use the partition module
- adapt mapping to the new (partitioned) scheme

Martin


Modified:
   branches/SOC/mkhl/testprogs-map/ejs/samba3sam


Changeset:
Modified: branches/SOC/mkhl/testprogs-map/ejs/samba3sam
===
--- branches/SOC/mkhl/testprogs-map/ejs/samba3sam   2006-07-05 12:24:27 UTC 
(rev 16818)
+++ branches/SOC/mkhl/testprogs-map/ejs/samba3sam   2006-07-05 12:32:09 UTC 
(rev 16819)
@@ -7,86 +7,85 @@
 libinclude(base.js);
 var mypath = substr(ARGV[0], 0, -strlen(samba3sam));
 
-/* TODO:
+var sys = sys_init();
+var s3url = tdb://samba3.ldb;
+var s4url = tdb://samba4.ldb;
+var s3 = ldb_init();
+var s4 = ldb_init();
+var ok;
 
-   1) register partitions:
+var basedn = new Object();
+basedn.BASEDN = dc=vernstok,dc=nl;
 
-dn: @PARTITION
-partition: CN=Samba3Sam,${BASEDN}:tdb://samba3.ldb
-partition: ${BASEDN}:tdb://samba4.ldb
+var prt_ldif = sprintf(dn: @PARTITION
+partition: CN=Samba3Sam,${BASEDN}:%s
+partition: ${BASEDN}:%s, s3url, s4url);
 
-   2) register modules:
-
-dn: @MODULES
[EMAIL PROTECTED]: 
rootdse,kludge_acl,paged_results,server_sort,extended_dn,asq,samldb,objectclass,password_hash,operational,objectguid,rdn_name,samab3sam,partition
-
-   3) register mapping:
-
-dn: @MAP=samba3sam
+var map_ldif = dn: @MAP=samba3sam
 @FROM: ${BASEDN}
 @TO: CN=Samba3Sam,${BASEDN}
+;
 
-*/
+var mod_ldif = dn: @MODULES
+replace: @LIST
[EMAIL PROTECTED]: 
rootdse,kludge_acl,paged_results,server_sort,extended_dn,asq,samldb,objectclass,password_hash,operational,objectguid,rdn_name,samba3sam,partition;
 
-var sys = sys_init();
-var s3url;
-var s3 = ldb_init();
-var ok;
+sys.unlink(samba3.ldb);
+ok = s3.connect(s3url);
+assert(ok);
 
-var basedn = new Object();
-basedn.BASEDN = dc=vernstok,dc=nl;
+println(Initial samba3 LDIF...);
+var path = ../../testdata/samba3/samba3.ldif
+var ldif = sys.file_load(mypath + path);
+ldif = substitute_var(ldif, basedn);
+assert(ldif != undefined);
+ok = s3.add(ldif);
+assert(ok);
 
-if (ARGV.length == 2) {
-   s3url = ARGV[1];
-   ok = s3.connect(s3url);
-   assert(ok);
-} else {
-   s3url = tdb://samba3.ldb;
-   sys.unlink(samba3.ldb);
-   println(Adding samba3 LDIF...);
-   var s3 = ldb_init();
-   ok = s3.connect(s3url);
-   assert(ok);
-   var ldif = sys.file_load(mypath + ../../testdata/samba3/samba3.ldif);
-   ldif = substitute_var(ldif, basedn);
-   assert(ldif != undefined);
-   ok = s3.add(ldif);
-   assert(ok);
-}
-
-println(Initial samba4 LDIF...);
-var s4 = ldb_init();
 sys.unlink(samba4.ldb);
 ok = s4.connect(tdb://samba4.ldb);
 assert(ok);
 
-var ldif = sys.file_load(mypath + ../../source/setup/provision_init.ldif);
+println(Initial samba4 LDIF...);
+var path = ../../source/setup/provision_init.ldif;
+var ldif = sys.file_load(mypath + path);
 ldif = substitute_var(ldif, basedn);
 assert(ldif != undefined);
 ok = s4.add(ldif);
 assert(ok);
 
-var ldif = sys.file_load(mypath + 
../../source/setup/provision_templates.ldif);
+var path = ../../source/setup/provision_templates.ldif;
+var ldif = sys.file_load(mypath + path);
 ldif = substitute_var(ldif, basedn);
 assert(ldif != undefined);
 ok = s4.add(ldif);
 assert(ok);
 
-ok = s4.add(sprintf(dn: @MAP=samba3sam
[EMAIL PROTECTED]: %s, s3url));
+println(Registering partitions...);
+var ldif = substitute_var(prt_ldif, basedn);
+assert(ldif != undefined);
+ok = s4.add(ldif);
 assert(ok);
 
-ok = s4.modify(
-dn: @MODULES
-replace: @LIST
[EMAIL PROTECTED]: samldb,timestamps,objectguid,rdn_name,samba3sam);
+println(Registering mapping...);
+var ldif = substitute_var(map_ldif, basedn);
+assert(ldif != undefined);
+ok = s4.add(ldif);
 assert(ok);
 
-println(Reconnecting to LDB database);
+println(Registering modules...);
+var ldif = substitute_var(mod_ldif, basedn);
+assert(ldif != undefined);
+ok = s4.modify(ldif);
+assert(ok);
+
+println(Reconnecting to LDB database...);
 s4 = ldb_init();
-ok = s4.connect(tdb://samba4.ldb);
+ok = s4.connect(s4url);
 assert(ok);
 
+return 0;
+
 msg = s4.search((ou=Users));
 assert(msg.length == 1);
 



svn commit: samba r16820 - in branches/SOC/mkhl/samdb-map/ldb_modules: .

2006-07-05 Thread mkhl
Author: mkhl
Date: 2006-07-05 12:33:28 + (Wed, 05 Jul 2006)
New Revision: 16820

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16820

Log:
Fix passing the ops around so none get corrupted before loading.

Martin

Modified:
   branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c


Changeset:
Modified: branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c
===
--- branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c 2006-07-05 12:32:09 UTC 
(rev 16819)
+++ branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c 2006-07-05 12:33:28 UTC 
(rev 16820)
@@ -873,11 +873,21 @@
 return ldb_next_init(module);
 }
 
+static struct ldb_module_ops samba3sam_ops = {
+   .name  = samba3sam,
+   .init_context  = samba3sam_init,
+};
+
 /* the init function */
 int ldb_samba3sam_module_init(void)
 {
 struct ldb_module_ops ops = ldb_map_get_ops();
-ops.init_context = samba3sam_init;
+   samba3sam_ops.add= ops.add;
+   samba3sam_ops.modify = ops.modify;
+   samba3sam_ops.del= ops.del;
+   samba3sam_ops.rename = ops.rename;
+   samba3sam_ops.search = ops.search;
+   samba3sam_ops.async_wait = ops.async_wait;
 
-return ldb_register_module(ops);
+return ldb_register_module(samba3sam_ops);
 }



svn commit: samba r16821 - in branches/SOC/mkhl/testprogs-map/ejs: .

2006-07-05 Thread mkhl
Author: mkhl
Date: 2006-07-05 12:34:53 + (Wed, 05 Jul 2006)
New Revision: 16821

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16821

Log:
Don't bail out early, we need to see the error messages.
(Tests up to (but excluding) the first search work.)

Martin

Modified:
   branches/SOC/mkhl/testprogs-map/ejs/samba3sam


Changeset:
Modified: branches/SOC/mkhl/testprogs-map/ejs/samba3sam
===
--- branches/SOC/mkhl/testprogs-map/ejs/samba3sam   2006-07-05 12:33:28 UTC 
(rev 16820)
+++ branches/SOC/mkhl/testprogs-map/ejs/samba3sam   2006-07-05 12:34:53 UTC 
(rev 16821)
@@ -84,8 +84,6 @@
 ok = s4.connect(s4url);
 assert(ok);
 
-return 0;
-
 msg = s4.search((ou=Users));
 assert(msg.length == 1);
 



svn commit: samba r16804 - in branches/SOC/mkhl: .

2006-07-04 Thread mkhl
Author: mkhl
Date: 2006-07-04 18:39:12 + (Tue, 04 Jul 2006)
New Revision: 16804

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16804

Log:

Branch directories I need for the samba3sam tests:
- samdb
- testdata
- testprogs

Martin

Added:
   branches/SOC/mkhl/samdb-map/
   branches/SOC/mkhl/testdata-map/
   branches/SOC/mkhl/testprogs-map/


Changeset:
Copied: branches/SOC/mkhl/samdb-map (from rev 16802, 
branches/SAMBA_4_0/source/dsdb/samdb)

Copied: branches/SOC/mkhl/testdata-map (from rev 16802, 
branches/SAMBA_4_0/testdata)

Copied: branches/SOC/mkhl/testprogs-map (from rev 16802, 
branches/SAMBA_4_0/testprogs)



svn commit: samba r16805 - in branches/SOC/mkhl/samdb-map/ldb_modules: .

2006-07-04 Thread mkhl
Author: mkhl
Date: 2006-07-04 18:45:47 + (Tue, 04 Jul 2006)
New Revision: 16805

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16805

Log:
Replay samba3sam-adapt-to-ldb_map.patch (r16575):

Include necessary headers to let samba3sam compile.
Adapt `ldb_samba3sam_module_init' to the fixed ldb_map init code.

Martin


Modified:
   branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c


Changeset:
Modified: branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c
===
--- branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c 2006-07-04 18:39:12 UTC 
(rev 16804)
+++ branches/SOC/mkhl/samdb-map/ldb_modules/samba3sam.c 2006-07-04 18:45:47 UTC 
(rev 16805)
@@ -5,11 +5,17 @@
 */
 
 #include includes.h
-#include ldb/modules/ldb_map.h
 #include ldb/include/ldb.h
 #include ldb/include/ldb_private.h
+#include ldb/include/ldb_errors.h
+#include ldb/modules/ldb_map.h
 #include system/passwd.h
 
+#include librpc/gen_ndr/ndr_security.h
+#include librpc/ndr/libndr.h
+#include libcli/security/security.h
+#include libcli/security/proto.h
+
 /* 
  * sambaSID - member  (dn!)
  * sambaSIDList - member (dn!) 
@@ -855,8 +861,23 @@
}
 };
 
+/* the context init function */
+static int samba3sam_init(struct ldb_module *module)
+{
+int ret;
+
+   ret = ldb_map_init(module, samba3_attributes, samba3_objectclasses, 
samba3sam);
+if (ret != LDB_SUCCESS)
+return ret;
+
+return ldb_next_init(module);
+}
+
 /* the init function */
 int ldb_samba3sam_module_init(void)
 {
-   return ldb_map_init(ldb, samba3_attributes, samba3_objectclasses, 
samba3sam);
+struct ldb_module_ops ops = ldb_map_get_ops();
+ops.init_context = samba3sam_init;
+
+return ldb_register_module(ops);
 }



svn commit: samba r16806 - in branches/SOC/mkhl: .

2006-07-04 Thread mkhl
Author: mkhl
Date: 2006-07-04 18:48:16 + (Tue, 04 Jul 2006)
New Revision: 16806

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16806

Log:
Remove patch to the samba3sam module: obsoleted by the samdb-map branch.

Martin

Removed:
   branches/SOC/mkhl/samba3sam.c-adapt-to-ldb_map.patch


Changeset:
Deleted: branches/SOC/mkhl/samba3sam.c-adapt-to-ldb_map.patch
===
--- branches/SOC/mkhl/samba3sam.c-adapt-to-ldb_map.patch2006-07-04 
18:45:47 UTC (rev 16805)
+++ branches/SOC/mkhl/samba3sam.c-adapt-to-ldb_map.patch2006-07-04 
18:48:16 UTC (rev 16806)
@@ -1,48 +0,0 @@
-Index: dsdb/samdb/ldb_modules/samba3sam.c
-===
 dsdb/samdb/ldb_modules/samba3sam.c (revision 16565)
-+++ dsdb/samdb/ldb_modules/samba3sam.c (working copy)
-@@ -5,11 +5,17 @@
- */
- 
- #include includes.h
--#include ldb/modules/ldb_map.h
- #include ldb/include/ldb.h
- #include ldb/include/ldb_private.h
-+#include ldb/include/ldb_errors.h
-+#include ldb/modules/ldb_map.h
- #include system/passwd.h
- 
-+#include librpc/gen_ndr/ndr_security.h
-+#include librpc/ndr/libndr.h
-+#include libcli/security/security.h
-+#include libcli/security/proto.h
-+
- /* 
-  * sambaSID - member  (dn!)
-  * sambaSIDList - member (dn!) 
-@@ -855,8 +861,23 @@
-   }
- };
- 
-+/* the context init function */
-+static int samba3sam_init(struct ldb_module *module)
-+{
-+int ret;
-+
-+  ret = ldb_map_init(module, samba3_attributes, samba3_objectclasses, 
samba3sam);
-+if (ret != LDB_SUCCESS)
-+return ret;
-+
-+return ldb_next_init(module);
-+}
-+
- /* the init function */
- int ldb_samba3sam_module_init(void)
- {
--  return ldb_map_init(ldb, samba3_attributes, samba3_objectclasses, 
samba3sam);
-+struct ldb_module_ops ops = ldb_map_get_ops();
-+ops.init_context = samba3sam_init;
-+
-+return ldb_register_module(ops);
- }



svn commit: samba r16807 - in branches/SOC/mkhl/testprogs-map/ejs: .

2006-07-04 Thread mkhl
Author: mkhl
Date: 2006-07-04 18:50:11 + (Tue, 04 Jul 2006)
New Revision: 16807

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16807

Log:
Add sketched TODO list and ldifs to samab3sam test script.

Martin


Modified:
   branches/SOC/mkhl/testprogs-map/ejs/samba3sam


Changeset:
Modified: branches/SOC/mkhl/testprogs-map/ejs/samba3sam
===
--- branches/SOC/mkhl/testprogs-map/ejs/samba3sam   2006-07-04 18:48:16 UTC 
(rev 16806)
+++ branches/SOC/mkhl/testprogs-map/ejs/samba3sam   2006-07-04 18:50:11 UTC 
(rev 16807)
@@ -7,11 +7,35 @@
 libinclude(base.js);
 var mypath = substr(ARGV[0], 0, -strlen(samba3sam));
 
+/* TODO:
+
+   1) register partitions:
+
+dn: @PARTITION
+partition: CN=Samba3Sam,${BASEDN}:tdb://samba3.ldb
+partition: ${BASEDN}:tdb://samba4.ldb
+
+   2) register modules:
+
+dn: @MODULES
[EMAIL PROTECTED]: 
rootdse,kludge_acl,paged_results,server_sort,extended_dn,asq,samldb,objectclass,password_hash,operational,objectguid,rdn_name,samab3sam,partition
+
+   3) register mapping:
+
+dn: @MAP=samba3sam
[EMAIL PROTECTED]: ${BASEDN}
[EMAIL PROTECTED]: CN=Samba3Sam,${BASEDN}
+
+*/
+
 var sys = sys_init();
 var s3url;
 var s3 = ldb_init();
 var ok;
 
+var basedn = new Object();
+basedn.BASEDN = dc=vernstok,dc=nl;
+
 if (ARGV.length == 2) {
s3url = ARGV[1];
ok = s3.connect(s3url);
@@ -24,6 +48,7 @@
ok = s3.connect(s3url);
assert(ok);
var ldif = sys.file_load(mypath + ../../testdata/samba3/samba3.ldif);
+   ldif = substitute_var(ldif, basedn);
assert(ldif != undefined);
ok = s3.add(ldif);
assert(ok);
@@ -36,20 +61,17 @@
 assert(ok);
 
 var ldif = sys.file_load(mypath + ../../source/setup/provision_init.ldif);
+ldif = substitute_var(ldif, basedn);
 assert(ldif != undefined);
 ok = s4.add(ldif);
 assert(ok);
 
 var ldif = sys.file_load(mypath + 
../../source/setup/provision_templates.ldif);
-var subobj = new Object();
-subobj.BASEDN = dc=vernstok,dc=nl;
-ldif = substitute_var(ldif, subobj);
+ldif = substitute_var(ldif, basedn);
 assert(ldif != undefined);
 ok = s4.add(ldif);
 assert(ok);
 
-
-
 ok = s4.add(sprintf(dn: @MAP=samba3sam
 @MAP_URL: %s, s3url));
 assert(ok);



svn commit: samba r16808 - in branches/SOC/mkhl/testdata-map/samba3: .

2006-07-04 Thread mkhl
Author: mkhl
Date: 2006-07-04 18:50:48 + (Tue, 04 Jul 2006)
New Revision: 16808

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16808

Log:
Allow variable baseDN in samab3sam initial ldif.

Martin

Modified:
   branches/SOC/mkhl/testdata-map/samba3/samba3.ldif


Changeset:
Modified: branches/SOC/mkhl/testdata-map/samba3/samba3.ldif
===
--- branches/SOC/mkhl/testdata-map/samba3/samba3.ldif   2006-07-04 18:50:11 UTC 
(rev 16807)
+++ branches/SOC/mkhl/testdata-map/samba3/samba3.ldif   2006-07-04 18:50:48 UTC 
(rev 16808)
@@ -1,19 +1,19 @@
-dn: sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: sambaDomainName=TESTS,${BASEDN}
 objectclass: sambaDomain
 objectclass: top
 sambaSID: S-1-5-21-4231626423-2410014848-2360679739
 sambaNextRid: 2000
 sambaDomainName: TESTS
 
-dn: ou=Users,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: ou=Users,sambaDomainName=TESTS,${BASEDN}
 objectClass: organizationalUnit
 ou: Users
 
-dn: ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: organizationalUnit
 ou: Groups
 
-dn: uid=nobody,ou=Users,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: uid=nobody,ou=Users,sambaDomainName=TESTS,${BASEDN}
 cn: nobody
 sn: nobody
 objectClass: inetOrgPerson
@@ -40,7 +40,7 @@
 sambaSID: S-1-5-21-4231626423-2410014848-2360679739-2998
 loginShell: /bin/false
 
-dn: cn=Domain Admins,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Domain Admins,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 512
@@ -51,7 +51,7 @@
 sambaGroupType: 2
 displayName: Domain Admins
 
-dn: cn=Domain Users,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Domain Users,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 513
@@ -61,7 +61,7 @@
 sambaGroupType: 2
 displayName: Domain Users
 
-dn: cn=Domain Guests,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Domain Guests,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 514
@@ -71,7 +71,7 @@
 sambaGroupType: 2
 displayName: Domain Guests
 
-dn: cn=Print Operators,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Print Operators,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 550
@@ -81,7 +81,7 @@
 sambaGroupType: 2
 displayName: Print Operators
 
-dn: cn=Backup Operators,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Backup Operators,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 551
@@ -91,7 +91,7 @@
 sambaGroupType: 2
 displayName: Backup Operators
 
-dn: cn=Replicator,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Replicator,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 552
@@ -101,7 +101,7 @@
 sambaGroupType: 2
 displayName: Replicator
 
-dn: cn=Domain Computers,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Domain Computers,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 553
@@ -111,7 +111,7 @@
 sambaGroupType: 2
 displayName: Domain Computers
 
-dn: cn=Administrators,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Administrators,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 544
@@ -121,7 +121,7 @@
 sambaGroupType: 2
 displayName: Administrators
 
-dn: cn=Users,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Users,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 545
@@ -131,7 +131,7 @@
 sambaGroupType: 2
 displayName: users
 
-dn: cn=Guests,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Guests,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 546
@@ -142,7 +142,7 @@
 sambaGroupType: 2
 displayName: Guests
 
-dn: cn=Power Users,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Power Users,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 547
@@ -152,7 +152,7 @@
 sambaGroupType: 2
 displayName: Power Users
 
-dn: cn=Account Operators,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Account Operators,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 548
@@ -162,7 +162,7 @@
 sambaGroupType: 2
 displayName: Account Operators
 
-dn: cn=Server Operators,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl
+dn: cn=Server Operators,ou=Groups,sambaDomainName=TESTS,${BASEDN}
 objectClass: posixGroup
 objectClass: sambaGroupMapping
 gidNumber: 549
@@ -172,11 +172,11 @@
 sambaGroupType: 2

svn commit: samba r16809 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-04 Thread mkhl
Author: mkhl
Date: 2006-07-04 18:52:24 + (Tue, 04 Jul 2006)
New Revision: 16809

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16809

Log:
Add splitting of parse trees into local and remote parts.  Their usage
for searching isn't right yet though.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Sorry, the patch is too large (735 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16809


svn commit: samba r16810 - in branches/SOC/mkhl: .

2006-07-04 Thread mkhl
Author: mkhl
Date: 2006-07-04 18:57:29 + (Tue, 04 Jul 2006)
New Revision: 16810

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16810

Log:
Add more considerations about searching and parse trees.

Martin

Modified:
   branches/SOC/mkhl/map.txt


Changeset:
Modified: branches/SOC/mkhl/map.txt
===
--- branches/SOC/mkhl/map.txt   2006-07-04 18:52:24 UTC (rev 16809)
+++ branches/SOC/mkhl/map.txt   2006-07-04 18:57:29 UTC (rev 16810)
@@ -240,3 +240,37 @@
 unmap remote result
 merge local and remote result
 remove isMapped from result
+
+
+Hmm... Assume that both the local and remote parts of a split parse
+tree are non-null.  Assume we are in the async callback of the local
+search, after having found a local record matching the local parse
+tree, and are preparing the search for the matching remote record.
+That remote record must match the remote parse tree so the original
+parse tree matches the merged record, so we should be able to search
+for the matching remote DN *and* the remote parse tree.  Right?
+
+So, we'll consider these cases:
+
+- there is no parse tree:
+  - just search as we did before
+
+- the parse tree is local:
+  - use the original parse tree for the local search
+  - continue as before
+
+- the parse tree is remote:
+  - search locally as before
+  - use the mapped parse tree for remote search
+  - on match:
+- merge remote result into local result
+  - otherwise:
+- skip local result
+
+- parse tree can be split:
+  - use the local parse tree for the local search
+  - use the mapped remote parse tree for remote search
+  - on match:
+- merge remote result into local result
+  - otherwise:
+- skip local result



svn commit: samba r16811 - in branches/SOC/mkhl/ldb-map/modules: .

2006-07-04 Thread mkhl
Author: mkhl
Date: 2006-07-04 21:32:29 + (Tue, 04 Jul 2006)
New Revision: 16811

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16811

Log:
Use the split parse trees in local and remote searches.

Define control flow for local and remote searching.

After merging local and remote search results, invoke the original
callback on the merged result.

Some reformatting... sorry.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Sorry, the patch is too large (676 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16811


svn commit: samba r16714 - in branches/SOC/mkhl/ldb-map/modules: .

2006-06-30 Thread mkhl
Author: mkhl
Date: 2006-06-30 17:06:06 + (Fri, 30 Jun 2006)
New Revision: 16714

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16714

Log:
Add simple chunks for handling parse-trees in searches.
Next up: lay out plan for parse-tree memory allocation; split compound
parse trees; implement async call structure below
`remote_search_callback' to merge local into remote results; maybe
re-eval original parse tree on merged results.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Sorry, the patch is too large (726 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16714


svn commit: samba r16574 - in branches/SOC/mkhl/ldb-map/modules: .

2006-06-27 Thread mkhl
Author: mkhl
Date: 2006-06-27 23:27:53 + (Tue, 27 Jun 2006)
New Revision: 16574

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16574

Log:

Adapt initialization so ldb_map can be used by other modules:

Split `ldb_map_init' into `ldb_map_init', to be called from a using
modules `init_context' op, and `ldb_map_get_ops', to be called from a
using modules initialization function.

Expose `ldb_map_init' and `ldb_map_get_ops' in the header.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c
   branches/SOC/mkhl/ldb-map/modules/ldb_map.h


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-27 22:16:36 UTC (rev 
16573)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-27 23:27:53 UTC (rev 
16574)
@@ -2740,38 +2740,31 @@
 }
 
 
-/* Initialize a module that performs the specified mappings.
+/* Get a copy of this modules ops. */
+struct ldb_module_ops
+ldb_map_get_ops(void)
+{
+   return map_ops;
+}
 
-   Should be called from the init function of the module that defines
-   these mappings. */
-struct ldb_module *
-ldb_map_init(struct ldb_context *ldb,
+/* Initialize private data. */
+int
+ldb_map_init(struct ldb_module *module,
 const struct ldb_map_attribute *attrs,
 const struct ldb_map_objectclass *ocls,
 const char *name)
 {
-   struct ldb_module *module;
struct map_private *data;
int ret;
 
-   /* prepare the module structure */
-   module = talloc(ldb, struct ldb_module);
-   if (module == NULL) {
-   ldb_oom(ldb);
-   return NULL;
-   }
-
-   /* and private data */
+   /* prepare private data */
data = talloc(module, struct map_private);
if (data == NULL) {
-   ldb_oom(ldb);
+   ldb_oom(module-ldb);
 goto failed;
}
 
module-private_data = data;
-   module-ldb = ldb;
-   module-prev = module-next = NULL;
-   module-ops = map_ops;
 
/* store local and remote baseDNs */
ret = map_init_dns(module, name);
@@ -2781,9 +2774,28 @@
/* store list of attribute and objectClass maps */
map_init_maps(module, attrs, ocls);
 
-   return module;
+   return LDB_SUCCESS;
 
 failed:
-   talloc_free(module);
-   return NULL;
+   talloc_free(data);
+   return LDB_ERR_OPERATIONS_ERROR;
 }
+
+/* Ussage note for initialization of this module:
+
+   ldb_map is meant to be used from a different module that sets up
+   the mappings and gets registered in LDB.
+
+   'ldb_map_init' initializes the private data of this module and
+   stores the attribute and objectClass maps in there.  It also looks
+   up the '@MAP' special DN so requests can be redirected to the
+   remote partition.
+
+   This function should be called from the 'init_context' op of the
+   module using ldb_map.
+
+   'ldb_map_get_ops' returns a copy of ldb_maps module operations.
+
+   It should be called from the initialize function of the using
+   module, which should then override the 'init_context' op with a
+   function making the appropriate calls to 'ldb_map_init'. */

Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.h
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.h 2006-06-27 22:16:36 UTC (rev 
16573)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.h 2006-06-27 23:27:53 UTC (rev 
16574)
@@ -146,5 +146,15 @@
const struct ldb_dn *remote_base_dn;
 };
 
+/* initialization function */
+int
+ldb_map_init(struct ldb_module *module,
+const struct ldb_map_attribute *attrs,
+const struct ldb_map_objectclass *ocls,
+const char *name);
 
+/* get copy of map_ops */
+struct ldb_module_ops
+ldb_map_get_ops(void);
+
 #endif /* __LDB_MAP_H__ */



svn commit: samba r16575 - in branches/SOC/mkhl: .

2006-06-27 Thread mkhl
Author: mkhl
Date: 2006-06-27 23:36:49 + (Tue, 27 Jun 2006)
New Revision: 16575

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16575

Log:

Include necessary headers to let samba3sam compile.
Adapt `ldb_samba3sam_module_init' to the fixed ldb_map init code.

Martin

Added:
   branches/SOC/mkhl/samba3sam.c-adapt-to-ldb_map.patch


Changeset:
Added: branches/SOC/mkhl/samba3sam.c-adapt-to-ldb_map.patch
===
--- branches/SOC/mkhl/samba3sam.c-adapt-to-ldb_map.patch2006-06-27 
23:27:53 UTC (rev 16574)
+++ branches/SOC/mkhl/samba3sam.c-adapt-to-ldb_map.patch2006-06-27 
23:36:49 UTC (rev 16575)
@@ -0,0 +1,48 @@
+Index: dsdb/samdb/ldb_modules/samba3sam.c
+===
+--- dsdb/samdb/ldb_modules/samba3sam.c (revision 16565)
 dsdb/samdb/ldb_modules/samba3sam.c (working copy)
+@@ -5,11 +5,17 @@
+ */
+ 
+ #include includes.h
+-#include ldb/modules/ldb_map.h
+ #include ldb/include/ldb.h
+ #include ldb/include/ldb_private.h
++#include ldb/include/ldb_errors.h
++#include ldb/modules/ldb_map.h
+ #include system/passwd.h
+ 
++#include librpc/gen_ndr/ndr_security.h
++#include librpc/ndr/libndr.h
++#include libcli/security/security.h
++#include libcli/security/proto.h
++
+ /* 
+  * sambaSID - member  (dn!)
+  * sambaSIDList - member (dn!) 
+@@ -855,8 +861,23 @@
+   }
+ };
+ 
++/* the context init function */
++static int samba3sam_init(struct ldb_module *module)
++{
++int ret;
++
++  ret = ldb_map_init(module, samba3_attributes, samba3_objectclasses, 
samba3sam);
++if (ret != LDB_SUCCESS)
++return ret;
++
++return ldb_next_init(module);
++}
++
+ /* the init function */
+ int ldb_samba3sam_module_init(void)
+ {
+-  return ldb_map_init(ldb, samba3_attributes, samba3_objectclasses, 
samba3sam);
++struct ldb_module_ops ops = ldb_map_get_ops();
++ops.init_context = samba3sam_init;
++
++return ldb_register_module(ops);
+ }



svn commit: samba r16534 - in branches/SOC/mkhl/ldb-map/modules: .

2006-06-26 Thread mkhl
Author: mkhl
Date: 2006-06-26 22:07:25 + (Mon, 26 Jun 2006)
New Revision: 16534

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16534

Log:
Add support for merging remote search results with local search
results.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-26 21:21:59 UTC (rev 
16533)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-26 22:07:25 UTC (rev 
16534)
@@ -791,7 +791,6 @@
return NULL;
 }
 
-
 /* local DN - remote DN (as LDB values) */
 static
 struct ldb_val
@@ -1131,112 +1130,6 @@
 /* } */
 
 /* /\* XXX *\/ */
-/* /\* Remote message element - Local message element *\/ */
-/* static struct ldb_message_element *mop_remote_msg_element(struct ldb_module 
*module, */
-/*   struct ldb_message 
*msg, */
-/*   const struct 
ldb_message *oldmsg, */
-/*   const struct 
ldb_map_attribute *attr) */
-/* { */
-/* struct ldb_message_element *el, *oldel; */
-/* int i; */
-
-/* el = talloc(msg, struct ldb_message_element); */
-/* if (el == NULL) */
-/* return NULL; */
-
-/* switch (attr-type) { */
-/* case MAP_IGNORE: */
-/* goto failed; */
-
-/* case MAP_KEEP: */
-/* ldb_debug(module-ldb, LDB_DEBUG_TRACE, ldb_map:  */
-/*   Keeping remote attribute '%s'\n, attr-local_name); 
*/
-
-/* oldel = ldb_msg_find_element(oldmsg, attr-local_name); */
-/* if (oldel == NULL) */
-/* goto failed; */
-
-/* el-name = talloc_strdup(el, attr-local_name); */
-/* el-flags = oldel-flags; */
-/* el-num_values = oldel-num_values; */
-/* el-values = talloc_array(el, struct ldb_val, el-num_values); 
*/
-/* if (el-values == NULL) */
-/* goto failed; */
-
-/* for (i = 0; i  el-num_values; i++) */
-/* el-values[i] = ldb_val_dup(el, oldel-values[i]); */
-
-/* return el; */
-
-/* case MAP_RENAME: */
-/* ldb_debug(module-ldb, LDB_DEBUG_TRACE, ldb_map:  */
-/*   Renaming remote attribute '%s' to '%s'\n, */
-/*   attr-u.rename.remote_name, attr-local_name); */
-
-/* oldel = ldb_msg_find_element(oldmsg, 
attr-u.rename.remote_name); */
-/* if (oldel == NULL) */
-/* goto failed; */
-
-/* el-name = talloc_strdup(el, attr-local_name); */
-/* el-flags = oldel-flags; */
-/* el-num_values = oldel-num_values; */
-/* el-values = talloc_array(el, struct ldb_val, el-num_values); 
*/
-/* if (el-values == NULL) */
-/* goto failed; */
-
-/* for (i = 0; i  el-num_values; i++) */
-/* el-values[i] = ldb_val_dup(el, oldel-values[i]); */
-
-/* return el; */
-   
-/* case MAP_CONVERT: */
-/* ldb_debug(module-ldb, LDB_DEBUG_TRACE, ldb_map:  */
-/*   Converting remote attribute '%s' to '%s'\n, */
-/*   attr-u.rename.remote_name, attr-local_name); */
-
-/* if (attr-u.convert.convert_remote == NULL) { */
-/* ldb_debug(module-ldb, LDB_DEBUG_ERROR, ldb_map:  */
-/*   'convert_remote' not set!\n); */
-/* goto failed; */
-/* } */
-
-/* oldel = ldb_msg_find_element(oldmsg, 
attr-u.rename.remote_name); */
-/* if (oldel == NULL)  */
-/* goto failed; */
-
-/* el-name = talloc_strdup(el, attr-local_name); */
-/* el-flags = oldel-flags; */
-/* el-num_values = oldel-num_values; */
-/* el-values = talloc_array(el, struct ldb_val, el-num_values); 
*/
-/* if (el-values == NULL) */
-/* goto failed; */
-
-/* for (i = 0; i  el-num_values; i++) */
-/* el-values[i] = attr-u.convert.convert_remote(module, 
el, oldel-values[i]); */
-
-/* return el; */
-
-/* case MAP_GENERATE: */
-/* ldb_debug(module-ldb, LDB_DEBUG_TRACE, ldb_map:  */
-/*   Generating local attribute '%s'\n, */
-/*   attr-local_name); */
-
-/* if (attr-u.generate.generate_local == NULL) { */
-/* ldb_debug(module-ldb, LDB_DEBUG_ERROR, ldb_map:  */
-/*   'generate_local' not set!\n); */
-/* goto failed; */
-/* } */
-
-/* talloc_free(el

svn commit: samba r16535 - in branches/SOC/mkhl/ldb-map/modules: .

2006-06-26 Thread mkhl
Author: mkhl
Date: 2006-06-26 22:28:04 + (Mon, 26 Jun 2006)
New Revision: 16535

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16535

Log:
Update header comment about this modules structure.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-26 22:07:25 UTC (rev 
16534)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-26 22:28:04 UTC (rev 
16535)
@@ -39,18 +39,39 @@
 
 /*
  - special attribute 'isMapped'
- - add/modify
-   - split up ldb_message into fallback and mapped parts if is_mappable
- - search: 
-   - search local one for not isMapped entries
-   - remove remote attributes from ldb_parse_tree
-   - search remote one
-- per record, search local one for additional data (by dn)
-- test if (full expression) is now true
- - delete
-   - delete both
- - rename
-   - rename locally and remotely
+ - search:
+ - search local records w/ isMapped
+ - for each local result
+ - if isMapped
+- search remote record
+- merge remote into local result
+ - add:
+ - split message into local and remote part
+ - if remote message is not empty
+ - add isMapped to local message
+ - add remote message
+ - add local message
+ - modify:
+ - split message into local and remote part
+ - if remote message is not empty
+ - search local record for isMapped
+- if isMapped
+- modify remote record
+- otherwise
+- add isMapped to local message
+- add remote record
+ - modify local record
+ - delete:
+ - search local record for isMapped
+ - if isMapped
+ - delete remote record
+ - delete local record
+ - rename:
+ - search local record for isMapped
+ - if isMapped
+ - rename remote record
+- modify local isMapped
+ - rename local record
 */
 
 



svn commit: samba r16538 - in branches/SOC/mkhl/ldb-map/modules: .

2006-06-26 Thread mkhl
Author: mkhl
Date: 2006-06-26 23:46:15 + (Mon, 26 Jun 2006)
New Revision: 16538

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16538

Log:
Add select_unmappable_msg_attrs func, which I'll need for mapping
parse-trees in search.
Fix some wrong talloc memory contexts in select_*.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-26 23:36:03 UTC (rev 
16537)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-26 23:46:15 UTC (rev 
16538)
@@ -456,7 +456,10 @@
return NULL;
 
last = 0;
-   result = NULL;
+   result = talloc_array(mem_ctx, const char *, 1);
+   if (result == NULL)
+   return NULL;
+   result[0] = NULL;
 
for (i = 0; attrs[i]; i++) {
/* keep * and ignored attrs */
@@ -467,7 +470,7 @@
if (result == NULL)
goto failed;
 
-   result[last] = talloc_strdup(mem_ctx, attrs[i]);
+   result[last] = talloc_strdup(result, attrs[i]);
result[last+1] = NULL;
last++;
}
@@ -497,12 +500,15 @@
return NULL;
 
last = 0;
-   result = NULL;
+   result = talloc_array(mem_ctx, const char *, 1);
+   if (result == NULL)
+   return NULL;
+   result[0] = NULL;
 
for (i = 0; attrs[i]; i++) {
/* keep * as is */
if (ldb_attr_cmp(attrs[i], *) == 0) {
-   name = talloc_strdup(mem_ctx, attrs[i]);
+   name = talloc_strdup(result, attrs[i]);
goto named;
}
 
@@ -529,7 +535,7 @@
for (j = 0; map-u.generate.remote_names[j]; j++) {
result = talloc_realloc(mem_ctx, result,
const char *, last+2);
-   result[last] = talloc_strdup(mem_ctx, map-u 
.generate.remote_names[j]);
+   result[last] = talloc_strdup(result, map-u 
.generate.remote_names[j]);
result[last+1] = NULL;
last++;
}
@@ -542,7 +548,7 @@
if (result == NULL)
goto failed;
 
-   result[last] = name;
+   result[last] = talloc_strdup(result, name);
result[last+1] = NULL;
last++;
}
@@ -554,6 +560,68 @@
return NULL;
 }
 
+/* select only local attrs that can be unmapped from msg */
+static
+const char **
+select_unmappable_msg_attrs(struct ldb_module *module,
+   void *mem_ctx,
+   const struct ldb_message *msg)
+{
+   struct ldb_map_context *data = map_get_context(module);
+   const struct ldb_map_attribute *map;
+   const char **result;
+   int i, j, last;
+
+   if (msg == NULL)
+   return NULL;
+
+   last = 0;
+   result = talloc_array(mem_ctx, const char *, 1);
+   if (result == NULL)
+   return NULL;
+   result[0] = NULL;
+
+   /* for each mapping, check if all remote attributes are present
+  if they are, add the local one to the result */
+   /* TODO: Alternatively, walk over msg-elements and use 
find_remote_attr. */
+   for (i = 0; data-attribute_maps[i].local_name; i++) {
+   BOOL avail = False;
+   map = data-attribute_maps[i];
+
+   switch (map-type) {
+   case MAP_IGNORE:
+   break;
+
+   case MAP_KEEP:
+   avail = (ldb_msg_find_element(msg, map-local_name) != 
NULL);
+   break;
+   
+   case MAP_RENAME:
+   case MAP_CONVERT:
+   avail = (ldb_msg_find_element(msg, 
map-u.rename.remote_name) != NULL);
+   break;
+
+   case MAP_GENERATE:
+   /* look for *all* remote names */
+   avail = True;
+   for (j = 0; map-u.generate.remote_names[j]; j++)
+   avail = (ldb_msg_find_element(msg, 
map-u.generate.remote_names[j]) != NULL);
+   break;
+   }
+
+   if (!avail)
+   continue;
+
+   result = talloc_realloc(mem_ctx, result, const char *, last+2);
+   result[last] = talloc_strdup(result, map-local_name);
+   result[last+1] = NULL;
+   last++;
+   }
+
+   return result;
+}
+
+
 /* Check whether the given objectClass is contained

svn commit: samba r16511 - in branches/SOC/mkhl/ldb-map/modules: .

2006-06-25 Thread mkhl
Author: mkhl
Date: 2006-06-25 16:08:19 + (Sun, 25 Jun 2006)
New Revision: 16511

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16511

Log:
Add remote search callback, not yet merging results.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-25 12:22:12 UTC (rev 
16510)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-25 16:08:19 UTC (rev 
16511)
@@ -1395,7 +1395,14 @@
return 0;
 }
 
+static
+int
+merge_mapped_results(struct map_async_search_context *context)
+{
+   return LDB_SUCCESS; /* TODO */
+}
 
+
 /* store single search result in async context */
 static
 int
@@ -1404,6 +1411,7 @@
 struct ldb_async_result *ares)
 {
struct map_async_context *ac;
+   const char *dn;
 
if (context == NULL || ares == NULL) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, NULL Context or 
Result in callback));
@@ -1418,19 +1426,17 @@
return LDB_SUCCESS;
}
 
-   /* we already have a remote DN */
+   /* we have already found a remote DN */
if (ac-remote_dn) {
-   ldb_set_errstring(ldb,
- talloc_asprintf(ldb, Too many results));
+   ldb_set_errstring(ldb, talloc_asprintf(ldb, Too many results 
to base search));
talloc_free(ares);
return LDB_ERR_OPERATIONS_ERROR;
}
 
/* extract remote DN */
-   ac-search_res = talloc_steal(ac, ares);
-   ac-remote_dn = ldb_dn_explode(ac,
-  ldb_msg_find_string(ares-message,
-  IS_MAPPED, NULL));
+   ac-search_res = ares;
+   dn = ldb_msg_find_string(ares-message, IS_MAPPED, NULL);
+   ac-remote_dn = ldb_dn_explode(ac, dn);
 
return LDB_SUCCESS;
 }
@@ -1492,6 +1498,47 @@
   void *context,
   struct ldb_async_result *ares)
 {
+   struct map_async_search_context *sc;
+   int ret;
+
+   if (context == NULL || ares == NULL) {
+   ldb_set_errstring(ldb, talloc_asprintf(ldb, NULL Context or 
Result in callback));
+   return LDB_ERR_OPERATIONS_ERROR;
+   }
+
+   sc = talloc_get_type(context, struct map_async_search_context);
+
+   switch (ares-type) {
+   case LDB_REPLY_ENTRY:
+   /* we have already found a remote record */
+   if (sc-remote_res) {
+   ldb_set_errstring(ldb, talloc_asprintf(ldb, Too many 
results to base search));
+   talloc_free(ares);
+   return LDB_ERR_OPERATIONS_ERROR;
+   }
+
+   /* store remote result */
+   sc-remote_res = ares;
+
+   /* merge remote into local record */
+   ret = merge_mapped_results(sc);
+   if (ret != LDB_SUCCESS)
+   talloc_free(ares);
+
+   return ret;
+
+   case LDB_REPLY_DONE:
+   /* no mapped record found, continue with local record */
+   if (sc-remote_res == NULL)
+   return sc-ac-orig_req-async.callback(ldb, 
sc-ac-orig_req-async.context, sc-local_res);
+   break;
+
+   default:
+   talloc_free(ares);
+   ldb_set_errstring(ldb, talloc_asprintf(ldb, Unexpected result 
type in base search for mapped entry));
+   return LDB_ERR_OPERATIONS_ERROR;
+   }
+
return LDB_SUCCESS;
 }
 
@@ -1516,13 +1563,11 @@
 
/* stop searching if it's not a record */
if (ares-type != LDB_REPLY_ENTRY)
-   return ac-orig_req-
-   async.callback(ldb, ac-orig_req-async.context, ares);
+   goto callback;
 
/* stop searching if it's not mapped */
if (!ldb_msg_find_element(ares-message, IS_MAPPED))
-   return ac-orig_req-
-   async.callback(ldb, ac-orig_req-async.context, ares);
+   goto callback;
 
/* extract remote DN */
dn = ldb_dn_explode(ac, ldb_msg_find_string(ares-message,
@@ -1541,8 +1586,9 @@
if (sc == NULL)
goto error;
 
+   /* store local result */
sc-ac = ac;
-   sc-local_res = ares;   /* TODO: steal? */
+   sc-local_res = ares;
sc-remote_res = NULL;
 
/* TODO: replace NULL with remote attrs! */
@@ -1552,6 +1598,9 @@
 
return ldb_next_remote_request(ac-module, req);
 
+callback:
+   return ac-orig_req-async.callback(ldb, ac-orig_req-async.context, 
ares);
+
 error:
talloc_free(ares);
return LDB_ERR_OPERATIONS_ERROR;
@@ -1561,7 +1610,6 @@
 /* Handling LDB requests */
 
 /* /\* Search fallback

svn commit: samba r16492 - in branches/SOC/mkhl: .

2006-06-24 Thread mkhl
Author: mkhl
Date: 2006-06-24 14:10:46 + (Sat, 24 Jun 2006)
New Revision: 16492

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16492

Log:
Reflection on denoting the relation between a local and remote
(i.e. mapped) record.
Improvement of request pseudo-code.

Martin

Modified:
   branches/SOC/mkhl/map.txt


Changeset:
Modified: branches/SOC/mkhl/map.txt
===
--- branches/SOC/mkhl/map.txt   2006-06-24 12:33:45 UTC (rev 16491)
+++ branches/SOC/mkhl/map.txt   2006-06-24 14:10:46 UTC (rev 16492)
@@ -35,13 +35,9 @@
 
 *** Internal attribute isMapped
 The local part of each mapped record includes an internal attribute
-isMapped, the value of which might denote the DN of the remote part.
-It is not present in the local part of a record that is not
-mapped. (Or maybe it is but with a distinguished/empty value).
+isMapped, the value of which is irrelevant.  It is not present in
+the local part of a record that is not mapped.
 
-The attribute is not visible from the outside(?) and cannot be
-modified directly.
-
 *** Local != Fallback
 Each attribute must either be mapped or ignored; the local part should
 be reserved for ignored data and not serve as fallback storage for
@@ -76,6 +72,39 @@
 of the map instance.
 
 
+** Alternatives to local isMapped
+
+*** Local isMappedTo
+Instead of setting a local attribute to just denote whether a record
+is mapped or not, the attribute could contain the DN of the remote
+part if the records data.  When looking for the attribute, its
+contents could be extracted and instantly reused to access remote
+data.
+
+*** Remote isMappedFrom
+Instead of the local part pointing to the remote part, the latter
+could be assigned an attribute containing the DN of the local part of
+the data.  Finding the remote part of a record with a local DN would
+then consist of searching for a record that claims to be mapped from
+that local DN.
+
+*** More GUIDs
+Use GUIDs instead of DNs to identify related records.
+
+*** Another masterGUID=% RDN
+The idea from local_password could be reused.  This would also save us
+from mapping DNs back and forth all over the place.
+
+
+** Problems with these alternatives
+The obvious problem is the use of a local/remote schema which might
+prevent our use of arbitrary internal attributes for mapped data.
+Another is mapping the directory structure in the remote backend,
+which the third alternative would prevent.
+We would also need to be in samdb to get to use GUIDs for all I
+understand.
+
+
 ** Mappings
 
 *** Abstractly
@@ -124,14 +153,14 @@
 ** Requests
 
 *** Delete
-look for isMapped on local self
-if set:
-  delete remote DN
-delete local DN
+look for remote record
+if found:
+  delete remote record
+delete local record
 
 *** Rename
-look for isMapped on local self
-if set:
+look for remote record
+if found:
   rename remote record
 rename local record
 
@@ -152,14 +181,25 @@
 otherwise:
   add local record w/o isMapped
 
+This doesn't make sense: we're trying to *add* the remote record, so
+we can't possibly query it before adding it!
+Our only choices are to either find out immediately which mappings
+cannot be performed due to missing context data or to split the remote
+message into an immediate and a postponed part, the immediate one
+being run *right now* and the postponed, well, postponed until after
+that; the postponed message would then have to be split up again and
+again until either the immediate part is empty (i.e. some data cannot
+be added) or the postponed part is empty (i.e. we're done and can go
+home now).
+
 *** Modify
 if no requested changes are remote:
   just run local request
-look for isMapped on local self
-if not set:
-  turn request into add
+look for remote record
+if not found:
+  turn remote request into add
   add remote record (with context)
-  modify local record with isMapped
+  register relation between local and remote record
 otherwise:
   modify remote record (with context)
   modify local record



svn commit: samba r16494 - in branches/SOC/mkhl/ldb-map: . modules

2006-06-24 Thread mkhl
Author: mkhl
Date: 2006-06-24 14:24:40 + (Sat, 24 Jun 2006)
New Revision: 16494

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16494

Log:
Replay of ,,ldb_map-async.patch, revision 16233
Modified:
   branches/SOC/mkhl/ldb-map/config.mk
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Sorry, the patch is too large (2548 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16494


svn commit: samba r16497 - in branches/SOC/mkhl/ldb-map/modules: .

2006-06-24 Thread mkhl
Author: mkhl
Date: 2006-06-24 14:29:39 + (Sat, 24 Jun 2006)
New Revision: 16497

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16497

Log:
Replay of ,,ldb_map-async.patch, revision 16491
Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Sorry, the patch is too large (629 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16497


svn commit: samba r16498 - in branches/SOC/mkhl: .

2006-06-24 Thread mkhl
Author: mkhl
Date: 2006-06-24 14:34:15 + (Sat, 24 Jun 2006)
New Revision: 16498

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16498

Log:
Remove the patch against samba4 that tries to implement an async
ldb_map module.  It is obsoleted by the ldb-map branch.

Martin

Removed:
   branches/SOC/mkhl/,,ldb_map-async.patch


Changeset:
Sorry, the patch is too large (3579 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16498


svn commit: samba r16499 - in branches/SOC/mkhl/ldb-map/modules: .

2006-06-24 Thread mkhl
Author: mkhl
Date: 2006-06-24 17:19:09 + (Sat, 24 Jun 2006)
New Revision: 16499

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16499

Log:
Update comments.
Reorganize request handlers.
Restructure initialization.
Fix timeout propagation.
Fix one undefined request.

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Sorry, the patch is too large (913 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16499


svn commit: samba r16500 - in branches/SOC/mkhl/ldb-map/modules: .

2006-06-24 Thread mkhl
Author: mkhl
Date: 2006-06-24 19:29:10 + (Sat, 24 Jun 2006)
New Revision: 16500

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16500

Log:
So the sorting was a dumb idea and needed forward declarations.  Bah.
Fix other compilation issues.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-24 17:19:09 UTC (rev 
16499)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-24 19:29:10 UTC (rev 
16500)
@@ -327,7 +327,7 @@
int i;
 
for (i = 0; i  msg-num_elements; i++) {
-   map = find_attr_local(data, msg-elements[i]);
+   map = find_attr_local(data, msg-elements[i].name);
if (map  map-type != MAP_IGNORE)
return 1;
}
@@ -1612,6 +1612,23 @@
 /* } */
 
 
+/* Add the local record */
+static
+int
+map_add_do_local(struct ldb_async_handle *handle)
+{
+   struct map_async_context *ac;
+
+   ac = talloc_get_type(handle-private_data, struct map_async_context);
+
+   ldb_set_timeout_from_prev_req(ac-module-ldb,
+ ac-orig_req, ac-local_req);
+
+   ac-step = MAP_DO_ADD_LOCAL;
+
+   return ldb_next_request(ac-module, ac-local_req);
+}
+
 /* Add a record */
 static
 int
@@ -1707,10 +1724,12 @@
return LDB_ERR_OPERATIONS_ERROR;
 }
 
-/* Add the local record */
+
+
+/* Modify the local record */
 static
 int
-map_add_do_local(struct ldb_async_handle *handle)
+map_modify_do_local(struct ldb_async_handle *handle)
 {
struct map_async_context *ac;
 
@@ -1719,12 +1738,50 @@
ldb_set_timeout_from_prev_req(ac-module-ldb,
  ac-orig_req, ac-local_req);
 
-   ac-step = MAP_DO_ADD_LOCAL;
+   ac-step = MAP_DO_MODIFY_LOCAL;
 
return ldb_next_request(ac-module, ac-local_req);
 }
 
+/* Modify the remote record */
+static
+int
+map_modify_do_remote(struct ldb_async_handle *handle)
+{
+   struct map_async_context *ac;
+   struct ldb_message *msg;
+   char *dn;
 
+   ac = talloc_get_type(handle-private_data, struct map_async_context);
+
+   /* no remote record, add it instead */
+   if (ac-remote_dn == NULL) {
+   /* turn request into 'add' */
+   msg = discard_const_p(struct ldb_message,
+ ac-remote_req-op.mod.message);
+   ac-remote_req-operation = LDB_ADD;
+   ac-remote_req-op.add.message = msg;
+/* TODO: Could I just leave msg in there?  I think so,
+   but it looks clearer this way. */
+
+   /* update local 'IS_MAPPED' */
+   msg = discard_const_p(struct ldb_message,
+ ac-local_req-op.mod.message);
+   dn = ldb_dn_linearize(msg, ac-remote_dn);
+   if (ldb_msg_add_empty(msg, IS_MAPPED, LDB_FLAG_MOD_ADD) != 0)
+return LDB_ERR_OPERATIONS_ERROR;
+   if (ldb_msg_add_string(msg, IS_MAPPED, dn) != 0)
+return LDB_ERR_OPERATIONS_ERROR;
+   }
+
+   ldb_set_timeout_from_prev_req(ac-module-ldb,
+ ac-orig_req, ac-remote_req);
+
+   ac-step = MAP_DO_MODIFY_REMOTE;
+
+   return ldb_next_remote_request(ac-module, ac-remote_req);
+}
+
 /* Modify a record */
 static
 int
@@ -1817,97 +1874,35 @@
return LDB_ERR_OPERATIONS_ERROR;
 }
 
-/* Modify the remote record */
+
+/* Delete the local record */
 static
 int
-map_modify_do_remote(struct ldb_async_handle *handle)
+map_delete_do_local(struct ldb_async_handle *handle)
 {
struct map_async_context *ac;
-   struct ldb_message *msg;
-   char *dn;
 
ac = talloc_get_type(handle-private_data, struct map_async_context);
 
-   /* no remote record, add it instead */
-   if (ac-remote_dn == NULL) {
-   /* turn request into 'add' */
-   msg = discard_const_p(struct ldb_message,
- ac-remote_req-op.mod.message);
-   ac-remote_req-operation = LDB_ADD;
-   ac-remote_req-op.add.message = msg;
-/* TODO: Could I just leave msg in there?  I think so,
-   but it looks clearer this way. */
-
-   /* update local 'IS_MAPPED' */
-   msg = discard_const_p(struct ldb_message,
- ac-local_req-op.mod.message);
-   dn = ldb_dn_linearize(msg, ac-remote_dn);
-   if (ldb_msg_add_empty(msg, IS_MAPPED, LDB_FLAG_MOD_ADD) != 0)
-return LDB_ERR_OPERATIONS_ERROR;
-   if (ldb_msg_add_string(msg, IS_MAPPED, dn) != 0)
-return LDB_ERR_OPERATIONS_ERROR;
+   /* prepare

svn commit: samba r16505 - in branches/SOC/mkhl/ldb-map/modules: .

2006-06-24 Thread mkhl
Author: mkhl
Date: 2006-06-24 22:00:52 + (Sat, 24 Jun 2006)
New Revision: 16505

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16505

Log:
Check incoming DN before performing mappings.
Add chunks of searching boilerplate.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-24 20:38:38 UTC (rev 
16504)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-24 22:00:52 UTC (rev 
16505)
@@ -1,25 +1,25 @@
 /* 
-   ldb database library - map backend
+   Mapping ldb module
 
Copyright (C) Jelmer Vernooij 2005
 
- ** NOTE! The following LGPL license applies to the ldb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
+   * NOTICE: this module is NOT released under the GNU LGPL license as
+   * other ldb code. This module is release under the GNU GPL v2 or
+   * later license.
+
+   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 2 of the License, or
+   (at your option) any later version.

-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
+   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
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 USA
+   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, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /*
@@ -27,7 +27,7 @@
  *
  *  Component: ldb ldb_map module
  *
- *  Description: ...
+ *  Description: Map portions of data into a different format on a remote 
partition.
  *
  *  Author: Jelmer Vernooij, Martin Kuehl
  */
@@ -57,7 +57,7 @@
 #define map_oom(module) ldb_set_errstring(module-ldb, talloc_asprintf(module, 
Out of Memory));
 
 
-/* Private data */
+/* private data */
 struct map_private {
struct ldb_map_context context;
 };
@@ -73,9 +73,11 @@
 }
 
 
-/* Async context data */
+/* async context data */
 struct map_async_context {
enum map_step {
+   MAP_SEARCH_LOCAL,
+   MAP_SEARCH_REMOTE,
MAP_DO_ADD_REMOTE,
MAP_DO_ADD_LOCAL,
MAP_SEARCH_SELF_MODIFY,
@@ -87,7 +89,7 @@
MAP_SEARCH_SELF_RENAME,
MAP_DO_RENAME_REMOTE,
MAP_DO_RENAME_FIXUP,
-   MAP_DO_RENAME_LOCAL,
+   MAP_DO_RENAME_LOCAL
} step;
 
struct ldb_module *module;
@@ -104,6 +106,13 @@
struct ldb_async_result *search_res;
 };
 
+/* async context data for searches */
+struct map_async_search_context {
+   struct map_async_context *ac;
+   struct ldb_async_result *local_res;
+   struct ldb_async_result *remote_res;
+};
+
 /* create async context and handle */
 static
 struct ldb_async_handle *
@@ -191,7 +200,7 @@
 return new;
 }
 
-#define MAP_DN_REBASE(dn) dn = ldb_dn_rebase(request, dn, map-local_base_dn, 
map-remote_base_dn)
+#define MAP_DN_REBASE(dn) dn = ldb_dn_rebase(request, dn, data-local_base_dn, 
data-remote_base_dn)
 
 /* run request in the remote partition */
 static
@@ -199,7 +208,7 @@
 ldb_next_remote_request(struct ldb_module *module,
struct ldb_request *request)
 {
-   struct ldb_map_context *map = map_get_privdat(module);
+   struct ldb_map_context *data = map_get_privdat(module);
 struct ldb_message *msg;
 
 switch (request-operation) {
@@ -315,24 +324,71 @@
 }
 
 
-/* Checking ldb_messages */
+/* Checking ... stuff  */
 
+/* True if dn is below the local baseDN */
 static
-int
-check_msg_is_mapped(struct ldb_module *module,
-   const struct ldb_message *msg)
+BOOL
+check_dn_local(struct ldb_module *module,
+  const struct ldb_dn *dn)
 {
struct ldb_map_context *data = map_get_privdat(module);
+
+   return ldb_dn_compare_base(module-ldb, data-local_base_dn, dn) == 0;
+}
+
+/* True if attr has an associated

svn commit: samba r16507 - in branches/SOC/mkhl: .

2006-06-24 Thread mkhl
Author: mkhl
Date: 2006-06-24 23:34:44 + (Sat, 24 Jun 2006)
New Revision: 16507

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16507

Log:

Add comments about problems I am imagining.

Martin

Modified:
   branches/SOC/mkhl/map.txt


Changeset:
Modified: branches/SOC/mkhl/map.txt
===
--- branches/SOC/mkhl/map.txt   2006-06-24 22:58:04 UTC (rev 16506)
+++ branches/SOC/mkhl/map.txt   2006-06-24 23:34:44 UTC (rev 16507)
@@ -96,7 +96,9 @@
 from mapping DNs back and forth all over the place.
 
 
-** Problems with these alternatives
+** Problems
+
+*** with these alternatives to isMapped
 The obvious problem is the use of a local/remote schema which might
 prevent our use of arbitrary internal attributes for mapped data.
 Another is mapping the directory structure in the remote backend,
@@ -104,7 +106,29 @@
 We would also need to be in samdb to get to use GUIDs for all I
 understand.
 
+*** with partitions
+When I use partitions (or really just different baseDNs) to separate
+the local and remote records, I *should* make sure to only modify DNs
+under the local baseDN.  What should one do in the case of a rename
+request where one of the old and new DN is under the local baseDN but
+the other isn't?
 
+*** with object existence
+The premises include that objects are always created locally, even if
+only to hold a isMapped attribute, but that they don't need to exist
+remotely.  The structure of the remote partition exactly mirrors that
+of the local partition though, i.e. an object has the same DN relative
+to the local as to the remote baseDN (except for mappings of the DN
+components, but those don't matter here).  This implies that *all*
+containers along this path must exist both locally *and* remotely,
+regardless of their attribute components.
+
+This means it *could* be possible to add a container (which isn't
+mapped for some reason) and later to create a record below that
+container that contains mapped data.  The request will fail due to the
+missing container, which, from the users point of view, *does* exist.
+
+
 ** Mappings
 
 *** Abstractly



svn commit: samba r16477 - in branches/SOC/mkhl: .

2006-06-22 Thread mkhl
Author: mkhl
Date: 2006-06-22 21:55:23 + (Thu, 22 Jun 2006)
New Revision: 16477

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16477

Log:

Reenable the largest parts of add and modify.  Eventual extensions to
generate mappings are postponed for now, at least until searches
work.

Martin

Modified:
   branches/SOC/mkhl/,,ldb_map-async.patch


Changeset:
Sorry, the patch is too large (2952 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16477


svn commit: samba r16434 - in branches/SOC/mkhl: .

2006-06-20 Thread mkhl
Author: mkhl
Date: 2006-06-21 00:31:40 + (Wed, 21 Jun 2006)
New Revision: 16434

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16434

Log:

Add a few chunks of async trampolining for delete and rename requests.
Those won't be necessary for add, but the modify trampolining will get
a lot more complex.

Martin

Modified:
   branches/SOC/mkhl/,,ldb_map-async.patch


Changeset:
Sorry, the patch is too large (2089 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16434


svn commit: samba r16384 - in branches/SOC/mkhl: .

2006-06-19 Thread mkhl
Author: mkhl
Date: 2006-06-20 01:08:18 + (Tue, 20 Jun 2006)
New Revision: 16384

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16384

Log:

Semi-informed doodling about a mapping module, affected by late
insights into local_password and password_hash concerning the scope of
mappings, the requirement for context and more asynchronism.

Martin

Added:
   branches/SOC/mkhl/map.txt


Changeset:
Added: branches/SOC/mkhl/map.txt
===
--- branches/SOC/mkhl/map.txt   2006-06-20 01:03:04 UTC (rev 16383)
+++ branches/SOC/mkhl/map.txt   2006-06-20 01:08:18 UTC (rev 16384)
@@ -0,0 +1,178 @@
+* An LDB Mapping Module -*- outline -*-
+
+** Scenario
+Usage of an instance of the map module requires tha full set of data
+to be split in two partitions, a local (fallback) and a remote
+(mapped) one.  The remote partition will be used to store additional
+data but may differ from the local partition in the schema it uses.
+The goal is to store as much data as possible on the remote partition.
+
+A user is required to define mappings between local and remote data
+schemas to account for these differences, but also to enable usage of
+the remote partition for as large a dataset as possible.
+
+Data not explicitly accounted for in the defined mappings is ignored
+by the remote partition and stored on the local partition instead.
+
+
+** Assumptions
+
+*** Mapped vs. Not Mapped
+Each record exists in either of two states:
+
+ Not mapped:
+The record and all of its data are stored on the local partition; the
+additional attribute isMapped is not present in the record.
+
+ Mapped:
+The record is split into a local and a remote part stored on the local
+and remote partition respectively; an additional internal attribute
+isMapped is added to the local part of the record.
+
+The local part of a mapped record is allowed to consist only of the
+isMapped attribute, denoting the case when all real data is mapped
+to the remote partition.
+
+*** Internal attribute isMapped
+The local part of each mapped record includes an internal attribute
+isMapped, the value of which might denote the DN of the remote part.
+It is not present in the local part of a record that is not
+mapped. (Or maybe it is but with a distinguished/empty value).
+
+The attribute is not visible from the outside(?) and cannot be
+modified directly.
+
+*** Local != Fallback
+Each attribute must either be mapped or ignored; the local part should
+be reserved for ignored data and not serve as fallback storage for
+failed mappings.
+
+Failure to map an attribute indicates a problem with the specified
+mappings and should be reported.
+
+*** No smart mapping
+The map module has no knowledge of constraints present in the backend
+of the remote partition, such as objectClass restrictions.
+
+Constraint violation results from the remote backend indicate a
+problem with the specified mappings and should be reported.
+
+*** Uniqueness of local names
+The specified mappings should be uniquely indexable by the local name
+of a handled attribute.
+
+Generation of multiple remote attributes from a single local attribute
+will be possible but should be defined in a single mapping to ease
+conversions from the remote to the local format (as for search
+responses).
+
+(This might be problematic for attributes that form a records RDN, as
+only one attribute can be used for that at a time...)
+
+*** Stable naming contexts
+Mappings must not tamper with the naming context of a record.  The
+naming context is (part of) what specifies the destination partition
+for a datase; its modification is defined globally in a special record
+of the map instance.
+
+
+** Mappings
+
+*** Abstractly
+A mapping represents, viewed abstractly, a function of type
+Request x Context -- Request
+
+The structure of LDB modules performs dispatching based on request
+type itself, so we can substitute the request contents for Request in
+that type.  Disregarding delete and rename requests, which contain
+only one or two target DNs, the contents of a request are of type LDB
+message, so we assume a type
+Message x Context -- Request
+
+The ldb_map module disregards context completely, modelling only
+functions 
+Message -- Message
+
+and a few restricted subforms of types
+Message Element -- Message Element
+
+or even just
+String -- String
+
+This is convenient for most cases and increases expressiveness of the
+mapping definition language but limits the overall power of
+mappings, as e.g. the password_hash module cannot currently be
+expressed with the ldb_map module due to lacking context (the domain
+data search result and the array `attrs' of the
+`password_hash_mod_search_self' function.
+
+The only way to access that data is by making (synchronous) LDB calls
+from within the attribute generation function.
+
+*** As Balls of Mud
+The canonical way to fetch context is to prefix the real

svn commit: samba r16257 - in branches/SOC/mkhl: .

2006-06-15 Thread mkhl
Author: mkhl
Date: 2006-06-15 14:31:53 + (Thu, 15 Jun 2006)
New Revision: 16257

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16257

Log:

Implement more parts of the unspecial module.  Including search,
async_wait and async callbacks.

Martin

Modified:
   branches/SOC/mkhl/,,ldb-unspecial.c-remap-special-DNs.patch


Changeset:
Sorry, the patch is too large (586 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16257


svn commit: samba r16258 - in branches/SOC/mkhl: .

2006-06-15 Thread mkhl
Author: mkhl
Date: 2006-06-15 14:53:45 + (Thu, 15 Jun 2006)
New Revision: 16258

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16258

Log:

Take Simo's feedback w.r.t. talloc_steal into account.

Martin

Modified:
   branches/SOC/mkhl/,,ldb-unspecial.c-remap-special-DNs.patch


Changeset:
Modified: branches/SOC/mkhl/,,ldb-unspecial.c-remap-special-DNs.patch
===
--- branches/SOC/mkhl/,,ldb-unspecial.c-remap-special-DNs.patch 2006-06-15 
14:31:53 UTC (rev 16257)
+++ branches/SOC/mkhl/,,ldb-unspecial.c-remap-special-DNs.patch 2006-06-15 
14:53:45 UTC (rev 16258)
@@ -1,8 +1,8 @@
 Index: modules/unspecial.c
 ===
 modules/unspecial.c(Revision 0)
-+++ modules/unspecial.c(Revision 0)
-@@ -0,0 +1,503 @@
+--- modules/unspecial.c(revision 0)
 modules/unspecial.c(revision 0)
+@@ -0,0 +1,508 @@
 +/* 
 +   special DN remapping ldb module
 +
@@ -193,11 +193,7 @@
 +  if (!ldb_dn_is_special(req-op.search.base))
 +  return ldb_next_request(module, req);
 +
-+  dn = un_remap_special_dn(module, req-op.search.base);
-+  if (dn == NULL)
-+  return LDB_ERR_OPERATIONS_ERROR;
 +
-+
 +  h = un_init_handle(req, module);
 +  if (!h) {
 +  talloc_free(dn);
@@ -225,8 +221,14 @@
 +  ldb_set_timeout_from_prev_req(module-ldb, req, ac-search_req);
 +
 +  /* adapt the message */
++  dn = un_remap_special_dn(ac-search_req, req-op.search.base);
++  if (dn == NULL) {
++talloc_free(ac-search_req);
++  return LDB_ERR_OPERATIONS_ERROR;
++}
++
 +  /* Is that enough or should I copy more members explicitly? */
-+  ac-search_req-op.search.base = talloc_steal(ac-search_req, dn);
++  ac-search_req-op.search.base = dn;
 +
 +  /* ac-step = UN_DO_SEARCH; */
 +
@@ -244,12 +246,6 @@
 +  if (!ldb_dn_is_special(req-op.add.message-dn))
 +  return ldb_next_request(module, req);
 +
-+  msg = un_msg_copy_with_dn(module, req-op.add.message,
-+un_remap_special_dn(module,
-+req-op.add.message-dn));
-+  if (msg == NULL)
-+  return LDB_ERR_OPERATIONS_ERROR;
-+
 +  h = un_init_handle(req, module);
 +  if (!h) {
 +  talloc_free(msg);
@@ -277,8 +273,16 @@
 +  ldb_set_timeout_from_prev_req(module-ldb, req, ac-down_req);
 +
 +  /* adapt the message */
-+  ac-down_req-op.add.message = talloc_steal(ac-down_req, msg);
++  msg = un_msg_copy_with_dn(ac-down_req, req-op.add.message,
++un_remap_special_dn(ac-down_req,
++req-op.add.message-dn));
++  if (msg == NULL) {
++talloc_free(ac-down_req);
++  return LDB_ERR_OPERATIONS_ERROR;
++}
 +
++  ac-down_req-op.add.message = msg;
++
 +  /* ac-step = UN_DO_REQ; */
 +
 +  return ldb_next_request(module, ac-down_req);
@@ -295,13 +299,6 @@
 +  if (!ldb_dn_is_special(req-op.mod.message-dn))
 +  return ldb_next_request(module, req);
 +
-+  msg = un_msg_copy_with_dn(module, req-op.mod.message,
-+un_remap_special_dn(module,
-+req-op.mod.message-dn));
-+  if (msg == NULL) {
-+  return LDB_ERR_OPERATIONS_ERROR;
-+  }
-+
 +  h = un_init_handle(req, module);
 +  if (!h) {
 +  talloc_free(msg);
@@ -329,8 +326,16 @@
 +  ldb_set_timeout_from_prev_req(module-ldb, req, ac-down_req);
 +
 +  /* adapt the message */
-+  ac-down_req-op.mod.message = talloc_steal(ac-down_req, msg);
++  msg = un_msg_copy_with_dn(ac-down_req, req-op.mod.message,
++un_remap_special_dn(ac-down_req,
++req-op.mod.message-dn));
++  if (msg == NULL) {
++talloc_free(ac-down_req);
++  return LDB_ERR_OPERATIONS_ERROR;
++  }
 +
++  ac-down_req-op.mod.message = msg;
++
 +  /* ac-step = UN_DO_REQ; */
 +
 +  return ldb_next_request(module, ac-down_req);



svn commit: samba r16259 - in branches/SOC/mkhl: .

2006-06-15 Thread mkhl
Author: mkhl
Date: 2006-06-15 14:55:40 + (Thu, 15 Jun 2006)
New Revision: 16259

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=revroot=sambarev=16259

Log:

Add tags from javascript source files to ctags/etags.
Add tags for javascript functions defined in C to etags (unsure
how this works for ctags).

Martin

Added:
   branches/SOC/mkhl/,,main.mk-tags-ejs-funcs.patch


Changeset:
Added: branches/SOC/mkhl/,,main.mk-tags-ejs-funcs.patch
===
--- branches/SOC/mkhl/,,main.mk-tags-ejs-funcs.patch2006-06-15 14:53:45 UTC 
(rev 16258)
+++ branches/SOC/mkhl/,,main.mk-tags-ejs-funcs.patch2006-06-15 14:55:40 UTC 
(rev 16259)
@@ -0,0 +1,18 @@
+Index: source/main.mk
+===
+--- source/main.mk (revision 16189)
 source/main.mk (working copy)
+@@ -174,10 +174,11 @@
+   ./config.status
+ 
+ etags:
+-  etags `find $(srcdir) -name *.[ch]`
++  etags 
--regex='/[[:space:]]*\(ejsDefineCFunction\|ejsDefineStringCFunction\)(-1, 
*\([^]+\)/\2/'  \
++  `find $(srcdir) -name *.[ch] -o -name *.js`
+ 
+ ctags:
+-  ctags `find $(srcdir) -name *.[ch]`
++  ctags `find $(srcdir) -name *.[ch] -o -name *.js`
+ 
+ pidl/Makefile: pidl/Makefile.PL
+   cd pidl  $(PERL) Makefile.PL 



  1   2   >