Symbolic link causes error in "File Manager"

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
4/30/2013 9:00:42 PM
Gravatar
Total Posts 3

Symbolic link causes error in "File Manager"

OS: Windows Server 2008 R2 SP1

DB: MSSQL 2008 R2

MojoPortal version: 2.3.9.7

.NET version: 4.0, FullTrust

Problem: When a symbolic link is created inside of the default directory the "File Manager" access, and error occurs and nothing is displayed. This does not happen when using "Alternate File Manager" and you are able to click the symlink folder successfully. More info on Symbolic links in Windows 2008 http://technet.microsoft.com/en-us/library/cc753194(v=ws.10).aspx

Error message: PathTooLongException

Error details:

Log Name:      Application
Source:        ASP.NET 4.0.30319.0
Date:          4/30/2013 4:16:51 PM
Event ID:      1309
Task Category: Web Event
Level:         Warning
Keywords:      Classic
User:          N/A
Computer:      APPSRVR
Description:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 4/30/2013 4:16:51 PM
Event time (UTC): 4/30/2013 11:16:51 PM
Event ID: 5479020daf3b4ac88c1a16a68962796d
Event sequence: 494
Event occurrence: 3
Event detail code: 0
 
Application information:
    Application domain: /LM/W3SVC/5/ROOT-4-130118362436404228
    Trust level: Full
    Application Virtual Path: /
    Application Path: C:\inetpub\CustomerWebs\ShowcaseMojo\
    Machine name: APPSRVR
 
Process information:
    Process ID: 10740
    Process name: w3wp.exe
    Account name: IIS APPPOOL\mojoPortal4
 
Exception information:
    Exception type: PathTooLongException
    Exception message: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
   at System.IO.PathHelper.GetFullPathName()
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength)
   at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
   at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
   at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
   at System.IO.FileSystemInfo.get_FullName()
   at mojoPortal.FileSystem.DiskFileSystem.<GetAllFolders>b__4(DirectoryInfo p)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
   at ASP.admin_controls_advfilemanager_ascx.__RenderpnlFile(HtmlTextWriter __w, Control parameterContainer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer)
   at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 
 
Request information:
    Request URL: http://www.mysite.com/Dialog/FileManagerDialog.aspx
    Request path: /Dialog/FileManagerDialog.aspx
    User host address: 192.168.0.2
    User: larry@mysite.com
    Is authenticated: True
    Authentication Type: Forms
    Thread account name: IIS APPPOOL\mojoPortal4
 
Thread information:
    Thread ID: 188
    Thread account name: IIS APPPOOL\mojoPortal4
    Is impersonating: False
    Stack trace:    at System.IO.PathHelper.GetFullPathName()
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength)
   at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
   at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
   at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
   at System.IO.FileSystemInfo.get_FullName()
   at mojoPortal.FileSystem.DiskFileSystem.<GetAllFolders>b__4(DirectoryInfo p)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
   at ASP.admin_controls_advfilemanager_ascx.__RenderpnlFile(HtmlTextWriter __w, Control parameterContainer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer)
   at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 
 
Custom event details:

Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="ASP.NET 4.0.30319.0" />
    <EventID Qualifiers="32768">1309</EventID>
    <Level>3</Level>
    <Task>3</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2013-04-30T23:16:51.000000000Z" />
    <EventRecordID>353244</EventRecordID>
    <Channel>Application</Channel>
    <Computer>APPSRVR</Computer>
    <Security />
  </System>
  <EventData>
    <Data>3005</Data>
    <Data>An unhandled exception has occurred.</Data>
    <Data>4/30/2013 4:16:51 PM</Data>
    <Data>4/30/2013 11:16:51 PM</Data>
    <Data>5479020daf3b4ac88c1a16a68962796d</Data>
    <Data>494</Data>
    <Data>3</Data>
    <Data>0</Data>
    <Data>/LM/W3SVC/5/ROOT-4-130118362436404228</Data>
    <Data>Full</Data>
    <Data>/</Data>
    <Data>C:\inetpub\CustomerWebs\ShowcaseMojo\</Data>
    <Data>APPSRVR</Data>
    <Data>
    </Data>
    <Data>10740</Data>
    <Data>w3wp.exe</Data>
    <Data>IIS APPPOOL\mojoPortal4</Data>
    <Data>PathTooLongException</Data>
    <Data>The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
   at System.IO.PathHelper.GetFullPathName()
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength)
   at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
   at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
   at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
   at System.IO.FileSystemInfo.get_FullName()
   at mojoPortal.FileSystem.DiskFileSystem.&lt;GetAllFolders&gt;b__4(DirectoryInfo p)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
   at ASP.admin_controls_advfilemanager_ascx.__RenderpnlFile(HtmlTextWriter __w, Control parameterContainer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer)
   at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

</Data>
    <Data>http://www.mysite.com/Dialog/FileManagerDialog.aspx</Data>
    <Data>/Dialog/FileManagerDialog.aspx</Data>
    <Data>76.28.134.163</Data>
    <Data>larry@mysite.com</Data>
    <Data>True</Data>
    <Data>Forms</Data>
    <Data>IIS APPPOOL\mojoPortal4</Data>
    <Data>188</Data>
    <Data>IIS APPPOOL\mojoPortal4</Data>
    <Data>False</Data>
    <Data>   at System.IO.PathHelper.GetFullPathName()
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength)
   at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
   at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
   at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
   at System.IO.FileSystemInfo.get_FullName()
   at mojoPortal.FileSystem.DiskFileSystem.&lt;GetAllFolders&gt;b__4(DirectoryInfo p)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
   at ASP.admin_controls_advfilemanager_ascx.__RenderpnlFile(HtmlTextWriter __w, Control parameterContainer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer)
   at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
</Data>
  </EventData>
</Event>

Workaround: Use alternate file manager

9/26/2013 6:53:18 PM
Gravatar
Total Posts 3

Re: Symbolic link causes error in "File Manager"

Well, the "workaround" to use alt file manager doesn't work either. All it lets you do is at least get into the file system, where file manager just crashes. But when you try to upload a file or create a folder, you get the same error. I just upgraded to 2.3.9.9 and the same thing happens. Can anyone get symbolic links to work with either file manager in mojoPortal?

9/27/2013 11:56:14 AM
Gravatar
Total Posts 18439

Re: Symbolic link causes error in "File Manager"

This is not something that I anticipate trying to "fix" so I guess you could say it is unsupported to manage symbolic linked files in mojoPortal file managers (both of which use the same back end code so I would expect them to work the same).  

The actual error is thrown from .NET framework code not from any mistake in mojoPortal code. The actual method in mojoPortal is just trying to get a list of folders and this symbolic link apparently breaks code that otherwise works:

public IEnumerable<WebFolder> GetFolderList(string virtualPath)
        {
            string fullPath = MapPath(virtualPath); ;
            
            if (!Directory.Exists(fullPath)) { return null; }

            DirectoryInfo di = new DirectoryInfo(fullPath);
            
            var folders = from folder in di.GetDirectories("*", SearchOption.TopDirectoryOnly)
                          where IsAllowed(folder.Name)
                          select folder;

            return folders.Select(p => new WebFolder() 
                {   
                    VirtualPath = virtualPath + p.Name,
                    Path = ResolvePathResult(p.FullName), 
                    Created = p.CreationTimeUtc,
                    Modified = p.LastWriteTimeUtc,
                    Name = p.Name 
                });

        }

Nothing in the above code looks like a bug or mistake to me. I'm just using System.IO classes and methods and getting this path too long exception from framework code apparently when it hits your symbolic link.

Managing files in a web site is tricky business where we want to keep things as secure as possible including such things as limiting the location of files that can be accessed, so I'm not inclined to add any tricky workarounds to try make it work as that could lead to security issues.

For this kind of scenario virtual directories are the more standard way to do it.

You must sign in to post in the forums. This thread is closed to new posts.