Imported Debian patch 4.7.2-3
This commit is contained in:
committed by
Mario Fetka
parent
27edeba051
commit
8bc559c5a1
@@ -33,24 +33,16 @@ class DebianPathNamespace(BasePathNamespace):
|
||||
OLD_IPA_KEYTAB = "/etc/apache2/ipa.keytab"
|
||||
HTTPD_PASSWORD_CONF = "/etc/apache2/password.conf"
|
||||
NAMED_CONF = "/etc/bind/named.conf"
|
||||
NAMED_CONF_BAK = "/etc/bind/named.conf.ipa-backup"
|
||||
NAMED_CUSTOM_CONF = "/etc/bind/ipa-ext.conf"
|
||||
NAMED_CUSTOM_OPTIONS_CONF = "/etc/bind/ipa-options-ext.conf"
|
||||
NAMED_VAR_DIR = "/var/cache/bind"
|
||||
NAMED_KEYTAB = "/etc/bind/named.keytab"
|
||||
NAMED_RFC1912_ZONES = "/etc/bind/named.conf.default-zones"
|
||||
NAMED_ROOT_KEY = "/etc/bind/bind.keys"
|
||||
NAMED_BINDKEYS_FILE = "/etc/bind/bind.keys"
|
||||
NAMED_MANAGED_KEYS_DIR = "/var/cache/bind/dynamic"
|
||||
CHRONY_CONF = "/etc/chrony/chrony.conf"
|
||||
OPENLDAP_LDAP_CONF = "/etc/ldap/ldap.conf"
|
||||
ETC_DEBIAN_VERSION = "/etc/debian_version"
|
||||
# Old versions of freeipa wrote all trusted certificates to a single
|
||||
# file, which is not supported by ca-certificates.
|
||||
CA_CERTIFICATES_BUNDLE_PEM = "/usr/local/share/ca-certificates/ipa-ca.crt"
|
||||
CA_CERTIFICATES_DIR = "/usr/local/share/ca-certificates/ipa-ca"
|
||||
# Debian's p11-kit does not use ipa.p11-kit, so the file is provided
|
||||
# for information only.
|
||||
IPA_P11_KIT = "/usr/local/share/ca-certificates/ipa.p11-kit"
|
||||
IPA_P11_KIT = "/usr/local/share/ca-certificates/ipa-ca.crt"
|
||||
ETC_SYSCONFIG_DIR = "/etc/default"
|
||||
SYSCONFIG_AUTOFS = "/etc/default/autofs"
|
||||
SYSCONFIG_DIRSRV = "/etc/default/dirsrv"
|
||||
@@ -66,15 +58,14 @@ class DebianPathNamespace(BasePathNamespace):
|
||||
SYSCONFIG_PKI = "/etc/dogtag/"
|
||||
SYSCONFIG_PKI_TOMCAT = "/etc/default/pki-tomcat"
|
||||
SYSCONFIG_PKI_TOMCAT_PKI_TOMCAT_DIR = "/etc/dogtag/tomcat/pki-tomcat"
|
||||
BIN_TOMCAT = "/usr/share/tomcat9/bin/version.sh"
|
||||
SYSTEMD_SYSTEM_HTTPD_D_DIR = "/etc/systemd/system/apache2.service.d/"
|
||||
SYSTEMD_SYSTEM_HTTPD_IPA_CONF = "/etc/systemd/system/apache2.service.d/ipa.conf"
|
||||
DNSSEC_TRUSTED_KEY = "/etc/bind/trusted-key.key"
|
||||
GSSAPI_SESSION_KEY = "/etc/apache2/ipasession.key"
|
||||
OLD_KRA_AGENT_PEM = "/etc/apache2/nssdb/kra-agent.pem"
|
||||
KEYCTL = "/bin/keyctl"
|
||||
SBIN_SERVICE = "/usr/sbin/service"
|
||||
CERTMONGER_COMMAND_TEMPLATE = "/usr/lib/ipa/certmonger/%s"
|
||||
ODS_KSMUTIL = None
|
||||
UPDATE_CA_TRUST = "/usr/sbin/update-ca-certificates"
|
||||
BIND_LDAP_DNS_IPA_WORKDIR = "/var/cache/bind/dyndb-ldap/ipa/"
|
||||
BIND_LDAP_DNS_ZONE_WORKDIR = "/var/cache/bind/dyndb-ldap/ipa/master/"
|
||||
@@ -82,32 +73,28 @@ class DebianPathNamespace(BasePathNamespace):
|
||||
LIBSOFTHSM2_SO = "/usr/lib/softhsm/libsofthsm2.so"
|
||||
PAM_KRB5_SO = "/usr/lib/{0}/security/pam_krb5.so".format(MULTIARCH)
|
||||
LIB_SYSTEMD_SYSTEMD_DIR = "/lib/systemd/system/"
|
||||
LIBEXEC_CERTMONGER_DIR = "/usr/lib/certmonger"
|
||||
DOGTAG_IPA_CA_RENEW_AGENT_SUBMIT = "/usr/lib/certmonger/dogtag-ipa-ca-renew-agent-submit"
|
||||
DOGTAG_IPA_RENEW_AGENT_SUBMIT = "/usr/lib/certmonger/dogtag-ipa-renew-agent-submit"
|
||||
CERTMONGER_DOGTAG_SUBMIT = "/usr/lib/certmonger/dogtag-submit"
|
||||
IPA_SERVER_GUARD = "/usr/lib/certmonger/ipa-server-guard"
|
||||
GENERATE_RNDC_KEY = "/bin/true"
|
||||
LIBEXEC_IPA_DIR = "/usr/lib/ipa"
|
||||
IPA_DNSKEYSYNCD_REPLICA = "/usr/lib/ipa/ipa-dnskeysync-replica"
|
||||
IPA_DNSKEYSYNCD = "/usr/lib/ipa/ipa-dnskeysyncd"
|
||||
IPA_HTTPD_KDCPROXY = "/usr/lib/ipa/ipa-httpd-kdcproxy"
|
||||
IPA_ODS_EXPORTER = "/usr/lib/ipa/ipa-ods-exporter"
|
||||
IPA_PKI_RETRIEVE_KEY = "/usr/lib/ipa/ipa-pki-retrieve-key"
|
||||
IPA_HTTPD_PASSWD_READER = "/usr/lib/ipa/ipa-httpd-pwdreader"
|
||||
IPA_PKI_WAIT_RUNNING = "/usr/lib/ipa/ipa-pki-wait-running"
|
||||
HTTPD = "/usr/sbin/apache2ctl"
|
||||
REMOVE_DS_PL = "/usr/sbin/remove-ds"
|
||||
SETUP_DS_PL = "/usr/sbin/setup-ds"
|
||||
FONTS_DIR = "/usr/share/fonts/truetype"
|
||||
FONTS_OPENSANS_DIR = "/usr/share/fonts/truetype/open-sans"
|
||||
FONTS_FONTAWESOME_DIR = "/usr/share/fonts/truetype/font-awesome"
|
||||
VAR_KERBEROS_KRB5KDC_DIR = "/var/lib/krb5kdc/"
|
||||
VAR_KRB5KDC_K5_REALM = "/var/lib/krb5kdc/.k5."
|
||||
CACERT_PEM = "/var/lib/ipa/certs/cacert.pem"
|
||||
CACERT_PEM = "/var/lib/krb5kdc/cacert.pem"
|
||||
KRB5KDC_KADM5_ACL = "/etc/krb5kdc/kadm5.acl"
|
||||
KRB5KDC_KADM5_KEYTAB = "/etc/krb5kdc/kadm5.keytab"
|
||||
KRB5KDC_KDC_CONF = "/etc/krb5kdc/kdc.conf"
|
||||
KDC_CERT = "/var/lib/ipa/certs/kdc.crt"
|
||||
KDC_KEY = "/var/lib/ipa/certs/kdc.key"
|
||||
KDC_CERT = "/var/lib/krb5kdc/kdc.crt"
|
||||
KDC_KEY = "/var/lib/krb5kdc/kdc.key"
|
||||
VAR_LOG_HTTPD_DIR = "/var/log/apache2"
|
||||
VAR_LOG_HTTPD_ERROR = "/var/log/apache2/error.log"
|
||||
NAMED_RUN = "/var/cache/bind/named.run"
|
||||
@@ -116,7 +103,6 @@ class DebianPathNamespace(BasePathNamespace):
|
||||
IPA_ODS_EXPORTER_CCACHE = "/var/lib/opendnssec/tmp/ipa-ods-exporter.ccache"
|
||||
IPA_CUSTODIA_SOCKET = "/run/apache2/ipa-custodia.sock"
|
||||
IPA_CUSTODIA_AUDIT_LOG = '/var/log/ipa-custodia.audit.log'
|
||||
IPA_CUSTODIA_HANDLER = "/usr/lib/ipa/custodia"
|
||||
WSGI_PREFIX_DIR = "/run/apache2/wsgi"
|
||||
|
||||
paths = DebianPathNamespace()
|
||||
|
||||
@@ -153,8 +153,6 @@ def debian_service_class_factory(name, api=None):
|
||||
return DebianNoService(name, api)
|
||||
if name == 'ipa':
|
||||
return redhat_services.RedHatIPAService(name, api)
|
||||
if name in ('pki-tomcatd', 'pki_tomcatd'):
|
||||
return redhat_services.RedHatCAService(name, api)
|
||||
if name == 'ntpd':
|
||||
return DebianSysvService("ntp", api)
|
||||
return DebianService(name, api)
|
||||
|
||||
@@ -8,21 +8,10 @@ This module contains default Debian-specific implementations of system tasks.
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from ipaplatform.base.tasks import BaseTaskNamespace
|
||||
from ipaplatform.redhat.tasks import RedHatTaskNamespace
|
||||
from ipaplatform.paths import paths
|
||||
|
||||
from ipapython import directivesetter
|
||||
from ipapython import ipautil
|
||||
from ipapython.dn import DN
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DebianTaskNamespace(RedHatTaskNamespace):
|
||||
@staticmethod
|
||||
@@ -68,146 +57,17 @@ class DebianTaskNamespace(RedHatTaskNamespace):
|
||||
# Debian doesn't use authconfig, nothing to restore
|
||||
return True
|
||||
|
||||
def migrate_auth_configuration(self, statestore):
|
||||
# Debian doesn't have authselect
|
||||
return True
|
||||
@staticmethod
|
||||
def parse_ipa_version(version):
|
||||
return BaseTaskNamespace.parse_ipa_version(version)
|
||||
|
||||
def configure_httpd_wsgi_conf(self):
|
||||
# Debian doesn't require special mod_wsgi configuration
|
||||
pass
|
||||
|
||||
def configure_httpd_protocol(self):
|
||||
# TLS 1.3 is not yet supported
|
||||
directivesetter.set_directive(paths.HTTPD_SSL_CONF,
|
||||
'SSLProtocol',
|
||||
'TLSv1.2', False)
|
||||
|
||||
def setup_httpd_logging(self):
|
||||
# Debian handles httpd logging differently
|
||||
pass
|
||||
|
||||
def configure_pkcs11_modules(self, fstore):
|
||||
# Debian doesn't use p11-kit
|
||||
pass
|
||||
|
||||
def restore_pkcs11_modules(self, fstore):
|
||||
pass
|
||||
|
||||
def platform_insert_ca_certs(self, ca_certs):
|
||||
# ca-certificates does not use this file, so it doesn't matter if we
|
||||
# fail to create it.
|
||||
try:
|
||||
self.write_p11kit_certs(paths.IPA_P11_KIT, ca_certs),
|
||||
except Exception:
|
||||
logger.exception("""\
|
||||
Could not create p11-kit anchor trust file. On Debian this file is not
|
||||
used by ca-certificates and is provided for information only.\
|
||||
""")
|
||||
|
||||
return any([
|
||||
self.write_ca_certificates_dir(
|
||||
paths.CA_CERTIFICATES_DIR, ca_certs
|
||||
),
|
||||
self.remove_ca_certificates_bundle(
|
||||
paths.CA_CERTIFICATES_BUNDLE_PEM
|
||||
),
|
||||
])
|
||||
|
||||
def write_ca_certificates_dir(self, directory, ca_certs):
|
||||
# pylint: disable=ipa-forbidden-import
|
||||
from ipalib import x509 # FixMe: break import cycle
|
||||
# pylint: enable=ipa-forbidden-import
|
||||
|
||||
path = Path(directory)
|
||||
try:
|
||||
path.mkdir(mode=0o755, exist_ok=True)
|
||||
except Exception:
|
||||
logger.error("Could not create %s", path)
|
||||
raise
|
||||
|
||||
for cert, nickname, trusted, _ext_key_usage in ca_certs:
|
||||
if not trusted:
|
||||
continue
|
||||
|
||||
# I'm not handling errors here because they have already
|
||||
# been checked by the time we get here
|
||||
subject = DN(cert.subject)
|
||||
issuer = DN(cert.issuer)
|
||||
|
||||
# Construct the certificate filename using the Subject DN so that
|
||||
# the user can see which CA a particular file is for, and include
|
||||
# the serial number to disambiguate clashes where a subordinate CA
|
||||
# had a new certificate issued.
|
||||
#
|
||||
# Strictly speaking, certificates are uniquely idenified by (Issuer
|
||||
# DN, Serial Number). Do we care about the possibility of a clash
|
||||
# where a subordinate CA had two certificates issued by different
|
||||
# CAs who used the same serial number?)
|
||||
filename = f'{subject.ldap_text()} {cert.serial_number}.crt'
|
||||
|
||||
# pylint: disable=old-division
|
||||
cert_path = path / filename
|
||||
# pylint: enable=old-division
|
||||
try:
|
||||
f = open(cert_path, 'w')
|
||||
except Exception:
|
||||
logger.error("Could not create %s", cert_path)
|
||||
raise
|
||||
|
||||
with f:
|
||||
try:
|
||||
os.fchmod(f.fileno(), 0o644)
|
||||
except Exception:
|
||||
logger.error("Could not set mode of %s", cert_path)
|
||||
raise
|
||||
|
||||
try:
|
||||
f.write(f"""\
|
||||
This file was created by IPA. Do not edit.
|
||||
|
||||
Description: {nickname}
|
||||
Subject: {subject.ldap_text()}
|
||||
Issuer: {issuer.ldap_text()}
|
||||
Serial Number (dec): {cert.serial_number}
|
||||
Serial Number (hex): {cert.serial_number:#x}
|
||||
|
||||
""")
|
||||
pem = cert.public_bytes(x509.Encoding.PEM).decode('ascii')
|
||||
f.write(pem)
|
||||
except Exception:
|
||||
logger.error("Could not write to %s", cert_path)
|
||||
raise
|
||||
|
||||
return True
|
||||
|
||||
def platform_remove_ca_certs(self):
|
||||
return any([
|
||||
self.remove_ca_certificates_dir(paths.CA_CERTIFICATES_DIR),
|
||||
self.remove_ca_certificates_bundle(paths.IPA_P11_KIT),
|
||||
self.remove_ca_certificates_bundle(
|
||||
paths.CA_CERTIFICATES_BUNDLE_PEM
|
||||
),
|
||||
])
|
||||
|
||||
def remove_ca_certificates_dir(self, directory):
|
||||
path = Path(paths.CA_CERTIFICATES_DIR)
|
||||
if not path.exists():
|
||||
return False
|
||||
|
||||
try:
|
||||
shutil.rmtree(path)
|
||||
except Exception:
|
||||
logger.error("Could not remove %s", path)
|
||||
raise
|
||||
|
||||
return True
|
||||
|
||||
# Debian doesn't use authselect, so call enable/disable_ldap_automount
|
||||
# from BaseTaskNamespace.
|
||||
def enable_ldap_automount(self, statestore):
|
||||
return BaseTaskNamespace.enable_ldap_automount(self, statestore)
|
||||
|
||||
def disable_ldap_automount(self, statestore):
|
||||
return BaseTaskNamespace.disable_ldap_automount(self, statestore)
|
||||
|
||||
tasks = DebianTaskNamespace()
|
||||
|
||||
Reference in New Issue
Block a user