Second part of fix for bug #8541 - readlink() on Linux clients fails if the symlink...
authorJeremy Allison <jra@samba.org>
Sat, 22 Oct 2011 00:46:12 +0000 (17:46 -0700)
committerKarolin Seeger <kseeger@samba.org>
Wed, 26 Oct 2011 17:28:05 +0000 (19:28 +0200)
The statcache has to do lstat instead of stat when returning cached
posix pathnames.
(cherry picked from commit 305d7d7f7d76e37d82ce6ac257f178ce654b26db)

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

index 691a779d8cab4ae93294c1ec6d2f537bd3b6f705..b2ed23972696109d6cfeb12faac8ff68210d2b59 100644 (file)
@@ -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;
        }
index 1e5d891e9f8ee06a4098183a607d2a84af5d7a43..02b5e407029a51dc32865529c701a19727eadc6a 100644 (file)
@@ -1038,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,
index e2ccc74a87ae2f11aee30855ae68267c0dd20b37..e910982b6c87581254e5d1b09dac6a23ccebe947 100644 (file)
@@ -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)));