mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-07-29 23:58:23 -05:00
sudocmd: ensure command doesn't contain trailing dot before adding it
Trailing dots aren't permitted in sudo commands, as enforced explicitly in `get_dn`. Performing this check before adding the command prevents the user from entering invalid commands, which would otherwise trigger errors when accessing them afterwards. RN: ipa sudocmd-* commands now validate SUDO command name to not end with a dot. RN: Previously a trailing dot was stripped away in when addressing a SUDO command's LDAP object. RN: As a result, a SUDO command was created but it was not possible to refer to it in other IPA commands. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1925410 Signed-off-by: Antonio Torres <antorres@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
committed by
Alexander Bokovoy
parent
3d2d06719f
commit
d6c5a92609
@@ -49,6 +49,12 @@ register = Registry()
|
|||||||
|
|
||||||
topic = 'sudo'
|
topic = 'sudo'
|
||||||
|
|
||||||
|
|
||||||
|
def command_validator(ugettext, value):
|
||||||
|
if value.endswith('.'):
|
||||||
|
return _('must not contain trailing dot: %s') % value
|
||||||
|
return None
|
||||||
|
|
||||||
@register()
|
@register()
|
||||||
class sudocmd(LDAPObject):
|
class sudocmd(LDAPObject):
|
||||||
"""
|
"""
|
||||||
@@ -112,7 +118,7 @@ class sudocmd(LDAPObject):
|
|||||||
label_singular = _('Sudo Command')
|
label_singular = _('Sudo Command')
|
||||||
|
|
||||||
takes_params = (
|
takes_params = (
|
||||||
Str('sudocmd',
|
Str('sudocmd', command_validator,
|
||||||
cli_name='command',
|
cli_name='command',
|
||||||
label=_('Sudo Command'),
|
label=_('Sudo Command'),
|
||||||
primary_key=True,
|
primary_key=True,
|
||||||
@@ -147,7 +153,6 @@ class sudocmd_add(LDAPCreate):
|
|||||||
|
|
||||||
msg_summary = _('Added Sudo Command "%(value)s"')
|
msg_summary = _('Added Sudo Command "%(value)s"')
|
||||||
|
|
||||||
|
|
||||||
@register()
|
@register()
|
||||||
class sudocmd_del(LDAPDelete):
|
class sudocmd_del(LDAPDelete):
|
||||||
__doc__ = _('Delete Sudo Command.')
|
__doc__ = _('Delete Sudo Command.')
|
||||||
|
|||||||
Reference in New Issue
Block a user