[SCM] Samba Shared Repository - branch v4-1-test updated

Karolin Seeger kseeger at samba.org
Tue May 20 05:55:03 MDT 2014


The branch, v4-1-test has been updated
       via  bb0871c bug #10609: CVE-2014-0239 Don't reply to replies
       via  60dbfbd lib-util: rename memdup to smb_memdup and fix all callers (bug #10556)
       via  2763d0f ad-dc: use exit_daemon() to communicate status of startup to systemd
       via  93979e0 winbindd: use exit_daemon() to pass startup status to systemd
       via  59d9a27 nmbd: use exit_daemon() to report status to systemd
       via  def308a smbd: use exit_daemon() to support reporting to systemd from smbd
       via  2c61618 add systemd integration
       via  7982500 pidl/lib/wscript_build: make use of PERL_LIB_INSTALL_DIR
       via  7a6173d script/autobuild: make use of --with-perl-{arch,lib}-install-dir
       via  a76395b wafsamba: Fail with error message if perl doesn't provide valid dirs.
       via  992e693 wafsamba: If perl can't provide defaults, define them.
      from  dbe2ef7 FSCTL_GET_SHADOW_COPY_DATA: Don't return 4 extra bytes at end

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-1-test


- Log -----------------------------------------------------------------
commit bb0871c3ec44f6fb5fbd01e0f1522dfd7934cfe5
Author: Kai Blin <kai at samba.org>
Date:   Tue May 13 08:13:29 2014 +0200

    bug #10609: CVE-2014-0239 Don't reply to replies
    
    Due to insufficient input checking, the DNS server will reply to a packet that
    has the "reply" bit set. Over UDP, this allows to send a packet with a spoofed
    sender address and have two servers DOS each other with circular replies.
    
    This patch fixes bug #10609 and adds a test to make sure we don't regress.
    CVE-2014-2039 has been assigned to this issue.
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10609
    
    Signed-off-by: Kai Blin <kai at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Kai Blin <kai at samba.org>
    Autobuild-Date(master): Tue May 20 04:15:44 CEST 2014 on sn-devel-104
    
    (cherry picked from commit 392ec4d241eb19c812cd49ff73bd32b2b09d8533)
    
    Autobuild-User(v4-1-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-1-test): Tue May 20 13:54:40 CEST 2014 on sn-devel-104

commit 60dbfbdadf7bce70cb2f74a79afe04017da3035d
Author: Björn Baumbach <bb at sernet.de>
Date:   Mon Apr 14 14:37:29 2014 +0200

    lib-util: rename memdup to smb_memdup and fix all callers (bug #10556)
    
    Signed-off-by: Björn Baumbach <bb at sernet.de>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit fae7e5d771d1c69bded1189b23335647023fa0f7)
    
    Conflicts:
    	ctdb/lib/util/util.h
    
    Also renamed memdup() in source3/locking/brlock.c

commit 2763d0f0671c852d71938dbbef768ee80f9b2b80
Author: Alexander Bokovoy <ab at samba.org>
Date:   Wed Mar 26 12:30:30 2014 +0200

    ad-dc: use exit_daemon() to communicate status of startup to systemd
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10517
    
    Signed-off-by: Alexander Bokovoy <ab at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit a343303cbcd5af303455843ebf202e2f30daf3a6)

commit 93979e068c7556f685381ed29a3a95f049035a81
Author: Alexander Bokovoy <ab at samba.org>
Date:   Wed Mar 26 11:45:21 2014 +0200

    winbindd: use exit_daemon() to pass startup status to systemd
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10517
    
    Signed-off-by: Alexander Bokovoy <ab at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 91013315c9fa946bf85c85df0ccd40a803f3dc6f)

commit 59d9a2766f88bf019170ed71a67e91e11596061c
Author: Alexander Bokovoy <ab at samba.org>
Date:   Wed Mar 26 11:34:56 2014 +0200

    nmbd: use exit_daemon() to report status to systemd
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10517
    
    Signed-off-by: Alexander Bokovoy <ab at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    (cherry picked from commit a54e94559b5ebabbb8c5c938fdf159efceff39e6)

commit def308a63a294fa2ec66dc5c210c804028e9fc2e
Author: Alexander Bokovoy <ab at samba.org>
Date:   Wed Mar 26 10:56:12 2014 +0200

    smbd: use exit_daemon() to support reporting to systemd from smbd
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10517
    
    Signed-off-by: Alexander Bokovoy <ab at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 2c616189a9f037d26dbdceb34b950002888bb23f
Author: Alexander Bokovoy <ab at samba.org>
Date:   Tue Mar 25 12:53:04 2014 +0200

    add systemd integration
    
    Add --with-systemd / --without-systemd options to check whether
    libsystemd-daemon library is available and use it to report service
    startup status to systemd for smbd/winbindd/nmbd and AD DC.
    
    The problem it solves is correct reporting of the Samba services
    at the point when they are ready to serve clients, important for
    high availability software integration.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10517
    
    Signed-off-by: Alexander Bokovoy <ab at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    (cherry picked from commit 54b5d9a7384ae27b2a26586ff909128427c05abe)

commit 79825000597b9772bae4f9e52cd3a3fc5ccb0257
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 9 11:49:10 2014 +0200

    pidl/lib/wscript_build: make use of PERL_LIB_INSTALL_DIR
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10472
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Sat May 10 01:37:33 CEST 2014 on sn-devel-104
    (cherry picked from commit cf75ef9f73f2cdbf2a039bbc9468f5da6a14834e)

commit 7a6173ddce2142d3c0465908f2ced29aee7f32e8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 9 11:48:26 2014 +0200

    script/autobuild: make use of --with-perl-{arch,lib}-install-dir
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10472
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit d18ee9e4b6f4c9a24b555c111e08396012c1755a)

commit a76395b3198f2393963f2a8c5e37b6179fef5abe
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 9 09:42:23 2014 +0200

    wafsamba: Fail with error message if perl doesn't provide valid dirs.
    
    We try harder to get valid directories, we now fallback like this:
    
    vendorarch => sitearch => archlib
    and
    vendorlib => sitelib => privlib
    
    The new options are --with-perl-arch-install-dir and
    --with-perl-lib-install-dir.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10472
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 2637890ef42a238093f0f3cbdda0d621d5f9b2e2)

commit 992e6933ca6a65a4f5f94cb4162c87c532d175be
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Apr 15 10:24:24 2014 +0200

    wafsamba: If perl can't provide defaults, define them.
    
    This should fix the installation on FreeBSD.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10472
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Thu May  8 13:55:50 CEST 2014 on sn-devel-104
    (cherry picked from commit 0ba276ebad57d75a769e22414f94acbe8c177d97)

-----------------------------------------------------------------------

Summary of changes:
 buildtools/wafadmin/Tools/perl.py |   52 +++++++++++++++++++++++++++---------
 lib/util/become_daemon.c          |   37 +++++++++++++++++++++++++-
 lib/util/samba_util.h             |   14 +++++++++-
 lib/util/util.c                   |    2 +-
 lib/util/wscript_build            |    2 +-
 packaging/systemd/nmb.service     |    3 +-
 packaging/systemd/samba.service   |    3 +-
 packaging/systemd/smb.service     |    3 +-
 packaging/systemd/winbind.service |    3 +-
 pidl/lib/wscript_build            |    4 +-
 python/samba/tests/dns.py         |   29 ++++++++++++++++++++
 script/autobuild.py               |    4 ++-
 source3/lib/interface.c           |    4 +-
 source3/lib/smbldap.c             |    2 +-
 source3/libsmb/clirap.c           |    4 +-
 source3/locking/brlock.c          |    2 +-
 source3/nmbd/nmbd.c               |   43 +++++++++++++-----------------
 source3/passdb/secrets.c          |    2 +-
 source3/smbd/seal.c               |    2 +-
 source3/smbd/sec_ctx.c            |    4 +-
 source3/smbd/server.c             |   48 ++++++++++++++++-----------------
 source3/winbindd/winbindd.c       |   18 ++++++------
 source3/winbindd/winbindd_cache.c |    2 +-
 source4/dns_server/dns_server.c   |    6 ++++
 source4/smbd/process_thread.c     |    4 +-
 source4/smbd/server.c             |   23 ++++++++--------
 wscript                           |   27 ++++++++++++++++---
 27 files changed, 235 insertions(+), 112 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildtools/wafadmin/Tools/perl.py b/buildtools/wafadmin/Tools/perl.py
index 8f13e28..0f34e79 100644
--- a/buildtools/wafadmin/Tools/perl.py
+++ b/buildtools/wafadmin/Tools/perl.py
@@ -98,27 +98,53 @@ def check_perl_ext_devel(conf):
 	conf.env.EXTUTILS_TYPEMAP  = read_out('print "$Config{privlib}/ExtUtils/typemap"')
 	conf.env.perlext_PATTERN   = '%s.' + read_out('print $Config{dlext}')[0]
 
-	if getattr(Options.options, 'perl_vendorarch_dir', None):
-		conf.env.PERL_VENDORARCH_DIR = Options.options.perl_vendorarch_dir
-	else:
-		conf.env.PERL_VENDORARCH_DIR = read_out('print $Config{vendorarch}')[0]
-
-	if getattr(Options.options, 'perl_vendorlib_dir', None):
-		conf.env.PERL_VENDORLIB_DIR = Options.options.perl_vendorlib_dir
-	else:
-		conf.env.PERL_VENDORLIB_DIR = read_out('print $Config{vendorlib}')[0]
+	def try_any(keys):
+		for k in keys:
+			conf.start_msg("Checking for perl $Config{%s}:" % k)
+			try:
+				v = read_out('print $Config{%s}' % k)[0]
+				conf.end_msg("'%s'" % (v), 'GREEN')
+				return v
+			except IndexError:
+				conf.end_msg(False, 'YELLOW')
+				pass
+		return None
+
+	perl_arch_install_dir = None
+	if getattr(Options.options, 'perl_arch_install_dir', None):
+		perl_arch_install_dir = Options.options.perl_arch_install_dir
+	if perl_arch_install_dir is None:
+		perl_arch_install_dir = try_any(['vendorarch', 'sitearch', 'archlib'])
+	if perl_arch_install_dir is None:
+		conf.fatal('No perl arch install directory autodetected.' +
+			   'Please define it with --with-perl-arch-install-dir.')
+	conf.start_msg("PERL_ARCH_INSTALL_DIR: ")
+	conf.end_msg("'%s'" % (perl_arch_install_dir), 'GREEN')
+	conf.env.PERL_ARCH_INSTALL_DIR = perl_arch_install_dir
+
+	perl_lib_install_dir = None
+	if getattr(Options.options, 'perl_lib_install_dir', None):
+		perl_lib_install_dir = Options.options.perl_lib_install_dir
+	if perl_lib_install_dir is None:
+		perl_lib_install_dir = try_any(['vendorlib', 'sitelib', 'privlib'])
+	if perl_lib_install_dir is None:
+		conf.fatal('No perl lib install directory autodetected. ' +
+			   'Please define it with --with-perl-lib-install-dir.')
+	conf.start_msg("PERL_LIB_INSTALL_DIR: ")
+	conf.end_msg("'%s'" % (perl_lib_install_dir), 'GREEN')
+	conf.env.PERL_LIB_INSTALL_DIR = perl_lib_install_dir
 
 def set_options(opt):
 	opt.add_option("--with-perl-binary", type="string", dest="perlbinary", help = 'Specify alternate perl binary', default=None)
 
-	opt.add_option("--with-perl-vendorarch",
+	opt.add_option("--with-perl-arch-install-dir",
 		       type="string",
-		       dest="perl_vendorarch_dir",
+		       dest="perl_arch_install_dir",
 		       help = ('Specify directory where to install arch specific files'),
 		       default=None)
 
-	opt.add_option("--with-perl-vendorlib",
+	opt.add_option("--with-perl-lib-install-dir",
 		       type="string",
-		       dest="perl_vendorlib_dir",
+		       dest="perl_lib_install_dir",
 		       help = ('Specify directory where to install vendor specific files'),
 		       default=None)
diff --git a/lib/util/become_daemon.c b/lib/util/become_daemon.c
index 2ca0478..35c8b32 100644
--- a/lib/util/become_daemon.c
+++ b/lib/util/become_daemon.c
@@ -24,6 +24,9 @@
 #include "includes.h"
 #include "system/filesys.h"
 #include "system/locale.h"
+#if HAVE_SYSTEMD
+#include <systemd/sd-daemon.h>
+#endif
 
 /*******************************************************************
  Close the low 3 fd's and open dev/null in their place.
@@ -75,8 +78,13 @@ _PUBLIC_ void close_low_fds(bool stdin_too, bool stdout_too, bool stderr_too)
 
 _PUBLIC_ void become_daemon(bool do_fork, bool no_process_group, bool log_stdout)
 {
+	pid_t newpid;
 	if (do_fork) {
-		if (fork()) {
+		newpid = fork();
+		if (newpid) {
+#if HAVE_SYSTEMD
+			sd_notifyf(0, "READY=0\nSTATUS=Starting process...\nMAINPID=%lu", (unsigned long) newpid);
+#endif /* HAVE_SYSTEMD */
 			_exit(0);
 		}
 	}
@@ -100,3 +108,30 @@ _PUBLIC_ void become_daemon(bool do_fork, bool no_process_group, bool log_stdout
 	 * never close stderr (but debug might dup it onto a log file) */
 	close_low_fds(do_fork, !log_stdout, false);
 }
+
+_PUBLIC_ void exit_daemon(const char *msg, int error)
+{
+#ifdef HAVE_SYSTEMD
+	if (msg == NULL) {
+		msg = strerror(error);
+	}
+
+	sd_notifyf(0, "STATUS=daemon failed to start: %s\n"
+				  "ERRNO=%i",
+				  msg,
+				  error);
+#endif
+	DEBUG(0, ("STATUS=daemon failed to start: %s, error code %d\n", msg, error));
+	exit(1);
+}
+
+_PUBLIC_ void daemon_ready(const char *daemon)
+{
+	if (daemon == NULL) {
+		daemon = "Samba";
+	}
+#ifdef HAVE_SYSTEMD
+	sd_notifyf(0, "READY=1\nSTATUS=%s: ready to serve connections...", daemon);
+#endif
+	DEBUG(0, ("STATUS=daemon '%s' finished starting up and ready to serve connections", daemon));
+}
diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index f52347e..e3fe6a6 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -739,7 +739,7 @@ char *smb_xstrndup(const char *s, size_t n);
 /**
  Like strdup but for memory.
 **/
-_PUBLIC_ void *memdup(const void *p, size_t size);
+_PUBLIC_ void *smb_memdup(const void *p, size_t size);
 
 /**
  * Write a password to the log file.
@@ -842,6 +842,18 @@ _PUBLIC_ void close_low_fds(bool stdin_too, bool stdout_too, bool stderr_too);
 _PUBLIC_ void become_daemon(bool do_fork, bool no_process_group, bool log_stdout);
 
 /**
+ Exit daemon and print error message to the log at level 0
+ Optionally report failure to systemd if systemd integration is enabled
+**/
+_PUBLIC_ void exit_daemon(const char *msg, int error);
+
+/**
+ Report that the daemon is ready to serve connections to the log at level 0
+ Optionally report status to systemd if systemd integration is enabled
+**/
+_PUBLIC_ void daemon_ready(const char *daemon);
+
+/**
  * @brief Get a password from the console.
  *
  * You should make sure that the buffer is an empty string!
diff --git a/lib/util/util.c b/lib/util/util.c
index 3e9047c..35c1896 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -693,7 +693,7 @@ char *smb_xstrndup(const char *s, size_t n)
  Like strdup but for memory.
 **/
 
-_PUBLIC_ void *memdup(const void *p, size_t size)
+_PUBLIC_ void *smb_memdup(const void *p, size_t size)
 {
 	void *p2;
 	if (size == 0)
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index 39a1613..5087116 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -10,7 +10,7 @@ bld.SAMBA_LIBRARY('samba-util',
                     server_id.c dprintf.c parmlist.c bitmap.c pidfile.c
                     tevent_debug.c util_process.c''',
                   deps='DYNCONFIG',
-                  public_deps='talloc tevent execinfo uid_wrapper pthread LIBCRYPTO charset util_setid',
+                  public_deps='talloc tevent execinfo uid_wrapper pthread LIBCRYPTO charset util_setid systemd-daemon',
                   public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h',
                   header_path= [ ('dlinklist.h samba_util.h', '.'), ('*', 'util') ],
                   local_include=False,
diff --git a/packaging/systemd/nmb.service b/packaging/systemd/nmb.service
index e5e81a1..3d71a7d 100644
--- a/packaging/systemd/nmb.service
+++ b/packaging/systemd/nmb.service
@@ -3,7 +3,8 @@ Description=Samba NMB Daemon
 After=syslog.target network.target
 
 [Service]
-Type=forking
+Type=notify
+NotifyAccess=all
 PIDFile=/run/nmbd.pid
 EnvironmentFile=-/etc/sysconfig/samba
 ExecStart=/usr/sbin/nmbd $NMBDOPTIONS
diff --git a/packaging/systemd/samba.service b/packaging/systemd/samba.service
index e2878d1..824f89c 100644
--- a/packaging/systemd/samba.service
+++ b/packaging/systemd/samba.service
@@ -3,7 +3,8 @@ Description=Samba AD Daemon
 After=syslog.target network.target
 
 [Service]
-Type=forking
+Type=notify
+NotifyAccess=all
 PIDFile=/run/samba.pid
 LimitNOFILE=16384
 EnvironmentFile=-/etc/sysconfig/samba
diff --git a/packaging/systemd/smb.service b/packaging/systemd/smb.service
index d0d945a..9810891 100644
--- a/packaging/systemd/smb.service
+++ b/packaging/systemd/smb.service
@@ -3,7 +3,8 @@ Description=Samba SMB Daemon
 After=syslog.target network.target nmb.service winbind.service
 
 [Service]
-Type=forking
+Type=notify
+NotifyAccess=all
 PIDFile=/run/smbd.pid
 LimitNOFILE=16384
 EnvironmentFile=-/etc/sysconfig/samba
diff --git a/packaging/systemd/winbind.service b/packaging/systemd/winbind.service
index eff266f..f711a17 100644
--- a/packaging/systemd/winbind.service
+++ b/packaging/systemd/winbind.service
@@ -3,7 +3,8 @@ Description=Samba Winbind Daemon
 After=syslog.target network.target nmb.service
 
 [Service]
-Type=forking
+Type=notify
+NotifyAccess=all
 PIDFile=/run/winbindd.pid
 EnvironmentFile=-/etc/sysconfig/samba
 ExecStart=/usr/sbin/winbindd "$WINBINDOPTIONS"
diff --git a/pidl/lib/wscript_build b/pidl/lib/wscript_build
index 5023e07..54b3170 100644
--- a/pidl/lib/wscript_build
+++ b/pidl/lib/wscript_build
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 # install the pidl modules
-bld.INSTALL_FILES(bld.env.PERL_VENDORLIB_DIR,
+bld.INSTALL_FILES(bld.env.PERL_LIB_INSTALL_DIR,
                   '''
                   Parse/Pidl.pm
                   Parse/Pidl/Samba4.pm
@@ -32,6 +32,6 @@ bld.INSTALL_FILES(bld.env.PERL_VENDORLIB_DIR,
                   flat=False)
 
 if not bld.CONFIG_SET('USING_SYSTEM_PARSE_YAPP_DRIVER'):
-    bld.INSTALL_FILES(bld.env.PERL_VENDORLIB_DIR,
+    bld.INSTALL_FILES(bld.env.PERL_LIB_INSTALL_DIR,
                       'Parse/Yapp/Driver.pm',
                       flat=False)
diff --git a/python/samba/tests/dns.py b/python/samba/tests/dns.py
index f2c5685..79e4158 100644
--- a/python/samba/tests/dns.py
+++ b/python/samba/tests/dns.py
@@ -833,6 +833,35 @@ class TestInvalidQueries(DNSTest):
         self.assertEquals(response.answers[0].rdata,
                           os.getenv('SERVER_IP'))
 
+    def test_one_a_reply(self):
+        "send a reply instead of a query"
+
+        p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
+        questions = []
+
+        name = "%s.%s" % ('fakefakefake', self.get_dns_domain())
+        q = self.make_name_question(name, dns.DNS_QTYPE_A, dns.DNS_QCLASS_IN)
+        print "asking for ", q.name
+        questions.append(q)
+
+        self.finish_name_packet(p, questions)
+        p.operation |= dns.DNS_FLAG_REPLY
+        s = None
+        try:
+            send_packet = ndr.ndr_pack(p)
+            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
+            host=os.getenv('SERVER_IP')
+            s.connect((host, 53))
+            tcp_packet = struct.pack('!H', len(send_packet))
+            tcp_packet += send_packet
+            s.send(tcp_packet, 0)
+            recv_packet = s.recv(0xffff + 2, 0)
+            self.assertEquals(0, len(recv_packet))
+        finally:
+            if s is not None:
+                s.close()
+
+
 if __name__ == "__main__":
     import unittest
     unittest.main()
diff --git a/script/autobuild.py b/script/autobuild.py
index 3136643..b5f054b 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -212,7 +212,9 @@ class builder(object):
         self.cmd = self.cmd.replace("${PYTHON_PREFIX}", get_python_lib(standard_lib=1, prefix=self.prefix))
         self.cmd = self.cmd.replace("${PREFIX}", "--prefix=%s" % self.prefix)
         self.cmd = self.cmd.replace("${PREFIX_DIR}", "%s" % self.prefix)
-        self.cmd = self.cmd.replace("${PERL_VENDOR_LIB}", "--with-perl-vendorlib=%s/share/perl5" % self.prefix)
+        perl_vendor_lib = "--with-perl-arch-install-dir=%s/share/perl5 " % self.prefix
+        perl_vendor_lib += "--with-perl-lib-install-dir=%s/lib/perl5" % self.prefix
+        self.cmd = self.cmd.replace("${PERL_VENDOR_LIB}", perl_vendor_lib)
 #        if self.output_mime_type == "text/x-subunit":
 #            self.cmd += " | %s --immediate" % (os.path.join(os.path.dirname(__file__), "selftest/format-subunit"))
         print '%s: [%s] Running %s' % (self.name, self.stage, self.cmd)
diff --git a/source3/lib/interface.c b/source3/lib/interface.c
index 39dc9cb..3edeae5 100644
--- a/source3/lib/interface.c
+++ b/source3/lib/interface.c
@@ -503,10 +503,10 @@ void load_interfaces(void)
 	total_probed = get_interfaces(talloc_tos(), &ifaces);
 
 	if (total_probed > 0) {
-		probed_ifaces = (struct iface_struct *)memdup(ifaces,
+		probed_ifaces = (struct iface_struct *)smb_memdup(ifaces,
 				sizeof(ifaces[0])*total_probed);
 		if (!probed_ifaces) {
-			DEBUG(0,("ERROR: memdup failed\n"));
+			DEBUG(0,("ERROR: smb_memdup failed\n"));
 			exit(1);
 		}
 	}
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index 08640d0..f2d58a5 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -353,7 +353,7 @@ static void smbldap_set_mod_internal(LDAPMod *** modlist, int modop, const char
 		mods[i]->mod_bvalues[j] = SMB_MALLOC_P(struct berval);
 		SMB_ASSERT(mods[i]->mod_bvalues[j] != NULL);
 
-		mods[i]->mod_bvalues[j]->bv_val = (char *)memdup(blob->data, blob->length);
+		mods[i]->mod_bvalues[j]->bv_val = (char *)smb_memdup(blob->data, blob->length);
 		SMB_ASSERT(mods[i]->mod_bvalues[j]->bv_val != NULL);
 		mods[i]->mod_bvalues[j]->bv_len = blob->length;
 
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c
index 7e6f8d7..036919f 100644
--- a/source3/libsmb/clirap.c
+++ b/source3/libsmb/clirap.c
@@ -67,14 +67,14 @@ bool cli_api(struct cli_state *cli,
 	 * talloc
 	 */
 
-	*rparam = (char *)memdup(my_rparam, num_my_rparam);
+	*rparam = (char *)smb_memdup(my_rparam, num_my_rparam);
 	if (*rparam == NULL) {
 		goto fail;
 	}
 	*rprcnt = num_my_rparam;
 	TALLOC_FREE(my_rparam);
 
-	*rdata = (char *)memdup(my_rdata, num_my_rdata);
+	*rdata = (char *)smb_memdup(my_rdata, num_my_rdata);
 	if (*rdata == NULL) {
 		goto fail;
 	}
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index df689a7..0f5f32b 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -1786,7 +1786,7 @@ static int brl_traverse_fn(struct db_record *rec, void *state)
 	/* In a traverse function we must make a copy of
 	   dbuf before modifying it. */
 
-	locks = (struct lock_struct *)memdup(value.dptr, value.dsize);
+	locks = (struct lock_struct *)smb_memdup(value.dptr, value.dsize);
 	if (!locks) {
 		return -1; /* Terminate traversal. */
 	}
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 8084e58..36d9082 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -970,16 +970,12 @@ static bool open_sockets(bool isdaemon, int port)
 
 	ok = directory_create_or_exist(lp_lockdir(), geteuid(), 0755);
 	if (!ok) {
-		DEBUG(0, ("Failed to create directory %s for lock files - %s\n",
-			  lp_lockdir(), strerror(errno)));
-		exit(1);
+		exit_daemon("Failed to create directory for lock files, check 'lock directory'", errno);
 	}
 
 	ok = directory_create_or_exist(lp_piddir(), geteuid(), 0755);
 	if (!ok) {
-		DEBUG(0, ("Failed to create directory %s for pid files - %s\n",
-			  lp_piddir(), strerror(errno)));
-		exit(1);
+		exit_daemon("Failed to create directory for pid files, check 'pid directory'", errno);
 	}
 
 	pidfile_create(lp_piddir(), "nmbd");
@@ -988,8 +984,7 @@ static bool open_sockets(bool isdaemon, int port)
 				   false);
 
 	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(0,("reinit_after_fork() failed\n"));
-		exit(1);
+		exit_daemon("reinit_after_fork() failed", map_errno_from_nt_status(status));
 	}
 
 	/*
@@ -999,16 +994,15 @@ static bool open_sockets(bool isdaemon, int port)
 	 */
 	status = init_before_fork();
 	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(0, ("init_before_fork failed: %s\n", nt_errstr(status)));
-		exit(1);
+		exit_daemon(nt_errstr(status), map_errno_from_nt_status(status));
 	}
 
 	if (!nmbd_setup_sig_term_handler(msg))
-		exit(1);
+		exit_daemon("NMBD failed to setup signal handler", EINVAL);
 	if (!nmbd_setup_stdin_handler(msg, !Fork))
-		exit(1);
+		exit_daemon("NMBD failed to setup stdin handler", EINVAL);
 	if (!nmbd_setup_sig_hup_handler(msg))
-		exit(1);
+		exit_daemon("NMBD failed to setup SIGHUP handler", EINVAL);
 
 	/* get broadcast messages */
 
@@ -1016,8 +1010,7 @@ static bool open_sockets(bool isdaemon, int port)
 				FLAG_MSG_GENERAL |
 				FLAG_MSG_NMBD |
 				FLAG_MSG_DBWRAP)) {
-		DEBUG(1, ("Could not register myself in serverid.tdb\n"));
-		exit(1);
+		exit_daemon("Could not register NMBD process in serverid.tdb", EACCES);
 	}
 
 	messaging_register(msg, NULL, MSG_FORCE_ELECTION,
@@ -1048,9 +1041,8 @@ static bool open_sockets(bool isdaemon, int port)
 
 	/* Create an nmbd subnet record for each of the above. */
 	if( False == create_subnets() ) {
-		DEBUG(0,("ERROR: Failed when creating subnet lists. Exiting.\n"));
 		kill_async_dns_child();
-		exit(1);
+		exit_daemon("NMBD failed when creating subnet lists", EACCES);
 	}
 
 	/* Load in any static local names. */ 
@@ -1062,9 +1054,8 @@ static bool open_sockets(bool isdaemon, int port)
 
 	/* If we are acting as a WINS server, initialise data structures. */
 	if( !initialise_wins() ) {
-		DEBUG( 0, ( "nmbd: Failed when initialising WINS server.\n" ) );
 		kill_async_dns_child();
-		exit(1);
+		exit_daemon( "NMBD failed when initialising WINS server.", EACCES);
 	}
 
 	/* 
@@ -1076,21 +1067,23 @@ static bool open_sockets(bool isdaemon, int port)
 	 */
 
 	if( False == register_my_workgroup_and_names() ) {
-		DEBUG(0,("ERROR: Failed when creating my my workgroup. Exiting.\n"));
 		kill_async_dns_child();
-		exit(1);
+		exit_daemon( "NMBD failed when creating my workgroup.", EACCES);
 	}
 
 	if (!initialize_nmbd_proxy_logon()) {
-		DEBUG(0,("ERROR: Failed setup nmbd_proxy_logon.\n"));
 		kill_async_dns_child();
-		exit(1);
+		exit_daemon( "NMBD failed to setup nmbd_proxy_logon.", EACCES);
 	}
 
 	if (!nmbd_init_packet_server()) {
 		kill_async_dns_child();
-                exit(1);
-        }
+		exit_daemon( "NMBD failed to setup packet server.", EACCES);
+	}
+
+	if (is_daemon && !opt_interactive) {
+		daemon_ready("nmbd");
+	}
 
 	TALLOC_FREE(frame);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list