Univention Bugzilla – Bug 32306
[Syntax] TrueFalse allows any value on CLI
Last modified: 2018-04-13 13:29:19 CEST
I can pass any value to TrueFalse attributes on CLI and they get applied: ========================================================================= root@master200:~# udm policies/dhcp_dnsupdate create --set name="some_policy" --set ddnsDoForwardUpdate="neither_true_nor_false" Object created: cn=some_policy,dc=ucs,dc=dev root@master200:~# univention-ldapsearch cn=some_policy # extended LDIF # # LDAPv3 # base <dc=ucs,dc=dev> (default) with scope subtree # filter: cn=some_policy # requesting: ALL # # some_policy, ucs.dev dn: cn=some_policy,dc=ucs,dc=dev objectClass: top objectClass: univentionPolicy objectClass: univentionPolicyDhcpDnsUpdate objectClass: univentionObject univentionDhcpDoForwardUpdates: neither_true_nor_false univentionObjectType: policies/dhcp_dnsupdate cn: some_policy ======================================================================== This might be a general problem of the IState syntax TrueFalse, which just returns the given value if no valid one was found or the value is an instance of "basestring".
> This might be a general problem of the IState syntax TrueFalse, which just ^^^^^^^^^ ignore this
As you said, it seems that the parse method accepts any value... has this been done intentionally this way? ==================== class IStates( select ): values = [] @ClassProperty def choices( cls ): return map( lambda x: ( x[ 1 ] ), cls.values ) @classmethod def parse( cls, text ): if isinstance( text, basestring ): return text for value, choice in cls.values: if text == value: return choice[ 0 ] return text class TrueFalse( IStates ): values = ( ( None, ( '', '' ) ), ( True, ( 'true', _('True') ) ), ( False, ( 'false', _('False')) ) ) ====================
I could find the following occurrences: > handlers/policies/release.py: syntax=univention.admin.syntax.TrueFalseUp, > handlers/policies/pwhistory.py: syntax=univention.admin.syntax.TrueFalseUp, > handlers/policies/dhcp_dnsupdate.py: syntax=univention.admin.syntax.ddnsUpdates, > handlers/policies/dhcp_dnsupdate.py: syntax=univention.admin.syntax.TrueFalse, > handlers/policies/dhcp_dnsupdate.py: syntax=univention.admin.syntax.TrueFalse, > handlers/policies/dhcp_dnsupdate.py: syntax=univention.admin.syntax.AllowDeny, > handlers/policies/dhcp_scope.py: syntax=univention.admin.syntax.AllowDenyIgnore, > handlers/policies/dhcp_scope.py: syntax=univention.admin.syntax.AllowDenyIgnore, > handlers/policies/dhcp_scope.py: syntax=univention.admin.syntax.AllowDenyIgnore, > handlers/policies/dhcp_scope.py: syntax=univention.admin.syntax.AllowDeny, > handlers/policies/dhcp_scope.py: syntax=univention.admin.syntax.AllowDenyIgnore, > handlers/policies/dhcp_statements.py: syntax=univention.admin.syntax.booleanNone, > handlers/policies/dhcp_statements.py: syntax=univention.admin.syntax.TrueFalse, > handlers/policies/dhcp_statements.py: syntax=univention.admin.syntax.TrueFalse, > handlers/policies/dhcp_statements.py: syntax=univention.admin.syntax.TrueFalse, > handlers/settings/syntax.py: syntax = univention.admin.syntax.TrueFalseUp, > handlers/settings/syntax.py: syntax=univention.admin.syntax.TrueFalseUp, > handlers/dhcp/pool.py: syntax=univention.admin.syntax.AllowDeny, > handlers/dhcp/pool.py: syntax=univention.admin.syntax.AllowDeny, > handlers/dhcp/pool.py: syntax=univention.admin.syntax.AllowDeny, > handlers/dhcp/pool.py: syntax=univention.admin.syntax.AllowDeny,
Revision 26262 introduced syntax IState and converted several syntax classes to IState (they used to be childs of syntax class select): > * all boolean syntax classes provide a mapping between the string > representation and the boolean value; Bug #23222 If I see it correctly, any string is accepted in the parse method, this should be wrong (and differs from the behaviour of the previously used select class): > def parse( cls, text ): > if isinstance( text, basestring ): > return text
*** Bug 35023 has been marked as a duplicate of this bug. ***
*** This bug has been marked as a duplicate of bug 40731 ***