1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-03-20 06:50:23 +03:00

Clean up OU values by removing spaces around commas and equals signs in Linux and Windows OS managers

This commit is contained in:
Adolfo Gómez García 2025-01-22 17:46:52 +01:00
parent 0f218cbeba
commit 77f582a8cf
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
2 changed files with 9 additions and 2 deletions

View File

@ -31,6 +31,7 @@
Author: Alexander Burmatov, thatman at altlinux dot org
"""
import logging
import re
import typing
from django.utils.translation import gettext_lazy
@ -155,7 +156,9 @@ class LinuxOsADManager(LinuxOsManager):
raise exceptions.ui.ValidationError(_('Must provide an account to add machines to domain!'))
if self.password.as_str() == '':
raise exceptions.ui.ValidationError(_('Must provide a password for the account!'))
self.ou.value = self.ou.value.strip()
# Remove spaces around , and = in ou
self.ou.value = re.sub(r'\s*([,=])\s*', r'\1', self.ou.value.strip())
def actor_data(self, userservice: 'UserService') -> types.osmanagers.ActorData:
return types.osmanagers.ActorData(

View File

@ -33,6 +33,7 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import codecs
import logging
import re
import typing
import collections.abc
@ -136,8 +137,11 @@ class WinDomainOsManager(WindowsOsManager):
super().initialize(values)
if values:
# Some cleaning of input data (remove spaces, etc..)
for fld in (self.domain, self.account, self.ou, self.grp, self.server_hint):
for fld in (self.domain, self.account, self.grp, self.server_hint):
fld.value = fld.value.strip().replace(' ', '')
# Remove spaces around , and = in ou
self.ou.value = re.sub(r'\s*([,=])\s*', r'\1', self.ou.value.strip())
if self.domain.as_str() == '':
raise exceptions.ui.ValidationError(_('Must provide a domain!'))