From 475851f81a5481a904fe0222df8212936cad2898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B8=D1=80=D0=B5=D1=86=D0=BA=D0=B8=D0=B9=20=D0=9C?= =?UTF-8?q?=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Tue, 30 Aug 2016 12:09:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=B1=D0=BB=D0=BE=D0=BA=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pym/unix/unix.py | 40 ++++++++++++++++++++++++-------- pym/unix/utils/cl_unix_passwd.py | 10 ++++---- pym/unix/variables/users.py | 23 +++++++----------- 3 files changed, 44 insertions(+), 29 deletions(-) diff --git a/pym/unix/unix.py b/pym/unix/unix.py index 23b84fa..e7b5be5 100644 --- a/pym/unix/unix.py +++ b/pym/unix/unix.py @@ -592,18 +592,38 @@ class Unix(Ldap): params['shell'] = shell self.printSUCCESS( _("Changed shell for user %s") % user.username) - if visible is not None and user.visible != visible: - params['visible'] = visible - if visible: - self.printSUCCESS(_("User %s is visible") % user.username) + if visible is not None: + if user.visible != visible: + params['visible'] = visible + if visible: + self.printSUCCESS( + _("User %s is visible") % user.username) + else: + self.printSUCCESS( + _("User %s is unvisible") % user.username) else: - self.printSUCCESS(_("User %s is unvisible") % user.username) - if lock is not None and user.lock != lock: - params['lock'] = lock - if lock: - self.printSUCCESS(_("User %s is locked") % user.username) + if visible: + self.printWARNING( + _("User %s is visible already") % user.username) + else: + self.printWARNING( + _("User %s is unvisible already") % user.username) + if lock is not None: + if user.lock != lock: + params['lock'] = lock + if lock: + self.printSUCCESS( + _("User %s is locked") % user.username) + else: + self.printSUCCESS( + _("User %s is unlocked") % user.username) else: - self.printSUCCESS(_("User %s is unlocked") % user.username) + if lock: + self.printWARNING( + _("User %s is locked already") % user.username) + else: + self.printWARNING( + _("User %s is unlocked already") % user.username) uu.modify_user(user.username, **params) else: raise UnixError(_("User %s not found") % user) diff --git a/pym/unix/utils/cl_unix_passwd.py b/pym/unix/utils/cl_unix_passwd.py index b23f4d6..39dd4c3 100644 --- a/pym/unix/utils/cl_unix_passwd.py +++ b/pym/unix/utils/cl_unix_passwd.py @@ -44,9 +44,9 @@ class ClUnixPasswdAction(Action): UnixError, LdapError) - successMessage = __("Password for user {ur_unix_login} in Unix service changed!") - failedMessage = __("Failed to change password for user {ur_unix_login} in Unix server!") - interruptMessage = __("User password changing manually interrupted") + successMessage = __("User {ur_unix_login} modified in Unix service!") + failedMessage = __("Failed to modify user {ur_unix_login} in Unix server!") + interruptMessage = __("Modifing of user manually interrupted") stop_tasks = [ ] @@ -57,7 +57,7 @@ class ClUnixPasswdAction(Action): tasks = [ {'name': 'user_change', 'method': 'Unix.modify_user(ur_unix_login,ur_unix_hash,' - 'ur_unix_pw_delete_set,' - 'None,None,None,ur_unix_lock_set,None,None)' + 'ur_unix_pw_delete_set,' + 'None,None,None,ur_unix_lock_set,None,None)' }, ] diff --git a/pym/unix/variables/users.py b/pym/unix/variables/users.py index fbfc654..64b96c1 100644 --- a/pym/unix/variables/users.py +++ b/pym/unix/variables/users.py @@ -468,10 +468,9 @@ class VariableUrUnixPw(Variable): def check(self, value): delete_pw = self.GetBool('ur_unix_pw_delete_set') - change_lock = (self.GetBool('ur_unix_lock_set') != - self.GetBool('ur_unix_lock_exists_set')) + change_lock = self.GetBool('ur_unix_lock_set') if (self.Get('cl_unix_action') == Actions.Passwd and - not delete_pw and not change_lock and not value): + not delete_pw and change_lock is None and not value): raise PasswordError(_("Specify user password")) if self.Get('cl_unix_action') in (Actions.Passwd, Actions.UserMod): if self.Get('ur_unix_pw_delete_set') == 'on' and value: @@ -552,7 +551,7 @@ class VariableUrUnixVisibleSet(ExistsUserHelper, UnixActionHelper, Variable): Виден ли пользователь """ attribute = "visible" - type = "bool" + type = "boolauto" opt = ("-v", "--visible") def init(self): @@ -562,28 +561,24 @@ class VariableUrUnixVisibleSet(ExistsUserHelper, UnixActionHelper, Variable): def get_new(self): return "on" + def get_exists(self): + return "auto" + class VariableUrUnixLockSet(ExistsUserHelper, UnixActionHelper, Variable): """ Виден ли пользователь """ attribute = "lock" - type = "bool" + type = "boolauto" opt = ("-l", "--lock") - value = "off" def init(self): self.label = _("Locked") self.help = _("lock the account") - -class VariableUrUnixLockExistsSet(ExistsUserHelper, UnixActionHelper, Variable): - """ - Виден ли пользователь - """ - type = "bool" - attribute = "lock" - value = "off" + def get(self): + return "auto" class VariableUrUnixVisibleFlag(UnixUserHelper, ReadonlyVariable):