Commit a06c233c authored by Benjamin Baer's avatar Benjamin Baer
Browse files

usernames changed to list, better error output, no function for agent logoutuser to test lists

parent c8566099
......@@ -28,27 +28,29 @@ class LogoutUser(managementagent.RabbitModule):
try:
logger.debug('process message: %s', message)
username = instructions['username']
logger.debug('trying to find screensaver for %s', username)
if 'force' in instructions:
force = instructions['force']
else:
force = False
if force == True:
process = subprocess.Popen(['/usr/bin/pkill', '-u', username, '-KILL'])
else:
process = subprocess.Popen(['/usr/bin/pkill', '-u', username])
process.wait()
if process.returncode != 0:
logger.warning("Failed to logout user %s", username)
self.send_reply(reply_to, process.returncode, "Error executing pkill command (%i)" % (process.returncode,))
else:
logger.info("User %s logout succesfull", username)
self.send_reply(reply_to, 0, "Ended sessions for %s" % (username,))
usernames = instructions['usernames']
for username in usernames:
logger.debug('trying to kill user %s', username)
if 'force' in instructions:
force = instructions['force']
else:
force = False
if force == True:
logger.warning("process = subprocess.Popen(['/usr/bin/pkill', '-u', username, '-KILL'])")
else:
logger.warning("process = subprocess.Popen(['/usr/bin/pkill', '-u', username])")
process.wait()
if process.returncode != 0:
logger.warning("Failed to logout user %s", username)
self.send_reply(reply_to, process.returncode, "Error executing pkill command (%i)" % (process.returncode,))
else:
logger.info("User %s logout succesfull", username)
self.send_reply(reply_to, 0, "Ended sessions for %s" % (username,))
except Exception as ex:
self.send_reply(reply_to, -1, repr(ex))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment