VFS chroot
David Collier-Brown
davec-b at rogers.com
Fri Nov 16 08:15:36 MST 2012
On 11/16/2012 09:48 AM, René Klomp wrote:
> Hi all,
>
> I am developing a VFS module that modifies certain files in a specific
> way that can be different each time that file is opened
> To do this I want to use an external script that takes a file as input
> and then changes it and writes those changes to a temporary file. The
> temporary file then has to be served to the client.
>
> How could I best do this?
> I tried the following:
> static int my_vfs_open(vfs_handle_struct *handle, struct smb_filename
> *smb_fname,
> files_struct *fsp, int flags, mode_t mode)
> {
> if(strcmp(smb_fname->base_name,"test.txt")==0){
> return open("test2.txt", flags, mode);
> }
> return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
> }
>
> This works, but it is not possible to open a file outside the current
> share directory... So I wont be able to let a script write a file to
> another directory so that it wont be visible in the share.
> Another thing I thought about was piping the output of the external
> script to the user. That would probably be more efficient? Is that
> possible? If yes, how?
This sounds a little bit like software copy-on-write, so you perhaps
could do something like
if(strcmp(smb_fname->base_name,"test.txt")==0){
return open("./.invisible_copy_dir/test.txt", flags, mode);
That's what you're doing, though, not what you *want* to be doing (:-))
What's the thing you want? In effect, "why?"
--dave
--
David Collier-Brown, | Always do right. This will gratify
System Programmer and Author | some people and astonish the rest
davecb at spamcop.net | -- Mark Twain
(416) 223-8968
More information about the samba-technical
mailing list