linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeremy Allison <jra@samba.org>
To: Igor Mammedov <niallain@gmail.com>
Cc: Jeremy Allison <jra@samba.org>, Steve French <smfrench@gmail.com>,
	"Q (Igor Mammedov)" <qwerty0987654321@mail.ru>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	linux-cifs-client@lists.samba.org
Subject: Re: dfs path construction fixup for / character in \\server\share component of dfs path
Date: Fri, 25 Apr 2008 14:16:58 -0700	[thread overview]
Message-ID: <20080425211658.GB21342@samba1> (raw)
In-Reply-To: <48103EF6.7010004@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 641 bytes --]

On Thu, Apr 24, 2008 at 12:04:06PM +0400, Igor Mammedov wrote:

> I'm doing the second call with a short path to get inode info
> including server generated inode number. If not for the last 
> then second call could be omitted and inode be filled with fake
> values and locally generated ino.
> 
> PS:
> Windows server does not object against the second call and returns
> info on the dfs junction point (as directory). 
> More uniform behavior between different implementations would be
> better for all.

Can you try this patch against the 3.2 code please. It should
cause smbd to return a directory on the short QFILEINFO call.

Jeremy.

[-- Attachment #2: look --]
[-- Type: text/plain, Size: 2611 bytes --]

diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 709eb39..74b167b 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -3768,6 +3768,28 @@ static void call_trans2qpipeinfo(connection_struct *conn,
 }
 
 /****************************************************************************
+ Needed to show the msdfs symlinks as directories. Modified psbuf
+ to be a directory.
+****************************************************************************/
+
+static bool check_msdfs_link(connection_struct *conn,
+				const char *pathname,
+				SMB_STRUCT_STAT *psbuf)
+{
+	if(lp_host_msdfs() &&
+		lp_msdfs_root(SNUM(conn)) &&
+		is_msdfs_link(conn, pathname, psbuf)) {
+
+		DEBUG(5,("check_msdfs_link: Masquerading msdfs link %s "
+			"as a directory\n",
+			pathname));
+		psbuf->st_mode = (psbuf->st_mode & 0xFFF) | S_IFDIR;
+		return true;
+	}
+	return false;
+}
+
+/****************************************************************************
  Reply to a TRANS2_QFILEPATHINFO or TRANSACT2_QFILEINFO (query file info by
  file name or file id).
 ****************************************************************************/
@@ -3806,6 +3828,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
 	struct ea_list *ea_list = NULL;
 	uint32 access_mask = 0x12019F; /* Default - GENERIC_EXECUTE mapping from Windows */
 	char *lock_data = NULL;
+	bool ms_dfs_link = false;
 	TALLOC_CTX *ctx = talloc_tos();
 
 	if (!params) {
@@ -3959,10 +3982,20 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
 				reply_unixerror(req, ERRDOS, ERRbadpath);
 				return;
 			}
+
+			ms_dfs_link = check_msdfs_link(conn,fname,&sbuf);
+
 		} else if (!VALID_STAT(sbuf) && SMB_VFS_STAT(conn,fname,&sbuf) && (info_level != SMB_INFO_IS_NAME_VALID)) {
-			DEBUG(3,("call_trans2qfilepathinfo: SMB_VFS_STAT of %s failed (%s)\n",fname,strerror(errno)));
-			reply_unixerror(req, ERRDOS, ERRbadpath);
-			return;
+			int saved_errno = errno;
+
+			ms_dfs_link = check_msdfs_link(conn,fname,&sbuf);
+
+			if (!ms_dfs_link) {
+				errno = saved_errno;
+				DEBUG(3,("call_trans2qfilepathinfo: SMB_VFS_STAT of %s failed (%s)\n",fname,strerror(errno)));
+				reply_unixerror(req, ERRDOS, ERRbadpath);
+				return;
+			}
 		}
 
 		fileid = vfs_file_id_from_sbuf(conn, &sbuf);
@@ -3987,7 +4020,11 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
 	else
 		base_name = p+1;
 
-	mode = dos_mode(conn,fname,&sbuf);
+	if (ms_dfs_link) {
+		mode = dos_mode_msdfs(conn,fname,&sbuf);
+	} else {
+		mode = dos_mode(conn,fname,&sbuf);
+	}
 	if (!mode)
 		mode = FILE_ATTRIBUTE_NORMAL;
 

  parent reply	other threads:[~2008-04-25 21:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-18 23:03 dfs path construction fixup for / character in \\server\share component of dfs path Steve French
2008-04-23 14:28 ` Igor Mammedov
2008-04-23 19:11   ` Jeremy Allison
2008-04-23 19:19     ` Jeremy Allison
2008-04-24  8:04       ` Igor Mammedov
2008-04-25 19:22         ` Jeremy Allison
2008-04-25 19:50           ` Jeremy Allison
2008-04-25 21:16         ` Jeremy Allison [this message]
2008-04-27 13:00           ` Igor Mammedov
2008-04-28 18:05             ` Jeremy Allison
2008-04-28 18:51             ` Jeremy Allison
2008-05-21 13:57               ` Igor Mammedov
2008-05-24  0:46                 ` Jeremy Allison
2008-05-24  1:33                   ` Steve French

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080425211658.GB21342@samba1 \
    --to=jra@samba.org \
    --cc=linux-cifs-client@lists.samba.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=niallain@gmail.com \
    --cc=qwerty0987654321@mail.ru \
    --cc=smfrench@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).