Пример #1
0
    def add_new_events(self, instance, subsystem):  # pylint: disable=W0613
        filename = os.path.join(subsystem.conf_dir, 'CS.cfg')
        self.backup(filename)

        properties = pki.PropertyFile(filename)
        properties.read()

        for prop_key in self.property_keys:
            prop_value = properties.get(prop_key)
            if prop_value is None:
                continue

            # comment value start with '## '
            if prop_value.startswith('## '):
                values = prop_value[3:]
            else:
                values = prop_value
            values = set(values.split(','))

            add_values = [
                event for event in self.events if event not in values
            ]
            if add_values:
                add_values.insert(0, '')  # trailing comma
                prop_value += ','.join(add_values)
                properties.set(prop_key, prop_value)

        properties.write()
Пример #2
0
    def upgrade_config(self, instance, subsystem):  # pylint: disable=W0613

        filename = os.path.join(subsystem.conf_dir, 'CS.cfg')
        server_xml = os.path.join(instance.conf_dir, 'server.xml')

        self.backup(filename)

        properties = pki.PropertyFile(filename)
        properties.read()

        # Get the unsecure phone home url out of the server.xml

        tps_unsecure_port = None
        hostname = socket.gethostname()

        document = etree.parse(server_xml, self.parser)
        server = document.getroot()
        connectors = server.findall('.//Connector')

        for connector in connectors:
            # find the Secure connector
            name = connector.get('name')
            if name != 'Unsecure':
                continue
            else:
                tps_unsecure_port = connector.get('port')

        # if the property exists, leave it alone', otherwise set
        # it to the value defined above
        # replace the standard non secure phone home url with value
        # from the server.xml file, which is known correct

        for k, v in proplist:

            cur = properties.get(k)

            if cur is not None:
                continue

            properties.set(k, v)

            if not k.endswith('.issuerinfo.value'):
                continue

            if tps_unsecure_port is None:
                continue

            properties.set(
                k, 'http://' + hostname + ':' + tps_unsecure_port +
                '/tps/phoneHome')

        properties.write()
Пример #3
0
    def upgrade_system(self):

        filename = os.path.join(pki.CONF_DIR, 'pki.conf')
        self.backup(filename)

        # read pki.conf
        conf = pki.PropertyFile(filename)
        conf.read()

        self.update_system_config(conf)

        # update pki.conf
        conf.write()
Пример #4
0
    def upgrade_system(self):

        # read pki.conf.default
        default_conf = pki.PropertyFile(
            os.path.join(pki.SHARE_DIR, 'etc', 'pki.conf'))
        default_conf.read()

        default_path = default_conf.get('JNI_JAR_DIR')

        filename = os.path.join(pki.CONF_DIR, 'pki.conf')
        self.backup(filename)

        # read pki.conf
        conf = pki.PropertyFile(filename)
        conf.read()

        # find JNI_JAR_DIR
        if conf.index('JNI_JAR_DIR') >= 0:
            # already exists
            conf.set('JNI_JAR_DIR', default_path)
            conf.write()
            return

        # find RESTEASY_LIB
        index = conf.index('RESTEASY_LIB')

        # insert JNI_JAR_DIR after RESTEASY_LIB
        index = index + 1
        conf.insert_line(index, '')

        index = index + 1
        conf.insert_line(index, '# JNI jar file location')

        index = index + 1
        conf.set('JNI_JAR_DIR', default_path, index=index)

        # update pki.conf
        conf.write()
Пример #5
0
    def __init__(self, name, filename, delimiter='=',
                 version_key='PKI_VERSION',
                 index_key='PKI_UPGRADE_INDEX'):

        self.name = name
        self.filename = filename

        self.version_key = version_key
        self.index_key = index_key

        # properties must be read and written immediately to avoid
        # interfering with scriptlets that update the same file

        self.properties = pki.PropertyFile(filename, delimiter)
    def add_plugin(self, instance, subsystem):  # pylint: disable=W0613
        filename = os.path.join(subsystem.conf_dir, 'CS.cfg')
        self.backup(filename)

        properties = pki.PropertyFile(filename)
        properties.read()

        properties.set(
            'auths.impl.SessionAuthentication.class',
            'com.netscape.cms.authentication.SessionAuthentication')
        properties.set('auths.instance.SessionAuthentication.pluginName',
                       'SessionAuthentication')

        properties.write()
Пример #7
0
    def upgrade_config(self, instance, subsystem):  # pylint: disable=W0613
        filename = os.path.join(subsystem.conf_dir, 'CS.cfg')
        self.backup(filename)

        properties = pki.PropertyFile(filename)
        properties.read()

        # if the property exists, leave it alone, otherwise set
        # it to the value defined above
        for k, v in proplist:
            cur = properties.get(k)
            if cur is None:
                properties.set(k, v)

        properties.write()
Пример #8
0
    def add_new_entries(self, instance, subsystem):  # pylint: disable=W0613
        filename = os.path.join(subsystem.conf_dir, 'registry.cfg')
        self.backup(filename)

        properties = pki.PropertyFile(filename)
        properties.read()

        # add constraint to constraint list
        constraints = properties.get('constraintPolicy.ids').split(',')
        if self.constraint_name in constraints:
            return  # update not required

        constraints.append(self.constraint_name)
        properties.set('constraintPolicy.ids', ','.join(constraints))

        for k, v in self.new_config.items():
            properties.set(k, v)

        properties.write()