summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-16 15:50:02 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:50:35 +0100
commit0a01f50f9802ecfae430d2218af3b96a3682218d (patch)
tree853f59e877f3433cdfaafc94ce5eae140ead38e4
parent1afe0549163bbc639ae1a030239c9ebcd1b922bf (diff)
downloadsamba-0a01f50f9802ecfae430d2218af3b96a3682218d.tar.gz
samba-0a01f50f9802ecfae430d2218af3b96a3682218d.tar.bz2
samba-0a01f50f9802ecfae430d2218af3b96a3682218d.zip
r26475: Add ldb.set_credentials function.
(This used to be commit dbebb4ef477d2c8de7b8d1e5cde9b9dada47044f)
-rw-r--r--source4/lib/ldb/ldb.i2
-rw-r--r--source4/scripting/python/misc.i10
-rw-r--r--source4/scripting/python/misc.py4
-rw-r--r--source4/scripting/python/misc_wrap.c134
-rw-r--r--source4/scripting/python/samba/__init__.py7
-rwxr-xr-xsource4/setup/provision.py7
-rwxr-xr-xsource4/setup/upgrade.py11
7 files changed, 154 insertions, 21 deletions
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index aec4e2294f..364b07ce34 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -25,7 +25,7 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-%module(package="ldb") ldb
+%module ldb
%{
diff --git a/source4/scripting/python/misc.i b/source4/scripting/python/misc.i
index 088522320e..3d886a25bc 100644
--- a/source4/scripting/python/misc.i
+++ b/source4/scripting/python/misc.i
@@ -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);
+}
+%}
diff --git a/source4/scripting/python/misc.py b/source4/scripting/python/misc.py
index afe7b723e0..94b341ba72 100644
--- a/source4/scripting/python/misc.py
+++ b/source4/scripting/python/misc.py
@@ -57,6 +57,10 @@ def _swig_setattr_nondynamic_method(set):
return set_attr
+import ldb
+import credentials
+import param
random_password = _misc.random_password
+ldb_set_credentials = _misc.ldb_set_credentials
diff --git a/source4/scripting/python/misc_wrap.c b/source4/scripting/python/misc_wrap.c
index fbdd33afda..1f34d7f3ac 100644
--- a/source4/scripting/python/misc_wrap.c
+++ b/source4/scripting/python/misc_wrap.c
@@ -2454,20 +2454,35 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
+ #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 @@ static swig_module_info swig_module = {swig_types, 10, 0, 0, 0, 0};
#include "includes.h"
#include "ldb.h"
-#include "auth/credentials/credentials.h"
SWIGINTERN int
@@ -2682,6 +2696,12 @@ SWIG_FromCharPtr(const char *cptr)
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 @@ fail:
}
+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 PyMethodDef SwigMethods[] = {
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,
};
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index 2c51440b0c..29d322e2fc 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -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 @@ if _in_source_tree():
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.
diff --git a/source4/setup/provision.py b/source4/setup/provision.py
index 38312f2946..71360cecc8 100755
--- a/source4/setup/provision.py
+++ b/source4/setup/provision.py
@@ -24,15 +24,16 @@ import optparse
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))
diff --git a/source4/setup/upgrade.py b/source4/setup/upgrade.py
index e5e6d2c832..96584a1026 100755
--- a/source4/setup/upgrade.py
+++ b/source4/setup/upgrade.py
@@ -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("--blank",
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])