[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Fri Jun 17 02:23:02 MDT 2011


The branch, master has been updated
       via  acc9535 s4-errors: Import error maps from the source3/ unix -> ntstatus mapping
       via  4162c7b errors: reorder error codes for easier s3/s4 comparison
       via  e645675 s4-util: removed the s4 nterr.c
       via  2644097 s3-util: remove the s3 nterr.c
       via  b341979 util: moved nt_errstr() into common code
       via  1233ba7 libclu/util: Move get_friendly_nt_error_msg() in common.
      from  d2bc45e build: only use the git version on install, not in the build tree

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit acc95354008ff11be5e59f74481228f04869095c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 17 17:07:26 2011 +1000

    s4-errors: Import error maps from the source3/ unix -> ntstatus mapping
    
    We need to syncronise these mappings, as the duplication of this
    symobol in the build means that either may be called based only on
    library link orders.
    
    Andrew Bartlett
    
    Autobuild-User: Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date: Fri Jun 17 10:22:07 CEST 2011 on sn-devel-104

commit 4162c7b74aa94ee77ef47f0abae058b80eca6e38
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 17 16:06:34 2011 +1000

    errors: reorder error codes for easier s3/s4 comparison

commit e645675aa46e945da5293b54a1bd368599b7b5a7
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Jun 17 14:40:26 2011 +1000

    s4-util: removed the s4 nterr.c
    
    this is now in common code
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 264409750a569b632576e8cd6fddd72fc29e9660
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Jun 17 14:40:07 2011 +1000

    s3-util: remove the s3 nterr.c
    
    this is now in common code
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit b341979adb950ae6abd518df3a170db9e9708797
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Jun 17 14:39:37 2011 +1000

    util: moved nt_errstr() into common code
    
    this brings nt_errstr() into common code, using the new
    talloc_stackframe_exists() to ensure that we only allocate an error
    string using talloc_tos() if a talloc stackframe does currently
    exists. This makes it safe to use in external libraries
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 1233ba7bf3d2dfd9a84eb52d601e589411c55185
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Jun 16 13:00:09 2011 +1000

    libclu/util: Move get_friendly_nt_error_msg() in common.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

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

Summary of changes:
 libcli/util/nterr.c            |   58 ++++++++++++++++++++++++++++++
 libcli/util/ntstatus.h         |    9 +++++
 libcli/util/wscript_build      |    2 +-
 source3/Makefile.in            |    2 +-
 source3/include/proto.h        |    7 ----
 source3/lib/errmap_unix.c      |   22 ++++++------
 source3/libsmb/nterr.c         |   77 ----------------------------------------
 source3/wscript_build          |    2 +-
 source4/libcli/util/errormap.c |   17 +++++++--
 source4/libcli/util/nterr.c    |   74 --------------------------------------
 source4/libcli/wscript_build   |    2 +-
 11 files changed, 96 insertions(+), 176 deletions(-)
 delete mode 100644 source3/libsmb/nterr.c
 delete mode 100644 source4/libcli/util/nterr.c


Changeset truncated at 500 lines:

diff --git a/libcli/util/nterr.c b/libcli/util/nterr.c
index 5f31c3c..1158fdd 100644
--- a/libcli/util/nterr.c
+++ b/libcli/util/nterr.c
@@ -1,7 +1,10 @@
 /*
  *  Unix SMB/CIFS implementation.
  *  RPC Pipe client / server routines
+ *
  *  Copyright (C) Luke Kenneth Casson Leighton 1997-2001.
+ *  Copyright (C) Andrew Bartlett
+ *  Copyright (C) Andrew Tridgell
  *
  *  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
@@ -906,3 +909,58 @@ NTSTATUS nt_status_squash(NTSTATUS nt_status)
 		return nt_status;
 	}
 }
+
+/*****************************************************************************
+ Returns an NT error message.  not amazingly helpful, but better than a number.
+ *****************************************************************************/
+
+const char *nt_errstr(NTSTATUS nt_code)
+{
+	int idx = 0;
+	char *result;
+
+	while (nt_errs[idx].nt_errstr != NULL) {
+		if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
+		    NT_STATUS_V(nt_code)) {
+			return nt_errs[idx].nt_errstr;
+		}
+		idx++;
+	}
+
+	if (!talloc_stackframe_exists()) {
+		/* prevent memory leaks from talloc_tos() by using a
+		 * static area. This means the caller will overwrite
+		 * the string with subsequent calls, which can cause
+		 * display of the wrong error. If that happens the
+		 * caller should have a talloc stackframe
+		 */
+		static char msg[20];
+		snprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code));
+		return msg;
+	}
+
+	result = talloc_asprintf(talloc_tos(), "NT code 0x%08x",
+				 NT_STATUS_V(nt_code));
+	SMB_ASSERT(result != NULL);
+	return result;
+}
+
+/************************************************************************
+ Print friendler version fo NT error code
+ ***********************************************************************/
+
+const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
+{
+	int idx = 0;
+
+	while (nt_err_desc[idx].nt_errstr != NULL) {
+		if (NT_STATUS_V(nt_err_desc[idx].nt_errcode) == NT_STATUS_V(nt_code)) {
+			return nt_err_desc[idx].nt_errstr;
+		}
+		idx++;
+	}
+
+	/* fall back to NT_STATUS_XXX string */
+
+	return nt_errstr(nt_code);
+}
diff --git a/libcli/util/ntstatus.h b/libcli/util/ntstatus.h
index 13ce733..2f16350 100644
--- a/libcli/util/ntstatus.h
+++ b/libcli/util/ntstatus.h
@@ -629,6 +629,15 @@ typedef uint32_t NTSTATUS;
 #define NT_STATUS_FOOBAR NT_STATUS_UNSUCCESSFUL
 
 /*****************************************************************************
+ Returns an NT error message.  not amazingly helpful, but better than a number.
+
+ This version is const, and so neither allocates memory nor uses a
+ static variable for unknown errors.
+ *****************************************************************************/
+
+const char *nt_errstr_const(NTSTATUS nt_code);
+
+/*****************************************************************************
  returns an NT error message.  not amazingly helpful, but better than a number.
  *****************************************************************************/
 const char *nt_errstr(NTSTATUS nt_code);
diff --git a/libcli/util/wscript_build b/libcli/util/wscript_build
index 6a07825..d87f0ba 100644
--- a/libcli/util/wscript_build
+++ b/libcli/util/wscript_build
@@ -3,6 +3,6 @@
 
 bld.SAMBA_SUBSYSTEM('LIBCLI_ERRORS',
 	source='doserr.c errormap.c nterr.c',
-	public_deps='talloc'
+	public_deps='talloc samba-util-common'
 	)
 
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 3ef7541..9140659 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -541,7 +541,7 @@ LIBNMB_OBJ = libsmb/unexpected.o libsmb/namecache.o libsmb/nmblib.o \
 	     libsmb/namequery.o ../libcli/nbt/lmhosts.o ../libcli/dns/dns_hosts_file.o libsmb/conncache.o \
 	     libads/dns.o libads/sitename_cache.o
 
-NTERR_OBJ = ../libcli/util/nterr.o libsmb/nterr.o libsmb/smberr.o
+NTERR_OBJ = ../libcli/util/nterr.o libsmb/smberr.o
 DOSERR_OBJ = ../libcli/util/doserr.o
 ERRORMAP_OBJ = ../libcli/util/errormap.o libsmb/errormap.o
 DCE_RPC_ERR_OBJ = ../librpc/rpc/dcerpc_error.o
diff --git a/source3/include/proto.h b/source3/include/proto.h
index f364307..98445d8 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1095,13 +1095,6 @@ bool get_dc_name(const char *domain,
 		fstring srv_name,
 		struct sockaddr_storage *ss_out);
 
-/* The following definitions come from libsmb/nterr.c  */
-
-const char *nt_errstr(NTSTATUS nt_code);
-const char *get_friendly_nt_error_msg(NTSTATUS nt_code);
-NTSTATUS nt_status_string_to_code(const char *nt_status_str);
-NTSTATUS nt_status_squash(NTSTATUS nt_status);
-
 /* The following definitions come from libsmb/ntlmssp.c  */
 struct ntlmssp_state;
 NTSTATUS ntlmssp_set_username(struct ntlmssp_state *ntlmssp_state, const char *user) ;
diff --git a/source3/lib/errmap_unix.c b/source3/lib/errmap_unix.c
index 8de397c..ea19547 100644
--- a/source3/lib/errmap_unix.c
+++ b/source3/lib/errmap_unix.c
@@ -28,6 +28,14 @@ static const struct {
 	int unix_error;
 	NTSTATUS nt_error;
 } unix_nt_errmap[] = {
+	{ EAGAIN,       NT_STATUS_NETWORK_BUSY },
+	{ EINTR,        NT_STATUS_RETRY },
+#ifdef ENOBUFS
+	{ ENOBUFS,      NT_STATUS_INSUFFICIENT_RESOURCES },
+#endif
+#ifdef EWOULDBLOCK
+	{ EWOULDBLOCK,  NT_STATUS_NETWORK_BUSY },
+#endif
 	{ EPERM,        NT_STATUS_ACCESS_DENIED },
 	{ EACCES,       NT_STATUS_ACCESS_DENIED },
 	{ ENOENT,       NT_STATUS_OBJECT_NAME_NOT_FOUND },
@@ -41,8 +49,10 @@ static const struct {
 	{ ENOSPC,       NT_STATUS_DISK_FULL },
 	{ ENOMEM,       NT_STATUS_NO_MEMORY },
 	{ EISDIR,       NT_STATUS_FILE_IS_A_DIRECTORY},
+#ifdef EPIPE
+	{ EPIPE,        NT_STATUS_PIPE_BROKEN},
+#endif
 	{ EMLINK,       NT_STATUS_TOO_MANY_LINKS },
-	{ EINTR,        NT_STATUS_RETRY },
 	{ ENOSYS,       NT_STATUS_NOT_SUPPORTED },
 #ifdef ELOOP
 	{ ELOOP,        NT_STATUS_OBJECT_PATH_NOT_FOUND },
@@ -68,10 +78,6 @@ static const struct {
 #ifdef EFBIG
 	{ EFBIG,        NT_STATUS_DISK_FULL },
 #endif
-#ifdef ENOBUFS
-	{ ENOBUFS,      NT_STATUS_INSUFFICIENT_RESOURCES },
-#endif
-	{ EAGAIN,       NT_STATUS_NETWORK_BUSY },
 #ifdef EADDRINUSE
 	{ EADDRINUSE,   NT_STATUS_ADDRESS_ALREADY_ASSOCIATED},
 #endif
@@ -96,12 +102,6 @@ static const struct {
 #ifdef ENODEV
 	{ ENODEV,       NT_STATUS_DEVICE_DOES_NOT_EXIST},
 #endif
-#ifdef EPIPE
-	{ EPIPE,        NT_STATUS_PIPE_BROKEN},
-#endif
-#ifdef EWOULDBLOCK
-	{ EWOULDBLOCK,  NT_STATUS_NETWORK_BUSY },
-#endif
 #ifdef ENOATTR
 	{ ENOATTR,      NT_STATUS_NOT_FOUND },
 #endif
diff --git a/source3/libsmb/nterr.c b/source3/libsmb/nterr.c
deleted file mode 100644
index 7d0b3d0..0000000
--- a/source3/libsmb/nterr.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- *  Unix SMB/CIFS implementation.
- *  RPC Pipe client / server routines
- *  Copyright (C) Luke Kenneth Casson Leighton 1997-2001.
- *
- *  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/>.
- */
-
-/* NT error codes.  please read nterr.h */
-
-#include "includes.h"
-
-extern const nt_err_code_struct nt_errs[];
-extern const nt_err_code_struct nt_err_desc[];
-
-#include "smb_ldap.h"
-#undef strcasecmp
-
-/*****************************************************************************
- Returns an NT error message.  not amazingly helpful, but better than a number.
- *****************************************************************************/
-
-const char *nt_errstr(NTSTATUS nt_code)
-{
-	int idx = 0;
-	char *result;
-
-	if (NT_STATUS_IS_DOS(nt_code)) {
-		return smb_dos_err_name(NT_STATUS_DOS_CLASS(nt_code),
-					NT_STATUS_DOS_CODE(nt_code));
-	}
-
-	while (nt_errs[idx].nt_errstr != NULL) {
-		if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
-		    NT_STATUS_V(nt_code)) {
-			return nt_errs[idx].nt_errstr;
-		}
-		idx++;
-	}
-
-	result = talloc_asprintf(talloc_tos(), "NT code 0x%08x",
-				 NT_STATUS_V(nt_code));
-	SMB_ASSERT(result != NULL);
-	return result;
-}
-
-/************************************************************************
- Print friendler version fo NT error code
- ***********************************************************************/
-
-const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
-{
-	int idx = 0;
-
-	while (nt_err_desc[idx].nt_errstr != NULL) {
-		if (NT_STATUS_V(nt_err_desc[idx].nt_errcode) == NT_STATUS_V(nt_code)) {
-			return nt_err_desc[idx].nt_errstr;
-		}
-		idx++;
-	}
-
-	/* fall back to NT_STATUS_XXX string */
-
-	return nt_errstr(nt_code);
-}
-
diff --git a/source3/wscript_build b/source3/wscript_build
index f09b870..9017215 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -1064,7 +1064,7 @@ bld.SAMBA3_SUBSYSTEM('ldb3',
                     deps='samba-util-common')
 
 bld.SAMBA3_SUBSYSTEM('errors3',
-                     source='libsmb/nterr.c libsmb/errormap.c libsmb/smberr.c lib/errmap_unix.c', 
+                     source='libsmb/errormap.c libsmb/smberr.c lib/errmap_unix.c',
                      deps='LIBCLI_ERRORS')
 
 bld.SAMBA3_SUBSYSTEM('LIBCLI_SAMR',
diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c
index 23432ca..6476426 100644
--- a/source4/libcli/util/errormap.c
+++ b/source4/libcli/util/errormap.c
@@ -599,14 +599,25 @@ static const struct {
 	{ EMSGSIZE,     NT_STATUS_INVALID_BUFFER_SIZE },
 	{ ENOMEM,       NT_STATUS_NO_MEMORY },
 	{ EISDIR,       NT_STATUS_FILE_IS_A_DIRECTORY},
+#ifdef EPIPE
 	{ EPIPE,        NT_STATUS_CONNECTION_DISCONNECTED },
+#endif
 	{ EBUSY,        NT_STATUS_SHARING_VIOLATION },
+	{ ENOSYS,	NT_STATUS_INVALID_SYSTEM_SERVICE },
 #ifdef EOPNOTSUPP
 	{ EOPNOTSUPP,   NT_STATUS_NOT_SUPPORTED},
 #endif
+	{ EMLINK,       NT_STATUS_TOO_MANY_LINKS },
+	{ ENOSYS,       NT_STATUS_NOT_SUPPORTED },
+#ifdef ELOOP
+	{ ELOOP,        NT_STATUS_OBJECT_PATH_NOT_FOUND },
+#endif
 #ifdef ENODATA
 	{ ENODATA,      NT_STATUS_NOT_FOUND },
 #endif
+#ifdef EFTYPE
+	{ EFTYPE,       NT_STATUS_OBJECT_PATH_NOT_FOUND },
+#endif
 #ifdef EDQUOT
 	{ EDQUOT,       NT_STATUS_DISK_FULL }, /* Windows apps need this, not NT_STATUS_QUOTA_EXCEEDED */
 #endif
@@ -649,6 +660,9 @@ static const struct {
 #ifdef EAFNOSUPPORT
 	{ EAFNOSUPPORT,	NT_STATUS_INVALID_PARAMETER_MIX },
 #endif
+#ifdef ECONNABORTED
+	{ ECONNABORTED, NT_STATUS_CONNECTION_ABORTED},
+#endif
 #ifdef ECONNRESET
 	{ ECONNRESET,   NT_STATUS_CONNECTION_RESET},
 #endif
@@ -664,9 +678,6 @@ static const struct {
 #ifdef ECANCELED
 	{ ECANCELED,    NT_STATUS_CANCELLED},
 #endif
-#ifdef ENOSYS
-	{ ENOSYS,	NT_STATUS_INVALID_SYSTEM_SERVICE },
-#endif
 #ifdef ENOTSUP
         { ENOTSUP,      NT_STATUS_NOT_SUPPORTED},
 #endif
diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c
deleted file mode 100644
index ea8c0fc..0000000
--- a/source4/libcli/util/nterr.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- *  Unix SMB/CIFS implementation.
- *  RPC Pipe client / server routines
- *  Copyright (C) Luke Kenneth Casson Leighton 1997-2001.
- *
- *  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/>.
- */
-
-/* NT error codes.  please read nterr.h */
-
-#include "includes.h"
-#include "../libcli/ldap/ldap_errors.h"
-#undef strcasecmp
-
-extern const nt_err_code_struct nt_errs[];
-extern const nt_err_code_struct nt_err_desc[];
-
-/*****************************************************************************
- Returns an NT error message.  not amazingly helpful, but better than a number.
- *****************************************************************************/
-
-const char *nt_errstr(NTSTATUS nt_code)
-{
-	static char msg[40];
-	int idx = 0;
-
-	while (nt_errs[idx].nt_errstr != NULL) {
-		if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
-		    NT_STATUS_V(nt_code)) {
-			return nt_errs[idx].nt_errstr;
-		}
-		idx++;
-	}
-
-	if (NT_STATUS_IS_LDAP(nt_code)) {
-		slprintf(msg, sizeof(msg), "LDAP code %u", NT_STATUS_LDAP_CODE(nt_code));
-		return msg;
-	}
-
-	slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code));
-
-	return msg;
-}
-
-/************************************************************************
- Print friendler version fo NT error code
- ***********************************************************************/
-
-const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
-{
-	int idx = 0;
-
-	while (nt_err_desc[idx].nt_errstr != NULL) {
-		if (NT_STATUS_V(nt_err_desc[idx].nt_errcode) == NT_STATUS_V(nt_code)) {
-			return nt_err_desc[idx].nt_errstr;
-		}
-		idx++;
-	}
-
-	/* fall back to NT_STATUS_XXX string */
-
-	return nt_errstr(nt_code);
-}
diff --git a/source4/libcli/wscript_build b/source4/libcli/wscript_build
index d9e85d6..02bb3b8 100644
--- a/source4/libcli/wscript_build
+++ b/source4/libcli/wscript_build
@@ -4,7 +4,7 @@ bld.RECURSE('ldap')
 bld.RECURSE('wbclient')
 
 bld.SAMBA_LIBRARY('errors',
-                  source='util/errormap.c util/nterr.c',
+                  source='util/errormap.c',
                   public_headers='../../libcli/util/error.h ../../libcli/util/ntstatus.h ../../libcli/util/doserr.h ../../libcli/util/werror.h',
                   header_path='core',
                   deps='talloc LIBCLI_ERRORS',


-- 
Samba Shared Repository


More information about the samba-cvs mailing list