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.
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;