mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-26 10:32:24 +03:00
get display number for remote access and remove folder for login manager safe mode
This commit is contained in:
parent
5d12735e85
commit
f9a9c7b7b5
4 changed files with 20 additions and 28 deletions
|
@ -245,7 +245,7 @@ class AhenkDaemon(BaseDaemon):
|
||||||
Util.create_file(System.Ahenk.fifo_file())
|
Util.create_file(System.Ahenk.fifo_file())
|
||||||
Util.set_permission(System.Ahenk.fifo_file(), '600')
|
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_hostname=hostName
|
||||||
self.register_user_name=username
|
self.register_user_name=username
|
||||||
self.register_user_password=password
|
self.register_user_password=password
|
||||||
|
|
|
@ -83,6 +83,8 @@ class CommandRunner(object):
|
||||||
domain = json_data['domain']
|
domain = json_data['domain']
|
||||||
|
|
||||||
self.logger.info('login event is handled for user: {0}'.format(username))
|
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")
|
Util.execute("systemctl restart sssd.service")
|
||||||
login_message = self.message_manager.login_msg(username,ip)
|
login_message = self.message_manager.login_msg(username,ip)
|
||||||
self.messenger.send_direct_message(login_message)
|
self.messenger.send_direct_message(login_message)
|
||||||
|
@ -129,6 +131,7 @@ class CommandRunner(object):
|
||||||
self.db_service.delete('session', '1=1')
|
self.db_service.delete('session', '1=1')
|
||||||
self.logger.info('Display is {0}, desktop env is {1} for {2}'.format(display, desktop, username))
|
self.logger.info('Display is {0}, desktop env is {1} for {2}'.format(display, desktop, username))
|
||||||
session_columns = self.db_service.get_cols('session')
|
session_columns = self.db_service.get_cols('session')
|
||||||
|
# ['username', 'display', 'desktop', 'timestamp', 'ip', 'domain']
|
||||||
self.db_service.update('session', session_columns,
|
self.db_service.update('session', session_columns,
|
||||||
[username, display, desktop, str(int(time.time())), ip, domain])
|
[username, display, desktop, str(int(time.time())), ip, domain])
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,12 @@ class Safe(AbstractPlugin):
|
||||||
self.logger.debug('Parameters were initialized.')
|
self.logger.debug('Parameters were initialized.')
|
||||||
|
|
||||||
def handle_safe_mode(self):
|
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(),
|
if self.is_exist(login_files):
|
||||||
self.username)
|
self.logger.debug('Delete login files folder')
|
||||||
if self.is_exist(user_permission_file):
|
self.delete_folder(login_files)
|
||||||
self.logger.debug('Delete permission file for user \'{0}\'...'.format(self.username))
|
|
||||||
self.delete_file(user_permission_file)
|
|
||||||
|
|
||||||
machine_permission_file = '{0}login-manager/login_files/None.permissions'.format(self.Ahenk.plugins_path())
|
machine_permission_file = '{0}login-manager/login_files/None.permissions'.format(self.Ahenk.plugins_path())
|
||||||
if self.is_exist(machine_permission_file):
|
if self.is_exist(machine_permission_file):
|
||||||
|
|
|
@ -62,7 +62,12 @@ class SetupVnc(AbstractPlugin):
|
||||||
result=False)
|
result=False)
|
||||||
self.logger.debug('Running VNC proceses were killed')
|
self.logger.debug('Running VNC proceses were killed')
|
||||||
self.logger.debug('Getting display and username...')
|
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)
|
homedir = self.get_homedir(user_name)
|
||||||
self.logger.info("Get home directory of {0} is {1}".format(user_name, homedir))
|
self.logger.info("Get home directory of {0} is {1}".format(user_name, homedir))
|
||||||
# this user_name for execute method
|
# this user_name for execute method
|
||||||
|
@ -80,39 +85,23 @@ class SetupVnc(AbstractPlugin):
|
||||||
if self.data['permission'] == "yes":
|
if self.data['permission'] == "yes":
|
||||||
self.send_notify("Liderahenk",
|
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.",
|
"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)
|
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)
|
user_name, self.port, homedir, user_name, display_number), result=False)
|
||||||
elif self.data["permission"] == "no":
|
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.logger.info("Lider Ahenk sistem yöneticisi 5 sn sonra bilgisayarınıza uzak erişim sağlayacaktır. ")
|
||||||
self.send_notify("Liderahenk",
|
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.",
|
"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)
|
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)
|
user_name, self.port, homedir, user_name, display_number), result=False)
|
||||||
else:
|
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)
|
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")
|
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):
|
def create_password(self, pass_range):
|
||||||
self.logger.debug('Password created')
|
self.logger.debug('Password created')
|
||||||
random_bytes = urandom(pass_range)
|
random_bytes = urandom(pass_range)
|
||||||
|
|
Loading…
Reference in a new issue