mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-26 00:02:19 +03:00
register,unregister and AD swap modified
This commit is contained in:
parent
2f00d9b72e
commit
73ece8417d
3 changed files with 13 additions and 99 deletions
|
@ -15,10 +15,6 @@ class ExecuteCancelSSSDAdAuthentication:
|
||||||
|
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
try:
|
try:
|
||||||
# Deleting packages require for AD entegration
|
|
||||||
self.util.execute(
|
|
||||||
"apt purge realmd sssd sssd-tools adcli krb5-user packagekit samba-common samba-common-bin samba-libs -y")
|
|
||||||
self.util.execute("apt autoremove -y")
|
|
||||||
|
|
||||||
# Read information about AD
|
# Read information about AD
|
||||||
if self.util.is_exist(self.ad_info_path):
|
if self.util.is_exist(self.ad_info_path):
|
||||||
|
@ -31,11 +27,12 @@ class ExecuteCancelSSSDAdAuthentication:
|
||||||
else:
|
else:
|
||||||
self.logger.error("ad_info file not found")
|
self.logger.error("ad_info file not found")
|
||||||
|
|
||||||
if self.util.is_exist("/etc/sssd"):
|
# Leave old domain
|
||||||
# self.util.delete_folder("/etc/sssd")
|
(result_code, p_out, p_err) = self.util.execute("realm leave ")
|
||||||
self.logger.info("SSSD is deleted")
|
if (result_code == 0):
|
||||||
|
self.logger.info("Realm Leave komutu başarılı")
|
||||||
else:
|
else:
|
||||||
self.logger.info("SSSD is not exist")
|
self.logger.error("Realm Leave komutu başarısız : " + str(p_err))
|
||||||
|
|
||||||
# Re-Configure dhclient.conf deleting AD IP address
|
# Re-Configure dhclient.conf deleting AD IP address
|
||||||
dhclient_conf_path = "/etc/dhcp/dhclient.conf"
|
dhclient_conf_path = "/etc/dhcp/dhclient.conf"
|
||||||
|
@ -54,6 +51,7 @@ class ExecuteCancelSSSDAdAuthentication:
|
||||||
file_dhclient.write(file_data)
|
file_dhclient.write(file_data)
|
||||||
file_dhclient.close()
|
file_dhclient.close()
|
||||||
|
|
||||||
|
|
||||||
# Configure hosts for deleting AD "IP address" and "AD hostname"
|
# Configure hosts for deleting AD "IP address" and "AD hostname"
|
||||||
hosts_conf_path = "/etc/hosts"
|
hosts_conf_path = "/etc/hosts"
|
||||||
file_hosts = open(hosts_conf_path, 'r')
|
file_hosts = open(hosts_conf_path, 'r')
|
||||||
|
|
|
@ -13,6 +13,13 @@ class ExecuteSSSDAdAuthentication:
|
||||||
|
|
||||||
def authenticate(self, domain_name, host_name, ip_address, password, ad_username):
|
def authenticate(self, domain_name, host_name, ip_address, password, ad_username):
|
||||||
try:
|
try:
|
||||||
|
# Execute the commands that require for leave
|
||||||
|
(result_code, p_out, p_err) = self.util.execute("realm leave")
|
||||||
|
if (result_code == 0):
|
||||||
|
self.logger.info("Realm Leave komutu başarılı")
|
||||||
|
else:
|
||||||
|
self.logger.error("Realm Leave komutu başarısız : " + str(p_err))
|
||||||
|
|
||||||
# Create and Configure ad_info file
|
# Create and Configure ad_info file
|
||||||
(result_code, p_out, p_err) = self.util.execute("touch /etc/ahenk/ad_info")
|
(result_code, p_out, p_err) = self.util.execute("touch /etc/ahenk/ad_info")
|
||||||
if (result_code == 0):
|
if (result_code == 0):
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
#!/usr/bin/python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Author: Hasan Kara <h.kara27@gmail.com>
|
|
||||||
|
|
||||||
from base.scope import Scope
|
|
||||||
from base.util.util import Util
|
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
class ExecuteCancelSSSDAuthentication:
|
|
||||||
def __init__(self):
|
|
||||||
scope = Scope().get_instance()
|
|
||||||
self.logger = scope.get_logger()
|
|
||||||
self.util = Util()
|
|
||||||
|
|
||||||
def cancel(self):
|
|
||||||
self.util.execute("apt purge libpam-sss sssd-common -y")
|
|
||||||
self.util.execute("apt autoremove -y")
|
|
||||||
|
|
||||||
if self.util.is_exist("/etc/sssd"):
|
|
||||||
self.util.delete_folder("/etc/sssd")
|
|
||||||
|
|
||||||
# pattern for clearing file data from spaces, tabs and newlines
|
|
||||||
pattern = re.compile(r'\s+')
|
|
||||||
|
|
||||||
# Configure nsswitch.conf
|
|
||||||
file_ns_switch = open("/etc/nsswitch.conf", 'r')
|
|
||||||
file_data = file_ns_switch.read()
|
|
||||||
|
|
||||||
# cleared file data from spaces, tabs and newlines
|
|
||||||
text = pattern.sub('', file_data)
|
|
||||||
|
|
||||||
did_configuration_change = False
|
|
||||||
if "passwd:compatsss" in text:
|
|
||||||
file_data = file_data.replace("passwd: compat sss", "passwd: compat")
|
|
||||||
did_configuration_change = True
|
|
||||||
|
|
||||||
if "group:compatsss" in text:
|
|
||||||
file_data = file_data.replace("group: compat sss", "group: compat")
|
|
||||||
did_configuration_change = True
|
|
||||||
|
|
||||||
if "shadow:compatsss" in text:
|
|
||||||
file_data = file_data.replace("shadow: compat sss", "shadow: compat")
|
|
||||||
did_configuration_change = True
|
|
||||||
|
|
||||||
if "services:dbfilessss" in text:
|
|
||||||
file_data = file_data.replace("services: db files sss", "services: db files")
|
|
||||||
did_configuration_change = True
|
|
||||||
|
|
||||||
if "netgroup:nissss" in text:
|
|
||||||
file_data = file_data.replace("netgroup: nis sss", "netgroup: nis")
|
|
||||||
did_configuration_change = True
|
|
||||||
|
|
||||||
if "sudoers:filessss" in text:
|
|
||||||
file_data = file_data.replace("sudoers: files sss", "")
|
|
||||||
did_configuration_change = True
|
|
||||||
|
|
||||||
if did_configuration_change:
|
|
||||||
self.logger.info("nsswitch.conf configuration has been configured")
|
|
||||||
else:
|
|
||||||
self.logger.info("nsswitch.conf has already been configured")
|
|
||||||
|
|
||||||
file_ns_switch.close()
|
|
||||||
file_ns_switch = open("/etc/nsswitch.conf", 'w')
|
|
||||||
file_ns_switch.write(file_data)
|
|
||||||
file_ns_switch.close()
|
|
||||||
|
|
||||||
common_session_conf_path = "/etc/pam.d/common-session"
|
|
||||||
|
|
||||||
# configure common-session for creating home directories for ldap users
|
|
||||||
file_common_session = open(common_session_conf_path, 'r')
|
|
||||||
file_data = file_common_session.read()
|
|
||||||
|
|
||||||
if "session optional pam_mkhomedir.so skel=/etc/skel umask=077" in file_data:
|
|
||||||
file_data = file_data.replace("session optional pam_mkhomedir.so skel=/etc/skel umask=077", "")
|
|
||||||
self.logger.info("common-session is configured")
|
|
||||||
|
|
||||||
file_common_session.close()
|
|
||||||
file_common_session = open(common_session_conf_path, 'w')
|
|
||||||
file_common_session.write(file_data)
|
|
||||||
file_common_session.close()
|
|
||||||
|
|
||||||
# Configure lightdm.service
|
|
||||||
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)
|
|
||||||
self.util.execute("systemctl restart nscd.service")
|
|
||||||
|
|
||||||
self.logger.info("LDAP Login iptal etme işlemi başarı ile sağlandı.")
|
|
||||||
|
|
Loading…
Reference in a new issue