diff --git a/src/ahenkd.py b/src/ahenkd.py index 2689662..1b6dbde 100644 --- a/src/ahenkd.py +++ b/src/ahenkd.py @@ -245,7 +245,7 @@ class AhenkDaemon(BaseDaemon): Util.create_file(System.Ahenk.fifo_file()) Util.set_permission(System.Ahenk.fifo_file(), '600') - def set_register_user(self, hostName, username, password,directoryServer): + def set_register_user(self, hostName, username, password): self.register_hostname=hostName self.register_user_name=username self.register_user_password=password diff --git a/src/base/command/command_runner.py b/src/base/command/command_runner.py index 0212af6..25a1ef6 100644 --- a/src/base/command/command_runner.py +++ b/src/base/command/command_runner.py @@ -83,6 +83,8 @@ class CommandRunner(object): domain = json_data['domain'] self.logger.info('login event is handled for user: {0}'.format(username)) + self.logger.info('login parameters of login user, username: {0}, display: {1}, desktop: {2}, domain: {3}'.format(username, display, desktop, domain)) + Util.execute("systemctl restart sssd.service") login_message = self.message_manager.login_msg(username,ip) self.messenger.send_direct_message(login_message) @@ -129,6 +131,7 @@ class CommandRunner(object): self.db_service.delete('session', '1=1') self.logger.info('Display is {0}, desktop env is {1} for {2}'.format(display, desktop, username)) session_columns = self.db_service.get_cols('session') + # ['username', 'display', 'desktop', 'timestamp', 'ip', 'domain'] self.db_service.update('session', session_columns, [username, display, desktop, str(int(time.time())), ip, domain]) diff --git a/src/plugins/login-manager/safe.py b/src/plugins/login-manager/safe.py index 0e63281..2e7135b 100644 --- a/src/plugins/login-manager/safe.py +++ b/src/plugins/login-manager/safe.py @@ -15,12 +15,12 @@ class Safe(AbstractPlugin): self.logger.debug('Parameters were initialized.') def handle_safe_mode(self): + user_permission_file = '{0}login-manager/login_files/{1}.permissions'.format(self.Ahenk.plugins_path(), self.username) + login_files = '{0}login-manager/login_files'.format(self.Ahenk.plugins_path()) - user_permission_file = '{0}login-manager/login_files/{1}.permissions'.format(self.Ahenk.plugins_path(), - self.username) - if self.is_exist(user_permission_file): - self.logger.debug('Delete permission file for user \'{0}\'...'.format(self.username)) - self.delete_file(user_permission_file) + if self.is_exist(login_files): + self.logger.debug('Delete login files folder') + self.delete_folder(login_files) machine_permission_file = '{0}login-manager/login_files/None.permissions'.format(self.Ahenk.plugins_path()) if self.is_exist(machine_permission_file): diff --git a/src/plugins/remote-access/setup-vnc-server.py b/src/plugins/remote-access/setup-vnc-server.py index f28f929..db43d0b 100644 --- a/src/plugins/remote-access/setup-vnc-server.py +++ b/src/plugins/remote-access/setup-vnc-server.py @@ -62,7 +62,12 @@ class SetupVnc(AbstractPlugin): result=False) self.logger.debug('Running VNC proceses were killed') self.logger.debug('Getting display and username...') - display_number = self.get_username_display(user_name) + # display_number = self.get_username_display(user_name) + display_number = self.Sessions.display(user_name) + desktop_env = self.get_desktop_env() + if desktop_env == "gnome": + self.get_username_display_gnome(user_name) + self.logger.info("Get display of {0} is {1}".format(user_name, display_number)) homedir = self.get_homedir(user_name) self.logger.info("Get home directory of {0} is {1}".format(user_name, homedir)) # this user_name for execute method @@ -80,39 +85,23 @@ class SetupVnc(AbstractPlugin): if self.data['permission'] == "yes": self.send_notify("Liderahenk", "Lider Ahenk Sistem Yoneticisi tarafindan\n5 sn sonra bilgisayarınıza uzak erişim sağlanacaktır.\nBağlantı kapatıldıktan sonra ayrıca bilgilendirilecektir.", - ":0", user_name, timeout=50000) + display_number, user_name, timeout=50000) time.sleep(5) - self.execute('su - {0} -c "x11vnc -accept \'popup\' -gone \'popup\' -rfbport {1} -rfbauth {2}/.vncahenk{0}/x11vncpasswd -o {2}/.vncahenk{3}/vnc.log -display :{4}"'.format( + self.execute('su - {0} -c "x11vnc -accept \'popup\' -gone \'popup\' -rfbport {1} -rfbauth {2}/.vncahenk{0}/x11vncpasswd -o {2}/.vncahenk{3}/vnc.log -display {4}"'.format( user_name, self.port, homedir, user_name, display_number), result=False) elif self.data["permission"] == "no": self.logger.info("Lider Ahenk sistem yöneticisi 5 sn sonra bilgisayarınıza uzak erişim sağlayacaktır. ") self.send_notify("Liderahenk", "Lider Ahenk Sistem Yoneticisi tarafindan\n5 sn sonra bilgisayarınıza uzak erişim sağlanacaktır.\nBağlantı kapatıldıktan sonra ayrıca bilgilendirilecektir.", - ":0", user_name, timeout=50000) + display_number, user_name, timeout=50000) time.sleep(5) - self.execute('su - {0} -c "x11vnc -gone \'popup\' -rfbport {1} -rfbauth {2}/.vncahenk{0}/x11vncpasswd -o {2}/.vncahenk{3}/vnc.log -display :{4}"'.format( + self.execute('su - {0} -c "x11vnc -gone \'popup\' -rfbport {1} -rfbauth {2}/.vncahenk{0}/x11vncpasswd -o {2}/.vncahenk{3}/vnc.log -display {4}"'.format( user_name, self.port, homedir, user_name, display_number), result=False) else: - self.execute('su - {0} -c "x11vnc -rfbport {1} -rfbauth {2}/.vncahenk{0}/x11vncpasswd -o {2}/.vncahenk{3}/vnc.log -display :{4}"'.format( + self.execute('su - {0} -c "x11vnc -rfbport {1} -rfbauth {2}/.vncahenk{0}/x11vncpasswd -o {2}/.vncahenk{3}/vnc.log -display {4}"'.format( user_name, self.port, homedir, user_name, display_number), result=False) self.logger.info("Lider Ahenk sistem yöneticisi tarafından kullanıcı izni ve bildirim gerektirmeksizin uzak erişim sağlanmıştır") - def get_username_display(self, user): - result_code, p_out, p_err = self.execute("who | awk '{print $1, $5}' | sed 's/(://' | sed 's/)//'", result=True) - display_number = None - result = [] - lines = str(p_out).split('\n') - for line in lines: - arr = line.split(' ') - if len(arr) > 1 and str(arr[1]).isnumeric() is True: - result.append(line) - for res in result: - arr = res.split(" ") - username = arr[0] - if username == user: - display_number = arr[1] - return display_number - def create_password(self, pass_range): self.logger.debug('Password created') random_bytes = urandom(pass_range)