svn commit: samba r26475 - in branches/SAMBA_4_0: . source/lib/ldb source/scripting/python source/scripting/python/samba source/setup

jelmer at samba.org jelmer at samba.org
Sun Dec 16 15:50:04 GMT 2007


Author: jelmer
Date: 2007-12-16 15:50:02 +0000 (Sun, 16 Dec 2007)
New Revision: 26475

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

Log:
Add ldb.set_credentials function.
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/lib/ldb/ldb.i
   branches/SAMBA_4_0/source/scripting/python/misc.i
   branches/SAMBA_4_0/source/scripting/python/misc.py
   branches/SAMBA_4_0/source/scripting/python/misc_wrap.c
   branches/SAMBA_4_0/source/scripting/python/samba/__init__.py
   branches/SAMBA_4_0/source/setup/provision.py
   branches/SAMBA_4_0/source/setup/upgrade.py


Changeset:

Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb.i
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb.i	2007-12-16 15:33:58 UTC (rev 26474)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb.i	2007-12-16 15:50:02 UTC (rev 26475)
@@ -25,7 +25,7 @@
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
-%module(package="ldb") ldb
+%module ldb
 
 %{
 

Modified: branches/SAMBA_4_0/source/scripting/python/misc.i
===================================================================
--- branches/SAMBA_4_0/source/scripting/python/misc.i	2007-12-16 15:33:58 UTC (rev 26474)
+++ branches/SAMBA_4_0/source/scripting/python/misc.i	2007-12-16 15:50:02 UTC (rev 26475)
@@ -21,12 +21,20 @@
 %{
 #include "includes.h"
 #include "ldb.h"
-#include "auth/credentials/credentials.h"
 %}
 
 %import "stdint.i"
+%include "exception.i"
 %import "../../lib/talloc/talloc.i"
+%import "../../lib/ldb/ldb.i"
+%import "../../auth/credentials/credentials.i"
 
 %rename(random_password) generate_random_str;
 char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len);
 
+%inline %{
+void ldb_set_credentials(struct ldb_context *ldb, struct cli_credentials *creds)
+{
+    ldb_set_opaque(ldb, "credentials", creds);
+}
+%}

Modified: branches/SAMBA_4_0/source/scripting/python/misc.py
===================================================================
--- branches/SAMBA_4_0/source/scripting/python/misc.py	2007-12-16 15:33:58 UTC (rev 26474)
+++ branches/SAMBA_4_0/source/scripting/python/misc.py	2007-12-16 15:50:02 UTC (rev 26475)
@@ -57,6 +57,10 @@
     return set_attr
 
 
+import ldb
+import credentials
+import param
 random_password = _misc.random_password
+ldb_set_credentials = _misc.ldb_set_credentials
 
 

Modified: branches/SAMBA_4_0/source/scripting/python/misc_wrap.c
===================================================================
--- branches/SAMBA_4_0/source/scripting/python/misc_wrap.c	2007-12-16 15:33:58 UTC (rev 26474)
+++ branches/SAMBA_4_0/source/scripting/python/misc_wrap.c	2007-12-16 15:50:02 UTC (rev 26475)
@@ -2454,20 +2454,35 @@
 
 
 
+  #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) 
+
+
 /* -------- TYPES TABLE (BEGIN) -------- */
 
 #define SWIGTYPE_p_TALLOC_CTX swig_types[0]
 #define SWIGTYPE_p_char swig_types[1]
-#define SWIGTYPE_p_int swig_types[2]
-#define SWIGTYPE_p_long_long swig_types[3]
-#define SWIGTYPE_p_short swig_types[4]
-#define SWIGTYPE_p_signed_char swig_types[5]
-#define SWIGTYPE_p_unsigned_char swig_types[6]
-#define SWIGTYPE_p_unsigned_int swig_types[7]
-#define SWIGTYPE_p_unsigned_long_long swig_types[8]
-#define SWIGTYPE_p_unsigned_short swig_types[9]
-static swig_type_info *swig_types[11];
-static swig_module_info swig_module = {swig_types, 10, 0, 0, 0, 0};
+#define SWIGTYPE_p_cli_credentials swig_types[2]
+#define SWIGTYPE_p_int swig_types[3]
+#define SWIGTYPE_p_ldb_context swig_types[4]
+#define SWIGTYPE_p_ldb_dn swig_types[5]
+#define SWIGTYPE_p_ldb_ldif swig_types[6]
+#define SWIGTYPE_p_ldb_message swig_types[7]
+#define SWIGTYPE_p_ldb_message_element swig_types[8]
+#define SWIGTYPE_p_ldb_result swig_types[9]
+#define SWIGTYPE_p_loadparm_context swig_types[10]
+#define SWIGTYPE_p_loadparm_service swig_types[11]
+#define SWIGTYPE_p_long_long swig_types[12]
+#define SWIGTYPE_p_param_context swig_types[13]
+#define SWIGTYPE_p_param_section swig_types[14]
+#define SWIGTYPE_p_short swig_types[15]
+#define SWIGTYPE_p_signed_char swig_types[16]
+#define SWIGTYPE_p_unsigned_char swig_types[17]
+#define SWIGTYPE_p_unsigned_int swig_types[18]
+#define SWIGTYPE_p_unsigned_long swig_types[19]
+#define SWIGTYPE_p_unsigned_long_long swig_types[20]
+#define SWIGTYPE_p_unsigned_short swig_types[21]
+static swig_type_info *swig_types[23];
+static swig_module_info swig_module = {swig_types, 22, 0, 0, 0, 0};
 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
@@ -2509,7 +2524,6 @@
 
 #include "includes.h"
 #include "ldb.h"
-#include "auth/credentials/credentials.h"
 
 
 SWIGINTERN int
@@ -2682,6 +2696,12 @@
   return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
 }
 
+
+void ldb_set_credentials(struct ldb_context *ldb, struct cli_credentials *creds)
+{
+    ldb_set_opaque(ldb, "credentials", creds);
+}
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -2714,8 +2734,52 @@
 }
 
 
+SWIGINTERN PyObject *_wrap_ldb_set_credentials(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+  PyObject *resultobj = 0;
+  struct ldb_context *arg1 = (struct ldb_context *) 0 ;
+  struct cli_credentials *arg2 = (struct cli_credentials *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  char *  kwnames[] = {
+    (char *) "Ldb",(char *) "creds", NULL 
+  };
+  
+  {
+    arg2 = NULL;
+  }
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:ldb_set_credentials",kwnames,&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_set_credentials" "', argument " "1"" of type '" "struct ldb_context *""'"); 
+  }
+  arg1 = (struct ldb_context *)(argp1);
+  if (obj1) {
+    res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_cli_credentials, 0 |  0 );
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_set_credentials" "', argument " "2"" of type '" "struct cli_credentials *""'"); 
+    }
+    arg2 = (struct cli_credentials *)(argp2);
+  }
+  {
+    if (arg1 == NULL)
+    SWIG_exception(SWIG_ValueError, 
+      "ldb context must be non-NULL");
+  }
+  ldb_set_credentials(arg1,arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 static PyMethodDef SwigMethods[] = {
 	 { (char *)"random_password", (PyCFunction) _wrap_random_password, METH_VARARGS | METH_KEYWORDS, NULL},
+	 { (char *)"ldb_set_credentials", (PyCFunction) _wrap_ldb_set_credentials, METH_VARARGS | METH_KEYWORDS, NULL},
 	 { NULL, NULL, 0, NULL }
 };
 
@@ -2724,48 +2788,96 @@
 
 static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_cli_credentials = {"_p_cli_credentials", "struct cli_credentials *|cli_credentials *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_ldb_context = {"_p_ldb_context", "struct ldb_context *|ldb *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_ldb_dn = {"_p_ldb_dn", "struct ldb_dn *|ldb_dn *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_ldb_ldif = {"_p_ldb_ldif", "struct ldb_ldif *|ldb_ldif *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_ldb_message = {"_p_ldb_message", "ldb_msg *|struct ldb_message *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_msg_element *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_ldb_result = {"_p_ldb_result", "struct ldb_result *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_context = {"_p_param_context", "struct param_context *|param *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_section = {"_p_param_section", "struct param_section *|param_section *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_long = {"_p_unsigned_long", "unsigned long *|time_t *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0};
 
 static swig_type_info *swig_type_initial[] = {
   &_swigt__p_TALLOC_CTX,
   &_swigt__p_char,
+  &_swigt__p_cli_credentials,
   &_swigt__p_int,
+  &_swigt__p_ldb_context,
+  &_swigt__p_ldb_dn,
+  &_swigt__p_ldb_ldif,
+  &_swigt__p_ldb_message,
+  &_swigt__p_ldb_message_element,
+  &_swigt__p_ldb_result,
+  &_swigt__p_loadparm_context,
+  &_swigt__p_loadparm_service,
   &_swigt__p_long_long,
+  &_swigt__p_param_context,
+  &_swigt__p_param_section,
   &_swigt__p_short,
   &_swigt__p_signed_char,
   &_swigt__p_unsigned_char,
   &_swigt__p_unsigned_int,
+  &_swigt__p_unsigned_long,
   &_swigt__p_unsigned_long_long,
   &_swigt__p_unsigned_short,
 };
 
 static swig_cast_info _swigc__p_TALLOC_CTX[] = {  {&_swigt__p_TALLOC_CTX, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_cli_credentials[] = {  {&_swigt__p_cli_credentials, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_int[] = {  {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_ldb_context[] = {  {&_swigt__p_ldb_context, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_ldb_dn[] = {  {&_swigt__p_ldb_dn, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_ldb_ldif[] = {  {&_swigt__p_ldb_ldif, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_ldb_message[] = {  {&_swigt__p_ldb_message, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_ldb_message_element[] = {  {&_swigt__p_ldb_message_element, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_ldb_result[] = {  {&_swigt__p_ldb_result, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_loadparm_context[] = {  {&_swigt__p_loadparm_context, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_loadparm_service[] = {  {&_swigt__p_loadparm_service, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_long_long[] = {  {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_context[] = {  {&_swigt__p_param_context, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_section[] = {  {&_swigt__p_param_section, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_short[] = {  {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_signed_char[] = {  {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_unsigned_char[] = {  {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_unsigned_int[] = {  {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_long[] = {  {&_swigt__p_unsigned_long, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_unsigned_long_long[] = {  {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_unsigned_short[] = {  {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}};
 
 static swig_cast_info *swig_cast_initial[] = {
   _swigc__p_TALLOC_CTX,
   _swigc__p_char,
+  _swigc__p_cli_credentials,
   _swigc__p_int,
+  _swigc__p_ldb_context,
+  _swigc__p_ldb_dn,
+  _swigc__p_ldb_ldif,
+  _swigc__p_ldb_message,
+  _swigc__p_ldb_message_element,
+  _swigc__p_ldb_result,
+  _swigc__p_loadparm_context,
+  _swigc__p_loadparm_service,
   _swigc__p_long_long,
+  _swigc__p_param_context,
+  _swigc__p_param_section,
   _swigc__p_short,
   _swigc__p_signed_char,
   _swigc__p_unsigned_char,
   _swigc__p_unsigned_int,
+  _swigc__p_unsigned_long,
   _swigc__p_unsigned_long_long,
   _swigc__p_unsigned_short,
 };

Modified: branches/SAMBA_4_0/source/scripting/python/samba/__init__.py
===================================================================
--- branches/SAMBA_4_0/source/scripting/python/samba/__init__.py	2007-12-16 15:33:58 UTC (rev 26474)
+++ branches/SAMBA_4_0/source/scripting/python/samba/__init__.py	2007-12-16 15:50:02 UTC (rev 26475)
@@ -19,10 +19,9 @@
 #
 
 import os
-from misc import ldb_set_credentials
 
 def _in_source_tree():
-    print os.path.exists("%s/../../../samba4-skip" % os.path.dirname(__file__))
+    return os.path.exists("%s/../../../samba4-skip" % os.path.dirname(__file__))
 
 # When running, in-tree, make sure bin/python is in the PYTHONPATH
 if _in_source_tree():
@@ -30,6 +29,10 @@
     dir = os.path.dirname(__file__)
     sys.path.append("%s/../../../bin/python" % os.path.dirname(__file__))
 
+import misc
+import ldb
+ldb.ldb.set_credentials = misc.ldb_set_credentials
+
 def Ldb(url, session_info=None, credentials=None, modules_dir=None):
     """Open a Samba Ldb file. 
 

Modified: branches/SAMBA_4_0/source/setup/provision.py
===================================================================
--- branches/SAMBA_4_0/source/setup/provision.py	2007-12-16 15:33:58 UTC (rev 26474)
+++ branches/SAMBA_4_0/source/setup/provision.py	2007-12-16 15:50:02 UTC (rev 26475)
@@ -24,15 +24,16 @@
 import sys
 
 # Add path to the library for in-tree use
-sys.path.append("bin/python")
 sys.path.append("scripting/python")
 
+import samba
+
 from auth import system_session
 import samba.getopt as options
 import param
 from samba.provision import (provision, provision_guess, 
-		                     provision_default_paths, provision_ldapbase, 
-							 provision_dns)
+                             provision_default_paths, provision_ldapbase, 
+                             provision_dns)
 
 parser = optparse.OptionParser("provision [options]")
 parser.add_option_group(options.SambaOptions(parser))

Modified: branches/SAMBA_4_0/source/setup/upgrade.py
===================================================================
--- branches/SAMBA_4_0/source/setup/upgrade.py	2007-12-16 15:33:58 UTC (rev 26474)
+++ branches/SAMBA_4_0/source/setup/upgrade.py	2007-12-16 15:50:02 UTC (rev 26475)
@@ -6,7 +6,10 @@
 #
 import getopt
 import optparse
-import samba.options
+import sys
+sys.path.append("scripting/python")
+import samba
+import samba.getopt
 
 parser = optparse.OptionParser("upgrade [options]")
 parser.add_option_group(options.SambaOptions(parser))
@@ -20,10 +23,12 @@
 parser.add_option("--targetdir", type="string", metavar="DIR", 
 		          help="Set target directory")
 
+opts = parser.parse_args()[0]
+
 def message(text):
     """Print a message if quiet is not set."""
-	if opts.quiet:
-		print text
+    if opts.quiet:
+        print text
 
 message("Reading Samba3 databases and smb.conf\n")
 samba3 = samba3_read(options.ARGV[0], options.ARGV[1])



More information about the samba-cvs mailing list