summaryrefslogtreecommitdiff
path: root/source3/smbd/statcache.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2011-10-21 17:46:12 -0700
committerJeremy Allison <jra@samba.org>2011-10-22 04:57:10 +0200
commitd1a4ee604ffaac4c6ddf6b8939e3d42688d2c73d (patch)
treee65f33dbc6634d75b33be2af640970b9eb717a03 /source3/smbd/statcache.c
parent60d9afa806e21bb932336f53842af9a5405ff588 (diff)
downloadsamba-d1a4ee604ffaac4c6ddf6b8939e3d42688d2c73d.tar.gz
samba-d1a4ee604ffaac4c6ddf6b8939e3d42688d2c73d.tar.bz2
samba-d1a4ee604ffaac4c6ddf6b8939e3d42688d2c73d.zip
Second part of fix for bug #8541 - readlink() on Linux clients fails if the symlink target is outside of the share.
The statcache has to do lstat instead of stat when returning cached posix pathnames.
Diffstat (limited to 'source3/smbd/statcache.c')
-rw-r--r--source3/smbd/statcache.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c
index 963b7c4bc1..92010c230d 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)));