mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2025-01-12 09:12:20 +03:00
polkit issues
This commit is contained in:
parent
866e530f51
commit
509c74145b
8 changed files with 43 additions and 3 deletions
|
@ -310,7 +310,7 @@ class AhenkDaemon(BaseDaemon):
|
|||
|
||||
self.check_registration()
|
||||
|
||||
#self.is_registered()
|
||||
self.is_registered()
|
||||
|
||||
self.disable_local_users()
|
||||
|
||||
|
@ -322,7 +322,8 @@ class AhenkDaemon(BaseDaemon):
|
|||
self.init_signal_listener()
|
||||
self.logger.info('Signals listeners was set')
|
||||
|
||||
Agreement().agreement_contract_update()
|
||||
# Agreement().agreement_contract_update()
|
||||
|
||||
global_scope.put_custom_map('ahenk_daemon', ahenk_daemon)
|
||||
self.init_message_response_queue()
|
||||
|
||||
|
|
|
@ -36,6 +36,15 @@ 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.write_file(ahenk_policy_file, content)
|
||||
self.logger.info('Root added ahenk polkit file')
|
||||
|
||||
def run_command_from_fifo(self, num, stack):
|
||||
""" docstring"""
|
||||
|
||||
|
@ -151,6 +160,9 @@ 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)
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ class ExecutionManager(object):
|
|||
self.event_manager.register_event(MessageType.RESPONSE_AGREEMENT.value, self.agreement_update)
|
||||
self.event_manager.register_event(MessageType.UPDATE_SCHEDULED_TASK.value, self.update_scheduled_task)
|
||||
self.event_manager.register_event(MessageType.REGISTRATION_RESPONSE.value, self.unregister) # registration message for unregister event
|
||||
self.event_manager.register_event(MessageType.LOGIN_RESPONSE.value, self.login_response) # registration message for unregister event
|
||||
|
||||
def agreement_update(self, arg):
|
||||
|
||||
|
@ -531,3 +532,23 @@ class ExecutionManager(object):
|
|||
user_execution_id=json_data['userCommandExecutionId'],
|
||||
agent_expiration_date=json_data['agentPolicyExpirationDate'],
|
||||
user_expiration_date=json_data['userPolicyExpirationDate'])
|
||||
|
||||
def login_response(self, msg):
|
||||
jData = json.loads(msg)
|
||||
username = jData['userName']
|
||||
if username is not None:
|
||||
self.create_sudo_polkit(username)
|
||||
|
||||
|
||||
def create_sudo_polkit(self,username):
|
||||
content = "[Configuration] \nAdminIdentities=unix-user:{}".format(username)
|
||||
ahenk_policy_file = "/etc/polkit-1/localauthority.conf.d/99-ahenk-policy.conf"
|
||||
if not Util.is_exist(ahenk_policy_file):
|
||||
Util.create_file(ahenk_policy_file)
|
||||
Util.write_file(ahenk_policy_file, content)
|
||||
self.logger.debug('Ahenk polkit file created and user added.. User : {}'.format(username))
|
||||
else:
|
||||
self.logger.debug('Writing result to file')
|
||||
Util.delete_file(ahenk_policy_file)
|
||||
Util.create_file(ahenk_policy_file)
|
||||
Util.write_file(ahenk_policy_file, content)
|
|
@ -123,7 +123,7 @@ class AnonymousMessenger(ClientXMPP):
|
|||
self.logger.info('Rebooting...')
|
||||
#System.Process.kill_by_pid(int(System.Ahenk.get_pid_number()))
|
||||
#sys.exit(2)
|
||||
Util.shutdown();
|
||||
#Util.shutdown();
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error('Error Message: {0}.'.format(str(e)))
|
||||
|
|
|
@ -72,6 +72,7 @@ class Messaging(object):
|
|||
data['ipAddresses'] = str(System.Hardware.Network.ip_addresses()).replace('[', '').replace(']', '')
|
||||
data['timestamp'] = Util.timestamp()
|
||||
data['userIp'] = ip
|
||||
data['hostname'] = str(System.Os.hostname())
|
||||
|
||||
self.logger.debug('USER IP : '+ str(ip)+ ' IPADDRESSES : '+ str(System.Hardware.Network.ip_addresses()).replace('[', '').replace(']', ''))
|
||||
|
||||
|
|
|
@ -24,3 +24,4 @@ class MessageType(Enum):
|
|||
RESPONSE_AGREEMENT = 'RESPONSE_AGREEMENT'
|
||||
UPDATE_SCHEDULED_TASK = 'UPDATE_SCHEDULED_TASK'
|
||||
REGISTRATION_RESPONSE ='REGISTRATION_RESPONSE'
|
||||
LOGIN_RESPONSE = 'LOGIN_RESPONSE'
|
||||
|
|
|
@ -508,6 +508,7 @@ class Registration:
|
|||
change_username = 'usermod -l {0} {1}'
|
||||
content = Util.read_file('/etc/passwd')
|
||||
kill_all_process = 'killall -KILL -u {}'
|
||||
change_permisson = "chmod -R 700 {}"
|
||||
for p in pwd.getpwall():
|
||||
self.logger.info("User: '{0}' will be disabled and changed username and home directory of username".format(p.pw_name))
|
||||
if not sysx.shell_is_interactive(p.pw_shell):
|
||||
|
@ -521,3 +522,4 @@ class Registration:
|
|||
Util.execute(passwd_cmd.format(p.pw_name))
|
||||
Util.execute(change_username.format(new_username, p.pw_name))
|
||||
Util.execute(change_home.format(new_home_dir, new_username))
|
||||
Util.execute(change_permisson.format(new_home_dir))
|
||||
|
|
|
@ -359,7 +359,9 @@ class Util:
|
|||
|
||||
@staticmethod
|
||||
def show_registration_message(login_user_name,message,title,host=None):
|
||||
|
||||
ask_path = '/usr/share/ahenk/base/agreement/ahenkmessage.py'
|
||||
|
||||
display_number = ":0"
|
||||
|
||||
if host is None:
|
||||
|
|
Loading…
Reference in a new issue