r23087: Fix POSIX setfilepathinfo to use lstat, not stat.
authorJeremy Allison <jra@samba.org>
Tue, 22 May 2007 22:35:13 +0000 (22:35 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:22:44 +0000 (12:22 -0500)
Still missing lchown (will add this for 3.0.26).
Don't merge for 3.0.25a - possibly 3.0.25b (if it
exists).
Jeremy.
(This used to be commit f546750176a22cdd7298a73afc81587923baaff9)

source3/smbd/open.c
source3/smbd/trans2.c

index 1a8a087bb704c24abc505860b8e539c7e3d03446..7784740063d6e1e818738a52d55e48f730e0c578 100644 (file)
@@ -47,7 +47,12 @@ static NTSTATUS fd_open(struct connection_struct *conn,
        NTSTATUS status = NT_STATUS_OK;
 
 #ifdef O_NOFOLLOW
-       if (!lp_symlinks(SNUM(conn))) {
+       /* 
+        * Never follow symlinks on a POSIX client. The
+        * client should be doing this.
+        */
+
+       if (fsp->posix_open || !lp_symlinks(SNUM(conn))) {
                flags |= O_NOFOLLOW;
        }
 #endif
index 63fd414e16f5155e2d8dd72fc85280102e1f1b97..a41aa3c7df61806a45c66fefab907a8f984f84d7 100644 (file)
@@ -5777,9 +5777,17 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
                         * to do this call. JRA.
                         */
                        pstrcpy(fname, fsp->fsp_name);
-                       if (SMB_VFS_STAT(conn,fname,&sbuf) != 0) {
-                               DEBUG(3,("call_trans2setfilepathinfo: fileinfo of %s failed (%s)\n",fname,strerror(errno)));
-                               return UNIXERROR(ERRDOS,ERRbadpath);
+                       if (INFO_LEVEL_IS_UNIX(info_level)) {
+                               /* Always do lstat for UNIX calls. */
+                               if (SMB_VFS_LSTAT(conn,fname,&sbuf)) {
+                                       DEBUG(3,("call_trans2setfilepathinfo: SMB_VFS_LSTAT of %s failed (%s)\n",fname,strerror(errno)));
+                                       return UNIXERROR(ERRDOS,ERRbadpath);
+                               }
+                       } else {
+                               if (SMB_VFS_STAT(conn,fname,&sbuf) != 0) {
+                                       DEBUG(3,("call_trans2setfilepathinfo: fileinfo of %s failed (%s)\n",fname,strerror(errno)));
+                                       return UNIXERROR(ERRDOS,ERRbadpath);
+                               }
                        }
                } else if (fsp && fsp->print_file) {
                        /*
@@ -5838,14 +5846,18 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
                        return ERROR_NT(status);
                }
 
-               /*
-                * For CIFS UNIX extensions the target name may not exist.
-                */
+               if (INFO_LEVEL_IS_UNIX(info_level)) {
+                       /*
+                        * For CIFS UNIX extensions the target name may not exist.
+                        */
+
+                       /* Always do lstat for UNIX calls. */
+                       SMB_VFS_LSTAT(conn,fname,&sbuf);
 
-               if(!VALID_STAT(sbuf) && !INFO_LEVEL_IS_UNIX(info_level)) {
-                       DEBUG(3,("call_trans2setfilepathinfo: stat of %s failed (%s)\n", fname, strerror(errno)));
+               } else if (!VALID_STAT(sbuf) && SMB_VFS_STAT(conn,fname,&sbuf)) {
+                       DEBUG(3,("call_trans2setfilepathinfo: SMB_VFS_STAT of %s failed (%s)\n",fname,strerror(errno)));
                        return UNIXERROR(ERRDOS,ERRbadpath);
-               }    
+               }
        }
 
        if (!CAN_WRITE(conn)) {