VFS chroot

René Klomp rene.klomp at os3.nl
Fri Nov 16 08:38:06 MST 2012


Op 16-11-2012 16:15, David Collier-Brown schreef:
> 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

I shall be more precise.
What I want to do for example i change a certain value in a file with
another value and then serve the file to the client. So for example
include his/her login name or the current time somewhere in the file.
After the file has been downloaded from the share the temp file can be
removed again. Thats why I also thought about piping the output of my
external script.
My knowledge of samba's internals are still limited. This is the first
time I develop on it.

Regards,
Rene

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20121116/ad91c949/attachment.pgp>


More information about the samba-technical mailing list