[Openstack] [nova][oslo.rootwrap] RegExpFilter optional parameter

Thierry Carrez thierry at openstack.org
Wed Jul 9 09:34:08 UTC 2014


Kai Brennenstuhl wrote:
> I want to create a RegExpFilter (in nova/rootwrap.d) where the last
> parameter is optional.
> I can create a filter so that it works either with the last parameter or
> without.
> But I don't know how the rule has to look like so that the last
> parameter is optional.
> 
> Following is in my *.filters file:
> 
> mycmd: RegExpFilter, /usr/local/bin/mycmd, root, mycmd, either|or,
> anotherparam, .*
> if I use the rule above there must be a 3rd parameter (no matter how it
> looks like)
> 
> However if I use the following I can't call  "mycmd" with a 3rd parameter
> mycmd: RegExpFilter, /usr/local/bin/mycmd, root, mycmd, either|or,
> anotherparam
> 
> If I use both rules the first one is ignored.
> 
> What should I change to have a rule with an optional parameter?

RegExpFilter checks the number of parameters, so if you want to leverage
RegExpFilter with an optional parameter you will have to write two
separate rules.

They have to be named differently though (mcmd1 and mycmd2 for example),
otherwise the second one overwrites the first one.

Regards,

-- 
Thierry Carrez (ttx)




More information about the Openstack mailing list