[PATCH] for "testparm should check for invalid vfs objects"

Amit amitkuma at redhat.com
Tue Sep 11 06:26:32 UTC 2018


Hey Metze,
Any thoughts.


On 09/07/2018 01:45 PM, Amit wrote:
> Dear Metze,
>
> I am obliged with your support.
>
> I did the code change but cannot find definition of function
> 'smb_vfs_find_module' in testparm.c
>
> # make
> default/source3/utils/testparm_38.o: In function `do_per_share_checks':
> testparm.c:(.text+0x15fa): undefined reference to `smb_vfs_find_module'
>
> cat vim source3/utils/testparm.c
> #include "smbd/smbd.h"
> static void do_per_share_checks(int s){
> ....
> smb_vfs_find_module(vfs_objects[k], NULL, NULL, NULL);
> }
>
> cat ./source3/smbd/proto.h
> bool smb_vfs_find_module(const char *vfs_object,
>                          const struct vfs_fn_pointers **fns_ptr,
>                          TALLOC_CTX *mem_ctx,
>                          const char **module_params_ptr);
>
>
> Also, module_params_ptr would be created by passing 1st argument of
> talloc_strdup as NULL since we donot pass connection_struct*
> smb_vfs_find_module
> {
>         if (module_param) {
>                 *module_params_ptr = talloc_strdup(NULL, module_param);
>         }
> }
>
> Thanks
> Amit
> On 08/28/2018 12:35 PM, Stefan Metzmacher wrote:
>> Hi Amit,
>>
>> it looks much better, but we also need to check builtin modules
>> not only share modules.
>>
>> I think we should split out the first part of vfs_init_custom(),
>> everything before 'handle = talloc_zero(conn, vfs_handle_struct);'
>> into a new function:
>>
>> NTSTATUS smb_vfs_find_module(const char *vfs_object,
>> 			     const struct vfs_fn_pointers **fns_ptr,
>> 			     TALLOC_CTX *mem_ctx,
>> 			     char **module_params_ptr);
>>
>> It should be allowed to pass fns_ptr = NULL, mem_ctx = NULL and
>> module_params_ptr = NULL. And that's what your code should do.
>>
>> You'll get extra points if you convert the code to use
>> 'TALLOC_CTX *frame = talloc_stackframe();' and talloc_strdup(frame, ...)
>> instead of smb_xstrdup().
>>
>> In your loop you just call
>>
>> status = smb_vfs_find_module(vfs_objects[k], NULL, NULL, NULL);
>>
>>
>> vfs_init_custom() will just be:
>>
>> handle = talloc_zero(conn, vfs_handle_struct);
>> ...
>> handle->conn = conn;
>>
>> status = smb_vfs_find_module(vfs_object,
>>                              &handle->fns,
>>                              handle,
>>                              &handle->param);
>> ...
>> DLIST_ADD(conn->vfs_handles, handle);
>>
>> I hope that helps!
>>
>> metze
>>
>>
>> Am 28.08.2018 um 07:13 schrieb Amit:
>>> Dear Metze/volker,
>>>
>>> Can you please look at the patch and suggest.
>>>
>>> # cat /usr/local/samba/etc/smb.conf | grep vfs
>>>     vfs objects = fruit1   23     worm2112
>>>  # /usr/local/samba/bin/testparm
>>> Load smb config files from /usr/local/samba/etc/smb.conf
>>> rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
>>> Processing section "[myshare]"
>>> Loaded services file OK.
>>> Error loading module '/usr/local/samba/lib/vfs/fruit1.so':
>>> /usr/local/samba/lib/vfs/fruit1.so: cannot open shared object file: No
>>> such file or directory
>>> WARNING: Wrong vfs module: fruit1
>>>
>>> Error loading module '/usr/local/samba/lib/vfs/23.so':
>>> /usr/local/samba/lib/vfs/23.so: cannot open shared object file: No such
>>> file or directory
>>> WARNING: Wrong vfs module: 23
>>>
>>> Error loading module '/usr/local/samba/lib/vfs/worm2112.so':
>>> /usr/local/samba/lib/vfs/worm2112.so: cannot open shared object file: No
>>> such file or directory
>>> WARNING: Wrong vfs module: worm2112
>>>
>>> Server role: ROLE_STANDALONE
>>>
>>> Press enter to see a dump of your service definitions
>>> ^C
>>> #
>>>
>>> Thanks
>>>
>>> Amit
>>>
>>>
>>> On 08/27/2018 12:34 PM, Amit wrote:
>>>> Hello All,
>>>>
>>>> New patch. PFA
>>>>
>>>> Thanks
>>>> Amit
>>>>
>>>>
>>>> On 08/21/2018 07:20 PM, Stefan Metzmacher wrote:
>>>>> Hello Amit,
>>>>>
>>>>>> I tried using getting vfs_object list as done in smbd_vfs_init(), Since
>>>>>> I donot have connection_struct i used #define GLOBAL_SECTION_SNUM    
>>>>>> (-1). But values are not retrieved.
>>>>> Testparm should have the snum for the section it is checking.
>>>>> do_per_share_checks(int s), 's' is the one you need.
>>>>>
>>>>>>         int test = -1, o=0;
>>>>>>         char **vfs_objects_test = lp_vfs_objects(test);
>>>>>>         while(vfs_objects_test[o]){
>>>>>>                 printf("vfs_objects_test=%s\n",vfs_objects_test[o]);
>>>>>>                 o++;
>>>>>>         }
>>>>> Within the loop you need a logic like vfs_init_custom(), you need the
>>>>> logic that converts the string 'vfs_object' into module_path and
>>>>> module_name and then the following check:
>>>>>
>>>>>         entry = vfs_find_backend_entry(module_name);
>>>>>         if (!entry) {
>>>>>                 NTSTATUS status;
>>>>>
>>>>>                 status = smb_load_module("vfs", module_path);
>>>>>                 if (!NT_STATUS_IS_OK(status)) {
>>>>>                         DEBUG(0, ("error probing vfs module '%s': %s\n",
>>>>>                                   module_path, nt_errstr(status)));
>>>>>                         goto fail;
>>>>>                 }
>>>>>
>>>>>                 entry = vfs_find_backend_entry(module_name);
>>>>>                 if (!entry) {
>>>>>                         DEBUG(0,("Can't find a vfs module
>>>>> [%s]\n",vfs_object));
>>>>>                         goto fail;
>>>>>                 }
>>>>>         }
>>>>>
>>>>>> Also have do we have any module extracted using 'waf' which can refereed
>>>>>> as for reference.
>>>>> It could get a list, but only with internal modules, at buildtime.
>>>>>
>>>>> If a packager moved some modules to separate rpm/deb packages and those
>>>>> are not installed, the list would still be wrong.
>>>>>
>>>>> I hope that helps...
>>>>>
>>>>> metze
>>>> -- 
>>>> Thanks
>>>> Amit Kumar
>>>> !!If you stumble, get back up. 
>>>> What happened yesterday, no longer matters.
>>>> Today is another day to move closer to your GOAL!!

-- 
Thanks
Amit Kumar
!!If you stumble, get back up. 
What happened yesterday, no longer matters.
Today is another day to move closer to your GOAL!!



More information about the samba-technical mailing list