Bug 36804 - Invalid SMB process definition
Invalid SMB process definition
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: ucs-test
UCS@school 4.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: Ammar Najjar
Florian Best
:
Depends on: 36800 41697 42113
Blocks: 38006
  Show dependency treegraph
 
Reported: 2014-11-18 12:43 CET by Florian Best
Modified: 2016-11-03 17:37 CET (History)
1 user (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments
103_ucsschool_smbstatus_parser (2.65 KB, text/plain)
2015-01-15 11:20 CET, Florian Best
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2014-11-18 12:43:55 CET
Every release the output of smbstatus changes. We should add a UCS-test which checks the library. IMHO the library should raise exceptions instead of just logging things.

+++ This bug was initially created as a clone of Bug #36800 +++

reset of computerroom settings does not work anymore.

18.11.14 11:52:44.794  PARSER      ( ERROR   ) : Invalid SMB process definition
18.11.14 11:52:44.794  PARSER      ( INFO    ) :
Samba version 4.2.0rc2-Debian
PID     Username      Group         Machine            Protocol Version
------------------------------------------------------------------------------
25470     d.krause1     Domain Users test  10.200.27.16 (ipv4:10.200.27.16:59306) NT1

Service      pid     machine       Connected at
-------------------------------------------------------
d.krause1    25470   10.200.27.16  Tue Nov 18 11:49:08 2014
IPC$         25470   10.200.27.16  Tue Nov 18 11:49:08 2014

Locked files:
Pid          Uid        DenyMode   Access      R/W        Oplock           SharePath   Name   Time
--------------------------------------------------------------------------------------------------
25470        7520       DENY_NONE  0x19b       RDWR       EXCLUSIVE        /home/test/lehrer/d.krause1   .kde/share/apps/ktp/cache.db   Tue Nov 18 11:49:24 2014
25470        7520       DENY_NONE  0x89        RDONLY     EXCLUSIVE        /home/test/lehrer/d.krause1   .local/share/baloo/file/record.DB   Tue Nov 18 11:49:25 2014
25470        7520       DENY_NONE  0x89        RDONLY     NONE             /home/test/lehrer/d.krause1   .local/share/baloo/file/postlist.DB   Tue Nov 18 11:49:23 2014
25470        7520       DENY_NONE  0x19b       RDWR       EXCLUSIVE        /home/test/lehrer/d.krause1   .local/share/baloo/file/fileMap.sqlite3-wal   Tue Nov 18 11:49:23 2014
25470        7520       DENY_NONE  0x89        RDONLY     NONE             /home/test/lehrer/d.krause1   .config/dconf/user   Tue Nov 18 11:49:09 2014
25470        7520       DENY_NONE  0x89        RDONLY     NONE             /home/test/lehrer/d.krause1   .local/share/baloo/file/position.DB   Tue Nov 18 11:49:23 2014
25470        7520       DENY_NONE  0x19b       RDWR       EXCLUSIVE        /home/test/lehrer/d.krause1   .local/share/baloo/file/fileMap.sqlite3   Tue Nov 18 11:49:23 2014
25470        7520       DENY_NONE  0x19b       RDWR       EXCLUSIVE        /home/test/lehrer/d.krause1   .kde/share/apps/activitymanager/activityranking/database   Tue Nov 18 11:49:18 2014
25470        7520       DENY_NONE  0x89        RDONLY     NONE             /home/test/lehrer/d.krause1   .local/share/baloo/file/termlist.DB   Tue Nov 18 11:49:23 2014
25470        7520       DENY_NONE  0x19b       RDWR       EXCLUSIVE        /home/test/lehrer/d.krause1   .kde/share/apps/activitymanager/resources/database   Tue Nov 18 11:49:18 2014
25470        7520       DENY_NONE  0x89        RDONLY     NONE             /home/test/lehrer/d.krause1   .config/dconf/user   Tue Nov 18 11:49:09 2014
25470        7520       DENY_NONE  0x89        RDONLY     NONE             /home/test/lehrer/d.krause1   .config/dconf/user   Tue Nov 18 11:49:23 2014
25470        7520       DENY_NONE  0x89        RDONLY     NONE             /home/test/lehrer/d.krause1   .config/dconf/user   Tue Nov 18 11:49:33 2014
25470        7520       DENY_NONE  0x89        RDONLY     NONE             /home/test/lehrer/d.krause1   .config/dconf/user   Tue Nov 18 11:49:33 2014
25470        7520       DENY_NONE  0x19b       RDWR       EXCLUSIVE        /home/test/lehrer/d.krause1   .local/share/baloo/file/fileMap.sqlite3-shm   Tue Nov 18 11:49:23 2014
25470        7520       DENY_NONE  0x192       WRONLY     EXCLUSIVE        /home/test/lehrer/d.krause1   .xsession-errors   Tue Nov 18 11:49:08 2014
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2014-11-26 10:53:57 CET
ucs-school-lib/python/smbstatus.py parses the output of smbstatus. Every now and then the samba project changes the output of smbstatus and this breaks our parser.

Please try to test if the parser is still working.
Comment 2 Ammar Najjar univentionstaff 2014-11-27 11:48:24 CET
A new script is created with the name "103_smbstatus_parser" to test the output of the smbstatus parser class, including:

  - creating three connections to the host (netlogon, sysvol, IPC$)
  - check the attributes of the result SMB_Status class ('pid', 'username', 'group', 'machine', 'services', 'ipaddress')
  - script fails if no connection was established or if any of the mentioned attributes were not parsed.

Tested on UCS 3.2.3 and UCS4.0 single master and multi-server.
Comment 3 Florian Best univentionstaff 2014-11-27 12:04:33 CET
Is it possible to also check if
* the PID of the processes you are starting is in the output
* the username actual is 'Administrator'
* if the IP address is the actual IP address
* close pop{1,2,3} after running the test
Comment 4 Ammar Najjar univentionstaff 2014-11-28 10:04:59 CET
(In reply to Florian Best from comment #3)
> Is it possible to also check if
> * the PID of the processes you are starting is in the output
> * the username actual is 'Administrator'
> * if the IP address is the actual IP address
> * close pop{1,2,3} after running the test

Yes.

- Additional checks are added to the same script to check matching:
(pid, username, services, ipaddress) with the actual values.
- All Popen objects are terminated manually before the script exits.
Comment 5 Florian Best univentionstaff 2015-01-15 11:20:08 CET
Created attachment 6603 [details]
103_ucsschool_smbstatus_parser

The test is good, here are some suggestions for improvement:

* Currently it is not correctly checked if e.g. the service of pop1 is 'netlogon' but it is checked if it is one of 'netlogon', 'IPC' or 'sysvol'.
* The test fails if there are some other concurrent smb connections which are not initiated by the test case:
"""Attribute (services) is parsed wrong as (['Marktplatz']), expected in ([['netlogon'], ['sysvol'], ['IPC$']])"""
To fix this I suggest to go through the processes by the services list.

It would be good to preserve the argument names in the check_attribute function. It is easier to understand what 'process' is than what is meant with '_dict'. It is also good to place the check_attribute method underneath of main() as this is the way we read the code.

You can use getattr(obj, attribute_name) instead of obj.__getattribute__(attribute_name)

The following code fails if IPv6 would be used:
if attr == 'ipaddress':
  value = value.split(':', 1)[0]
→ value.rsplit have to be used.

Attached is a alternative working test script, which could also be easier adapted to test for IPv6 or 2 services with 1 smb-connection.
Comment 6 Ammar Najjar univentionstaff 2015-01-16 10:52:00 CET
(In reply to Florian Best from comment #5)

> * Currently it is not correctly checked if e.g. the service of pop1 is
> 'netlogon' but it is checked if it is one of 'netlogon', 'IPC' or 'sysvol'.
> * The test fails if there are some other concurrent smb connections which
> are not initiated by the test case:
> """Attribute (services) is parsed wrong as (['Marktplatz']), expected in
> ([['netlogon'], ['sysvol'], ['IPC$']])"""
> To fix this I suggest to go through the processes by the services list.
> 

As Comment 3 suggested: to check if
* the PID of the processes you are starting is in the output

Popen.pid does not return the pid of the invoked process. so it is not possible to check which pid matches which service, so I checked if the pids/services all are running without making a match to each ones Popen object.

> It would be good to preserve the argument names in the check_attribute
> function. It is easier to understand what 'process' is than what is meant
> with '_dict'. It is also good to place the check_attribute method underneath
> of main() as this is the way we read the code.
> 

OK.

> You can use getattr(obj, attribute_name) instead of
> obj.__getattribute__(attribute_name)
> 

OK.

> The following code fails if IPv6 would be used:
> if attr == 'ipaddress':
>   value = value.split(':', 1)[0]
> → value.rsplit have to be used.
> 

OK.

> Attached is a alternative working test script, which could also be easier
> adapted to test for IPv6 or 2 services with 1 smb-connection.

The alternative test script is taken including:
- Ignore pids.
- Check via service attribute.
- Rename _dict, and use getattr for the used dictionary.
- Reorder the functions in the script.
- Use rsplit instead of split.
Comment 7 Florian Best univentionstaff 2015-01-19 12:15:54 CET
OK