mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-28 09:12:16 +03:00
registration add util methods
This commit is contained in:
parent
bf304c9969
commit
4493fb34d3
1 changed files with 68 additions and 88 deletions
|
@ -15,7 +15,6 @@ import pwd
|
||||||
from base.timer.setup_timer import SetupTimer
|
from base.timer.setup_timer import SetupTimer
|
||||||
from base.timer.timer import Timer
|
from base.timer.timer import Timer
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class Registration:
|
class Registration:
|
||||||
|
@ -46,30 +45,22 @@ class Registration:
|
||||||
|
|
||||||
self.host = self.conf_manager.get("CONNECTION", "host")
|
self.host = self.conf_manager.get("CONNECTION", "host")
|
||||||
self.servicename = self.conf_manager.get("CONNECTION", "servicename")
|
self.servicename = self.conf_manager.get("CONNECTION", "servicename")
|
||||||
|
|
||||||
self.user_name = ''
|
self.user_name = ''
|
||||||
self.user_password= ''
|
self.user_password= ''
|
||||||
|
|
||||||
user_name= os.getlogin()
|
user_name= os.getlogin()
|
||||||
|
|
||||||
self.logger.debug('User : '+ str(user_name))
|
self.logger.debug('User : '+ str(user_name))
|
||||||
|
|
||||||
pout = Util.show_registration_message(user_name,'Makineyi Lider MYS sistemine kaydetmek için bilgileri ilgili alanlara giriniz. LÜTFEN DEVAM EDEN İŞLEMLERİ SONLANDIRDIĞINZA EMİN OLUNUZ !',
|
pout = Util.show_registration_message(user_name,'Makineyi Lider MYS sistemine kaydetmek için bilgileri ilgili alanlara giriniz. LÜTFEN DEVAM EDEN İŞLEMLERİ SONLANDIRDIĞINZA EMİN OLUNUZ !',
|
||||||
'LIDER MYS SISTEMINE KAYIT', self.host)
|
'LIDER MYS SISTEMINE KAYIT', self.host)
|
||||||
|
|
||||||
self.logger.debug('pout : ' + str(pout))
|
self.logger.debug('pout : ' + str(pout))
|
||||||
|
|
||||||
field_values = pout.split(' ')
|
field_values = pout.split(' ')
|
||||||
|
|
||||||
user_registration_info = list(field_values)
|
user_registration_info = list(field_values)
|
||||||
|
|
||||||
if self.host == '' :
|
if self.host == '' :
|
||||||
self.host = user_registration_info[0]
|
self.host = user_registration_info[0]
|
||||||
self.user_name = user_registration_info[1];
|
self.user_name = user_registration_info[1]
|
||||||
self.user_password = user_registration_info[2];
|
self.user_password = user_registration_info[2]
|
||||||
else:
|
else:
|
||||||
self.user_name = user_registration_info[0];
|
self.user_name = user_registration_info[0]
|
||||||
self.user_password = user_registration_info[1];
|
self.user_password = user_registration_info[1]
|
||||||
|
|
||||||
#anon_messenger = AnonymousMessenger(self.message_manager.registration_msg(user_name,user_password), self.host,self.servicename)
|
#anon_messenger = AnonymousMessenger(self.message_manager.registration_msg(user_name,user_password), self.host,self.servicename)
|
||||||
#anon_messenger.connect_to_server()
|
#anon_messenger.connect_to_server()
|
||||||
|
@ -97,7 +88,6 @@ class Registration:
|
||||||
print(e)
|
print(e)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def update_registration_attrs(self, dn=None):
|
def update_registration_attrs(self, dn=None):
|
||||||
self.logger.debug('Registration configuration is updating...')
|
self.logger.debug('Registration configuration is updating...')
|
||||||
self.db_service.update('registration', ['dn', 'registered'], [dn, 1], ' registered = 0')
|
self.db_service.update('registration', ['dn', 'registered'], [dn, 1], ' registered = 0')
|
||||||
|
@ -125,7 +115,6 @@ class Registration:
|
||||||
admin_dn = str(reg_reply['ldapUserDn']) # get user full dn from server.. password same
|
admin_dn = str(reg_reply['ldapUserDn']) # get user full dn from server.. password same
|
||||||
#admin_password = self.user_password # same user get from server
|
#admin_password = self.user_password # same user get from server
|
||||||
admin_password = self.db_service.select_one_result('registration', 'password', ' registered=1')
|
admin_password = self.db_service.select_one_result('registration', 'password', ' registered=1')
|
||||||
|
|
||||||
if server_address != '' and dn != '' and version != '' and admin_dn != '' and admin_password != '':
|
if server_address != '' and dn != '' and version != '' and admin_dn != '' and admin_password != '':
|
||||||
(result_code, p_out, p_err) = self.util.execute("/bin/bash /usr/share/ahenk/plugins/ldap-login/scripts/ldap-login.sh {0} {1} {2} {3} {4}".format(
|
(result_code, p_out, p_err) = self.util.execute("/bin/bash /usr/share/ahenk/plugins/ldap-login/scripts/ldap-login.sh {0} {1} {2} {3} {4}".format(
|
||||||
server_address, "\'" + dn + "\'", "\'" + admin_dn + "\'", "\'" + admin_password + "\'", version))
|
server_address, "\'" + dn + "\'", "\'" + admin_dn + "\'", "\'" + admin_password + "\'", version))
|
||||||
|
@ -140,13 +129,15 @@ class Registration:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'LDAP Ayarları yapılırken hata oluştu. Lütfen ağ bağlantınızı kontrol ediniz. Deponuzun güncel olduğundan emin olunuz.')
|
'LDAP Ayarları yapılırken hata oluştu. Lütfen ağ bağlantınızı kontrol ediniz. Deponuzun güncel olduğundan emin olunuz.')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def registration_error(self, reg_reply):
|
def registration_error(self, reg_reply):
|
||||||
self.re_register()
|
self.re_register()
|
||||||
|
|
||||||
|
|
||||||
def change_pam_ldap_configs(self):
|
def change_pam_ldap_configs(self,reg_reply):
|
||||||
|
|
||||||
|
server_address = str(reg_reply['ldapServer'])
|
||||||
|
dn = str(reg_reply['ldapBaseDn'])
|
||||||
|
|
||||||
# pattern for clearing file data from spaces, tabs and newlines
|
# pattern for clearing file data from spaces, tabs and newlines
|
||||||
pattern = re.compile(r'\s+')
|
pattern = re.compile(r'\s+')
|
||||||
|
|
||||||
|
@ -161,32 +152,32 @@ class Registration:
|
||||||
pam_script_configured_file_path = "/usr/share/ahenk/plugins/ldap-login/config-files/pam_script"
|
pam_script_configured_file_path = "/usr/share/ahenk/plugins/ldap-login/config-files/pam_script"
|
||||||
|
|
||||||
# create pam_scripts_original directory if not exists
|
# create pam_scripts_original directory if not exists
|
||||||
if not self.is_exist(pam_scripts_original_directory_path):
|
if not self.util.is_exist(pam_scripts_original_directory_path):
|
||||||
self.logger.info("Creating {0} directory.".format(pam_scripts_original_directory_path))
|
self.logger.info("Creating {0} directory.".format(pam_scripts_original_directory_path))
|
||||||
self.create_directory(pam_scripts_original_directory_path)
|
self.util.create_directory(pam_scripts_original_directory_path)
|
||||||
|
|
||||||
if self.is_exist(ldap_back_up_file_path):
|
if self.util.is_exist(ldap_back_up_file_path):
|
||||||
self.logger.info("Changing {0} with {1}.".format(ldap_original_file_path, ldap_configured_file_path))
|
self.logger.info("Changing {0} with {1}.".format(ldap_original_file_path, ldap_configured_file_path))
|
||||||
self.copy_file(ldap_configured_file_path, ldap_original_file_path)
|
self.util.copy_file(ldap_configured_file_path, ldap_original_file_path)
|
||||||
else:
|
else:
|
||||||
self.logger.info("Backing up {0}".format(ldap_original_file_path))
|
self.logger.info("Backing up {0}".format(ldap_original_file_path))
|
||||||
self.copy_file(ldap_original_file_path, ldap_back_up_file_path)
|
self.util.copy_file(ldap_original_file_path, ldap_back_up_file_path)
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"{0} file is replaced with {1}.".format(ldap_original_file_path, ldap_configured_file_path))
|
"{0} file is replaced with {1}.".format(ldap_original_file_path, ldap_configured_file_path))
|
||||||
self.copy_file(ldap_configured_file_path, ldap_original_file_path)
|
self.util.copy_file(ldap_configured_file_path, ldap_original_file_path)
|
||||||
|
|
||||||
if self.is_exist(pam_script_back_up_file_path):
|
if self.util.is_exist(pam_script_back_up_file_path):
|
||||||
self.copy_file(pam_script_configured_file_path, pam_script_original_file_path)
|
self.util.copy_file(pam_script_configured_file_path, pam_script_original_file_path)
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"{0} is replaced with {1}.".format(pam_script_original_file_path, pam_script_configured_file_path))
|
"{0} is replaced with {1}.".format(pam_script_original_file_path, pam_script_configured_file_path))
|
||||||
else:
|
else:
|
||||||
self.logger.info("Backing up {0}".format(pam_script_original_file_path))
|
self.logger.info("Backing up {0}".format(pam_script_original_file_path))
|
||||||
self.copy_file(pam_script_original_file_path, pam_script_back_up_file_path)
|
self.util.copy_file(pam_script_original_file_path, pam_script_back_up_file_path)
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"{0} file is replaced with {1}".format(pam_script_original_file_path, pam_script_configured_file_path))
|
"{0} file is replaced with {1}".format(pam_script_original_file_path, pam_script_configured_file_path))
|
||||||
self.copy_file(pam_script_configured_file_path, pam_script_original_file_path)
|
self.util.copy_file(pam_script_configured_file_path, pam_script_original_file_path)
|
||||||
|
|
||||||
(result_code, p_out, p_err) = self.execute("DEBIAN_FRONTEND=noninteractive pam-auth-update --package")
|
(result_code, p_out, p_err) = self.util.execute("DEBIAN_FRONTEND=noninteractive pam-auth-update --package")
|
||||||
if result_code == 0:
|
if result_code == 0:
|
||||||
self.logger.info("'DEBIAN_FRONTEND=noninteractive pam-auth-update --package' has run successfully")
|
self.logger.info("'DEBIAN_FRONTEND=noninteractive pam-auth-update --package' has run successfully")
|
||||||
else:
|
else:
|
||||||
|
@ -201,15 +192,15 @@ class Registration:
|
||||||
text = pattern.sub('', file_data)
|
text = pattern.sub('', file_data)
|
||||||
|
|
||||||
is_configuration_done_before = False
|
is_configuration_done_before = False
|
||||||
if ("passwd:compatldap" not in text):
|
if "passwd:compatldap" not in text:
|
||||||
file_data = file_data.replace("passwd: compat", "passwd: compat ldap")
|
file_data = file_data.replace("passwd: compat", "passwd: compat ldap")
|
||||||
is_configuration_done_before = True
|
is_configuration_done_before = True
|
||||||
|
|
||||||
if ("group:compatldap" not in text):
|
if "group:compatldap" not in text:
|
||||||
file_data = file_data.replace("group: compat", "group: compat ldap")
|
file_data = file_data.replace("group: compat", "group: compat ldap")
|
||||||
is_configuration_done_before = True
|
is_configuration_done_before = True
|
||||||
|
|
||||||
if ("shadow:compatldap" not in text):
|
if "shadow:compatldap" not in text:
|
||||||
file_data = file_data.replace("shadow: compat", "shadow: compat ldap")
|
file_data = file_data.replace("shadow: compat", "shadow: compat ldap")
|
||||||
is_configuration_done_before = True
|
is_configuration_done_before = True
|
||||||
|
|
||||||
|
@ -225,7 +216,7 @@ class Registration:
|
||||||
|
|
||||||
# configure ldap-cache
|
# configure ldap-cache
|
||||||
self.logger.info("Starting to ldap-cache configurations.")
|
self.logger.info("Starting to ldap-cache configurations.")
|
||||||
result_code, p_out, p_err = self.execute("apt-get install nss-updatedb -y")
|
result_code, p_out, p_err = self.util.execute("apt-get install nss-updatedb -y")
|
||||||
if result_code != 0:
|
if result_code != 0:
|
||||||
self.logger.error("Error occured while downloading nss-updatedb.")
|
self.logger.error("Error occured while downloading nss-updatedb.")
|
||||||
else:
|
else:
|
||||||
|
@ -260,26 +251,26 @@ class Registration:
|
||||||
file_ns_switch = open("/etc/nsswitch.conf", 'w')
|
file_ns_switch = open("/etc/nsswitch.conf", 'w')
|
||||||
file_ns_switch.write(file_data)
|
file_ns_switch.write(file_data)
|
||||||
file_ns_switch.close()
|
file_ns_switch.close()
|
||||||
self.execute("nss_updatedb ldap")
|
self.util.execute("nss_updatedb ldap")
|
||||||
|
|
||||||
# create cron job for ldap cache
|
# create cron job for ldap cache
|
||||||
content = "#!/bin/bash\n" \
|
content = "#!/bin/bash\n" \
|
||||||
"nss-updatedb ldap"
|
"nss-updatedb ldap"
|
||||||
nss_update_cron_job_file_path = "/etc/cron.daily/nss-updatedb"
|
nss_update_cron_job_file_path = "/etc/cron.daily/nss-updatedb"
|
||||||
if self.is_exist(nss_update_cron_job_file_path):
|
if self.util.is_exist(nss_update_cron_job_file_path):
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"{0} exists. File will be deleted and creating new one.".format(nss_update_cron_job_file_path))
|
"{0} exists. File will be deleted and creating new one.".format(nss_update_cron_job_file_path))
|
||||||
self.delete_file(nss_update_cron_job_file_path)
|
self.util.delete_file(nss_update_cron_job_file_path)
|
||||||
self.create_file(nss_update_cron_job_file_path)
|
self.util.create_file(nss_update_cron_job_file_path)
|
||||||
self.write_file(nss_update_cron_job_file_path, content, 'w+')
|
self.util.write_file(nss_update_cron_job_file_path, content, 'w+')
|
||||||
self.execute("chmod +x " + nss_update_cron_job_file_path)
|
self.util.execute("chmod +x " + nss_update_cron_job_file_path)
|
||||||
else:
|
else:
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"{0} doesnt exist. File will be created and content will be written.".format(
|
"{0} doesnt exist. File will be created and content will be written.".format(
|
||||||
nss_update_cron_job_file_path))
|
nss_update_cron_job_file_path))
|
||||||
self.create_file(nss_update_cron_job_file_path)
|
self.util.create_file(nss_update_cron_job_file_path)
|
||||||
self.write_file(nss_update_cron_job_file_path, content, 'w+')
|
self.util.write_file(nss_update_cron_job_file_path, content, 'w+')
|
||||||
self.execute("chmod +x " + nss_update_cron_job_file_path)
|
self.util.execute("chmod +x " + nss_update_cron_job_file_path)
|
||||||
|
|
||||||
# configure /etc/libnss-ldap.conf
|
# configure /etc/libnss-ldap.conf
|
||||||
libnss_ldap_file_path = "/etc/libnss-ldap.conf"
|
libnss_ldap_file_path = "/etc/libnss-ldap.conf"
|
||||||
|
@ -288,17 +279,17 @@ class Registration:
|
||||||
"\nnss_reconnect_sleeptime 1" \
|
"\nnss_reconnect_sleeptime 1" \
|
||||||
"\nnss_reconnect_maxsleeptime 8" \
|
"\nnss_reconnect_maxsleeptime 8" \
|
||||||
"\nnss_reconnect_maxconntries 2"
|
"\nnss_reconnect_maxconntries 2"
|
||||||
if self.is_exist(libnss_ldap_file_path):
|
if self.util.is_exist(libnss_ldap_file_path):
|
||||||
self.logger.info("{0} exists.".format(libnss_ldap_file_path))
|
self.logger.info("{0} exists.".format(libnss_ldap_file_path))
|
||||||
self.execute("sed -i '/bind_policy hard/c\\' " + libnss_ldap_file_path)
|
self.util.execute("sed -i '/bind_policy hard/c\\' " + libnss_ldap_file_path)
|
||||||
self.execute("sed -i '/nss_reconnect_tries 1/c\\' " + libnss_ldap_file_path)
|
self.util.execute("sed -i '/nss_reconnect_tries 1/c\\' " + libnss_ldap_file_path)
|
||||||
self.execute("sed -i '/nss_reconnect_sleeptime 1/c\\' " + libnss_ldap_file_path)
|
self.util.execute("sed -i '/nss_reconnect_sleeptime 1/c\\' " + libnss_ldap_file_path)
|
||||||
self.execute("sed -i '/nss_reconnect_maxsleeptime 8/c\\' " + libnss_ldap_file_path)
|
self.util.execute("sed -i '/nss_reconnect_maxsleeptime 8/c\\' " + libnss_ldap_file_path)
|
||||||
self.execute("sed -i '/nss_reconnect_maxconntries 2/c\\' " + libnss_ldap_file_path)
|
self.util.execute("sed -i '/nss_reconnect_maxconntries 2/c\\' " + libnss_ldap_file_path)
|
||||||
self.write_file(libnss_ldap_file_path, content, 'a+')
|
self.util.write_file(libnss_ldap_file_path, content, 'a+')
|
||||||
self.logger.info("Configuration has been made to {0}.".format(libnss_ldap_file_path))
|
self.logger.info("Configuration has been made to {0}.".format(libnss_ldap_file_path))
|
||||||
|
|
||||||
result_code, p_out, p_err = self.execute("apt-get install libnss-db libpam-ccreds -y")
|
result_code, p_out, p_err = self.util.execute("apt-get install libnss-db libpam-ccreds -y")
|
||||||
if result_code != 0:
|
if result_code != 0:
|
||||||
self.logger.error("Error occured while downloading libnss-db libpam-ccreds.")
|
self.logger.error("Error occured while downloading libnss-db libpam-ccreds.")
|
||||||
else:
|
else:
|
||||||
|
@ -306,25 +297,25 @@ class Registration:
|
||||||
|
|
||||||
# configure sudo-ldap
|
# configure sudo-ldap
|
||||||
sudo_ldap_conf_file_path = "/etc/sudo-ldap.conf"
|
sudo_ldap_conf_file_path = "/etc/sudo-ldap.conf"
|
||||||
content = "sudoers_base ou=Roles," + self.data['dn'] \
|
content = "sudoers_base ou=Roles," + dn \
|
||||||
+ "\nBASE " + self.data['dn'] \
|
+ "\nBASE " + dn \
|
||||||
+ "\nURI ldap://" + self.data['server-address']
|
+ "\nURI ldap://" + server_address
|
||||||
# clean if config is already written
|
# clean if config is already written
|
||||||
self.execute("sed -i '/BASE /c\\' " + sudo_ldap_conf_file_path)
|
self.util.execute("sed -i '/BASE /c\\' " + sudo_ldap_conf_file_path)
|
||||||
self.execute("sed -i '/sudoers_base /c\\' " + sudo_ldap_conf_file_path)
|
self.util.execute("sed -i '/sudoers_base /c\\' " + sudo_ldap_conf_file_path)
|
||||||
self.execute("sed -i '/URI /c\\' " + sudo_ldap_conf_file_path)
|
self.util.execute("sed -i '/URI /c\\' " + sudo_ldap_conf_file_path)
|
||||||
|
|
||||||
if self.is_exist(sudo_ldap_conf_file_path):
|
if self.util.is_exist(sudo_ldap_conf_file_path):
|
||||||
self.logger.info("{0} exists.".format(sudo_ldap_conf_file_path))
|
self.logger.info("{0} exists.".format(sudo_ldap_conf_file_path))
|
||||||
self.write_file(sudo_ldap_conf_file_path, content, 'a+')
|
self.util.write_file(sudo_ldap_conf_file_path, content, 'a+')
|
||||||
self.logger.info("Content is written to {0} successfully.".format(sudo_ldap_conf_file_path))
|
self.logger.info("Content is written to {0} successfully.".format(sudo_ldap_conf_file_path))
|
||||||
|
|
||||||
# Configure lightdm.service
|
# Configure lightdm.service
|
||||||
# check if 99-pardus-xfce.conf exists if not create
|
# check if 99-pardus-xfce.conf exists if not create
|
||||||
pardus_xfce_path = "/usr/share/lightdm/lightdm.conf.d/99-pardus-xfce.conf"
|
pardus_xfce_path = "/usr/share/lightdm/lightdm.conf.d/99-pardus-xfce.conf"
|
||||||
if not self.is_exist(pardus_xfce_path):
|
if not self.util.is_exist(pardus_xfce_path):
|
||||||
self.logger.info("99-pardus-xfce.conf does not exist.")
|
self.logger.info("99-pardus-xfce.conf does not exist.")
|
||||||
self.create_file(pardus_xfce_path)
|
self.util.create_file(pardus_xfce_path)
|
||||||
|
|
||||||
file_lightdm = open(pardus_xfce_path, 'a')
|
file_lightdm = open(pardus_xfce_path, 'a')
|
||||||
file_lightdm.write("[Seat:*]\n")
|
file_lightdm.write("[Seat:*]\n")
|
||||||
|
@ -333,20 +324,18 @@ class Registration:
|
||||||
self.logger.info("lightdm has been configured.")
|
self.logger.info("lightdm has been configured.")
|
||||||
else:
|
else:
|
||||||
self.logger.info("99-pardus-xfce.conf exists. Delete file and create new one.")
|
self.logger.info("99-pardus-xfce.conf exists. Delete file and create new one.")
|
||||||
self.delete_file(pardus_xfce_path)
|
self.util.delete_file(pardus_xfce_path)
|
||||||
self.create_file(pardus_xfce_path)
|
self.util.create_file(pardus_xfce_path)
|
||||||
|
|
||||||
file_lightdm = open(pardus_xfce_path, 'a')
|
file_lightdm = open(pardus_xfce_path, 'a')
|
||||||
file_lightdm.write("[Seat:*]")
|
file_lightdm.write("[Seat:*]")
|
||||||
file_lightdm.write("greeter-hide-users=true")
|
file_lightdm.write("greeter-hide-users=true")
|
||||||
file_lightdm.close()
|
file_lightdm.close()
|
||||||
self.logger.info("lightdm.conf has been configured.")
|
self.logger.info("lightdm.conf has been configured.")
|
||||||
self.execute("systemctl restart nscd.service")
|
self.util.execute("systemctl restart nscd.service")
|
||||||
self.execute("pam-auth-update --force")
|
self.util.execute("pam-auth-update --force")
|
||||||
self.logger.info("LDAP Login operation has been completed.")
|
self.logger.info("LDAP Login operation has been completed.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def is_registered(self):
|
def is_registered(self):
|
||||||
try:
|
try:
|
||||||
if str(System.Ahenk.uid()):
|
if str(System.Ahenk.uid()):
|
||||||
|
@ -450,17 +439,11 @@ class Registration:
|
||||||
'and it is connected to XMPP server! Check your Ahenk configuration file (/etc/ahenk/ahenk.conf)')
|
'and it is connected to XMPP server! Check your Ahenk configuration file (/etc/ahenk/ahenk.conf)')
|
||||||
self.logger.error('Ahenk is shutting down...')
|
self.logger.error('Ahenk is shutting down...')
|
||||||
print('Ahenk is shutting down...')
|
print('Ahenk is shutting down...')
|
||||||
|
|
||||||
Util.show_message(os.getlogin(),':0',"Lider MYS sistemine ulaşılamadı. Lütfen sunucu adresini kontrol ediniz....","HATA")
|
Util.show_message(os.getlogin(),':0',"Lider MYS sistemine ulaşılamadı. Lütfen sunucu adresini kontrol ediniz....","HATA")
|
||||||
|
|
||||||
System.Process.kill_by_pid(int(System.Ahenk.get_pid_number()))
|
System.Process.kill_by_pid(int(System.Ahenk.get_pid_number()))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def purge_and_unregister(self):
|
def purge_and_unregister(self):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
|
||||||
self.logger.info('Ahenk conf cleaned')
|
self.logger.info('Ahenk conf cleaned')
|
||||||
self.logger.info('Ahenk conf cleaning from db')
|
self.logger.info('Ahenk conf cleaning from db')
|
||||||
self.unregister()
|
self.unregister()
|
||||||
|
@ -477,11 +460,8 @@ class Registration:
|
||||||
self.logger.info('Enable Users')
|
self.logger.info('Enable Users')
|
||||||
self.enable_local_users()
|
self.enable_local_users()
|
||||||
Util.shutdown()
|
Util.shutdown()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error("Error while running purge_and_unregister process.. Error Message " + str(e))
|
self.logger.error("Error while running purge_and_unregister process.. Error Message " + str(e))
|
||||||
|
|
||||||
|
|
||||||
#System.Process.kill_by_pid(int(System.Ahenk.get_pid_number()))
|
#System.Process.kill_by_pid(int(System.Ahenk.get_pid_number()))
|
||||||
#sys.exit(2)
|
#sys.exit(2)
|
||||||
|
|
||||||
|
@ -495,20 +475,20 @@ class Registration:
|
||||||
pam_script_back_up_file_path = "/usr/share/ahenk/pam_scripts_original/pam_script"
|
pam_script_back_up_file_path = "/usr/share/ahenk/pam_scripts_original/pam_script"
|
||||||
pam_script_original_file_path = "/usr/share/pam-configs/pam_script"
|
pam_script_original_file_path = "/usr/share/pam-configs/pam_script"
|
||||||
|
|
||||||
if self.is_exist(ldap_back_up_file_path):
|
if self.util.is_exist(ldap_back_up_file_path):
|
||||||
self.logger.info("Replacing {0} with {1}".format(ldap_original_file_path, ldap_back_up_file_path))
|
self.logger.info("Replacing {0} with {1}".format(ldap_original_file_path, ldap_back_up_file_path))
|
||||||
self.copy_file(ldap_back_up_file_path, ldap_original_file_path)
|
self.util.copy_file(ldap_back_up_file_path, ldap_original_file_path)
|
||||||
self.logger.info("Deleting {0}".format(ldap_back_up_file_path))
|
self.logger.info("Deleting {0}".format(ldap_back_up_file_path))
|
||||||
self.delete_file(ldap_back_up_file_path)
|
self.util.delete_file(ldap_back_up_file_path)
|
||||||
|
|
||||||
if self.is_exist(pam_script_back_up_file_path):
|
if self.util.is_exist(pam_script_back_up_file_path):
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"Replacing {0} with {1}".format(pam_script_original_file_path, pam_script_back_up_file_path))
|
"Replacing {0} with {1}".format(pam_script_original_file_path, pam_script_back_up_file_path))
|
||||||
self.copy_file(pam_script_back_up_file_path, pam_script_original_file_path)
|
self.util.copy_file(pam_script_back_up_file_path, pam_script_original_file_path)
|
||||||
self.logger.info("Deleting {0}".format(pam_script_back_up_file_path))
|
self.logger.info("Deleting {0}".format(pam_script_back_up_file_path))
|
||||||
self.delete_file(pam_script_back_up_file_path)
|
self.util.delete_file(pam_script_back_up_file_path)
|
||||||
|
|
||||||
(result_code, p_out, p_err) = self.execute("DEBIAN_FRONTEND=noninteractive pam-auth-update --package")
|
(result_code, p_out, p_err) = self.util.execute("DEBIAN_FRONTEND=noninteractive pam-auth-update --package")
|
||||||
if result_code == 0:
|
if result_code == 0:
|
||||||
self.logger.info("'DEBIAN_FRONTEND=noninteractive pam-auth-update --package' has run successfully")
|
self.logger.info("'DEBIAN_FRONTEND=noninteractive pam-auth-update --package' has run successfully")
|
||||||
else:
|
else:
|
||||||
|
@ -551,17 +531,17 @@ class Registration:
|
||||||
|
|
||||||
# Configure ldap-cache
|
# Configure ldap-cache
|
||||||
nss_update_cron_job_file_path = "/etc/cron.daily/nss-updatedb"
|
nss_update_cron_job_file_path = "/etc/cron.daily/nss-updatedb"
|
||||||
if self.is_exist(nss_update_cron_job_file_path):
|
if self.util.is_exist(nss_update_cron_job_file_path):
|
||||||
self.delete_file(nss_update_cron_job_file_path)
|
self.util.delete_file(nss_update_cron_job_file_path)
|
||||||
self.logger.info("{0} is deleted.".format(nss_update_cron_job_file_path))
|
self.logger.info("{0} is deleted.".format(nss_update_cron_job_file_path))
|
||||||
|
|
||||||
# Configure lightdm.service
|
# Configure lightdm.service
|
||||||
pardus_xfce_path = "/usr/share/lightdm/lightdm.conf.d/99-pardus-xfce.conf"
|
pardus_xfce_path = "/usr/share/lightdm/lightdm.conf.d/99-pardus-xfce.conf"
|
||||||
if self.is_exist(pardus_xfce_path):
|
if self.util.is_exist(pardus_xfce_path):
|
||||||
self.logger.info("99-pardus-xfce.conf exists. Deleting file.")
|
self.logger.info("99-pardus-xfce.conf exists. Deleting file.")
|
||||||
self.delete_file(pardus_xfce_path)
|
self.util.delete_file(pardus_xfce_path)
|
||||||
|
|
||||||
self.execute("systemctl restart nscd.service")
|
self.util.execute("systemctl restart nscd.service")
|
||||||
self.logger.info("Operation finished")
|
self.logger.info("Operation finished")
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
@ -633,4 +613,4 @@ class Registration:
|
||||||
Util.execute(passwd_cmd.format(p.pw_name))
|
Util.execute(passwd_cmd.format(p.pw_name))
|
||||||
Util.execute(change_username.format(new_username, 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_home.format(new_home_dir, new_username))
|
||||||
Util.execute(change_permisson.format(new_home_dir))
|
Util.execute(change_permisson.format(new_home_dir))
|
Loading…
Reference in a new issue