Bug 1572137

Summary: lsmcli fs-export --*-host does not validate the value
Product: Red Hat Enterprise Linux 7 Reporter: Jakub Krysl <jkrysl>
Component: libstoragemgmtAssignee: Tony Asleson <tasleson>
Status: CLOSED ERRATA QA Contact: Jakub Krysl <jkrysl>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.5CC: tasleson
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-06 12:40:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jakub Krysl 2018-04-26 09:15:47 UTC
Description of problem:
Using 'lsmcli fs-export' with arguments --ro-host, --rw-host or --root-host, the user can insert any value to those arguments and the command will succeed:

# lsmcli -u "sim://" fs-export --fs='FS_ID_00001' --rw-host='wrong'
ID           | FileSystem ID | Export Path       | Root Hosts | RW Hosts | RO Hosts | Options
---------------------------------------------------------------------------------------------
EXP_ID_00001 | FS_ID_00001   | /nfs_exp_503138e0 |            | wrong    |          |     

# lsmcli -u "sim://" fs-export --fs='FS_ID_00001' --rw-host='-1'
ID           | FileSystem ID | Export Path       | Root Hosts | RW Hosts | RO Hosts | Options
---------------------------------------------------------------------------------------------
EXP_ID_00001 | FS_ID_00001   | /nfs_exp_50009d14 |            | -1       |          |        

# lsmcli -u "sim://" fs-export --fs='FS_ID_00001' --ro-host='-1'
ID           | FileSystem ID | Export Path       | Root Hosts | RW Hosts | RO Hosts | Options
---------------------------------------------------------------------------------------------
EXP_ID_00001 | FS_ID_00001   | /nfs_exp_50619569 |            |          | -1       |

        
# lsmcli -u "sim://" fs-export --fs='FS_ID_00001' --ro-host='-1' --root-host='-1'
ID           | FileSystem ID | Export Path       | Root Hosts | RW Hosts | RO Hosts | Options
---------------------------------------------------------------------------------------------
EXP_ID_00001 | FS_ID_00001   | /nfs_exp_507458cd | -1         |          | -1       |   


Version-Release number of selected component (if applicable):
libstoragemgmt-1.6.1-2.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. lsmcli -u "sim://" fs-export --fs='FS_ID_00001' --rw-host='wrong'

Actual results:
ID           | FileSystem ID | Export Path       | Root Hosts | RW Hosts | RO Hosts | Options
---------------------------------------------------------------------------------------------
EXP_ID_00001 | FS_ID_00001   | /nfs_exp_503138e0 |            | wrong    |          | 

Expected results:
lsmcli error: 'wrong' is not a valid --rw-host address/IP.

Additional info:

Comment 2 Tony Asleson 2018-12-14 21:44:31 UTC
Just to clarify, 'wrong' is a valid hostname.  Users should be free to specify IP address or hostname.  I believe it would be a mistake to actually do a dns query or try to ping an IP address to validate that it's indeed correct.  I've submitted a patch upstream which ensures that the specified string is a valid IP or hostname, but I'm reluctant to do anything more.

Comment 4 Jakub Krysl 2018-12-17 12:21:39 UTC
(In reply to Tony Asleson from comment #2)
> Just to clarify, 'wrong' is a valid hostname.  Users should be free to
> specify IP address or hostname.  I believe it would be a mistake to actually
> do a dns query or try to ping an IP address to validate that it's indeed
> correct.  I've submitted a patch upstream which ensures that the specified
> string is a valid IP or hostname, but I'm reluctant to do anything more.

I agree, hostname might not be reachable at the moment. Checking for hostname validity is fine, thanks.

Comment 6 Jakub Krysl 2019-01-28 17:05:39 UTC
libstoragemgmt-1.7.2-1.el7.x86_64

# lsmcli -u "sim://" fs-export --fs='FS_ID_00001' --ro-host='*invalid*'
usage: lsmcli fs-export [-h] [-v] [-u <URI>] [-P] [-H] [-t <SEP>] [-e] [-f]
                        [-w CHILD_WAIT] [--header] [-b] [-s] --fs <FS_ID>                             
                        [--exportpath <EXPORT_PATH>] [--anonuid <ANON_UID>]                                 
                        [--anongid <ANON_GID>] [--auth-type <AUTH_TYPE>]                            
                        [--root-host <ROOT_HOST>] [--ro-host <RO_HOST>]                                                                                                                                            
                        [--rw-host <RW_HOST>]                                                                                                                                                                     
lsmcli fs-export: error: argument --ro-host: *invalid* is invalid IP or hostname

Comment 8 errata-xmlrpc 2019-08-06 12:40:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:2064