* Updated version of the readlink() patch.

svn path=/nixpkgs/trunk/; revision=30013
This commit is contained in:
Eelco Dolstra 2011-10-25 12:52:41 +00:00
parent c7b6e96d84
commit f31cd519b6

82
pkgs/servers/samba/readlink.patch Executable file → Normal file
View File

@ -11,9 +11,18 @@ index 3a64af7..549ebb2 100644
/*
* smb_filename
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 25301e6..691a779 100644
index 25301e6..b2ed239 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -383,7 +383,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
if((!conn->case_sensitive || !(conn->fs_capabilities &
FILE_CASE_SENSITIVE_SEARCH)) &&
- stat_cache_lookup(conn, &smb_fname->base_name, &dirpath, &start,
+ stat_cache_lookup(conn, posix_pathnames, &smb_fname->base_name, &dirpath, &start,
&smb_fname->st)) {
goto done;
}
@@ -977,26 +977,39 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
}
@ -77,7 +86,7 @@ index 25301e6..691a779 100644
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3,("filename_convert: check_name failed "
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index c455ffe..1e5d891 100644
index c455ffe..02b5e40 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -336,6 +336,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
@ -88,8 +97,59 @@ index c455ffe..1e5d891 100644
NTSTATUS check_name(connection_struct *conn, const char *name);
int get_real_filename(connection_struct *conn, const char *path,
const char *name, TALLOC_CTX *mem_ctx,
@@ -1037,6 +1038,7 @@ void stat_cache_add( const char *full_orig_name,
char *translated_path,
bool case_sensitive);
bool stat_cache_lookup(connection_struct *conn,
+ bool posix_paths,
char **pp_name,
char **pp_dirpath,
char **pp_start,
diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c
index e2ccc74..e910982 100644
--- a/source3/smbd/statcache.c
+++ b/source3/smbd/statcache.c
@@ -150,6 +150,7 @@ void stat_cache_add( const char *full_orig_name,
* Look through the stat cache for an entry
*
* @param conn A connection struct to do the stat() with.
+ * @param posix_paths Whether to lookup using stat() or lstat()
* @param name The path we are attempting to cache, modified by this routine
* to be correct as far as the cache can tell us. We assume that
* it is a talloc'ed string from top of stack, we free it if
@@ -166,6 +167,7 @@ void stat_cache_add( const char *full_orig_name,
*/
bool stat_cache_lookup(connection_struct *conn,
+ bool posix_paths,
char **pp_name,
char **pp_dirpath,
char **pp_start,
@@ -181,6 +183,7 @@ bool stat_cache_lookup(connection_struct *conn,
char *name;
TALLOC_CTX *ctx = talloc_tos();
struct smb_filename smb_fname;
+ int ret;
*pp_dirpath = NULL;
*pp_start = *pp_name;
@@ -283,7 +286,13 @@ bool stat_cache_lookup(connection_struct *conn,
ZERO_STRUCT(smb_fname);
smb_fname.base_name = translated_path;
- if (SMB_VFS_STAT(conn, &smb_fname) != 0) {
+ if (posix_paths) {
+ ret = SMB_VFS_LSTAT(conn, &smb_fname);
+ } else {
+ ret = SMB_VFS_STAT(conn, &smb_fname);
+ }
+
+ if (ret != 0) {
/* Discard this entry - it doesn't exist in the filesystem. */
memcache_delete(smbd_memcache(), STAT_CACHE,
data_blob_const(chk_name, strlen(chk_name)));
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 0931fff..284635d 100644
index 0931fff..129ab01 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -2271,6 +2271,7 @@ static void call_trans2findfirst(connection_struct *conn,
@ -108,7 +168,17 @@ index 0931fff..284635d 100644
break;
default:
reply_nterror(req, NT_STATUS_INVALID_LEVEL);
@@ -5103,6 +5105,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
@@ -2331,8 +2333,7 @@ close_if_end = %d requires_resume_key = %d level = 0x%x, max_data_bytes = %d\n",
ntstatus = filename_convert(ctx, conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
directory,
- (UCF_SAVE_LCOMP |
- UCF_ALWAYS_ALLOW_WCARD_LCOMP),
+ ucf_flags,
&mask_contains_wcard,
&smb_dname);
if (!NT_STATUS_IS_OK(ntstatus)) {
@@ -5103,6 +5104,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
} else {
uint32_t name_hash;
char *fname = NULL;
@ -116,7 +186,7 @@ index 0931fff..284635d 100644
/* qpathinfo */
if (total_params < 7) {
@@ -5114,9 +5117,16 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
@@ -5114,9 +5116,16 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
DEBUG(3,("call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = %d\n", info_level));
@ -136,7 +206,7 @@ index 0931fff..284635d 100644
}
srvstr_get_path(req, params, req->flags2, &fname, &params[6],
@@ -5131,7 +5141,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
@@ -5131,7 +5140,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,