From fa5a44898367461d0e215c12061939c516a8bc51 Mon Sep 17 00:00:00 2001 From: rgbj Date: Fri, 3 Jan 2014 15:41:12 +0100 Subject: [PATCH] On OpenBSD, make user module status 'changed' only if necessary when using 'login_class' parameter --- system/user | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/system/user b/system/user index 48bcf751716..797c25e87a4 100644 --- a/system/user +++ b/system/user @@ -901,8 +901,21 @@ class OpenBSDUser(User): cmd.append(self.shell) if self.login_class is not None: - cmd.append('-L') - cmd.append(self.login_class) + # find current login class + user_login_class = None + userinfo_cmd = [self.module.get_bin_path('userinfo', True), self.name] + (rc, out, err) = self.execute_command(userinfo_cmd) + + for line in out.splitlines(): + tokens = line.split() + + if tokens[0] == 'class' and len(tokens) == 2: + user_login_class = tokens[1] + + # act only if login_class change + if self.login_class != user_login_class: + cmd.append('-L') + cmd.append(self.login_class) if self.update_password == 'always' and self.password is not None and info[1] != self.password: cmd.append('-p')