[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Fri Apr 29 02:01:05 MDT 2011


The branch, master has been updated
       via  f967931 build: put doserr.c into it's own subsystem, so it's no longer a duplicate
       via  3542bd3 selftest: Restore the s3member environment by avoiding smbcacls
       via  bc31e9c s4-param Rename lp_destructor() -> lpcfg_destructor() for consistency
       via  96136ad s4-param Rename unused lp_ functions to match param.h
       via  7730ab0 s4-param Rename volume_label() -> lpcfg_volume_label()
       via  93ace5c lib/util Re-merge the string_sub() and all_string_sub() from source3
       via  9a9124b lib/util/charset Move strstr_m() to the top level
       via  67905b4 s4-param Rename private_path() -> lpcfg_private_path()
       via  dbbc6e9 s4-param Remove config_path() -> lpcfg_config_path()
       via  209d47c s4-param Rename lock_path() -> lpcfg_lock_path()
       via  6021af4 libcli/smb Move attrib_string in common
       via  724915f s3-client Add TALLOC_CTX argument to attrib_string().
       via  0520da2 s3-smb Use FILE_ATTRIBUTE_ARCHIVE intead of aARCH
       via  0eca33b s3-smb Use FILE_ATTRIBUTE_DIRECTORY intead of aDIR
       via  08c90d6 s3-smb Use FILE_ATTRIBUTE_VOLUME intead of aVOLID
       via  0a3c84b s3-smb Use FILE_ATTRIBUTE_SYSTEM intead of aSYSTEM
       via  317e19a s3-smb Use FILE_ATTRIBUTE_HIDDEN intead of aHIDDEN
       via  7f66ebd s3-smb Use FILE_ATTRIBUTE_READONLY intead of aRONLY
       via  9f75b7c libcli/smb Move FILE_ATTRIBUTE defines to the top level
       via  5cc7a3a s3-libads Move variables into if (socket_wrapper_dir()) where they are used.
       via  bb520dc build: Fix kerberos build issues in top level build
       via  a3ec605 s3-ldap Move ldap prototypes to inside #ifdef HAVE_LDAP_H
      from  e050677 Revert "s4:selftest: skip s3member tests for now"

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


- Log -----------------------------------------------------------------
commit f96793142d0b5a6e0bdb0bcf4811178f3274949c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 16:57:41 2011 +1000

    build: put doserr.c into it's own subsystem, so it's no longer a duplicate
    
    Autobuild-User: Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date: Fri Apr 29 10:00:32 CEST 2011 on sn-devel-104

commit 3542bd324ecea130292909fd052f71ab0790b7d3
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 15:54:20 2011 +1000

    selftest: Restore the s3member environment by avoiding smbcacls
    
    This removes the need for acls on the filesystem for simple domain
    member tests.  ACL tests should be written at some point...
    
    Andrew Bartlett
    
    Pair-Programmed-With: Andrew Tridgell <tridge at samba.org>

commit bc31e9c7d2a030dc0f63322f5c42d2fe22bbf7ff
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 14:02:16 2011 +1000

    s4-param Rename lp_destructor() -> lpcfg_destructor() for consistency

commit 96136ad6567fc1793bf0669c4fd65f680d521dae
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 13:58:26 2011 +1000

    s4-param Rename unused lp_ functions to match param.h

commit 7730ab00b5c0c8c8bf7b239c65cf769108874dae
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 13:30:18 2011 +1000

    s4-param Rename volume_label() -> lpcfg_volume_label()

commit 93ace5cc2484b53fc33d4689ccc286defbe2b728
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 13:20:51 2011 +1000

    lib/util Re-merge the string_sub() and all_string_sub() from source3
    
    Andrew Bartlett

commit 9a9124b08760a6235059f517b9a138337754cd02
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 13:19:41 2011 +1000

    lib/util/charset Move strstr_m() to the top level

commit 67905b41a97fb7c0a7f4c7070e837f1fcb8bfbb4
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 12:47:11 2011 +1000

    s4-param Rename private_path() -> lpcfg_private_path()
    
    This is consistent with lock_path()
    
    Andrew Bartlett

commit dbbc6e9ddac30de869d67410869dba90b4bd4a19
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 12:46:10 2011 +1000

    s4-param Remove config_path() -> lpcfg_config_path()
    
    This is consistent with lock_path()
    
    Andrew Bartlett

commit 209d47c100bf59f15519c4c82089285210041c2e
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 12:41:45 2011 +1000

    s4-param Rename lock_path() -> lpcfg_lock_path()
    
    This avoids a conflict with the source3/ lock_path()

commit 6021af4fd38d2a712dca42a3cacf8537007fd160
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 12:41:27 2011 +1000

    libcli/smb Move attrib_string in common

commit 724915f721819705c7cf5c850a24b32f815c07e3
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 12:05:07 2011 +1000

    s3-client Add TALLOC_CTX argument to attrib_string().
    
    This ensures the caller knows where the memory was allocated.
    
    Andrew Bartlett

commit 0520da2bbe246c45d89bfdec0d399862ecb867ba
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 12:00:57 2011 +1000

    s3-smb Use FILE_ATTRIBUTE_ARCHIVE intead of aARCH
    
    This means we use just one constant for this file attribute.
    
    Andrew Bartlett

commit 0eca33bbf620678759bbe39efaa74f33f96efb74
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 11:57:02 2011 +1000

    s3-smb Use FILE_ATTRIBUTE_DIRECTORY intead of aDIR
    
    This means we use just one constant for this file attribute.
    
    Andrew Bartlett

commit 08c90d6f2df85499f43c5766a62839e80437290f
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 11:52:48 2011 +1000

    s3-smb Use FILE_ATTRIBUTE_VOLUME intead of aVOLID
    
    This means we use just one constant for this file attribute.
    
    Andrew Bartlett

commit 0a3c84b554f3862b3e558f62e67ceb8311b248ce
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 13:23:14 2011 +1000

    s3-smb Use FILE_ATTRIBUTE_SYSTEM intead of aSYSTEM
    
    This means we use just one constant for this file attribute.
    
    Andrew Bartlett

commit 317e19aeb3fbdb21573b6ef1bc8c2af646a7e61e
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 11:43:35 2011 +1000

    s3-smb Use FILE_ATTRIBUTE_HIDDEN intead of aHIDDEN
    
    This means we use just one constant for this file attribute.
    
    Andrew Bartlett

commit 7f66ebde2e2975b079f6c135b131d064dab38624
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 11:36:14 2011 +1000

    s3-smb Use FILE_ATTRIBUTE_READONLY intead of aRONLY
    
    This means we use just one constant for this file attribute.
    
    Andrew Bartlett

commit 9f75b7cbb3d25b3a799f0dc50587260036e40719
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Apr 29 11:25:56 2011 +1000

    libcli/smb Move FILE_ATTRIBUTE defines to the top level

commit 5cc7a3a22261d92ca07c09e14545a9ad38a90db9
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Apr 28 18:12:03 2011 +1000

    s3-libads Move variables into if (socket_wrapper_dir()) where they are used.

commit bb520dceac7e55ba63826edd9a12aba7c877db38
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Apr 28 16:23:53 2011 +1000

    build: Fix kerberos build issues in top level build

commit a3ec6052f90562a1e973ca7fc8a2acf9f41de7f0
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Apr 28 15:49:21 2011 +1000

    s3-ldap Move ldap prototypes to inside #ifdef HAVE_LDAP_H
    
    This fixes the build without LDAP development headers.

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

Summary of changes:
 lib/util/charset/charset.h                         |    1 +
 lib/util/charset/util_str.c                        |   83 +++++++
 lib/util/substitute.c                              |   55 ++++--
 lib/util/util.h                                    |    2 +
 lib/util/wscript_build                             |    4 +-
 libcli/smb/smb_common.h                            |    1 +
 libcli/smb/smb_constants.h                         |   23 ++
 .../auth_server_service.c => libcli/smb/smb_util.h |   14 +-
 libcli/smb/util.c                                  |   69 ++++++
 libcli/smb/wscript_build                           |    2 +-
 libcli/util/wscript_build                          |    8 +
 selftest/selftest.pl                               |   10 +-
 selftest/target/Samba3.pm                          |   18 +--
 source3/Makefile.in                                |    5 +-
 source3/client/client.c                            |   44 ++--
 source3/client/clitar.c                            |   22 +-
 source3/include/proto.h                            |    7 -
 source3/include/smb.h                              |   28 ---
 source3/include/smb_ldap.h                         |   21 +-
 source3/include/smb_macros.h                       |   10 +-
 source3/lib/util.c                                 |   20 --
 source3/lib/util_str.c                             |  209 ------------------
 source3/libads/ldap.c                              |    8 +-
 source3/libgpo/gpo_filesync.c                      |    4 +-
 source3/libsmb/clifile.c                           |    6 +-
 source3/libsmb/libsmb_dir.c                        |   18 +-
 source3/locking/locking.c                          |    2 +-
 source3/modules/onefs_acl.c                        |    2 +-
 source3/modules/onefs_open.c                       |    8 +-
 source3/rpc_server/wscript_build                   |    3 +-
 source3/smbd/dir.c                                 |    8 +-
 source3/smbd/dosmode.c                             |   90 ++++----
 source3/smbd/fileio.c                              |    2 +-
 source3/smbd/nttrans.c                             |    4 +-
 source3/smbd/open.c                                |   10 +-
 source3/smbd/reply.c                               |   40 ++--
 source3/smbd/smb2_find.c                           |    2 +-
 source3/smbd/trans2.c                              |   18 +-
 source3/torture/denytest.c                         |    8 +-
 source3/torture/locktest.c                         |    2 +-
 source3/torture/locktest2.c                        |    2 +-
 source3/torture/mangle_test.c                      |   10 +-
 source3/torture/masktest.c                         |   10 +-
 source3/torture/nbio.c                             |    8 +-
 source3/torture/scanner.c                          |    4 +-
 source3/torture/torture.c                          |  228 ++++++++++----------
 source3/torture/utable.c                           |    8 +-
 source3/utils/net_rpc.c                            |    4 +-
 source3/utils/smbcacls.c                           |    2 +-
 source3/wscript_build                              |   21 +-
 source4/auth/kerberos/krb5_init_context.c          |    2 +-
 source4/dns_server/dlz_bind9.c                     |    2 +-
 source4/dsdb/dns/dns_update.c                      |    4 +-
 source4/ldap_server/ldap_server.c                  |    4 +-
 source4/lib/ldb-samba/ldb_wrap.c                   |    2 +-
 source4/libcli/raw/rawfile.c                       |   46 ----
 source4/libcli/raw/smb.h                           |   18 --
 source4/libcli/wscript_build                       |    4 +-
 source4/nbt_server/wins/winsdb.c                   |    4 +-
 source4/param/loadparm.c                           |   26 ++--
 source4/param/param.h                              |    8 +-
 source4/param/pyparam.c                            |    2 +-
 source4/param/secrets.c                            |    2 +-
 source4/param/share_classic.c                      |    2 +-
 source4/param/share_ldb.c                          |    2 +-
 source4/param/util.c                               |    8 +-
 source4/smb_server/smb/negprot.c                   |    2 +-
 source4/wrepl_server/wrepl_server.c                |    2 +-
 wscript_build                                      |    1 +
 69 files changed, 609 insertions(+), 720 deletions(-)
 copy source4/auth/ntlm/auth_server_service.c => libcli/smb/smb_util.h (77%)
 create mode 100644 libcli/smb/util.c
 create mode 100644 libcli/util/wscript_build


Changeset truncated at 500 lines:

diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h
index 1078035..d027daa 100644
--- a/lib/util/charset/charset.h
+++ b/lib/util/charset/charset.h
@@ -155,6 +155,7 @@ bool strhasupper_handle(struct smb_iconv_handle *ic,
 			const char *string);
 char *strrchr_m(const char *s, char c);
 char *strchr_m(const char *s, char c);
+char *strstr_m(const char *src, const char *findstr);
 
 bool push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
 bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src, size_t *converted_size);
diff --git a/lib/util/charset/util_str.c b/lib/util/charset/util_str.c
index e8f0b78..71a3778 100644
--- a/lib/util/charset/util_str.c
+++ b/lib/util/charset/util_str.c
@@ -5,6 +5,8 @@
    Copyright (C) Simo Sorce 2001
    Copyright (C) Andrew Bartlett 2011
    Copyright (C) Jeremy Allison  1992-2007
+   Copyright (C) Martin Pool     2003
+   Copyright (C) James Peach	 2006
 
    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
@@ -473,3 +475,84 @@ _PUBLIC_ bool strhasupper(const char *string)
 	struct smb_iconv_handle *ic = get_iconv_handle();
 	return strhasupper_handle(ic, string);
 }
+
+/***********************************************************************
+ strstr_m - We convert via ucs2 for now.
+***********************************************************************/
+
+char *strstr_m(const char *src, const char *findstr)
+{
+	smb_ucs2_t *p;
+	smb_ucs2_t *src_w, *find_w;
+	const char *s;
+	char *s2;
+	char *retp;
+
+	size_t converted_size, findstr_len = 0;
+
+	/* for correctness */
+	if (!findstr[0]) {
+		return (char*)src;
+	}
+
+	/* Samba does single character findstr calls a *lot*. */
+	if (findstr[1] == '\0')
+		return strchr_m(src, *findstr);
+
+	/* We optimise for the ascii case, knowing that all our
+	   supported multi-byte character sets are ascii-compatible
+	   (ie. they match for the first 128 chars) */
+
+	for (s = src; *s && !(((unsigned char)s[0]) & 0x80); s++) {
+		if (*s == *findstr) {
+			if (!findstr_len)
+				findstr_len = strlen(findstr);
+
+			if (strncmp(s, findstr, findstr_len) == 0) {
+				return (char *)s;
+			}
+		}
+	}
+
+	if (!*s)
+		return NULL;
+
+#if 1 /* def BROKEN_UNICODE_COMPOSE_CHARACTERS */
+	/* 'make check' fails unless we do this */
+
+	/* With compose characters we must restart from the beginning. JRA. */
+	s = src;
+#endif
+
+	if (!push_ucs2_talloc(talloc_tos(), &src_w, src, &converted_size)) {
+		DEBUG(0,("strstr_m: src malloc fail\n"));
+		return NULL;
+	}
+
+	if (!push_ucs2_talloc(talloc_tos(), &find_w, findstr, &converted_size)) {
+		TALLOC_FREE(src_w);
+		DEBUG(0,("strstr_m: find malloc fail\n"));
+		return NULL;
+	}
+
+	p = strstr_w(src_w, find_w);
+
+	if (!p) {
+		TALLOC_FREE(src_w);
+		TALLOC_FREE(find_w);
+		return NULL;
+	}
+
+	*p = 0;
+	if (!pull_ucs2_talloc(talloc_tos(), &s2, src_w, &converted_size)) {
+		TALLOC_FREE(src_w);
+		TALLOC_FREE(find_w);
+		DEBUG(0,("strstr_m: dest malloc fail\n"));
+		return NULL;
+	}
+	retp = (char *)(s+strlen(s2));
+	TALLOC_FREE(src_w);
+	TALLOC_FREE(find_w);
+	TALLOC_FREE(s2);
+	return retp;
+}
diff --git a/lib/util/substitute.c b/lib/util/substitute.c
index 32945a7..500d127 100644
--- a/lib/util/substitute.c
+++ b/lib/util/substitute.c
@@ -29,18 +29,20 @@
  **/
 
 /**
- Substitute a string for a pattern in another string. Make sure there is 
+ Substitute a string for a pattern in another string. Make sure there is
  enough room!
 
- This routine looks for pattern in s and replaces it with 
- insert. It may do multiple replacements.
+ This routine looks for pattern in s and replaces it with
+ insert. It may do multiple replacements or just one.
 
  Any of " ; ' $ or ` in the insert string are replaced with _
  if len==0 then the string cannot be extended. This is different from the old
  use of len==0 which was for no length checks to be done.
 **/
 
-_PUBLIC_ void string_sub(char *s, const char *pattern, const char *insert, size_t len)
+static void string_sub2(char *s,const char *pattern, const char *insert, size_t len,
+			bool remove_unsafe_characters, bool replace_once,
+			bool allow_trailing_dollar)
 {
 	char *p;
 	ssize_t ls, lp, li, i;
@@ -55,9 +57,10 @@ _PUBLIC_ void string_sub(char *s, const char *pattern, const char *insert, size_
 	if (len == 0)
 		len = ls + 1; /* len is number of *bytes* */
 
-	while (lp <= ls && (p = strstr(s, pattern))) {
+	while (lp <= ls && (p = strstr_m(s,pattern))) {
 		if (ls + (li-lp) >= len) {
-			DEBUG(0,("ERROR: string overflow by %d in string_sub(%.50s, %d)\n", 
+			DEBUG(0,("ERROR: string overflow by "
+				"%d in string_sub(%.50s, %d)\n",
 				 (int)(ls + (li-lp) - len),
 				 pattern, (int)len));
 			break;
@@ -67,25 +70,50 @@ _PUBLIC_ void string_sub(char *s, const char *pattern, const char *insert, size_
 		}
 		for (i=0;i<li;i++) {
 			switch (insert[i]) {
+			case '$':
+				/* allow a trailing $
+				 * (as in machine accounts) */
+				if (allow_trailing_dollar && (i == li - 1 )) {
+					p[i] = insert[i];
+					break;
+				}
 			case '`':
 			case '"':
 			case '\'':
 			case ';':
-			case '$':
 			case '%':
 			case '\r':
 			case '\n':
-				p[i] = '_';
-				break;
+				if ( remove_unsafe_characters ) {
+					p[i] = '_';
+					/* yes this break should be here
+					 * since we want to fall throw if
+					 * not replacing unsafe chars */
+					break;
+				}
 			default:
 				p[i] = insert[i];
 			}
 		}
 		s = p + li;
 		ls += (li-lp);
+
+		if (replace_once)
+			break;
 	}
 }
 
+void string_sub_once(char *s, const char *pattern,
+		const char *insert, size_t len)
+{
+	string_sub2( s, pattern, insert, len, true, true, false );
+}
+
+void string_sub(char *s,const char *pattern, const char *insert, size_t len)
+{
+	string_sub2( s, pattern, insert, len, true, false, false );
+}
+
 /**
  * Talloc'ed version of string_sub
  */
@@ -146,13 +174,14 @@ _PUBLIC_ void all_string_sub(char *s,const char *pattern,const char *insert, siz
 
 	if (!*pattern)
 		return;
-	
+
 	if (len == 0)
 		len = ls + 1; /* len is number of *bytes* */
-	
-	while (lp <= ls && (p = strstr(s,pattern))) {
+
+	while (lp <= ls && (p = strstr_m(s,pattern))) {
 		if (ls + (li-lp) >= len) {
-			DEBUG(0,("ERROR: string overflow by %d in all_string_sub(%.50s, %d)\n", 
+			DEBUG(0,("ERROR: string overflow by "
+				"%d in all_string_sub(%.50s, %d)\n",
 				 (int)(ls + (li-lp) - len),
 				 pattern, (int)len));
 			break;
diff --git a/lib/util/util.h b/lib/util/util.h
index 4577991..8bbaa0e 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -284,6 +284,8 @@ _PUBLIC_ char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_
 **/
 _PUBLIC_ void string_sub(char *s,const char *pattern, const char *insert, size_t len);
 
+_PUBLIC_ void string_sub_once(char *s, const char *pattern,
+			      const char *insert, size_t len);
 
 _PUBLIC_ char *string_sub_talloc(TALLOC_CTX *mem_ctx, const char *s, 
 				const char *pattern, const char *insert);
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index f1bb9e7..561dcc4 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -5,11 +5,11 @@ common_util_sources = '''talloc_stack.c smb_threads.c xfile.c data_blob.c
                     genrand.c fsusage.c blocking.c become_daemon.c
                     signal.c system.c params.c util.c util_id.c util_net.c
                     util_strlist.c idtree.c debug.c fault.c base64.c
-                    util_str_common.c'''
+                    util_str_common.c substitute.c'''
 
 common_util_headers = 'debug.h'
 common_util_public_deps = 'talloc pthread LIBCRYPTO'
-s4_util_sources = '''dprintf.c ms_fnmatch.c parmlist.c substitute.c util_str.c'''
+s4_util_sources = '''dprintf.c ms_fnmatch.c parmlist.c util_str.c'''
 s4_util_deps = 'DYNCONFIG'
 s4_util_public_deps = 'talloc CHARSET execinfo uid_wrapper'
 s4_util_public_headers = 'attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h util.h'
diff --git a/libcli/smb/smb_common.h b/libcli/smb/smb_common.h
index 8fe0623..ca04eb3 100644
--- a/libcli/smb/smb_common.h
+++ b/libcli/smb/smb_common.h
@@ -25,5 +25,6 @@
 #include "../libcli/smb/smb2_constants.h"
 #include "../libcli/smb/smb2_create_blob.h"
 #include "../libcli/smb/smb_constants.h"
+#include "../libcli/smb/smb_util.h"
 
 #endif
diff --git a/libcli/smb/smb_constants.h b/libcli/smb/smb_constants.h
index 83e6388..59a6d9e 100644
--- a/libcli/smb/smb_constants.h
+++ b/libcli/smb/smb_constants.h
@@ -35,5 +35,28 @@
 #define FLAGS2_UNICODE_STRINGS         0x8000
 #define FLAGS2_WIN2K_SIGNATURE         0xC852 /* Hack alert ! For now... JRA. */
 
+/* FileAttributes (search attributes) field */
+#define FILE_ATTRIBUTE_READONLY		0x0001L
+#define FILE_ATTRIBUTE_HIDDEN		0x0002L
+#define FILE_ATTRIBUTE_SYSTEM		0x0004L
+#define FILE_ATTRIBUTE_VOLUME		0x0008L
+#define FILE_ATTRIBUTE_DIRECTORY	0x0010L
+#define FILE_ATTRIBUTE_ARCHIVE		0x0020L
+#define FILE_ATTRIBUTE_DEVICE		0x0040L
+#define FILE_ATTRIBUTE_NORMAL		0x0080L
+#define FILE_ATTRIBUTE_TEMPORARY	0x0100L
+#define FILE_ATTRIBUTE_SPARSE		0x0200L
+#define FILE_ATTRIBUTE_REPARSE_POINT	0x0400L
+#define FILE_ATTRIBUTE_COMPRESSED	0x0800L
+#define FILE_ATTRIBUTE_OFFLINE		0x1000L
+#define FILE_ATTRIBUTE_NONINDEXED	0x2000L
+#define FILE_ATTRIBUTE_ENCRYPTED	0x4000L
+#define FILE_ATTRIBUTE_ALL_MASK 	0x7FFFL
+
+#define SAMBA_ATTRIBUTES_MASK		(FILE_ATTRIBUTE_READONLY|\
+					FILE_ATTRIBUTE_HIDDEN|\
+					FILE_ATTRIBUTE_SYSTEM|\
+					FILE_ATTRIBUTE_DIRECTORY|\
+					FILE_ATTRIBUTE_ARCHIVE)
 
 #endif /* _SMB_CONSTANTS_H */
diff --git a/source4/auth/ntlm/auth_server_service.c b/libcli/smb/smb_util.h
similarity index 77%
copy from source4/auth/ntlm/auth_server_service.c
copy to libcli/smb/smb_util.h
index 65b9dc2..8a67c30 100644
--- a/source4/auth/ntlm/auth_server_service.c
+++ b/libcli/smb/smb_util.h
@@ -1,7 +1,9 @@
 /*
    Unix SMB/CIFS implementation.
-   Password and authentication handling
-   Copyright (C) Andrew Bartlett         2010
+   client file operations
+   Copyright (C) Andrew Tridgell 1994-1998
+   Copyright (C) Jeremy Allison 2001-2002
+   Copyright (C) James Myers 2003
 
    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
@@ -17,10 +19,4 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
-#include "auth/auth.h"
-
-NTSTATUS server_service_auth_init(void)
-{
-	return auth4_init();
-}
+char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib);
diff --git a/libcli/smb/util.c b/libcli/smb/util.c
new file mode 100644
index 0000000..f8fa56f
--- /dev/null
+++ b/libcli/smb/util.c
@@ -0,0 +1,69 @@
+/*
+   Unix SMB/CIFS implementation.
+   client file operations
+   Copyright (C) Andrew Tridgell 1994-1998
+   Copyright (C) Jeremy Allison 2001-2002
+   Copyright (C) James Myers 2003
+
+   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/smb/smb_common.h"
+
+/**
+ Return a string representing a CIFS attribute for a file.
+**/
+char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib)
+{
+	int i, len;
+	const struct {
+		char c;
+		uint16_t attr;
+	} attr_strs[] = {
+		{'V', FILE_ATTRIBUTE_VOLUME},
+		{'D', FILE_ATTRIBUTE_DIRECTORY},
+		{'A', FILE_ATTRIBUTE_ARCHIVE},
+		{'H', FILE_ATTRIBUTE_HIDDEN},
+		{'S', FILE_ATTRIBUTE_SYSTEM},
+		{'N', FILE_ATTRIBUTE_NORMAL},
+		{'R', FILE_ATTRIBUTE_READONLY},
+		{'d', FILE_ATTRIBUTE_DEVICE},
+		{'t', FILE_ATTRIBUTE_TEMPORARY},
+		{'s', FILE_ATTRIBUTE_SPARSE},
+		{'r', FILE_ATTRIBUTE_REPARSE_POINT},
+		{'c', FILE_ATTRIBUTE_COMPRESSED},
+		{'o', FILE_ATTRIBUTE_OFFLINE},
+		{'n', FILE_ATTRIBUTE_NONINDEXED},
+		{'e', FILE_ATTRIBUTE_ENCRYPTED}
+	};
+	char *ret;
+
+	ret = talloc_array(mem_ctx, char, ARRAY_SIZE(attr_strs)+1);
+	if (!ret) {
+		return NULL;
+	}
+
+	for (len=i=0; i<ARRAY_SIZE(attr_strs); i++) {
+		if (attrib & attr_strs[i].attr) {
+			ret[len++] = attr_strs[i].c;
+		}
+	}
+
+	ret[len] = 0;
+
+	talloc_set_name_const(ret, ret);
+
+	return ret;
+}
diff --git a/libcli/smb/wscript_build b/libcli/smb/wscript_build
index 6796b4c..36d9d10 100644
--- a/libcli/smb/wscript_build
+++ b/libcli/smb/wscript_build
@@ -2,7 +2,7 @@
 
 
 bld.SAMBA_SUBSYSTEM('LIBCLI_SMB_COMMON',
-	source='smb2_create_blob.c',
+	source='smb2_create_blob.c util.c',
 	autoproto='smb_common_proto.h',
 	public_deps='talloc'
 	)
diff --git a/libcli/util/wscript_build b/libcli/util/wscript_build
new file mode 100644
index 0000000..9382e11
--- /dev/null
+++ b/libcli/util/wscript_build
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+
+bld.SAMBA_SUBSYSTEM('LIBCLI_ERRORS',
+	source='doserr.c',
+	public_deps='talloc'
+	)
+
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 5077a17..6f8cbe1 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -399,8 +399,14 @@ $prefix =~ s+/$++;
 
 die("using an empty prefix isn't allowed") unless $prefix ne "";
 
-#Ensure we have the test prefix around
-mkdir($prefix, 0777) unless -d $prefix;
+# Ensure we have the test prefix around.
+#
+# We need restrictive
+# permissions on this as some subdirectories in this tree will have
+# wider permissions (ie 0777) and this would allow other users on the
+# host to subvert the test process.
+mkdir($prefix, 0700) unless -d $prefix;
+chmod 0700, $prefix;
 
 my $prefix_abs = abs_path($prefix);
 my $tmpdir_abs = abs_path("$prefix/tmp");
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 6312d65..0115834 100644
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -247,24 +247,16 @@ sub setup_admember($$$$)
 	    return undef;
 	}
 
+	# We need world access to this share, as otherwise the domain
+	# administrator from the AD domain provided by Samba4 can't
+	# access the share for tests.
+	chmod 0777, "$prefix/share";
+
 	$self->check_or_start($ret,
 			      "yes", "yes", "yes");
 
 	$self->wait_for_start($ret);
 
-	my $smbcacls = Samba::bindir_path($self, "smbcacls");
-	#Allow domain users to manipulate the share
-	$cmd = "";
-	$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
-	$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
-	$cmd .= "$smbcacls $ret->{CONFIGURATION} //127.0.0.29/tmp / -U$ret->{USERNAME}%$ret->{PASSWORD} ";
-	$cmd .= "-S ACL:$dcvars->{DOMAIN}\\\\Domain\\ Users:ALLOWED/0x0/FULL";
-
-	if (system($cmd) != 0) {
-	    warn("smbcacls failed, your filesystem may not support ACLs.  Try mount $prefix_abs -oremount,acl\nThis support is required for S3 member in S4 tests\n$cmd");
-	    return undef;
-	}
-
 	$ret->{DC_SERVER} = $dcvars->{SERVER};
 	$ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
 	$ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 4ec1868..9746a21 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -461,7 +461,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
 	  ../lib/util/charset/util_unistr_w.o ../lib/util/charset/codepoints.o ../lib/util/charset/util_str.o lib/util_file.o \
 	  lib/util.o lib/util_cmdline.o lib/util_names.o \
 	  lib/util_sock.o lib/sock_exec.o lib/util_sec.o \
-	  lib/substitute.o lib/dbwrap_util.o \
+	  lib/substitute.o ../lib/util/substitute.o lib/dbwrap_util.o \
 	  lib/ms_fnmatch.o lib/errmap_unix.o \
 	  lib/tallocmsg.o lib/dmallocmsg.o \


-- 
Samba Shared Repository


More information about the samba-cvs mailing list