]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Second part of fix for bug #8541 - readlink() on Linux clients fails if the symlink...
authorJeremy Allison <jra@samba.org>
Mon, 24 Oct 2011 22:34:27 +0000 (15:34 -0700)
committerKarolin Seeger <kseeger@samba.org>
Wed, 26 Oct 2011 17:22:45 +0000 (19:22 +0200)
The statcache has to do lstat instead of stat when returning cached
posix pathnames.

source3/include/proto.h
source3/smbd/filename.c
source3/smbd/statcache.c

index 8afc2e7161f1e732cb0423238b79e1439f95faa3..2e04ca11b3c9037f73bd5d7ab23b9f32ef9497e5 100644 (file)
@@ -7055,6 +7055,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,
index 2ea9d24f873eaf52b9887c8fa2a5545ef222dc6c..0c34aa83dce62635d2d3b1125f1c774c3dd051a4 100644 (file)
@@ -295,7 +295,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;
        }
index db347b5b7e86755f0618027f04e3306772cd3786..5f58d5e54db559b9bf01b486b664e4997ae13291 100644 (file)
@@ -145,6 +145,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
@@ -161,6 +162,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,
@@ -176,6 +178,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;
@@ -278,7 +281,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)));