You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by info <in...@iond.it> on 2004/11/07 14:42:50 UTC
[VFS] How to resolve all local files relative to a chroot dir ?
Hi all,
is there anyone can give me some hints how to resolve all absolute
and relative paths versus a chroot (jail) directory with VFS ?
Of course only for the "file://" and "tmp://" schemes.
Ex. having as jail "file://myJail"
"file://myDir/myFile.txt" --> "file://myJail/myDir/myFile.txt"
"../../myDir/myFile.txt" --> "file://myJail/myDir/myFile.txt"
FileName.getRelativeName() doesn't make this job...
I can't realize it reading the api docs.
Maybe creating a FileSystem ?
Thanks in advance
Lucio
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [VFS] How to resolve all local files relative to a chroot dir
?
Posted by Mario Ivankovits <im...@apache.org>.
info wrote:
>is there anyone can give me some hints how to resolve all absolute
>and relative paths versus a chroot (jail) directory with VFS ?
>
>
Currently VFS do not provide a "chroot" functionallity.
The only thing you can do is setting a "baseFile" on the FileSystemManager.
StandardFileSystemManager sm = new StandardFileSystemManager();
sm.init();
sm.setBaseFile(new File("/home/im"));
FileObject fo = sm.resolveFile("projects");
System.err.println(fo.getName().getURI());
Now the resolveFile resolves by taking the baseFile into account, but
the user can break out of the jail.
--
Mario
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [VFS] How to resolve all local files relative to a chroot dir ?
Posted by info <in...@iond.it>.
Alle 10:10, martedì 9 novembre 2004, Mario Ivankovits ha scritto:
> info wrote:
>
> >is there anyone can give me some hints how to resolve all absolute
> >and relative paths versus a chroot (jail) directory with VFS ?
> >
> >
> Looks like I was not quite true what I told you in my last post.
>
> You can use the VirtualFileSystem to archive this behaviour:
>
> FileSystemManager sm = VFS.getManager();
> FileObject fo = sm.resolveFile("file:/home/im/projects");
> FileObject foVirt = sm.createVirtualFileSystem(fo);
>
> If you try to resolve using a relative Path outside "fo" you get an
> "FileSystemException: Invalid relative file name."
>
> Hope this helps!
>
Thanks Mario
Tests of mine didn't work cause I used createFileSystem (only for zip, jar...)
Lucio
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [VFS] How to resolve all local files relative to a chroot dir
?
Posted by Mario Ivankovits <im...@apache.org>.
info wrote:
>is there anyone can give me some hints how to resolve all absolute
>and relative paths versus a chroot (jail) directory with VFS ?
>
>
Looks like I was not quite true what I told you in my last post.
You can use the VirtualFileSystem to archive this behaviour:
FileSystemManager sm = VFS.getManager();
FileObject fo = sm.resolveFile("file:/home/im/projects");
FileObject foVirt = sm.createVirtualFileSystem(fo);
If you try to resolve using a relative Path outside "fo" you get an
"FileSystemException: Invalid relative file name."
Hope this helps!
--
Mario
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org