mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 07:33:27 -06:00
ipautil: remove SHARE_DIR and PLUGIN_SHARE_DIR
SHARE_DIR and PLUGIN_SHARE_DIR depend on ipaplatform. Replace all uses of SHARE_DIR with paths.USR_SHARE_IPA_DIR and remove both SHARE_DIR and PLUGIN_SHARE_DIR. https://fedorahosted.org/freeipa/ticket/6474 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
parent
f919ab4ee0
commit
d6b755e3fc
@ -17,6 +17,7 @@ import shutil
|
||||
|
||||
from hashlib import sha1
|
||||
|
||||
from ipaplatform.paths import paths
|
||||
from ipapython import ipautil
|
||||
from ipapython.ipa_log_manager import root_logger, standard_logging_setup
|
||||
from ipaserver.install.dsinstance import schema_dirname
|
||||
@ -65,7 +66,7 @@ def add_ca_schema():
|
||||
pki_pent = pwd.getpwnam(PKI_USER)
|
||||
ds_pent = pwd.getpwnam(DS_USER)
|
||||
for schema_fname in SCHEMA_FILENAMES:
|
||||
source_fname = os.path.join(ipautil.SHARE_DIR, schema_fname)
|
||||
source_fname = os.path.join(paths.USR_SHARE_IPA_DIR, schema_fname)
|
||||
target_fname = os.path.join(schema_dirname(SERVERID), schema_fname)
|
||||
if not os.path.exists(source_fname):
|
||||
root_logger.debug('File does not exist: %s', source_fname)
|
||||
|
@ -234,7 +234,6 @@ class BasePathNamespace(object):
|
||||
HTML_KRBREALM_CON = "/usr/share/ipa/html/krbrealm.con"
|
||||
NIS_ULDIF = "/usr/share/ipa/nis.uldif"
|
||||
NIS_UPDATE_ULDIF = "/usr/share/ipa/nis-update.uldif"
|
||||
IPA_PLUGINS = "/usr/share/ipa/plugins"
|
||||
SCHEMA_COMPAT_ULDIF = "/usr/share/ipa/schema_compat.uldif"
|
||||
IPA_JS_PLUGINS_DIR = "/usr/share/ipa/ui/js/plugins"
|
||||
UPDATES_DIR = "/usr/share/ipa/updates/"
|
||||
|
@ -446,7 +446,7 @@ class RedHatTaskNamespace(BaseTaskNamespace):
|
||||
os.mkdir(paths.SYSTEMD_SYSTEM_HTTPD_D_DIR, 0o755)
|
||||
|
||||
ipautil.copy_template_file(
|
||||
os.path.join(ipautil.SHARE_DIR, 'ipa-httpd.conf.template'),
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, 'ipa-httpd.conf.template'),
|
||||
paths.SYSTEMD_SYSTEM_HTTPD_IPA_CONF,
|
||||
dict(
|
||||
KRB5CC_HTTPD=paths.KRB5CC_HTTPD,
|
||||
|
@ -54,9 +54,6 @@ from ipapython import config
|
||||
from ipaplatform.paths import paths
|
||||
from ipapython.dn import DN
|
||||
|
||||
SHARE_DIR = paths.USR_SHARE_IPA_DIR
|
||||
PLUGINS_SHARE_DIR = paths.IPA_PLUGINS
|
||||
|
||||
GEN_PWD_LEN = 22
|
||||
GEN_TMP_PWD_LEN = 12 # only for OTP password that is manually retyped by user
|
||||
|
||||
|
@ -20,8 +20,9 @@ import os
|
||||
|
||||
from ipalib import api
|
||||
from ipalib.plugable import Registry
|
||||
from ipaplatform.paths import paths
|
||||
from ipaserver.advise.base import Advice
|
||||
from ipapython.ipautil import template_file, SHARE_DIR
|
||||
from ipapython.ipautil import template_file
|
||||
|
||||
register = Registry()
|
||||
|
||||
@ -67,7 +68,7 @@ class config_base_legacy_client(Advice):
|
||||
def configure_and_start_sssd(self):
|
||||
uri, base = self.get_uri_and_base()
|
||||
template = os.path.join(
|
||||
SHARE_DIR,
|
||||
paths.USR_SHARE_IPA_DIR,
|
||||
'advise',
|
||||
'legacy',
|
||||
'sssd.conf.template'
|
||||
@ -132,7 +133,7 @@ class config_generic_linux_sssd_before_1_9(config_base_legacy_client):
|
||||
self.check_compat_plugin()
|
||||
|
||||
with open(os.path.join(
|
||||
SHARE_DIR,
|
||||
paths.USR_SHARE_IPA_DIR,
|
||||
'advise',
|
||||
'legacy',
|
||||
'pam.conf.sssd.template')) as fd:
|
||||
@ -222,7 +223,7 @@ class config_generic_linux_nss_pam_ldapd(config_base_legacy_client):
|
||||
self.check_compat_plugin()
|
||||
|
||||
with open(os.path.join(
|
||||
SHARE_DIR,
|
||||
paths.USR_SHARE_IPA_DIR,
|
||||
'advise',
|
||||
'legacy',
|
||||
'pam.conf.nss_pam_ldapd.template')) as fd:
|
||||
@ -289,7 +290,7 @@ class config_freebsd_nss_pam_ldapd(config_base_legacy_client):
|
||||
self.check_compat_plugin()
|
||||
|
||||
with open(os.path.join(
|
||||
SHARE_DIR,
|
||||
paths.USR_SHARE_IPA_DIR,
|
||||
'advise',
|
||||
'legacy',
|
||||
'pam_conf_sshd.template')) as fd:
|
||||
|
@ -804,7 +804,8 @@ class DomainValidator(object):
|
||||
|
||||
if not self._creds:
|
||||
self._parm = param.LoadParm()
|
||||
self._parm.load(os.path.join(ipautil.SHARE_DIR, "smb.conf.empty"))
|
||||
self._parm.load(
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "smb.conf.empty"))
|
||||
self._parm.set('netbios name', self.flatname)
|
||||
self._creds = credentials.Credentials()
|
||||
self._creds.set_kerberos_state(credentials.MUST_USE_KERBEROS)
|
||||
@ -868,7 +869,7 @@ class TrustDomainInstance(object):
|
||||
|
||||
def __init__(self, hostname, creds=None):
|
||||
self.parm = param.LoadParm()
|
||||
self.parm.load(os.path.join(ipautil.SHARE_DIR, "smb.conf.empty"))
|
||||
self.parm.load(os.path.join(paths.USR_SHARE_IPA_DIR, "smb.conf.empty"))
|
||||
if len(hostname) > 0:
|
||||
self.parm.set('netbios name', hostname)
|
||||
self.creds = creds
|
||||
|
@ -504,7 +504,7 @@ class ADTRUSTInstance(service.Service):
|
||||
self.print_msg(UPGRADE_ERROR % dict(dn=targets_dn))
|
||||
|
||||
def __write_smb_registry(self):
|
||||
template = os.path.join(ipautil.SHARE_DIR, "smb.conf.template")
|
||||
template = os.path.join(paths.USR_SHARE_IPA_DIR, "smb.conf.template")
|
||||
conf = ipautil.template_file(template, self.sub_dict)
|
||||
[tmp_fd, tmp_name] = tempfile.mkstemp()
|
||||
os.write(tmp_fd, conf)
|
||||
|
@ -913,7 +913,9 @@ class BindInstance(service.Service):
|
||||
if not self.fstore.has_file(NAMED_CONF):
|
||||
self.fstore.backup_file(NAMED_CONF)
|
||||
|
||||
named_txt = ipautil.template_file(ipautil.SHARE_DIR + "bind.named.conf.template", self.sub_dict)
|
||||
named_txt = ipautil.template_file(
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "bind.named.conf.template"),
|
||||
self.sub_dict)
|
||||
named_fd = open(NAMED_CONF, 'w')
|
||||
named_fd.seek(0)
|
||||
named_fd.truncate(0)
|
||||
|
@ -1324,7 +1324,7 @@ def replica_ca_install_check(config, promote):
|
||||
'on them: %s\n'
|
||||
'If you are certain that this is a false positive, use '
|
||||
'--skip-schema-check.',
|
||||
os.path.join(ipautil.SHARE_DIR, 'copy-schema-to-ca.py'))
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, 'copy-schema-to-ca.py'))
|
||||
exit('IPA schema missing on master CA directory server')
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@ class CustodiaInstance(SimpleServiceInstance):
|
||||
|
||||
def __config_file(self):
|
||||
template_file = os.path.basename(self.config_file) + '.template'
|
||||
template = os.path.join(ipautil.SHARE_DIR, template_file)
|
||||
template = os.path.join(paths.USR_SHARE_IPA_DIR, template_file)
|
||||
httpd_info = pwd.getpwnam(constants.HTTPD_USER)
|
||||
sub_dict = dict(IPA_CUSTODIA_CONF_DIR=paths.IPA_CUSTODIA_CONF_DIR,
|
||||
IPA_CUSTODIA_SOCKET=paths.IPA_CUSTODIA_SOCKET,
|
||||
|
@ -258,7 +258,8 @@ class DogtagInstance(service.Service):
|
||||
|
||||
def http_proxy(self):
|
||||
""" Update the http proxy file """
|
||||
template_filename = ipautil.SHARE_DIR + "ipa-pki-proxy.conf"
|
||||
template_filename = (
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "ipa-pki-proxy.conf"))
|
||||
sub_dict = dict(
|
||||
DOGTAG_PORT=8009,
|
||||
CLONE='' if self.clone else '#',
|
||||
|
@ -607,7 +607,9 @@ class DsInstance(service.Service):
|
||||
pent = pwd.getpwnam(DS_USER)
|
||||
for schema_fname in IPA_SCHEMA_FILES:
|
||||
target_fname = schema_dirname(self.serverid) + schema_fname
|
||||
shutil.copyfile(ipautil.SHARE_DIR + schema_fname, target_fname)
|
||||
shutil.copyfile(
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, schema_fname),
|
||||
target_fname)
|
||||
os.chmod(target_fname, 0o440) # read access for dirsrv user/group
|
||||
os.chown(target_fname, pent.pw_uid, pent.pw_gid)
|
||||
|
||||
@ -616,7 +618,9 @@ class DsInstance(service.Service):
|
||||
schema_dirname(self.serverid) + "05rfc2247.ldif.old")
|
||||
|
||||
target_fname = schema_dirname(self.serverid) + "05rfc2247.ldif"
|
||||
shutil.copyfile(ipautil.SHARE_DIR + "05rfc2247.ldif", target_fname)
|
||||
shutil.copyfile(
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "05rfc2247.ldif"),
|
||||
target_fname)
|
||||
os.chmod(target_fname, 0o440)
|
||||
os.chown(target_fname, pent.pw_uid, pent.pw_gid)
|
||||
except IOError:
|
||||
@ -919,8 +923,9 @@ class DsInstance(service.Service):
|
||||
self._ldap_mod("indices.ldif")
|
||||
|
||||
def __certmap_conf(self):
|
||||
shutil.copyfile(ipautil.SHARE_DIR + "certmap.conf.template",
|
||||
config_dirname(self.serverid) + "certmap.conf")
|
||||
shutil.copyfile(
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "certmap.conf.template"),
|
||||
os.path.join(config_dirname(self.serverid), "certmap.conf"))
|
||||
installutils.update_file(config_dirname(self.serverid) + "certmap.conf",
|
||||
'$SUBJECT_BASE', str(self.subject_base))
|
||||
sysupgrade.set_upgrade_state(
|
||||
|
@ -215,7 +215,8 @@ class HTTPInstance(service.Service):
|
||||
self.update_httpd_service_ipa_conf()
|
||||
|
||||
target_fname = paths.HTTPD_IPA_CONF
|
||||
http_txt = ipautil.template_file(ipautil.SHARE_DIR + "ipa.conf", self.sub_dict)
|
||||
http_txt = ipautil.template_file(
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "ipa.conf"), self.sub_dict)
|
||||
self.fstore.backup_file(paths.HTTPD_IPA_CONF)
|
||||
http_fd = open(target_fname, "w")
|
||||
http_fd.write(http_txt)
|
||||
@ -223,7 +224,9 @@ class HTTPInstance(service.Service):
|
||||
os.chmod(target_fname, 0o644)
|
||||
|
||||
target_fname = paths.HTTPD_IPA_REWRITE_CONF
|
||||
http_txt = ipautil.template_file(ipautil.SHARE_DIR + "ipa-rewrite.conf", self.sub_dict)
|
||||
http_txt = ipautil.template_file(
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "ipa-rewrite.conf"),
|
||||
self.sub_dict)
|
||||
self.fstore.backup_file(paths.HTTPD_IPA_REWRITE_CONF)
|
||||
http_fd = open(target_fname, "w")
|
||||
http_fd.write(http_txt)
|
||||
@ -457,7 +460,9 @@ class HTTPInstance(service.Service):
|
||||
target_fname = paths.HTTPD_IPA_KDCPROXY_CONF
|
||||
sub_dict = dict(KDCPROXY_CONFIG=paths.KDCPROXY_CONFIG)
|
||||
http_txt = ipautil.template_file(
|
||||
ipautil.SHARE_DIR + "ipa-kdc-proxy.conf.template", sub_dict)
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR,
|
||||
"ipa-kdc-proxy.conf.template"),
|
||||
sub_dict)
|
||||
self.fstore.backup_file(target_fname)
|
||||
with open(target_fname, 'w') as f:
|
||||
f.write(http_txt)
|
||||
|
@ -250,7 +250,8 @@ class KrbInstance(service.Service):
|
||||
self._ldap_mod("default-aci.ldif", self.sub_dict)
|
||||
|
||||
def __template_file(self, path, chmod=0o644):
|
||||
template = os.path.join(ipautil.SHARE_DIR, os.path.basename(path) + ".template")
|
||||
template = os.path.join(paths.USR_SHARE_IPA_DIR,
|
||||
os.path.basename(path) + ".template")
|
||||
conf = ipautil.template_file(template, self.sub_dict)
|
||||
self.fstore.backup_file(path)
|
||||
fd = open(path, "w+")
|
||||
|
@ -176,7 +176,8 @@ class OpenDNSSECInstance(service.Service):
|
||||
sub_conf_dict['PIN'] = pin
|
||||
|
||||
ods_conf_txt = ipautil.template_file(
|
||||
ipautil.SHARE_DIR + "opendnssec_conf.template", sub_conf_dict)
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "opendnssec_conf.template"),
|
||||
sub_conf_dict)
|
||||
ods_conf_fd = open(paths.OPENDNSSEC_CONF_FILE, 'w')
|
||||
ods_conf_fd.seek(0)
|
||||
ods_conf_fd.truncate(0)
|
||||
@ -184,7 +185,8 @@ class OpenDNSSECInstance(service.Service):
|
||||
ods_conf_fd.close()
|
||||
|
||||
ods_kasp_txt = ipautil.template_file(
|
||||
ipautil.SHARE_DIR + "opendnssec_kasp.template", self.kasp_file_dict)
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "opendnssec_kasp.template"),
|
||||
self.kasp_file_dict)
|
||||
ods_kasp_fd = open(paths.OPENDNSSEC_KASP_FILE, 'w')
|
||||
ods_kasp_fd.seek(0)
|
||||
ods_kasp_fd.truncate(0)
|
||||
|
@ -1547,12 +1547,15 @@ def upgrade_configuration():
|
||||
ds_dirname = dsinstance.config_dirname(ds_serverid)
|
||||
|
||||
upgrade_file(sub_dict, paths.HTTPD_IPA_CONF,
|
||||
ipautil.SHARE_DIR + "ipa.conf")
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "ipa.conf"))
|
||||
upgrade_file(sub_dict, paths.HTTPD_IPA_REWRITE_CONF,
|
||||
ipautil.SHARE_DIR + "ipa-rewrite.conf")
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "ipa-rewrite.conf"))
|
||||
if ca.is_configured():
|
||||
upgrade_file(sub_dict, paths.HTTPD_IPA_PKI_PROXY_CONF,
|
||||
ipautil.SHARE_DIR + "ipa-pki-proxy.conf", add=True)
|
||||
upgrade_file(
|
||||
sub_dict,
|
||||
paths.HTTPD_IPA_PKI_PROXY_CONF,
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "ipa-pki-proxy.conf"),
|
||||
add=True)
|
||||
else:
|
||||
if ipautil.file_exists(paths.HTTPD_IPA_PKI_PROXY_CONF):
|
||||
os.remove(paths.HTTPD_IPA_PKI_PROXY_CONF)
|
||||
@ -1560,7 +1563,7 @@ def upgrade_configuration():
|
||||
upgrade_file(
|
||||
sub_dict,
|
||||
os.path.join(ds_dirname, "certmap.conf"),
|
||||
os.path.join(ipautil.SHARE_DIR, "certmap.conf.template")
|
||||
os.path.join(paths.USR_SHARE_IPA_DIR, "certmap.conf.template")
|
||||
)
|
||||
upgrade_pki(ca, fstore)
|
||||
|
||||
@ -1770,7 +1773,7 @@ def upgrade_check(options):
|
||||
|
||||
def upgrade():
|
||||
realm = api.env.realm
|
||||
schema_files = [os.path.join(ipautil.SHARE_DIR, f) for f
|
||||
schema_files = [os.path.join(paths.USR_SHARE_IPA_DIR, f) for f
|
||||
in dsinstance.ALL_SCHEMA_FILES]
|
||||
|
||||
schema_files.extend(dsinstance.get_all_external_schema_files(
|
||||
|
@ -184,7 +184,7 @@ class Service(object):
|
||||
ldap_uri=None, dm_password=None):
|
||||
pw_name = None
|
||||
fd = None
|
||||
path = ipautil.SHARE_DIR + ldif
|
||||
path = os.path.join(paths.USR_SHARE_IPA_DIR, ldif)
|
||||
nologlist = []
|
||||
|
||||
if sub_dict is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user