s3: Convert some callers of vfs_lstat_smb_fname to SMB_VFS_LSTAT()
authorTim Prouty <tprouty@samba.org>
Tue, 21 Jul 2009 22:55:25 +0000 (15:55 -0700)
committerTim Prouty <tprouty@samba.org>
Wed, 22 Jul 2009 18:48:22 +0000 (11:48 -0700)
source3/smbd/msdfs.c
source3/smbd/vfs.c

index d40b8a8902882237e0c0460477f5fbdd862a144e..2b63eb17432fc24ab1808125c94cd3954b2d5236 100644 (file)
@@ -411,7 +411,6 @@ static bool is_msdfs_link_internal(TALLOC_CTX *ctx,
                        char **pp_link_target,
                        SMB_STRUCT_STAT *sbufp)
 {
-       SMB_STRUCT_STAT st;
        int referral_len = 0;
 #if defined(HAVE_BROKEN_READLINK)
        char link_target_buf[PATH_MAX];
@@ -420,6 +419,8 @@ static bool is_msdfs_link_internal(TALLOC_CTX *ctx,
 #endif
        size_t bufsize = 0;
        char *link_target = NULL;
+       struct smb_filename *smb_fname = NULL;
+       NTSTATUS status;
 
        if (pp_link_target) {
                bufsize = 1024;
@@ -433,21 +434,28 @@ static bool is_msdfs_link_internal(TALLOC_CTX *ctx,
                link_target = link_target_buf;
        }
 
-       if (sbufp == NULL) {
-               sbufp = &st;
+       status = create_synthetic_smb_fname(talloc_tos(), path, NULL, NULL,
+                                           &smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto err;
        }
 
-       if (vfs_lstat_smb_fname(conn, path, sbufp) != 0) {
+       if (SMB_VFS_LSTAT(conn, smb_fname) != 0) {
                DEBUG(5,("is_msdfs_link_read_target: %s does not exist.\n",
                        path));
+               TALLOC_FREE(smb_fname);
                goto err;
        }
-
-       if (!S_ISLNK(sbufp->st_ex_mode)) {
+       if (!S_ISLNK(smb_fname->st.st_ex_mode)) {
                DEBUG(5,("is_msdfs_link_read_target: %s is not a link.\n",
                                        path));
+               TALLOC_FREE(smb_fname);
                goto err;
        }
+       if (sbufp != NULL) {
+               *sbufp = smb_fname->st;
+       }
+       TALLOC_FREE(smb_fname);
 
        referral_len = SMB_VFS_READLINK(conn, path, link_target, bufsize - 1);
        if (referral_len == -1) {
index 55495183bd813a463ebc32bcb0f8a2a8a07067f5..cd78c7962ee0d6e34da802ce0caf9565ef3ea265 100644 (file)
@@ -972,15 +972,28 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
 
 #ifdef S_ISLNK
         if (!lp_symlinks(SNUM(conn))) {
-                SMB_STRUCT_STAT statbuf;
-                if ( (vfs_lstat_smb_fname(conn,fname,&statbuf) != -1) &&
-                                (S_ISLNK(statbuf.st_ex_mode)) ) {
+               struct smb_filename *smb_fname = NULL;
+               NTSTATUS status;
+
+               status = create_synthetic_smb_fname(talloc_tos(), fname, NULL,
+                                                   NULL, &smb_fname);
+               if (!NT_STATUS_IS_OK(status)) {
+                       if (free_resolved_name) {
+                               SAFE_FREE(resolved_name);
+                       }
+                        return status;
+               }
+
+               if ( (SMB_VFS_LSTAT(conn, smb_fname) != -1) &&
+                                (S_ISLNK(smb_fname->st.st_ex_mode)) ) {
                        if (free_resolved_name) {
                                SAFE_FREE(resolved_name);
                        }
                         DEBUG(3,("reduce_name: denied: file path name %s is a symlink\n",resolved_name));
+                       TALLOC_FREE(smb_fname);
                        return NT_STATUS_ACCESS_DENIED;
                 }
+               TALLOC_FREE(smb_fname);
         }
 #endif