From 32e92028aa235f6c77985f923f12fb22bed5272c Mon Sep 17 00:00:00 2001 From: Hasan Kara Date: Mon, 13 May 2019 12:10:42 +0300 Subject: [PATCH] firefox autostart is added if profile is not created for user. --- src/base/command/command_runner.py | 53 ++++++++++++++++++------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/src/base/command/command_runner.py b/src/base/command/command_runner.py index 3bb804c..534c93d 100644 --- a/src/base/command/command_runner.py +++ b/src/base/command/command_runner.py @@ -36,16 +36,6 @@ class CommandRunner(object): else: return True - def delete_polkit_user(self): - content = "[Configuration] \nAdminIdentities=unix-user:root" - ahenk_policy_file = "/etc/polkit-1/localauthority.conf.d/99-ahenk-policy.conf" - if not Util.is_exist(ahenk_policy_file): - self.logger.info('Ahenk polkit file not found') - else: - Util.delete_file(ahenk_policy_file) - Util.write_file(ahenk_policy_file, content) - self.logger.info('Root added ahenk polkit file') - def run_command_from_fifo(self, num, stack): """ docstring""" @@ -71,7 +61,6 @@ class CommandRunner(object): display = json_data['display'] desktop = json_data['desktop'] - ip = None if 'ip' in json_data: ip = json_data['ip'] @@ -83,6 +72,38 @@ class CommandRunner(object): agreement = Agreement() agreement_choice = None + self.logger.info("if mozilla profile is not created run firefox to create profile for user: " + username) + if not Util.is_exist("/home/" + username + "/.mozilla/"): + self.logger.info("firefox profile does not exist. Check autostart file.") + if not Util.is_exist("/home/" + username + "/.config/autostart/"): + self.logger.info(".config/autostart folder does not exist. Creating folder.") + Util.create_directory("/home/" + username + "/.config/autostart/") + else: + self.logger.info(".config/autostart folder exists.") + self.logger.info( + "Checking if firefox-esr-autostart-for-profile.desktop autorun file exists.") + + if not Util.is_exist( + "/home/" + username + "/.config/autostart/firefox-esr-autostart-for-profile.desktop"): + self.logger.info( + "firefox-esr-autostart-for-profile.desktop autorun file does not exists. Creating file.") + Util.create_file( + "/home/" + username + "/.config/autostart/firefox-esr-autostart-for-profile.desktop") + content = "[Desktop Entry]\n\n" \ + "Type=Application\n\n" \ + "Exec=firefox-esr www.liderahenk.org" + Util.write_file( + "/home/" + username + "/.config/autostart/firefox-esr-autostart-for-profile.desktop", + content) + self.logger.info( + "Autorun config is written to firefox-esr-autostart-for-profile.desktop.") + else: + self.logger.info("firefox-esr-autostart-for-profile.desktop exists") + else: + self.logger.info(".mozilla firefox profile path exists. Delete autorun file.") + Util.delete_file( + "/home/" + username + "/.config/autostart/firefox-esr-autostart-for-profile.desktop") + if agreement.check_agreement(username) is not True and System.Ahenk.agreement() == '1': self.logger.debug('User {0} has not accepted agreement.'.format(username)) thread_ask = Process(target=agreement.ask, args=(username, display,)) @@ -161,9 +182,6 @@ class CommandRunner(object): logout_message = self.message_manager.logout_msg(username,ip) self.messenger.send_direct_message(logout_message) - self.logger.info('Ahenk polkit file deleting..') - self.delete_polkit_user(); - self.plugin_manager.process_mode('logout', username) self.plugin_manager.process_mode('safe', username) @@ -173,13 +191,6 @@ class CommandRunner(object): message = json.dumps(json_data['message']) self.messenger.send_direct_message(message) - - elif str(json_data['event']) == 'unregister': - self.logger.info('Unregistering..') - unregister_message = self.message_manager.unregister_msg() - if unregister_message is not None: - self.messenger.send_direct_message(unregister_message) - elif str(json_data['event']) == 'load': plugin_name = str(json_data['plugins'])