s3compat: first version of s3compat system
authorAndrew Tridgell <tridge@samba.org>
Sun, 25 Apr 2010 02:59:57 +0000 (12:59 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 3 Jun 2010 01:12:27 +0000 (11:12 +1000)
This is a prototype of a system to allow Samba4 to call functions from
Samba3 via a shared library. We use hide_symbols=True to avoid symbol
conflicts.

source4/s3compat/compat/includes.h [new file with mode: 0644]
source4/s3compat/s3compat.c [new file with mode: 0644]
source4/s3compat/s3dynconfig.c [new file with mode: 0644]
source4/s3compat/s3replace.c [new file with mode: 0644]
source4/s3compat/wscript_build [new file with mode: 0644]
source4/smbd/server.c
source4/smbd/wscript_build
source4/wscript
source4/wscript_build

diff --git a/source4/s3compat/compat/includes.h b/source4/s3compat/compat/includes.h
new file mode 100644 (file)
index 0000000..38076e5
--- /dev/null
@@ -0,0 +1,4 @@
+/* this wraps the s3 includes.h to give the opportunity
+   to override some defines if need be */
+#include "source3/include/includes.h"
+
diff --git a/source4/s3compat/s3compat.c b/source4/s3compat/s3compat.c
new file mode 100644 (file)
index 0000000..6a8c705
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   s3 compatibility routines
+
+   Copyright (C) Andrew Tridgell               2010
+
+   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"
+#include "lib/util/talloc_stack.h"
+#include "s3compat.h"
+
+
+_PUBLIC_ const char *s3compat_samba_version_string(void)
+{
+       const char *samba_version_string(void);
+       return samba_version_string();
+}
+
+_PUBLIC_
+void s3compat_test(void)
+{
+       TALLOC_CTX *stack = talloc_stackframe();
+       /* use stdout logging for now */
+       setup_logging("s3compat", true);
+       DEBUG(0,("s3compat: samba_version_string: %s\n",
+                s3compat_samba_version_string()));
+}
diff --git a/source4/s3compat/s3dynconfig.c b/source4/s3compat/s3dynconfig.c
new file mode 100644 (file)
index 0000000..35c3211
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   s3 compatibility routines
+
+   Copyright (C) Andrew Tridgell               2010
+
+   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"
+#include "s3compat.h"
+#include "source4/dynconfig/dynconfig.h"
+
+const char *get_dyn_CODEPAGEDIR(void)
+{
+       return "";
+}
+
+const char *get_dyn_MODULESDIR(void)
+{
+       return "";
+}
+
+const char *get_dyn_SHLIBEXT(void)
+{
+       return ".so";
+}
+
+const char *get_dyn_CONFIGFILE(void)
+{
+       return dyn_CONFIGFILE;
+}
+
+const char *get_dyn_LIBDIR(void)
+{
+       return "";
+}
+
+const char *get_dyn_LOGFILEBASE(void)
+{
+       return dyn_LOGFILEBASE;
+}
+
+const char *get_dyn_PRIVATE_DIR(void)
+{
+       return dyn_PRIVATE_DIR;
+}
+
+const char *get_dyn_STATEDIR(void)
+{
+       return "";
+}
+
+const char *get_dyn_PIDDIR(void)
+{
+       return dyn_PIDDIR;
+}
+
+const char *get_dyn_LOCKDIR(void)
+{
+       return dyn_LOCKDIR;
+}
+
+const char *get_dyn_CACHEDIR(void)
+{
+       return "";
+}
+
+const char *get_dyn_SMB_PASSWD_FILE(void)
+{
+       return "";
+}
+
diff --git a/source4/s3compat/s3replace.c b/source4/s3compat/s3replace.c
new file mode 100644 (file)
index 0000000..9ba162e
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   s3 compatibility routines
+
+   Copyright (C) Andrew Tridgell               2010
+
+   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"
+#include "../libcli/auth/libcli_auth.h"
+#include "librpc/gen_ndr/ndr_secrets.h"
+#include "s3replace.h"
+
diff --git a/source4/s3compat/wscript_build b/source4/s3compat/wscript_build
new file mode 100644 (file)
index 0000000..1c63be0
--- /dev/null
@@ -0,0 +1,192 @@
+#!/usr/bin/env python
+
+PARAM_WITHOUT_REG_SRC = '''param/loadparm.c param/util.c lib/sharesec.c lib/ldap_debug_handler.c'''
+
+PRIVILEGES_BASIC_SRC = '''lib/privileges_basic.c'''
+
+UTIL_SRC = '''../lib/util/rbtree.c ../lib/util/signal.c ../lib/util/time.c
+                  ../lib/util/xfile.c ../lib/util/util_strlist.c
+                  ../lib/util/util_file.c ../lib/util/data_blob.c
+                  ../lib/util/util.c ../lib/util/fsusage.c
+                  ../lib/util/params.c ../lib/util/talloc_stack.c
+                  ../lib/util/genrand.c ../lib/util/util_net.c
+                  ../lib/util/become_daemon.c ../lib/util/system.c
+                  ../lib/util/tevent_unix.c ../lib/util/tevent_ntstatus.c
+                  ../lib/util/smb_threads.c ../lib/util/util_id.c
+                  ../lib/util/blocking.c ../lib/util/rfc1738.c '''
+
+CRYPTO_SRC = '''../lib/crypto/crc32.c ../lib/crypto/md5.c
+                        ../lib/crypto/hmacmd5.c ../lib/crypto/arcfour.c
+                        ../lib/crypto/md4.c
+                        ../lib/crypto/sha256.c ../lib/crypto/hmacsha256.c
+                        ../lib/crypto/aes.c ../lib/crypto/rijndael-alg-fst.c'''
+
+TDB_LIB_SRC = '''lib/util_tdb.c ../lib/util/util_tdb.c
+         lib/dbwrap.c lib/dbwrap_tdb.c
+         lib/dbwrap_ctdb.c
+         lib/g_lock.c
+         lib/dbwrap_rbt.c'''
+
+TDB_VALIDATE_SRC = '''lib/tdb_validate.c'''
+
+VERSION_SRC = '''lib/version.c'''
+
+UTIL_REG_SRC = '''lib/util_reg.c'''
+UTIL_REG_API_SRC = '''lib/util_reg_api.c'''
+
+LIBNDR_SRC = '''../librpc/ndr/ndr_basic.c
+            ../librpc/ndr/ndr.c
+            ../librpc/ndr/ndr_misc.c
+            ../librpc/gen_ndr/ndr_misc.c
+            ../librpc/gen_ndr/ndr_security.c
+            ../librpc/ndr/ndr_sec_helper.c
+            librpc/ndr/ndr_string.c
+            ../librpc/ndr/uuid.c
+            librpc/ndr/util.c
+            ../librpc/gen_ndr/ndr_dcerpc.c'''
+
+S3_SMBCONF_SRC = '''lib/smbconf/smbconf_init.c lib/smbconf/smbconf_reg.c'''
+
+REGFIO_SRC = '''registry/regfio.c'''
+
+REGSRCS_SRC = '''registry/reg_objects.c'''
+
+REG_BACKENDS_BASE_SRC = '''registry/reg_backend_db.c'''
+
+REG_BACKENDS_SMBCONF_SRC = '''registry/reg_backend_smbconf.c'''
+
+REG_BACKENDS_EXTRA_SRC = '''registry/reg_backend_printing.c
+                        registry/reg_backend_shares.c
+                        registry/reg_backend_netlogon_params.c
+                        registry/reg_backend_prod_options.c
+                        registry/reg_backend_tcpip_params.c
+                        registry/reg_backend_hkpt_params.c
+                        registry/reg_backend_current_version.c
+                        registry/reg_backend_perflib.c'''
+
+REG_INIT_BASIC_SRC = '''registry/reg_init_basic.c'''
+REG_INIT_SMBCONF_SRC = '''registry/reg_init_smbconf.c'''
+REG_INIT_FULL_SRC = '''registry/reg_init_full.c'''
+
+RPC_PARSE_SRC0 = '''rpc_parse/parse_prs.c rpc_parse/parse_misc.c'''
+
+# this includes only the low level parse code, not stuff
+# that requires knowledge of security contexts
+RPC_PARSE_SRC1 = '''${RPC_PARSE_SRC0}'''
+
+RPC_PARSE_SRC2 = '''rpc_parse/parse_rpc.c
+                rpc_client/init_netlogon.c
+                rpc_client/init_lsa.c'''
+
+RPC_PARSE_SRC = '''${RPC_PARSE_SRC2}'''
+
+REG_BASE_SRC = '''registry/reg_api.c
+              registry/reg_dispatcher.c
+              registry/reg_cachehook.c
+              ${REGFIO_SRC}
+              ${REGSRCS_SRC}
+              registry/reg_util.c
+              ${UTIL_REG_API_SRC}
+              lib/util_nttoken.c
+              ${REG_BACKENDS_BASE_SRC}
+              ${REG_INIT_BASIC_SRC}'''
+
+NTERR_SRC = '''libsmb/nterr.c libsmb/smberr.c'''
+DOSERR_SRC = '../libcli/util/doserr.c'
+ERRORMAP_SRC = 'libsmb/errormap.c'
+DCE_RPC_ERR_SRC = '../librpc/rpc/dcerpc_error.c'
+
+SECRETS_SRC = '''passdb/secrets.c passdb/machine_sid.c
+             librpc/gen_ndr/ndr_secrets.c'''
+
+LIBSMB_ERR_SRC0 = '''${NTERR_SRC} ${ERRORMAP_SRC} ${DCE_RPC_ERR_SRC}'''
+
+LIBSMB_ERR_SRC1 = '''../libcli/auth/smbdes.c ../libcli/auth/smbencrypt.c ../libcli/auth/msrpc_parse.c ../libcli/auth/session.c'''
+
+LIBSMB_ERR_SRC = '''${LIBSMB_ERR_SRC0} ${LIBSMB_ERR_SRC1}
+                ${RPC_PARSE_SRC1}
+                ${SECRETS_SRC}'''
+
+LIB_SRC = '''
+         lib/messages.c lib/debug.c librpc/gen_ndr/ndr_messaging.c lib/messages_local.c
+         lib/messages_ctdbd.c lib/packet.c lib/ctdbd_conn.c
+         lib/interfaces.c lib/memcache.c
+         lib/talloc_dict.c
+         lib/serverid.c
+         lib/util_transfer_file.c ../lib/async_req/async_sock.c
+         ${TDB_LIB_SRC}
+         ${VERSION_SRC} lib/charcnv.c lib/fault.c
+         lib/interface.c lib/pidfile.c
+         lib/system.c lib/sendfile.c lib/recvfile.c lib/time.c
+         lib/username.c
+         ../libds/common/flag_mapping.c
+         lib/util_pw.c lib/access.c lib/smbrun.c
+         lib/bitmap.c lib/dprintf.c ${UTIL_REG_SRC}
+         lib/wins_srv.c
+         lib/util_str.c lib/clobber.c lib/util_sid.c lib/util_uuid.c
+         lib/util_unistr.c lib/util_file.c
+         lib/util.c lib/util_sock.c lib/sock_exec.c lib/util_sec.c
+         lib/substitute.c lib/dbwrap_util.c
+         lib/ms_fnmatch.c lib/select.c lib/errmap_unix.c
+         lib/tallocmsg.c lib/dmallocmsg.c
+         libsmb/clisigning.c libsmb/smb_signing.c
+         lib/iconv.c lib/pam_errors.c intl/lang_tdb.c
+         lib/conn_tdb.c lib/adt_tree.c lib/gencache.c
+         lib/sessionid_tdb.c
+         lib/module.c lib/events.c
+         lib/ldap_escape.c
+         lib/secdesc.c lib/util_seaccess.c
+         lib/fncall.c
+         libads/krb5_errs.c lib/system_smbd.c lib/audit.c
+         lib/file_id.c lib/idmap_cache.c
+          ${PRIVILEGES_BASIC_SRC}
+          librpc/ndr/util.c
+          ${S3_SMBCONF_SRC}
+          ${REG_BASE_SRC}
+          ${RPC_PARSE_SRC}
+          ${LIBSMB_ERR_SRC}
+          ${REG_INIT_SMBCONF_SRC}
+          ${REG_BACKENDS_SMBCONF_SRC}
+         '''
+
+LIB_SRC = bld.EXPAND_VARIABLES(LIB_SRC, vars=locals())
+
+SAMBA3_INCLUDES = '#source4/s3compat/compat #source4/dynconfig #source3 #source3/lib #source3/include #lib/replace #lib/talloc #source3/libaddns #source3/librpc #source3/build'
+
+bld.SAMBA_SUBSYSTEM('s3_lib',
+                    bld.SUBDIR('../../source3', LIB_SRC),
+                    includes=SAMBA3_INCLUDES,
+                    deps='talloc tevent tdb',
+                    hide_symbols=True)
+
+bld.SAMBA_SUBSYSTEM('s3_loadparm',
+                    bld.SUBDIR('../../source3', PARAM_WITHOUT_REG_SRC),
+                    includes=SAMBA3_INCLUDES,
+                    deps='talloc tevent tdb',
+                    hide_symbols=True)
+
+bld.SAMBA_SUBSYSTEM('s3_lib_dummy',
+                    bld.SUBDIR('../../source3/lib', 'dummysmbd.c dummyroot.c'),
+                    includes=SAMBA3_INCLUDES,
+                    deps='talloc tevent tdb',
+                    hide_symbols=True)
+
+bld.SAMBA_SUBSYSTEM('s3compat_wrapper',
+                    source='s3compat.c',
+                    hide_symbols=True)
+
+bld.SAMBA_SUBSYSTEM('s3replace',
+                    source='s3replace.c',
+                    includes=SAMBA3_INCLUDES,
+                    deps='talloc tevent tdb',
+                    hide_symbols=True)
+
+bld.SAMBA_SUBSYSTEM('s3dynconfig',
+                    source='s3dynconfig.c',
+                    hide_symbols=True)
+
+bld.SAMBA_LIBRARY('s3compat',
+                  source='s3compat.c',
+                  autoproto='s3replace.h',
+                  deps='s3replace s3dynconfig s3_lib s3_lib_dummy s3_loadparm LIBSMBCONF LIBSECURITY_COMMON LIBCRYPTO LIBSAMBA-UTIL',
+                  hide_symbols=True)
index 88917c4f388b50a98fc138b2a8309ad14b2c9e1b..15a276027d1bf1a1f1deb2bcca7b86ad38e95ffb 100644 (file)
@@ -41,6 +41,7 @@
 #include "librpc/gen_ndr/ndr_irpc.h"
 #include "cluster/cluster.h"
 #include "dynconfig/dynconfig.h"
+#include "s3compat/s3compat.h"
 
 /*
   recursively delete a directory tree
@@ -373,6 +374,10 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
        DEBUG(0,("%s version %s started.\n", binary_name, SAMBA_VERSION_STRING));
        DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2010\n"));
 
+#ifdef ENABLE_S3COMPAT
+       s3compat_test();
+#endif
+
        if (sizeof(uint16_t) < 2 || sizeof(uint32_t) < 4 || sizeof(uint64_t) < 8) {
                DEBUG(0,("ERROR: Samba is not configured correctly for the word size on your machine\n"));
                DEBUGADD(0,("sizeof(uint16_t) = %u, sizeof(uint32_t) %u, sizeof(uint64_t) = %u\n",
index 131741153ca7d9546e7766c8f8556ab57f51bc12..193b4fab5355f1518e54cf64aefceddd0656cc0e 100644 (file)
@@ -19,7 +19,7 @@ bld.SAMBA_BINARY('samba',
        manpages='samba.8',
         subsystem_name='service',
        deps='''LIBEVENTS process_model service LIBSAMBA-HOSTCONFIG LIBSAMBA-UTIL POPT_SAMBA PIDFILE
-                popt gensec registry ntptr ntvfs share CLUSTER DCESRV''',
+                popt gensec registry ntptr ntvfs share CLUSTER DCESRV s3compat''',
         needs_python=True,
         install_path='${SBINDIR}'
        )
index 2be159cc4fd7490023cb4bdf515a9c4feccf8d2b..856492ac5e2bb143675c0f7bf7a85ac9e9efcc3e 100644 (file)
@@ -43,6 +43,7 @@ def set_options(opt):
     opt.RECURSE('../lib/socket_wrapper')
     opt.RECURSE('../lib/uid_wrapper')
     opt.RECURSE('../pidl')
+    opt.RECURSE('s3compat')
 
     gr = opt.option_group('developer options')
     gr.add_option('--enable-build-farm',
@@ -102,6 +103,7 @@ def configure(conf):
     conf.RECURSE('lib/smbreadline')
     conf.RECURSE('../pidl')
     conf.RECURSE('selftest')
+    conf.RECURSE('s3compat')
 
     # we don't want PYTHONDIR in config.h, as otherwise changing
     # --prefix causes a complete rebuild
index 00c3e73dc984a7319af2efb29c3f9b739d1d6dcb..5a18fb1d120851d93ae7ddf7c8fdd2d9cefede6a 100644 (file)
@@ -116,6 +116,8 @@ bld.RECURSE('setup')
 bld.RECURSE('scripting')
 bld.RECURSE('../pidl')
 bld.RECURSE('../lib')
+if bld.env.ENABLE_S3COMPAT:
+    bld.RECURSE('s3compat')
 
 # install some extra empty directories
 bld.INSTALL_DIRS("", "${LOCKDIR} ${SYSCONFDIR} ${LOCKDIR} ${PIDDIR} ${LOCALSTATEDIR}/lib ${PRIVATEDIR}/smbd.tmp/messaging")