[Kimchi-devel] [PATCH] bug fix: accept '-' & '_' for network name.

Zhou Zheng Sheng zhshzhou at linux.vnet.ibm.com
Mon Jun 16 07:10:32 UTC 2014


on 2014/06/16 15:06, Zhou Zheng Sheng wrote:
> From your experiments and explanations, I can see though libvirt put
> little restriction on names, but it does not handle the names correctly
> when it contains special chars. To make support all these special chars,
> we have to escape them in Kimchi. However consider there is several
> level to escape, html, xml, shell names, dnsmasq. It makes the escape
> rules complicated. These are only the common tools Kimchi usually works
> with. It's unpredictable if it would cause trouble when the admin uses
> other tools. In this terms, libvirt is actually broken, because it
> allows special chars but it does not process it correctly.
> 
> From my opinion, Kimchi should filter out
>   ~`!@#$%^&*()=+{}[]\|;:'"/?.>,<
> It implies, a to z, A to Z, underscore, dash and whitespace are
> supported. Unicode chars should be also supported.
> 

Sorry, 0 to 9, and dot should also be supported, I forgot to mention them.

> on 2014/06/14 23:30, Sheldon wrote:
>> I'd like to give up to support ".
>>
>> " is not allowed by dnsmasq.
>> the  number of " but be even
>>
>> ERROR:cherrypy.error.62418064:[14/Jun/2014:23:11:44] HTTP Traceback
>> (most recent call last):
>>   File "/usr/lib/python2.7/site-packages/cherrypy/_cprequest.py", line
>> 656, in respond
>>     response.body = self.handler()
>>   File "/usr/lib/python2.7/site-packages/cherrypy/lib/encoding.py", line
>> 188, in __call__
>>     self.body = self.oldhandler(*args, **kwargs)
>>   File "/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line
>> 34, in __call__
>>     return self.callable(*self.args, **self.kwargs)
>>   File "/home/shhfeng/work/workdir/kimchi/src/kimchi/control/base.py",
>> line 72, in wrapper
>>     ident = fn(*model_args)
>>   File "/home/shhfeng/work/workdir/kimchi/src/kimchi/model/networks.py",
>> line 308, in activate
>>     network.create()
>>   File
>> "/home/shhfeng/work/workdir/kimchi/src/kimchi/model/libvirtconnection.py",
>> line 62, in wrapper
>>     ret = f(*args, **kwargs)
>>   File "/usr/lib64/python2.7/site-packages/libvirt.py", line 2318, in
>> create
>>     if ret == -1: raise libvirtError ('virNetworkCreate() failed',
>> net=self)
>> libvirtError: internal error: Child process (/sbin/dnsmasq
>> '--conf-file=/var/lib/libvirt/dnsmasq/@#$%^&*()_+=-!~|{}[];'\''`"::::?><\.conf')
>> unexpected exit status 1:
>> dnsmasq: missing " at line 10 of
>> /var/lib/libvirt/dnsmasq/@#$%^&*()_+=-!~|{}[];'`"::::?><\.conf
>>
>>
>>
>> I create a network with name "ab", with contains two ". also error.
>>
>> ERROR:cherrypy.error.62418064:[14/Jun/2014:23:24:49] HTTP Traceback
>> (most recent call last):
>>   File "/usr/lib/python2.7/site-packages/cherrypy/_cprequest.py", line
>> 656, in respond
>>     response.body = self.handler()
>>   File "/usr/lib/python2.7/site-packages/cherrypy/lib/encoding.py", line
>> 188, in __call__
>>     self.body = self.oldhandler(*args, **kwargs)
>>   File "/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line
>> 34, in __call__
>>     return self.callable(*self.args, **self.kwargs)
>>   File "/home/shhfeng/work/workdir/kimchi/src/kimchi/control/base.py",
>> line 72, in wrapper
>>     ident = fn(*model_args)
>>   File "/home/shhfeng/work/workdir/kimchi/src/kimchi/model/networks.py",
>> line 308, in activate
>>     network.create()
>>   File
>> "/home/shhfeng/work/workdir/kimchi/src/kimchi/model/libvirtconnection.py",
>> line 62, in wrapper
>>     ret = f(*args, **kwargs)
>>   File "/usr/lib64/python2.7/site-packages/libvirt.py", line 2318, in
>> create
>>     if ret == -1: raise libvirtError ('virNetworkCreate() failed',
>> net=self)
>> libvirtError: An error occurred, but the cause is unknown
>>
>>
>> On 06/14/2014 10:16 PM, Sheldon wrote:
>>> On 06/14/2014 06:01 PM, Sheldon wrote:
>>>> On 06/13/2014 07:52 PM, Aline Manera wrote:
>>>>> On 06/13/2014 04:43 AM, Sheldon wrote:
>>>>>> On 06/13/2014 04:58 AM, Aline Manera wrote:
>>>>>>> On 06/12/2014 08:19 AM, shaohef at linux.vnet.ibm.com wrote:
>>>>>>>> From: ShaoHe Feng<shaohef at linux.vnet.ibm.com>
>>>>>>>>
>>>>>>>> Both '-' and '_' are allowed by libvirt,  so we should not put extra
>>>>>>>> restrictions.
>>>>>>>>
>>>>>>>> Signed-off-by: ShaoHe Feng<shaohef at linux.vnet.ibm.com>
>>>>>>>> ---
>>>>>>>>   ui/js/src/kimchi.network.js | 2 +-
>>>>>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>>>
>>>>>>>> diff --git a/ui/js/src/kimchi.network.js
>>>>>>>> b/ui/js/src/kimchi.network.js
>>>>>>>> index 23930cd..c6e828d 100644
>>>>>>>> --- a/ui/js/src/kimchi.network.js
>>>>>>>> +++ b/ui/js/src/kimchi.network.js
>>>>>>>> @@ -321,7 +321,7 @@ kimchi.cleanNetworkDialog = function() {
>>>>>>>>
>>>>>>>>   kimchi.setupNetworkFormEvent = function() {
>>>>>>>>       $("#networkName").on("keyup", function(event) {
>>>>>>>> -        $("#networkName").toggleClass("invalid-field",
>>>>>>>> !$("#networkName").val().match(/^[a-zA-Z0-9_]+$/));
>>>>>>>> +        $("#networkName").toggleClass("invalid-field",
>>>>>>>> !$("#networkName").val().match(/^[\-\w]+$/));
>>>>>>>>           kimchi.updateNetworkFormButton();
>>>>>>>>       });
>>>>>>>>       $("#networkTypeIso").on("click", function(event) {
>>>>>>>
>>>>>>> I agree with Cristian.
>>>>>>> You should remove the whole line:
>>>>>>>
>>>>>>> $("#networkName").toggleClass("invalid-field",
>>>>>>> !$("#networkName").val().match(/^[a-zA-Z0-9_]+$/));
>>>>>>>
>>>>>> what about some little restrictions than libvirt.
>>>>>> such as  wildcard "*", "?" and "/", [], {} ! are not allowed.
>>>>>>
>>>>>
>>>>> Yes, we need to restrict only the characters not allowed by libvirt
>>>> so only "/" is  restricted? the same rule with VM name and
>>>> storage-pool name?
>>>>>
>>>>>> for  wildcard can be used in shell. such as:
>>>>>> $ ls dat*
>>>>>> debugreports  objectstore  screenshots  sessions
>>>>>> $ ls dat?
>>>>>> debugreports  objectstore  screenshots  sessions
>>>>>> $ ls data
>>>>>> debugreports  objectstore  screenshots  sessions
>>>>>> $ ls [d]ata
>>>>>> debugreports  objectstore  screenshots  sessions
>>>>>>
>>>>>> shell meta characters and control operator should we support?
>>>>>> " ' ` = $ < > | & ( ) { } ; && || !
>>>>>> I have do some test as follow:
>>>>>>
>>>>>> 1.
>>>>>> I rename the network as "dd/ddd", libvirt will  report an error:
>>>>>> create file '/etc/libvirt/qemu/networks/dd/ddd.xml.new': No such
>>>>>> file or directory
>>>>>> We do can help libvirt to escape "/". And seems linux support every
>>>>>> character.
>>>>>>
>>>>>
>>>>> It is because '/' is a special character in xml files.
>>> Seems it is not the xml special character.
>>> $ touch dd\/ddd.xml
>>> touch: cannot touch 'dd/ddd.xml': No such file or directory.
>>>
>>> "\" may cause a big trouble.
>>> I'd like to not escape "\", what about you?
>>>
>>> seems only "< & >" are xml special characters.
>>>>> We need to scape it.
>>>>>
>>>>>> 2.
>>>>>> I also create a network named "*.efault",  kimchi can work works
>>>>>> well, that's kimchi UI's problem.
>>>>>> it report: "Error: Syntax error, unrecognized expression: #*.efault".
>>>>>> I can also fix this problem.
>>>>>>
>>>>>
>>>>> Please, send a patch for it too
>>>>>
>>>>>> virsh # net-list --all
>>>>>>  Name                 State      Autostart     Persistent
>>>>>> ----------------------------------------------------------
>>>>>>  *.efault             inactive   yes           yes
>>>>>>  brg20                active     yes           yes
>>>>>>  dddd                 active     yes           yes
>>>>>>  default              active     yes           yes
>>>>>>  test_abc             active     yes           yes
>>>>>>
>>>>>> strangely, I can not list the persistent network *.efault.xml file.
>>>>>> $ sudo ls  /var/lib/libvirt/network/
>>>>>> dddd.xml  default.xml  test_abc.xml
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>>
>>>>>> -- 
>>>>>> Thanks and best regards!
>>>>>>
>>>>>> Sheldon Feng(???)<shaohef at linux.vnet.ibm.com>
>>>>>> IBM Linux Technology Center
>>>>>
>>>>
>>>>
>>>> -- 
>>>> Thanks and best regards!
>>>>
>>>> Sheldon Feng(???)<shaohef at linux.vnet.ibm.com>
>>>> IBM Linux Technology Center
>>>>
>>>>
>>>> _______________________________________________
>>>> Kimchi-devel mailing list
>>>> Kimchi-devel at ovirt.org
>>>> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>>>
>>>
>>> -- 
>>> Thanks and best regards!
>>>
>>> Sheldon Feng(???)<shaohef at linux.vnet.ibm.com>
>>> IBM Linux Technology Center
>>>
>>>
>>> _______________________________________________
>>> Kimchi-devel mailing list
>>> Kimchi-devel at ovirt.org
>>> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>>
>>
> 
> 


-- 
Zhou Zheng Sheng / 周征晟
E-mail: zhshzhou at linux.vnet.ibm.com
Telephone: 86-10-82454397




More information about the Kimchi-devel mailing list