Author: jelmer Date: 2007-11-19 18:20:16 +0000 (Mon, 19 Nov 2007) New Revision: 26030
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26030 Log: Add initial python bindings for the credentials code. Added: branches/4.0-python/source/auth/credentials/credentials.i branches/4.0-python/source/auth/credentials/tests/bindings.py branches/4.0-python/source/lib/registry/registry.i Modified: branches/4.0-python/ branches/4.0-python/source/auth/credentials/config.mk branches/4.0-python/source/lib/ldb/swig/ldb.i branches/4.0-python/source/lib/registry/config.mk branches/4.0-python/source/lib/registry/hive.h branches/4.0-python/source/setup/provision Changeset: Property changes on: branches/4.0-python ___________________________________________________________________ Name: bzr:revision-info ...skipped... Name: bzr:file-ids ...skipped... Name: bzr:revision-id:v3-trunk0 ...skipped... Modified: branches/4.0-python/source/auth/credentials/config.mk =================================================================== --- branches/4.0-python/source/auth/credentials/config.mk 2007-11-19 15:01:03 UTC (rev 26029) +++ branches/4.0-python/source/auth/credentials/config.mk 2007-11-19 18:20:16 UTC (rev 26030) @@ -11,4 +11,7 @@ KERBEROS_CORE \ LIBCLI_AUTH \ LIBEVENTS -#KERBEROS + +[PYTHON::swig_credentials] +PUBLIC_DEPENDENCIES = CREDENTIALS LIBPYTHON +SWIG_FILE = credentials.i Added: branches/4.0-python/source/auth/credentials/credentials.i =================================================================== --- branches/4.0-python/source/auth/credentials/credentials.i 2007-11-19 15:01:03 UTC (rev 26029) +++ branches/4.0-python/source/auth/credentials/credentials.i 2007-11-19 18:20:16 UTC (rev 26030) @@ -0,0 +1,53 @@ +/* + Unix SMB/CIFS implementation. + Copyright (C) Jelmer Vernooij <[EMAIL PROTECTED]> 2007 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +%module credentials + +%{ + +/* Include headers */ +#include <stdint.h> +#include <stdbool.h> + +#include "includes.h" +#include "credentials.h" +typedef struct cli_credentials cli_credentials; +%} + +%include "carrays.i" +%include "typemaps.i" + +%rename(Credentials) cli_credentials; +typedef struct cli_credentials { + %extend { + cli_credentials() { + return cli_credentials_init(NULL); + } + ~cli_credentials() { + talloc_free($self); + } + bool set_username(const char *value, + enum credentials_obtained=CRED_SPECIFIED); + bool set_password(const char *val, + enum credentials_obtained=CRED_SPECIFIED); + bool set_domain(const char *val, + enum credentials_obtained=CRED_SPECIFIED); + bool set_realm(const char *val, + enum credentials_obtained=CRED_SPECIFIED); + } +} cli_credentials; Added: branches/4.0-python/source/auth/credentials/tests/bindings.py =================================================================== --- branches/4.0-python/source/auth/credentials/tests/bindings.py 2007-11-19 15:01:03 UTC (rev 26029) +++ branches/4.0-python/source/auth/credentials/tests/bindings.py 2007-11-19 18:20:16 UTC (rev 26030) @@ -0,0 +1,37 @@ +#!/usr/bin/python + +# Unix SMB/CIFS implementation. +# Copyright (C) Jelmer Vernooij <[EMAIL PROTECTED]> 2007 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import unittest +import credentials + +class CredentialsTests(unittest.TestCase): + def setUp(self): + self.creds = credentials.Credentials() + + def test_set_username(self): + self.creds.set_username("somebody") + + def test_set_password(self): + self.creds.set_password("S3CreT") + + def test_set_domain(self): + self.creds.set_domain("ABMAS") + + def test_set_realm(self): + self.creds.set_realm("myrealm") Modified: branches/4.0-python/source/lib/ldb/swig/ldb.i =================================================================== --- branches/4.0-python/source/lib/ldb/swig/ldb.i 2007-11-19 15:01:03 UTC (rev 26029) +++ branches/4.0-python/source/lib/ldb/swig/ldb.i 2007-11-19 18:20:16 UTC (rev 26030) @@ -29,14 +29,9 @@ %{ -/* Some typedefs to help swig along */ - -typedef unsigned char uint8_t; -typedef unsigned long long uint64_t; -typedef long long int64_t; - /* Include headers */ +#include <stdint.h> #include <stdbool.h> #include "talloc.h" #include "ldb.h" Modified: branches/4.0-python/source/lib/registry/config.mk =================================================================== --- branches/4.0-python/source/lib/registry/config.mk 2007-11-19 15:01:03 UTC (rev 26029) +++ branches/4.0-python/source/lib/registry/config.mk 2007-11-19 18:20:16 UTC (rev 26030) @@ -100,3 +100,8 @@ tests/hive.o \ tests/diff.o \ tests/registry.o + +[PYTHON::swig_registry] +PUBLIC_DEPENDENCIES = registry LIBPYTHON +SWIG_FILE = registry.i + Modified: branches/4.0-python/source/lib/registry/hive.h =================================================================== --- branches/4.0-python/source/lib/registry/hive.h 2007-11-19 15:01:03 UTC (rev 26029) +++ branches/4.0-python/source/lib/registry/hive.h 2007-11-19 18:20:16 UTC (rev 26030) @@ -22,6 +22,7 @@ #define __REGISTRY_HIVE_H__ #include <talloc.h> +#include "libcli/util/werror.h" #include "librpc/gen_ndr/security.h" #include "libcli/util/ntstatus.h" Added: branches/4.0-python/source/lib/registry/registry.i =================================================================== --- branches/4.0-python/source/lib/registry/registry.i 2007-11-19 15:01:03 UTC (rev 26029) +++ branches/4.0-python/source/lib/registry/registry.i 2007-11-19 18:20:16 UTC (rev 26030) @@ -0,0 +1,39 @@ +/* + Unix SMB/CIFS implementation. + Copyright (C) Jelmer Vernooij <[EMAIL PROTECTED]> 2007 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +%module registry + +%{ + +/* Include headers */ +#include <stdint.h> +#include <stdbool.h> + +#include "includes.h" +#include "registry.h" +%} + +WERROR reg_open_local(TALLOC_CTX *mem_ctx, + struct registry_context **ctx, + struct auth_session_info *session_info, + struct cli_credentials *credentials); + +WERROR reg_open_samba(TALLOC_CTX *mem_ctx, + struct registry_context **ctx, + struct auth_session_info *session_info, + struct cli_credentials *credentials); Modified: branches/4.0-python/source/setup/provision =================================================================== --- branches/4.0-python/source/setup/provision 2007-11-19 15:01:03 UTC (rev 26029) +++ branches/4.0-python/source/setup/provision 2007-11-19 18:20:16 UTC (rev 26030) @@ -27,7 +27,7 @@ sys.path.append("scripting/python") sys.path.append("lib/ldb/swig") -from credentials import system_session +from samba.credentials import system_session import samba.getopt as options import param from samba.provision import (provision, provision_guess,
