[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Tue May 31 20:07:04 MDT 2011


The branch, master has been updated
       via  c7d2f6d Remove the char * argument from the SMB_VFS_GETWD() call. Now always returns malloc'ed memory.
       via  1cee717 Change sys_getcd() to take no arguments and always return malloc'ed memory (or NULL).
       via  5abab13 Add check for the getcwd function being able to take NULL,0 arguments.
       via  313bb1f Split the ACE flag mapping between nfs4 and Windows into two separate functions rather than trying to do it inline. Allows us to carefully control what flags are mapped to what in one place. Modification to bug #8191 - vfs_gpfs dosn't honor ACE_FLAG_INHERITED_ACE
      from  697d5c0 s3:doc: update the ldap_user_dn documentation in the idmap_ldap manpage

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


- Log -----------------------------------------------------------------
commit c7d2f6d35a95678c91faf0b5ac7f83bc5d1abfde
Author: Jeremy Allison <jra at samba.org>
Date:   Tue May 31 16:36:06 2011 -0700

    Remove the char * argument from the SMB_VFS_GETWD() call. Now always
    returns malloc'ed memory.
    
    Autobuild-User: Jeremy Allison <jra at samba.org>
    Autobuild-Date: Wed Jun  1 04:06:12 CEST 2011 on sn-devel-104

commit 1cee71713f75dbee653ea86bd4e7c87efe677cf6
Author: Jeremy Allison <jra at samba.org>
Date:   Tue May 31 16:14:04 2011 -0700

    Change sys_getcd() to take no arguments and always return malloc'ed memory (or NULL).
    
    Part of the efforts to remove PATH_MAX on modern systems.

commit 5abab13851ff2fc3a5792d08cc753c9b479c8cc1
Author: Jeremy Allison <jra at samba.org>
Date:   Tue May 31 15:38:55 2011 -0700

    Add check for the getcwd function being able to take NULL,0 arguments.

commit 313bb1fb9c87084084439c6b45e4c01e82e3f9ec
Author: Jeremy Allison <jra at samba.org>
Date:   Tue May 31 15:37:30 2011 -0700

    Split the ACE flag mapping between nfs4 and Windows
    into two separate functions rather than trying to do
    it inline. Allows us to carefully control what flags
    are mapped to what in one place. Modification to
    bug #8191 - vfs_gpfs dosn't honor ACE_FLAG_INHERITED_ACE

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

Summary of changes:
 examples/VFS/skel_opaque.c       |    2 +-
 examples/VFS/skel_transparent.c  |    4 +-
 source3/client/client.c          |    5 ++-
 source3/configure.in             |   11 ++++++
 source3/include/proto.h          |    2 +-
 source3/include/vfs.h            |    5 ++-
 source3/include/vfs_macros.h     |    8 ++--
 source3/lib/system.c             |   41 +++++++++++++++++----
 source3/modules/nfs4_acls.c      |   73 ++++++++++++++++++++++++++++++-------
 source3/modules/vfs_default.c    |    4 +-
 source3/modules/vfs_full_audit.c |    8 ++--
 source3/modules/vfs_time_audit.c |    4 +-
 source3/printing/print_generic.c |   16 ++++----
 source3/smbd/vfs.c               |   17 +++++----
 source3/torture/cmd_vfs.c        |    5 ++-
 source3/wscript                  |   10 +++++
 16 files changed, 156 insertions(+), 59 deletions(-)


Changeset truncated at 500 lines:

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index f60f0fe..f839993 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -293,7 +293,7 @@ static int skel_chdir(vfs_handle_struct *handle,  const char *path)
 	return -1;
 }
 
-static char *skel_getwd(vfs_handle_struct *handle,  char *buf)
+static char *skel_getwd(vfs_handle_struct *handle)
 {
 	errno = ENOSYS;
 	return NULL;
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index f06e02a..7c91a61 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -280,9 +280,9 @@ static int skel_chdir(vfs_handle_struct *handle,  const char *path)
 	return SMB_VFS_NEXT_CHDIR(handle, path);
 }
 
-static char *skel_getwd(vfs_handle_struct *handle,  char *buf)
+static char *skel_getwd(vfs_handle_struct *handle)
 {
-	return SMB_VFS_NEXT_GETWD(handle, buf);
+	return SMB_VFS_NEXT_GETWD(handle);
 }
 
 static int skel_ntimes(vfs_handle_struct *handle,
diff --git a/source3/client/client.c b/source3/client/client.c
index 7cffddb..f088c7c 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -3876,11 +3876,12 @@ static int cmd_lcd(void)
 				buf, strerror(errno));
 		}
 	}
-	d = TALLOC_ARRAY(ctx, char, PATH_MAX+1);
+	d = sys_getwd();
 	if (!d) {
 		return 1;
 	}
-	DEBUG(2,("the local directory is now %s\n",sys_getwd(d)));
+	DEBUG(2,("the local directory is now %s\n",d));
+	SAFE_FREE(d);
 	return 0;
 }
 
diff --git a/source3/configure.in b/source3/configure.in
index e1e2d39..12d083b 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -2602,6 +2602,17 @@ if test x"$samba_cv_HAVE_LINUX_FALLOCATE64" = x"yes" && test x"$ac_cv_func_fallo
     AC_DEFINE(HAVE_LINUX_FALLOCATE64,1,[Whether the Linux 'fallocate64' function is available])
 fi
 
+AC_CACHE_CHECK([for getcwd takes NULL],samba_cv_GETCWD_TAKES_NULL,[
+AC_TRY_RUN([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+main() { char *s = getcwd(NULL,0); if (s) exit(0); exit(1); }],
+samba_cv_GETCWD_TAKES_NULL=yes,samba_cv_GETCWD_TAKES_NULL=no,samba_cv_GETCWD_TAKES_NULL=cross)])
+if test x"$samba_cv_GETCWD_TAKES_NULL" = x"yes"; then
+    AC_DEFINE(GETCWD_TAKES_NULL,1,[Whether the getcwd function takes NULL as an argument])
+fi
+
 ICONV_LOOK_DIRS="/usr /usr/local /sw /opt"
 AC_ARG_WITH(libiconv,
 [AS_HELP_STRING([--with-libiconv=BASEDIR], [Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto)])],
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 23654e1..8338259 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -391,7 +391,7 @@ void sys_rewinddir(SMB_STRUCT_DIR *dirp);
 int sys_closedir(SMB_STRUCT_DIR *dirp);
 int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev);
 int sys_waitpid(pid_t pid,int *status,int options);
-char *sys_getwd(char *s);
+char *sys_getwd(void);
 void set_effective_capability(enum smbd_capability capability);
 void drop_effective_capability(enum smbd_capability capability);
 long sys_random(void);
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 185bc76..145b52c 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -134,6 +134,7 @@
 		to split out the two possible uses. JRA. */
 /* Leave at 28 - not yet released. Add fdopendir. JRA. */
 /* Leave at 28 - not yet released. Rename open function to open_fn. - gd */
+/* Leave at 28 - not yet released. Make getwd function always return malloced memory. JRA. */
 #define SMB_VFS_INTERFACE_VERSION 28
 
 /*
@@ -250,7 +251,7 @@ struct vfs_fn_pointers {
 	int (*fchown)(struct vfs_handle_struct *handle, struct files_struct *fsp, uid_t uid, gid_t gid);
 	int (*lchown)(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid);
 	int (*chdir)(struct vfs_handle_struct *handle, const char *path);
-	char *(*getwd)(struct vfs_handle_struct *handle, char *buf);
+	char *(*getwd)(struct vfs_handle_struct *handle);
 	int (*ntimes)(struct vfs_handle_struct *handle,
 		      const struct smb_filename *smb_fname,
 		      struct smb_file_time *ft);
@@ -613,7 +614,7 @@ int smb_vfs_call_fchown(struct vfs_handle_struct *handle,
 int smb_vfs_call_lchown(struct vfs_handle_struct *handle, const char *path,
 			uid_t uid, gid_t gid);
 int smb_vfs_call_chdir(struct vfs_handle_struct *handle, const char *path);
-char *smb_vfs_call_getwd(struct vfs_handle_struct *handle, char *buf);
+char *smb_vfs_call_getwd(struct vfs_handle_struct *handle);
 int smb_vfs_call_ntimes(struct vfs_handle_struct *handle,
 			const struct smb_filename *smb_fname,
 			struct smb_file_time *ft);
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 4b1d1d2..c7686f1 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -239,10 +239,10 @@
 #define SMB_VFS_NEXT_CHDIR(handle, path) \
 	smb_vfs_call_chdir((handle)->next, (path))
 
-#define SMB_VFS_GETWD(conn, buf) \
-	smb_vfs_call_getwd((conn)->vfs_handles, (buf))
-#define SMB_VFS_NEXT_GETWD(handle, buf) \
-	smb_vfs_call_getwd((handle)->next, (buf))
+#define SMB_VFS_GETWD(conn) \
+	smb_vfs_call_getwd((conn)->vfs_handles)
+#define SMB_VFS_NEXT_GETWD(handle) \
+	smb_vfs_call_getwd((handle)->next)
 
 #define SMB_VFS_NTIMES(conn, path, ts) \
 	smb_vfs_call_ntimes((conn)->vfs_handles, (path), (ts))
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 0dd4b81..a6f7de0 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -959,18 +959,45 @@ int sys_waitpid(pid_t pid,int *status,int options)
 }
 
 /*******************************************************************
- System wrapper for getwd
+ System wrapper for getwd. Always returns MALLOC'ed memory, or NULL
+ on error (malloc fail usually).
 ********************************************************************/
 
-char *sys_getwd(char *s)
+char *sys_getwd(void)
 {
-	char *wd;
-#ifdef HAVE_GETCWD
-	wd = (char *)getcwd(s, PATH_MAX);
+#ifdef GETCWD_TAKES_NULL
+	return getcwd(NULL, 0);
+#elif HAVE_GETCWD
+	char *wd = NULL, *s = NULL;
+	size_t allocated = PATH_MAX;
+
+	while (1) {
+		s = SMB_REALLOC_ARRAY(s, char, allocated);
+		if (s == NULL) {
+			return NULL;
+		}
+		wd = getcwd(s, allocated);
+		if (wd) {
+			break;
+		}
+		if (errno != ERANGE) {
+			SAFE_FREE(s);
+			break;
+		}
+		allocated *= 2;
+		if (allocated < PATH_MAX) {
+			SAFE_FREE(s);
+			break;
+		}
+	}
+	return wd;
 #else
-	wd = (char *)getwd(s);
+	char *s = SMB_MALLOC_ARRAY(char, PATH_MAX);
+	if (s == NULL) {
+		return NULL;
+	}
+	return getwd(s);
 #endif
-	return wd;
 }
 
 #if defined(HAVE_POSIX_CAPABILITIES)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 7303d0b..bbde532 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -52,6 +52,57 @@ typedef struct _SMB_ACL4_INT_T
 	SMB_ACE4_INT_T	*last;
 } SMB_ACL4_INT_T;
 
+/************************************************
+ Split the ACE flag mapping between nfs4 and Windows
+ into two separate functions rather than trying to do
+ it inline. Allows us to carefully control what flags
+ are mapped to what in one place.
+************************************************/
+
+static uint32_t map_nfs4_ace_flags_to_windows_ace_flags(uint32_t nfs4_ace_flags)
+{
+	uint32_t win_ace_flags = 0;
+
+	/* The nfs4 flags <= 0xf map perfectly. */
+	win_ace_flags = nfs4_ace_flags & (SEC_ACE_FLAG_OBJECT_INHERIT|
+				      SEC_ACE_FLAG_CONTAINER_INHERIT|
+				      SEC_ACE_FLAG_NO_PROPAGATE_INHERIT|
+				      SEC_ACE_FLAG_INHERIT_ONLY);
+
+	/* flags greater than 0xf have diverged :-(. */
+	/* See the nfs4 ace flag definitions here:
+	   http://www.ietf.org/rfc/rfc3530.txt.
+	   And the Windows ace flag definitions here:
+	   librpc/idl/security.idl. */
+	if (nfs4_ace_flags & SMB_ACE4_INHERITED_ACE) {
+		win_ace_flags |= SEC_ACE_FLAG_INHERITED_ACE;
+	}
+
+	return win_ace_flags;
+}
+
+static uint32_t map_windows_ace_flags_to_nfs4_ace_flags(uint32_t win_ace_flags)
+{
+	uint32_t nfs4_ace_flags = 0;
+
+	/* The windows flags <= 0xf map perfectly. */
+	nfs4_ace_flags = win_ace_flags & (SMB_ACE4_FILE_INHERIT_ACE|
+				      SMB_ACE4_DIRECTORY_INHERIT_ACE|
+				      SMB_ACE4_NO_PROPAGATE_INHERIT_ACE|
+				      SMB_ACE4_INHERIT_ONLY_ACE);
+
+	/* flags greater than 0xf have diverged :-(. */
+	/* See the nfs4 ace flag definitions here:
+	   http://www.ietf.org/rfc/rfc3530.txt.
+	   And the Windows ace flag definitions here:
+	   librpc/idl/security.idl. */
+	if (win_ace_flags & SEC_ACE_FLAG_INHERITED_ACE) {
+		nfs4_ace_flags |= SMB_ACE4_INHERITED_ACE;
+	}
+
+	return nfs4_ace_flags;
+}
+
 static SMB_ACL4_INT_T *get_validated_aclint(SMB4ACL_T *theacl)
 {
 	SMB_ACL4_INT_T *aclint = (SMB_ACL4_INT_T *)theacl;
@@ -234,7 +285,7 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx, SMB4ACL_T *theacl, /* in */
 		uint32_t mask;
 		struct dom_sid sid;
 		SMB_ACE4PROP_T	*ace = &aceint->prop;
-		uint32_t mapped_ace_flags;
+		uint32_t win_ace_flags;
 
 		DEBUG(10, ("magic: 0x%x, type: %d, iflags: %x, flags: %x, mask: %x, "
 			"who: %d\n", aceint->magic, ace->aceType, ace->flags,
@@ -271,28 +322,25 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx, SMB4ACL_T *theacl, /* in */
 			ace->aceMask |= SMB_ACE4_DELETE_CHILD;
 		}
 
-		mapped_ace_flags = ace->aceFlags & 0xf;
-		if (ace->aceFlags & SMB_ACE4_INHERITED_ACE) {
-			mapped_ace_flags |= SEC_ACE_FLAG_INHERITED_ACE;
-		}
-		if (!is_directory && (mapped_ace_flags & (SMB_ACE4_FILE_INHERIT_ACE|SMB_ACE4_DIRECTORY_INHERIT_ACE))) {
+		win_ace_flags = map_nfs4_ace_flags_to_windows_ace_flags(ace->aceFlags);
+		if (!is_directory && (win_ace_flags & (SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT))) {
 			/*
 			 * GPFS sets inherits dir_inhert and file_inherit flags
 			 * to files, too, which confuses windows, and seems to
 			 * be wrong anyways. ==> Map these bits away for files.
 			 */
 			DEBUG(10, ("removing inherit flags from nfs4 ace\n"));
-			mapped_ace_flags &= ~(SMB_ACE4_FILE_INHERIT_ACE|SMB_ACE4_DIRECTORY_INHERIT_ACE);
+			win_ace_flags &= ~(SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT);
 		}
-		DEBUG(10, ("mapped ace flags: 0x%x => 0x%x\n",
-		      ace->aceFlags, mapped_ace_flags));
+		DEBUG(10, ("Windows mapped ace flags: 0x%x => 0x%x\n",
+		      ace->aceFlags, win_ace_flags));
 
 		/* Windows clients expect SYNC on acls to
 		   correctly allow rename. See bug #7909. */
 		mask = ace->aceMask | SMB_ACE4_SYNCHRONIZE;
 		init_sec_ace(&nt_ace_list[good_aces++], &sid,
 			ace->aceType, mask,
-			mapped_ace_flags);
+			win_ace_flags);
 	}
 
 	*ppnt_ace_list = nt_ace_list;
@@ -566,10 +614,7 @@ static bool smbacl4_fill_ace4(
 
 	memset(ace_v4, 0, sizeof(SMB_ACE4PROP_T));
 	ace_v4->aceType = ace_nt->type; /* only ACCESS|DENY supported right now */
-	ace_v4->aceFlags = ace_nt->flags & SEC_ACE_FLAG_VALID_INHERIT;
-	if (ace_nt->flags & SEC_ACE_FLAG_INHERITED_ACE) {
-		ace_v4->aceFlags |= SMB_ACE4_INHERITED_ACE;
-	}
+	ace_v4->aceFlags = map_windows_ace_flags_to_nfs4_ace_flags(ace_nt->flags);
 	ace_v4->aceMask = ace_nt->access_mask &
 		(SEC_STD_ALL | SEC_FILE_ALL);
 
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 4d06a10..2dc7ec7 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -748,12 +748,12 @@ static int vfswrap_chdir(vfs_handle_struct *handle,  const char *path)
 	return result;
 }
 
-static char *vfswrap_getwd(vfs_handle_struct *handle,  char *path)
+static char *vfswrap_getwd(vfs_handle_struct *handle)
 {
 	char *result;
 
 	START_PROFILE(syscall_getwd);
-	result = sys_getwd(path);
+	result = sys_getwd();
 	END_PROFILE(syscall_getwd);
 	return result;
 }
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index 3b9c20a..bf7dacd 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -1208,14 +1208,14 @@ static int smb_full_audit_chdir(vfs_handle_struct *handle,
 	return result;
 }
 
-static char *smb_full_audit_getwd(vfs_handle_struct *handle,
-			 char *path)
+static char *smb_full_audit_getwd(vfs_handle_struct *handle)
 {
 	char *result;
 
-	result = SMB_VFS_NEXT_GETWD(handle, path);
+	result = SMB_VFS_NEXT_GETWD(handle);
 	
-	do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
+	do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s",
+		result == NULL? "" : result);
 
 	return result;
 }
diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c
index d21542c..0f32619 100644
--- a/source3/modules/vfs_time_audit.c
+++ b/source3/modules/vfs_time_audit.c
@@ -869,14 +869,14 @@ static int smb_time_audit_chdir(vfs_handle_struct *handle, const char *path)
 	return result;
 }
 
-static char *smb_time_audit_getwd(vfs_handle_struct *handle, char *path)
+static char *smb_time_audit_getwd(vfs_handle_struct *handle)
 {
 	char *result;
 	struct timespec ts1,ts2;
 	double timediff;
 
 	clock_gettime_mono(&ts1);
-	result = SMB_VFS_NEXT_GETWD(handle, path);
+	result = SMB_VFS_NEXT_GETWD(handle);
 	clock_gettime_mono(&ts2);
 	timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c
index b925bed..14f4c6d 100644
--- a/source3/printing/print_generic.c
+++ b/source3/printing/print_generic.c
@@ -155,17 +155,17 @@ static int generic_job_submit(int snum, struct printjob *pjob)
 
 	/* we print from the directory path to give the best chance of
            parsing the lpq output */
-	current_directory = TALLOC_ARRAY(ctx,
-					char,
-					PATH_MAX+1);
-	if (!current_directory) {
-		return -1;
-	}
-	wd = sys_getwd(current_directory);
+	wd = sys_getwd();
 	if (!wd) {
 		return -1;
 	}
 
+	current_directory = talloc_strdup(ctx, wd);
+	SAFE_FREE(wd);
+
+	if (!current_directory) {
+		return -1;
+	}
 	print_directory = talloc_strdup(ctx, pjob->filename);
 	if (!print_directory) {
 		return -1;
@@ -205,7 +205,7 @@ static int generic_job_submit(int snum, struct printjob *pjob)
 
  out:
 
-	if (chdir(wd) == -1) {
+	if (chdir(current_directory) == -1) {
 		smb_panic("chdir failed in generic_job_submit");
 	}
 	TALLOC_FREE(current_directory);
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 015fc56..8c526fa 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -795,7 +795,7 @@ int vfs_ChDir(connection_struct *conn, const char *path)
 
 char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
 {
-        char s[PATH_MAX+1];
+        char *current_dir = NULL;
 	char *result = NULL;
 	DATA_BLOB cache_value;
 	struct file_id key;
@@ -803,8 +803,6 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
 	struct smb_filename *smb_fname_full = NULL;
 	NTSTATUS status;
 
-	*s = 0;
-
 	if (!lp_getwd_cache()) {
 		goto nocache;
 	}
@@ -866,7 +864,8 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
 	 * systems, or the not quite so bad getwd.
 	 */
 
-	if (!SMB_VFS_GETWD(conn,s)) {
+	current_dir = SMB_VFS_GETWD(conn);
+	if (current_dir == NULL) {
 		DEBUG(0, ("vfs_GetWd: SMB_VFS_GETWD call failed: %s\n",
 			  strerror(errno)));
 		goto out;
@@ -877,10 +876,11 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
 
 		memcache_add(smbd_memcache(), GETWD_CACHE,
 			     data_blob_const(&key, sizeof(key)),
-			     data_blob_const(s, strlen(s)+1));
+			     data_blob_const(current_dir,
+						strlen(current_dir)+1));
 	}
 
-	result = talloc_strdup(ctx, s);
+	result = talloc_strdup(ctx, current_dir);
 	if (result == NULL) {
 		errno = ENOMEM;
 	}
@@ -888,6 +888,7 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
  out:
 	TALLOC_FREE(smb_fname_dot);
 	TALLOC_FREE(smb_fname_full);
+	SAFE_FREE(current_dir);
 	return result;
 }
 
@@ -1553,10 +1554,10 @@ int smb_vfs_call_chdir(struct vfs_handle_struct *handle, const char *path)
 	return handle->fns->chdir(handle, path);
 }
 
-char *smb_vfs_call_getwd(struct vfs_handle_struct *handle, char *buf)
+char *smb_vfs_call_getwd(struct vfs_handle_struct *handle)
 {
 	VFS_FIND(getwd);
-	return handle->fns->getwd(handle, buf);
+	return handle->fns->getwd(handle);
 }
 
 int smb_vfs_call_ntimes(struct vfs_handle_struct *handle,
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index 2c3a416..c73bf6f 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -889,13 +889,14 @@ static NTSTATUS cmd_fchown(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
 
 static NTSTATUS cmd_getwd(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
 {
-	char buf[PATH_MAX];
-	if (SMB_VFS_GETWD(vfs->conn, buf) == NULL) {
+	char *buf = SMB_VFS_GETWD(vfs->conn);
+	if (buf == NULL) {
 		printf("getwd: error=%d (%s)\n", errno, strerror(errno));
 		return NT_STATUS_UNSUCCESSFUL;
 	}
 
 	printf("getwd: %s\n", buf);
+	SAFE_FREE(buf);
 	return NT_STATUS_OK;
 }
 
diff --git a/source3/wscript b/source3/wscript
index ee4a98c..83b0a0e 100644
--- a/source3/wscript
+++ b/source3/wscript


-- 
Samba Shared Repository


More information about the samba-cvs mailing list