mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-24 16:10:02 -06:00
install: Move private_ccache from ipaserver to ipapython
https://fedorahosted.org/freeipa/ticket/4468 Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
parent
4c70590c2a
commit
08229a0c54
@ -25,8 +25,7 @@ from ipapython import ipautil
|
||||
|
||||
from ipaserver.install import installutils
|
||||
from ipaserver.install import certs
|
||||
from ipaserver.install.installutils import (private_ccache,
|
||||
create_replica_config)
|
||||
from ipaserver.install.installutils import create_replica_config
|
||||
from ipaserver.install import dsinstance, ca
|
||||
from ipapython import version
|
||||
from ipalib import api
|
||||
@ -209,7 +208,7 @@ Run /usr/sbin/ipa-server-install --uninstall to clean up.
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
with private_ccache():
|
||||
with ipautil.private_ccache():
|
||||
installutils.run_script(main, log_file_name=log_file_name,
|
||||
operation_name='ipa-ca-install',
|
||||
fail_message=fail_message)
|
||||
|
@ -38,6 +38,7 @@ import krbV
|
||||
import pwd
|
||||
from dns import resolver, rdatatype
|
||||
from dns.exception import DNSException
|
||||
from contextlib import contextmanager
|
||||
|
||||
from ipapython.ipa_log_manager import *
|
||||
from ipapython import ipavalidate
|
||||
@ -1300,3 +1301,26 @@ def restore_hostname(statestore):
|
||||
run([paths.BIN_HOSTNAME, old_hostname])
|
||||
except CalledProcessError, e:
|
||||
print >>sys.stderr, "Failed to set this machine hostname back to %s: %s" % (old_hostname, str(e))
|
||||
|
||||
|
||||
@contextmanager
|
||||
def private_ccache(path=None):
|
||||
|
||||
if path is None:
|
||||
(desc, path) = tempfile.mkstemp(prefix='krbcc')
|
||||
os.close(desc)
|
||||
|
||||
original_value = os.environ.get('KRB5CCNAME', None)
|
||||
|
||||
os.environ['KRB5CCNAME'] = path
|
||||
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if original_value is not None:
|
||||
os.environ['KRB5CCNAME'] = original_value
|
||||
else:
|
||||
os.environ.pop('KRB5CCNAME')
|
||||
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
|
@ -590,7 +590,7 @@ class DomainValidator(object):
|
||||
(ccache_name, principal) = self.kinit_as_http(info['dns_domain'])
|
||||
|
||||
if ccache_name:
|
||||
with installutils.private_ccache(path=ccache_name):
|
||||
with ipautil.private_ccache(path=ccache_name):
|
||||
entries = None
|
||||
|
||||
try:
|
||||
@ -1093,7 +1093,7 @@ def fetch_domains(api, mydomain, trustdomain, creds=None):
|
||||
td.creds = credentials.Credentials()
|
||||
td.creds.set_kerberos_state(credentials.MUST_USE_KERBEROS)
|
||||
if ccache_name:
|
||||
with installutils.private_ccache(path=ccache_name):
|
||||
with ipautil.private_ccache(path=ccache_name):
|
||||
td.creds.guess(td.parm)
|
||||
td.creds.set_workstation(domain_validator.flatname)
|
||||
domains = communicate(td)
|
||||
|
@ -915,28 +915,6 @@ def load_pkcs12(cert_files, key_password, key_nickname, ca_cert_files,
|
||||
|
||||
return out_file, out_password, ca_cert
|
||||
|
||||
@contextmanager
|
||||
def private_ccache(path=None):
|
||||
|
||||
if path is None:
|
||||
(desc, path) = tempfile.mkstemp(prefix='krbcc')
|
||||
os.close(desc)
|
||||
|
||||
original_value = os.environ.get('KRB5CCNAME', None)
|
||||
|
||||
os.environ['KRB5CCNAME'] = path
|
||||
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if original_value is not None:
|
||||
os.environ['KRB5CCNAME'] = original_value
|
||||
else:
|
||||
os.environ.pop('KRB5CCNAME')
|
||||
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
|
||||
|
||||
@contextmanager
|
||||
def stopped_service(service, instance_name=""):
|
||||
|
@ -28,8 +28,7 @@ from ipaserver.install import (
|
||||
otpdinstance, replication, service, sysupgrade)
|
||||
from ipaserver.install.installutils import (
|
||||
IPA_MODULES, BadHostError, get_fqdn, get_server_ip_address,
|
||||
is_ipa_configured, load_pkcs12, private_ccache,
|
||||
read_password, verify_fqdn)
|
||||
is_ipa_configured, load_pkcs12, read_password, verify_fqdn)
|
||||
from ipaserver.plugins.ldap2 import ldap2
|
||||
try:
|
||||
from ipaserver.install import adtrustinstance
|
||||
|
Loading…
Reference in New Issue
Block a user