def purge_and_unregister(self): try: self.logger.info('Ahenk conf cleaned') self.logger.info('Ahenk conf cleaning from db') self.unregister() self.logger.info('Purge ldap packages') Util.execute( "sudo apt purge libpam-ldap libnss-ldap ldap-utils -y") # self.logger.info('Purge ahenk packages') # Util.execute("sudo apt purge ahenk ahenk-* -y") Util.execute("sudo apt autoremove -y") self.change_configs_after_purge() self.logger.info('purging successfull') self.logger.info('Cleaning ahenk conf..') self.clean() self.logger.info('Ahenk conf cleaned from db') self.logger.info('Enable Users') self.enable_local_users() Util.shutdown() except Exception as e: self.logger.error( "Error while running purge_and_unregister process.. Error Message " + str(e))
def recv_direct_message(self, msg): if msg['type'] in ['normal']: self.logger.info('---------->Received message: {0}'.format( str(msg['body']))) self.logger.info('Reading registration reply') j = json.loads(str(msg['body'])) message_type = j['type'] status = str(j['status']).lower() dn = str(j['agentDn']) self.logger.debug('Registration status: ' + str(status)) if 'not_authorized' == str(status): self.logger.info('Registration is failed. User not authorized') Util.show_message( os.getlogin(), ':0', 'Ahenk Lider MYS sistemine alınamadı !! Sadece yetkili kullanıcılar kayıt yapabilir.', 'Kullanıcı Yetkilendirme Hatası') self.logger.debug('Disconnecting...') self.disconnect() elif 'already_exists' == str(status) or 'registered' == str( status) or 'registered_without_ldap' == str(status): try: self.logger.info( 'Registred from server. Registration process starting.' ) self.event_manager.fireEvent('REGISTRATION_SUCCESS', j) msg = str(self.host) + " Etki Alanına hoş geldiniz." Util.show_message(os.getlogin(), ':0', msg, "UYARI") msg = "Değişikliklerin etkili olması için sistem yeniden başlayacaktır. Sistem yeniden başlatılıyor...." Util.show_message(os.getlogin(), ':0', msg, "UYARI") time.sleep(3) self.logger.info('Disconnecting...') self.disconnect() self.logger.info('Rebooting...') #System.Process.kill_by_pid(int(System.Ahenk.get_pid_number())) #sys.exit(2) Util.shutdown() except Exception as e: self.logger.error('Error Message: {0}.'.format(str(e))) Util.show_message(os.getlogin(), ':0', str(e)) self.logger.debug('Disconnecting...') self.disconnect() elif 'registration_error' == str(status): self.logger.info( 'Registration is failed. New registration request will send' ) #self.event_manager.fireEvent('REGISTRATION_ERROR', str(j)) Util.show_message( os.getlogin(), ':0', 'Ahenk Lider MYS sistemine alınamadı !! Kayıt esnasında hata oluştu. Lütfen sistem yöneticinize başvurunuz.', 'Sistem Hatası') self.logger.debug('Disconnecting...') self.disconnect() else: self.event_manger.fireEvent(message_type, str(msg['body'])) self.logger.debug('Fired event is: {0}'.format(message_type))
def purge_and_unregister(self): try: self.logger.info('Ahenk conf cleaned') self.logger.info('Ahenk conf cleaning from db') self.unregister() directory_type = "LDAP" if self.util.is_exist("/etc/ahenk/ad_info"): directory_type = "AD" if directory_type == "LDAP": self.ldap_login_cancel.cancel() else: self.ad_login_cancel.cancel() self.logger.info('Cleaning ahenk conf..') self.clean() self.logger.info('Ahenk conf cleaned from db') if self.conf_manager.has_section('MACHINE'): user_disabled = self.conf_manager.get("MACHINE", "user_disabled") self.logger.info('User disabled value=' + str(user_disabled)) if user_disabled != 'false': self.logger.info('Enable Users') self.enable_local_users() else: self.logger.info('Local users already enabled') # İf desktop env is XFCE configured lightdm.service if self.util.get_desktop_env() == "xfce": pardus_xfce_path = "/usr/share/lightdm/lightdm.conf.d/99-pardus-xfce.conf" if self.util.is_exist(pardus_xfce_path): self.logger.info( "99-pardus-xfce.conf exists. Deleting file.") self.util.delete_file(pardus_xfce_path) Util.shutdown() except Exception as e: self.logger.error( "Error while running purge_and_unregister process.. Error Message " + str(e))
def recv_direct_message(self, msg): if msg['type'] in ['normal']: self.logger.info('Reading registration reply') j = json.loads(str(msg['body'])) message_type = j['type'] status = str(j['status']).lower() dn = str(j['agentDn']) self.logger.debug('Registration status: ' + str(status)) is_password = False body_without_password = json.loads(str(msg['body'])) for key, value in body_without_password.items(): if "password" in key.lower(): body_without_password[key] = "********" is_password = True if is_password: self.logger.info('---------->Received message: {0}'.format( str(body_without_password))) else: self.logger.info('---------->Received message: {0}'.format( str(msg['body']))) if 'not_authorized' == str(status): self.logger.debug( '[REGISTRATION IS FAILED]. User not authorized') if self.registration.showUserNotify == True: Util.show_message( os.getlogin(), ':0', 'Ahenk Lider MYS\`ye alınamadı !! Sadece yetkili kullanıcılar kayıt yapabilir.', 'Kullanıcı Yetkilendirme Hatası') self.logger.debug('Disconnecting...') self.disconnect() elif 'registered' == str( status) or 'registered_without_ldap' == str(status): try: self.logger.info( 'Registred from server. Registration process starting.' ) self.event_manager.fireEvent('REGISTRATION_SUCCESS', j) if self.registration.showUserNotify == True: msg = str(self.host) + " Etki Alanına hoş geldiniz." Util.show_message(os.getlogin(), ':0', msg, "UYARI") msg = "Değişikliklerin etkili olması için sistem yeniden başlayacaktır. Sistem yeniden başlatılıyor...." Util.show_message(os.getlogin(), ':0', msg, "UYARI") time.sleep(3) self.logger.info('Disconnecting...') self.disconnect() self.logger.info('Rebooting...') #System.Process.kill_by_pid(int(System.Ahenk.get_pid_number())) #sys.exit(2) Util.shutdown() except Exception as e: self.logger.error('Error Message: {0}.'.format(str(e))) if self.registration.showUserNotify == True: Util.show_message(os.getlogin(), ':0', str(e)) self.logger.debug('Disconnecting...') self.disconnect() elif 'already_exists' == str(status): self.logger.debug( '[REGISTRATION IS FAILED] - Hostname already in use!') if self.registration.showUserNotify == True: Util.show_message( os.getlogin(), ':0', '{0} bilgisayar adı zaten kullanılmaktadır. Lütfen bilgisayar adını değiştirerek tekrar deneyiniz' .format(System.Os.hostname()), 'Bilgisayar İsimlendirme Hatası') self.logger.debug('Disconnecting...') self.disconnect() elif 'registration_error' == str(status): self.logger.info( '[REGISTRATION IS FAILED] - New registration request will send' ) #self.event_manager.fireEvent('REGISTRATION_ERROR', str(j)) if self.registration.showUserNotify == True: Util.show_message( os.getlogin(), ':0', 'Ahenk Lider MYS\`ye alınamadı !! Kayıt esnasında hata oluştu. Lütfen sistem yöneticinize başvurunuz.', 'Sistem Hatası') self.logger.debug('Disconnecting...') self.disconnect() else: self.event_manager.fireEvent(message_type, str(msg['body'])) self.logger.debug('Fired event is: {0}'.format(message_type))
def purge_and_unregister(self): try: self.logger.info('Ahenk conf cleaned') self.logger.info('Ahenk conf cleaning from db') self.unregister() directory_type = "LDAP" if self.util.is_exist("/etc/ahenk/ad_info"): directory_type = "AD" if directory_type == "LDAP": self.ldap_login_cancel.cancel() else: self.ad_login_cancel.cancel() self.logger.info('Cleaning ahenk conf..') self.clean() self.logger.info('Ahenk conf cleaned from db') if self.conf_manager.has_section('MACHINE'): user_disabled = self.conf_manager.get("MACHINE", "user_disabled") self.logger.info('User disabled value=' + str(user_disabled)) if user_disabled != 'false': self.logger.info('Enable Users') self.enable_local_users() else: self.logger.info('Local users already enabled') # İf desktop env is XFCE configured lightdm.service if self.util.get_desktop_env() == "xfce": pardus_xfce_path = "/usr/share/lightdm/lightdm.conf.d/99-pardus-xfce.conf" if self.util.is_exist(pardus_xfce_path): self.logger.info( "99-pardus-xfce.conf exists. Deleting file.") self.util.delete_file(pardus_xfce_path) if self.util.get_desktop_env() == "gnome": pardus_gnome_path = "/etc/gdm3/greeter.dconf-defaults" if not self.util.is_exist(pardus_gnome_path): self.logger.info("Gnome conf doesn't exist") else: reading_file = open(pardus_gnome_path, "r") new_file_content = "" for line in reading_file: stripped_line = line.strip() new_line = stripped_line.replace( "disable-user-list=true", "# disable-user-list=true") new_file_content += new_line + "\n" reading_file.close() writing_file = open(pardus_gnome_path, "w") writing_file.write(new_file_content) writing_file.close() self.logger.info("gdm.conf has been configured.") Util.shutdown() except Exception as e: self.logger.error( "Error while running purge_and_unregister process.. Error Message " + str(e))