def request_service_keytab(self): super(DsInstance, self).request_service_keytab() # Configure DS to use the keytab vardict = {"KRB5_KTNAME": self.keytab} ipautil.config_replace_variables(paths.SYSCONFIG_DIRSRV, replacevars=vardict)
def _request_service_keytab(self): super(DsInstance, self)._request_service_keytab() # Configure DS to use the keytab vardict = {"KRB5_KTNAME": self.keytab} ipautil.config_replace_variables(paths.SYSCONFIG_DIRSRV, replacevars=vardict)
def __create_ds_keytab(self): ldap_principal = "ldap/" + self.fqdn + "@" + self.realm installutils.kadmin_addprinc(ldap_principal) self.move_service(ldap_principal) self.fstore.backup_file(paths.DS_KEYTAB) installutils.create_keytab(paths.DS_KEYTAB, ldap_principal) vardict = {"KRB5_KTNAME": paths.DS_KEYTAB} ipautil.config_replace_variables(paths.SYSCONFIG_DIRSRV, replacevars=vardict) pent = pwd.getpwnam(constants.DS_USER) os.chown(paths.DS_KEYTAB, pent.pw_uid, pent.pw_gid)
def test_config_replace_variables(tempdir): conffile = os.path.join(tempdir, 'test.conf') conf = textwrap.dedent(""" replaced=foo removed=gone """) expected = textwrap.dedent(""" replaced=bar addreplaced=baz """) with open(conffile, 'w') as f: f.write(conf) result = ipautil.config_replace_variables(conffile, replacevars=dict( replaced="bar", addreplaced="baz"), removevars={'removed'}) assert result == {'removed': 'gone', 'replaced': 'foo'} with open(conffile, 'r') as f: newconf = f.read() assert newconf == expected