2008-02-15 01:28:31 +03:00
/*
Unix SMB / CIFS implementation .
Samba utility functions
Copyright ( C ) Jelmer Vernooij < jelmer @ samba . org > 2008
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/>.
*/
# include "includes.h"
2008-02-15 02:23:56 +03:00
# include "auth/auth.h"
2008-02-15 03:16:12 +03:00
# include "lib/ldb_wrap.h"
2008-03-28 11:40:08 +03:00
# include "torture/torture.h"
# include "libcli/raw/libcliraw.h"
2008-02-15 17:53:06 +03:00
# include "torture/util.h"
2008-02-15 01:28:31 +03:00
# include "param/param.h"
# include <Python.h>
# include "scripting/python/modules.h"
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
NTSTATUS provision_bare ( TALLOC_CTX * mem_ctx , struct loadparm_context * lp_ctx ,
2008-03-28 11:40:08 +03:00
struct provision_settings * settings )
2008-02-15 01:28:31 +03:00
{
2008-02-15 04:12:37 +03:00
PyObject * provision_mod , * provision_dict , * provision_fn , * result , * parameters ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
2008-02-15 17:14:55 +03:00
DEBUG ( 0 , ( " Provision for Become-DC test using python \n " ) ) ;
2008-02-15 01:28:31 +03:00
py_load_samba_modules ( ) ;
Py_Initialize ( ) ;
2008-02-15 04:12:37 +03:00
py_update_path ( " bin " ) ; /* FIXME: Can't assume this is always the case */
2008-02-15 01:28:31 +03:00
2008-02-15 04:12:37 +03:00
provision_mod = PyImport_Import ( PyString_FromString ( " samba.provision " ) ) ;
2008-02-15 01:28:31 +03:00
2008-02-15 04:12:37 +03:00
if ( provision_mod = = NULL ) {
PyErr_Print ( ) ;
2008-02-15 01:28:31 +03:00
DEBUG ( 0 , ( " Unable to import provision Python module. \n " ) ) ;
return NT_STATUS_UNSUCCESSFUL ;
}
2008-02-15 04:12:37 +03:00
provision_dict = PyModule_GetDict ( provision_mod ) ;
if ( provision_dict = = NULL ) {
DEBUG ( 0 , ( " Unable to get dictionary for provision module \n " ) ) ;
return NT_STATUS_UNSUCCESSFUL ;
}
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
provision_fn = PyDict_GetItemString ( provision_dict , " provision_become_dc " ) ;
2008-02-15 04:12:37 +03:00
if ( provision_fn = = NULL ) {
PyErr_Print ( ) ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
DEBUG ( 0 , ( " Unable to get provision_become_dc function \n " ) ) ;
2008-02-15 04:12:37 +03:00
return NT_STATUS_UNSUCCESSFUL ;
}
2008-02-15 01:28:31 +03:00
2008-02-15 17:14:55 +03:00
DEBUG ( 0 , ( " New Server[%s] in Site[%s] \n " , settings - > dns_name ,
settings - > site_name ) ) ;
2008-02-15 01:28:31 +03:00
DEBUG ( 0 , ( " DSA Instance [%s] \n "
" \t objectGUID[%s] \n "
" \t invocationId[%s] \n " ,
2008-02-15 17:14:55 +03:00
settings - > ntds_dn_str ,
settings - > ntds_guid = = NULL ? " None " : GUID_string ( mem_ctx , settings - > ntds_guid ) ,
settings - > invocation_id = = NULL ? " None " : GUID_string ( mem_ctx , settings - > invocation_id ) ) ) ;
2008-02-15 01:28:31 +03:00
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
DEBUG ( 0 , ( " Pathes under targetdir[%s] \n " ,
settings - > targetdir ) ) ;
2008-02-15 01:28:31 +03:00
parameters = PyDict_New ( ) ;
2008-02-15 17:14:55 +03:00
PyDict_SetItemString ( parameters , " rootdn " ,
PyString_FromString ( settings - > root_dn_str ) ) ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
if ( settings - > targetdir ! = NULL )
PyDict_SetItemString ( parameters , " targetdir " ,
PyString_FromString ( settings - > targetdir ) ) ;
PyDict_SetItemString ( parameters , " setup_dir " ,
PyString_FromString ( " setup " ) ) ;
2008-02-15 17:14:55 +03:00
PyDict_SetItemString ( parameters , " hostname " ,
PyString_FromString ( settings - > netbios_name ) ) ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
PyDict_SetItemString ( parameters , " domain " ,
PyString_FromString ( settings - > domain ) ) ;
PyDict_SetItemString ( parameters , " realm " ,
PyString_FromString ( settings - > realm ) ) ;
if ( settings - > root_dn_str )
PyDict_SetItemString ( parameters , " rootdn " ,
PyString_FromString ( settings - > root_dn_str ) ) ;
if ( settings - > domain_dn_str )
PyDict_SetItemString ( parameters , " domaindn " ,
PyString_FromString ( settings - > domain_dn_str ) ) ;
if ( settings - > schema_dn_str )
PyDict_SetItemString ( parameters , " schemadn " ,
PyString_FromString ( settings - > schema_dn_str ) ) ;
if ( settings - > config_dn_str )
PyDict_SetItemString ( parameters , " configdn " ,
PyString_FromString ( settings - > config_dn_str ) ) ;
if ( settings - > site_name )
PyDict_SetItemString ( parameters , " sitename " ,
PyString_FromString ( settings - > site_name ) ) ;
2008-02-15 17:14:55 +03:00
PyDict_SetItemString ( parameters , " machinepass " ,
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
PyString_FromString ( settings - > machine_password ) ) ;
2008-02-15 01:28:31 +03:00
result = PyEval_CallObjectWithKeywords ( provision_fn , NULL , parameters ) ;
Py_DECREF ( parameters ) ;
if ( result = = NULL ) {
PyErr_Print ( ) ;
PyErr_Clear ( ) ;
return NT_STATUS_UNSUCCESSFUL ;
}
return NT_STATUS_OK ;
}