Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-trivial
authorJelmer Vernooij <jelmer@samba.org>
Thu, 24 Jan 2008 21:00:07 +0000 (22:00 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 24 Jan 2008 21:00:07 +0000 (22:00 +0100)
source/auth/credentials/config.mk
source/auth/credentials/credentials.i
source/auth/credentials/credentials.py
source/auth/credentials/credentials_wrap.c
source/auth/credentials/tests/bindings.py
source/scripting/python/samba/getopt.py
source/scripting/python/samba/provision.py

index 8d33bdbd554fa35cfdc2e51234f683d301b1d3b7..fee9519ae5b8893287d537c6b7c8a2fab6f3e005 100644 (file)
@@ -14,5 +14,5 @@ PRIVATE_DEPENDENCIES = \
                SECRETS
 
 [PYTHON::swig_credentials]
-PUBLIC_DEPENDENCIES = CREDENTIALS
+PUBLIC_DEPENDENCIES = CREDENTIALS LIBCMDLINE_CREDENTIALS
 SWIG_FILE = credentials.i
index fedb8bd1d754671321dc03848f0c0f803fa7d0f7..41ec67580e713365b6a97e3650a28374ac923083 100644 (file)
@@ -27,6 +27,7 @@
 #include "includes.h"
 #include "auth/credentials/credentials.h"
 #include "param/param.h"
+#include "lib/cmdline/credentials.h"
 typedef struct cli_credentials cli_credentials;
 %}
 
@@ -93,6 +94,8 @@ typedef struct cli_credentials {
         bool authentication_requested(void);
 
         bool wrong_password(void);
+
+        bool set_cmdline_callbacks();
     }
 } cli_credentials;
 
index 0d91526b8fd4e92fb79611eb9c5da18ac59fdc43..14526af9100274c20024e226b724dfdbbffd8528 100644 (file)
@@ -82,6 +82,7 @@ Credentials.is_anonymous = new_instancemethod(_credentials.Credentials_is_anonym
 Credentials.get_nt_hash = new_instancemethod(_credentials.Credentials_get_nt_hash,None,Credentials)
 Credentials.authentication_requested = new_instancemethod(_credentials.Credentials_authentication_requested,None,Credentials)
 Credentials.wrong_password = new_instancemethod(_credentials.Credentials_wrong_password,None,Credentials)
+Credentials.set_cmdline_callbacks = new_instancemethod(_credentials.Credentials_set_cmdline_callbacks,None,Credentials)
 Credentials_swigregister = _credentials.Credentials_swigregister
 Credentials_swigregister(Credentials)
 
index 849b28ebfffd2f456ac2880d35341021f9e8e07a..b1b904c8a3a68e6c0142931602b59a3d98704abd 100644 (file)
@@ -2521,6 +2521,7 @@ static swig_module_info swig_module = {swig_types, 16, 0, 0, 0, 0};
 #include "includes.h"
 #include "auth/credentials/credentials.h"
 #include "param/param.h"
+#include "lib/cmdline/credentials.h"
 typedef struct cli_credentials cli_credentials;
 
 
@@ -3486,6 +3487,34 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_Credentials_set_cmdline_callbacks(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+  PyObject *resultobj = 0;
+  cli_credentials *arg1 = (cli_credentials *) 0 ;
+  bool result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  char *  kwnames[] = {
+    (char *) "self", NULL 
+  };
+  
+  arg1 = NULL;
+  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_set_cmdline_callbacks",kwnames,&obj0)) SWIG_fail;
+  if (obj0) {
+    res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Credentials_set_cmdline_callbacks" "', argument " "1"" of type '" "cli_credentials *""'"); 
+    }
+    arg1 = (cli_credentials *)(argp1);
+  }
+  result = (bool)cli_credentials_set_cmdline_callbacks(arg1);
+  resultobj = SWIG_From_bool((bool)(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_delete_Credentials(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
   PyObject *resultobj = 0;
   cli_credentials *arg1 = (cli_credentials *) 0 ;
@@ -3545,6 +3574,7 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"Credentials_get_nt_hash", (PyCFunction) _wrap_Credentials_get_nt_hash, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Credentials_authentication_requested", (PyCFunction) _wrap_Credentials_authentication_requested, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Credentials_wrong_password", (PyCFunction) _wrap_Credentials_wrong_password, METH_VARARGS | METH_KEYWORDS, NULL},
+        { (char *)"Credentials_set_cmdline_callbacks", (PyCFunction) _wrap_Credentials_set_cmdline_callbacks, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"delete_Credentials", (PyCFunction) _wrap_delete_Credentials, METH_VARARGS | METH_KEYWORDS, NULL},
         { (char *)"Credentials_swigregister", Credentials_swigregister, METH_VARARGS, NULL},
         { (char *)"Credentials_swiginit", Credentials_swiginit, METH_VARARGS, NULL},
index 8312e77e9ea716eb838f0f3d9ffbccd29644e5e8..d2ca68d11578276b4b75df0375e5b4b0859c596a 100644 (file)
@@ -83,6 +83,9 @@ class CredentialsTests(unittest.TestCase):
         # Just check the method is there and doesn't raise an exception
         self.creds.guess()
 
+    def test_set_cmdline_callbacks(self):
+        self.creds.set_cmdline_callbacks()
+
     def test_authentication_requested(self):
         self.creds.set_username("")
         self.assertFalse(self.creds.authentication_requested())
index dfcf2c457e8bc278ea8343a0f3b75517e6592523..088a5acf6fc84f5fe48c58880499a4b2eb083169 100644 (file)
@@ -50,6 +50,7 @@ class VersionOptions(optparse.OptionGroup):
 
 class CredentialsOptions(optparse.OptionGroup):
     def __init__(self, parser):
+        self.no_pass = False
         optparse.OptionGroup.__init__(self, parser, "Credentials Options")
         self.add_option("--simple-bind-dn", metavar="DN", action="callback",
                         callback=self._set_simple_bind_dn, type=str,
@@ -62,6 +63,8 @@ class CredentialsOptions(optparse.OptionGroup):
         self.add_option("-W", "--workgroup", metavar="WORKGROUP", 
                         action="callback", type=str,
                         help="Workgroup", callback=self._parse_workgroup)
+        self.add_option("-N", "--no-pass", action="store_true",
+                        help="Don't ask for a password")
         self.creds = Credentials()
 
     def _parse_username(self, option, opt_str, arg, parser):
@@ -77,4 +80,7 @@ class CredentialsOptions(optparse.OptionGroup):
         self.creds.set_bind_dn(arg)
 
     def get_credentials(self):
+        self.creds.guess()
+        if not self.no_pass:
+            self.creds.set_cmdline_callbacks()
         return self.creds
index d59cea121e8b0e4c0467867bd1d4e4eed110c1f2..11dd819ad3a57a78765a81d6171bae743760a305 100644 (file)
@@ -289,6 +289,14 @@ def provision_become_dc(setup_dir, message, paths, lp, session_info,
 
 
 def setup_secretsdb(path, setup_path, session_info, credentials, lp):
+    """Setup the secrets database.
+
+    :param path: Path to the secrets database.
+    :param setup_path: Get the path to a setup file.
+    :param session_info: Session info.
+    :param credentials: Credentials
+    :param lp: Loadparm context
+    """
     if os.path.exists(path):
         os.unlink(path)
     secrets_ldb = Ldb(path, session_info=session_info, credentials=credentials, lp=lp)
@@ -299,6 +307,14 @@ def setup_secretsdb(path, setup_path, session_info, credentials, lp):
 
 
 def setup_templatesdb(path, setup_path, session_info, credentials, lp):
+    """Setup the templates database.
+
+    :param path: Path to the database.
+    :param setup_path: Function for obtaining the path to setup files.
+    :param session_info: Session info
+    :param credentials: Credentials
+    :param lp: Loadparm context
+    """
     templates_ldb = SamDB(path, session_info=session_info,
                         credentials=credentials, lp=lp)
     templates_ldb.erase()
@@ -306,6 +322,14 @@ def setup_templatesdb(path, setup_path, session_info, credentials, lp):
 
 
 def setup_registry(path, setup_path, session_info, credentials, lp):
+    """Setup the registry.
+    
+    :param path: Path to the registry database
+    :param setup_path: Function that returns the path to a setup.
+    :param session_info: Session information
+    :param credentials: Credentials
+    :param lp: Loadparm context
+    """
     reg = registry.Registry()
     hive = registry.open_ldb(path, session_info=session_info, 
                          credentials=credentials, lp_ctx=lp)
@@ -317,6 +341,12 @@ def setup_registry(path, setup_path, session_info, credentials, lp):
 
 def setup_samdb_rootdse(samdb, setup_path, schemadn, domaindn, hostname, 
                         dnsdomain, realm, rootdn, configdn, netbiosname):
+    """Setup the SamDB rootdse.
+
+    :param samdb: Sam Database handle
+    :param setup_path: Obtain setup path
+    ...
+    """
     setup_add_ldif(samdb, setup_path("provision_rootdse_add.ldif"), {
         "SCHEMADN": schemadn, 
         "NETBIOSNAME": netbiosname,
@@ -332,6 +362,14 @@ def setup_samdb_rootdse(samdb, setup_path, schemadn, domaindn, hostname,
 
 
 def setup_samdb_partitions(samdb, setup_path, schemadn, configdn, domaindn):
+    """Setup SAM database partitions.
+
+    :param samdb: Sam Database handle
+    :param setup_path: Setup path function
+    :param schemadn: Schema DN.
+    :param configdn: Configuration DN.
+    :param domaindn: Domain DN.
+    """
     #Add modules to the list to activate them by default
     #beware often order is important
     #
@@ -561,11 +599,14 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
 
             if lp.get("server role") == "domain controller":
                 message("Setting up self join")
-                setup_self_join(samdb, configdn=configdn, schemadn=schemadn, domaindn=domaindn, 
-                                invocationid=invocationid, dnspass=dnspass, netbiosname=netbiosname,
-                                dnsdomain=dnsdomain, realm=realm, machinepass=machinepass, 
-                                domainname=domainname, domainsid=domainsid, policyguid=policyguid,
-                                hostname=hostname, hostguid=hostguid, setup_path=setup_path)
+                setup_self_join(samdb, configdn=configdn, schemadn=schemadn, 
+                                domaindn=domaindn, invocationid=invocationid, 
+                                dnspass=dnspass, netbiosname=netbiosname, 
+                                dnsdomain=dnsdomain, realm=realm, 
+                                machinepass=machinepass, domainname=domainname, 
+                                domainsid=domainsid, policyguid=policyguid,
+                                hostname=hostname, hostguid=hostguid, 
+                                setup_path=setup_path)
 
         message("Setting up sam.ldb index")
         samdb.load_ldif_file_add(setup_path("provision_index.ldif"))