Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion python3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ install:
$(IPROG) -d $(DESTDIR)/usr/lib/systemd/system
$(IPROG) -d $(DESTDIR)$(EXTENSIONDIR)


$(IDATA) packages/inventory.py $(DESTDIR)$(SITE3_DIR)/
$(IDATA) packages/observer.py $(DESTDIR)$(SITE3_DIR)/

Expand All @@ -39,6 +38,8 @@ install:
$(IPROG) plugins/install-supp-pack $(DESTDIR)$(PLUGINDIR)
$(IPROG) plugins/echo.py $(DESTDIR)$(PLUGINDIR)/echo
$(IPROG) plugins/openvswitch-config-update $(DESTDIR)$(PLUGINDIR)
$(IPROG) plugins/extauth-hook $(DESTDIR)$(PLUGINDIR)
$(IPROG) plugins/extauth-hook-AD.py $(DESTDIR)$(PLUGINDIR)

$(IPROG) perfmon/perfmon $(DESTDIR)$(PLUGINDIR)
$(IDATA) perfmon/perfmon.service $(DESTDIR)/usr/lib/systemd/system/perfmon.service
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
#
# extauth-hook-AD.py
#
# This plugin manages the following configuration files for external authentication
# - /etc/nsswitch.conf
# - /etc/pam.d/sshd
# - /etc/pam.d/hcp_users
# - /etc/ssh/ssh_config
#
# This module can be called directly as a plugin. It handles
# Active Directory being enabled or disabled as the hosts external_auth_type,
# or subjects being added or removed while AD is the external_auth_type,
Expand All @@ -21,12 +27,6 @@
import XenAPIPlugin


# this plugin manage following configuration files for external auth
# - /etc/nsswitch.conf
# - /etc/pam.d/sshd
# - /etc/pam.d/hcp_users
# - /etc/ssh/ssh_config

# pylint: disable=too-few-public-methods
# pytype: disable=ignored-abstractmethod

Expand All @@ -44,7 +44,7 @@ def setup_logger():
log = logging.getLogger()

if not os.path.exists(addr):
log.warning("{} not available, logs are not redirected".format(addr))
log.warning("%s not available, logs are not redirected", addr)
return

# Send to syslog local5, which will be redirected to xapi log /var/log/xensource.log
Expand Down Expand Up @@ -92,7 +92,7 @@ def __init__(self, path, session, args, ad_enabled=True, load_existing=True, fil
self._ad_enabled = ad_enabled
self._file_mode = file_mode
if load_existing and os.path.exists(self._file_path):
with open(self._file_path, 'r') as file:
with open(self._file_path, "r", encoding="utf-8") as file:
lines = file.readlines()
self._lines = [l.strip() for l in lines]

Expand Down Expand Up @@ -237,9 +237,8 @@ def _add_subject(self, subject_rec):
def _install(self):
if self._ad_enabled:
super(DynamicPam, self)._install()
else:
if os.path.exists(self._file_path):
os.remove(self._file_path)
elif os.path.exists(self._file_path):
os.remove(self._file_path)


class UsersList(DynamicPam):
Expand All @@ -261,7 +260,7 @@ def _add_upn(self, subject_rec):
if self._backend == ADBackend.BD_PBIS:
# PBIS convert domain to UPPER case, we revert it back
domain = domain.lower()
self._lines.append(u"{}{}{}".format(user, sep, domain))
self._lines.append("{}{}{}".format(user, sep, domain))
except KeyError:
logger.info("subject does not have upn %s", subject_rec)
except ValueError:
Expand Down Expand Up @@ -362,7 +361,7 @@ def _apply_value(self, key, value):
if self._is_special_line(key):
line = value
else: # normal line, construct the key value pair
sep = self._sep if self._sep else " "
sep = self._sep or " "
line = "{}{}{}".format(key, sep, value)
self._lines.append(line)

Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ install:
mkdir -p $(DESTDIR)$(EXTENSIONDIR)
$(IPROG) extensions/pool_update.precheck $(DESTDIR)$(EXTENSIONDIR)
mkdir -p $(DESTDIR)$(PLUGINDIR)
$(IPROG) plugins/extauth-hook $(DESTDIR)$(PLUGINDIR)
$(IPROG) plugins/extauth-hook-AD.py $(DESTDIR)$(PLUGINDIR)
$(IPROG) plugins/firewall-port $(DESTDIR)$(PLUGINDIR)
mkdir -p $(DESTDIR)$(HOOKSDIR)/host-post-declare-dead
$(IPROG) 10resetvdis $(DESTDIR)$(HOOKSDIR)/host-post-declare-dead
Expand Down