コード例 #1
0
    def make_connection(self, host):
        host, self._extra_headers, x509 = self.get_host_info(host)
        # Python 2.7 changed the internal class used in xmlrpclib from
        # HTTP to HTTPConnection. We need to use the proper subclass

        # If we an existing connection exists using the same NSS database
        # there is no need to re-initialize. Pass thsi into the NSS
        # connection creator.
        dbdir = '/etc/pki/nssdb'
        no_init = self.__nss_initialized(dbdir)
        (major, minor, micro, releaselevel, serial) = sys.version_info
        if major == 2 and minor < 7:
            conn = NSSHTTPS(host,
                            443,
                            dbdir=dbdir,
                            no_init=no_init,
                            tls_version_min=api.env.tls_version_min,
                            tls_version_max=api.env.tls_version_max)
        else:
            conn = NSSConnection(host,
                                 443,
                                 dbdir=dbdir,
                                 no_init=no_init,
                                 tls_version_min=api.env.tls_version_min,
                                 tls_version_max=api.env.tls_version_max)
        self.dbdir = dbdir
        conn.connect()
        return conn
コード例 #2
0
ファイル: rpc.py プロジェクト: cajunken/freeipa
    def make_connection(self, host):
        host, self._extra_headers, x509 = self.get_host_info(host)
        # Python 2.7 changed the internal class used in xmlrpclib from
        # HTTP to HTTPConnection. We need to use the proper subclass

        # If we an existing connection exists using the same NSS database
        # there is no need to re-initialize. Pass thsi into the NSS
        # connection creator.
        if sys.version_info >= (2, 7):
            if self._connection and host == self._connection[0]:
                return self._connection[1]

        dbdir = '/etc/pki/nssdb'
        no_init = self.__nss_initialized(dbdir)
        if sys.version_info < (2, 7):
            conn = NSSHTTPS(host, 443, dbdir=dbdir, no_init=no_init)
        else:
            conn = NSSConnection(host, 443, dbdir=dbdir, no_init=no_init)
        self.dbdir=dbdir

        conn.connect()
        if sys.version_info < (2, 7):
            return conn
        else:
            self._connection = host, conn
            return self._connection[1]
コード例 #3
0
    def make_connection(self, host):
        host, self._extra_headers, x509 = self.get_host_info(host)
        # Python 2.7 changed the internal class used in xmlrpclib from
        # HTTP to HTTPConnection. We need to use the proper subclass

        if sys.version_info >= (2, 7):
            if self._connection and host == self._connection[0]:
                return self._connection[1]

        dbdir = getattr(context, 'nss_dir', paths.IPA_NSSDB_DIR)
        connection_dbdir = self.get_connection_dbdir()

        if connection_dbdir:
            # If an existing connection is already using the same NSS
            # database there is no need to re-initialize.
            no_init = dbdir == connection_dbdir

        else:
            # If the NSS database is already being used there is no
            # need to re-initialize.
            no_init = dbdir == ipapython.nsslib.current_dbdir

        if sys.version_info < (2, 7):
            conn = NSSHTTPS(host, 443, dbdir=dbdir, no_init=no_init)
        else:
            conn = NSSConnection(host,
                                 443,
                                 dbdir=dbdir,
                                 no_init=no_init,
                                 tls_version_min=api.env.tls_version_min,
                                 tls_version_max=api.env.tls_version_max)
        self.dbdir = dbdir

        conn.connect()
        if sys.version_info < (2, 7):
            return conn
        else:
            self._connection = host, conn
            return self._connection[1]
コード例 #4
0
ファイル: rpc.py プロジェクト: jtux270/translate
    def make_connection(self, host):
        host, self._extra_headers, x509 = self.get_host_info(host)
        # Python 2.7 changed the internal class used in xmlrpclib from
        # HTTP to HTTPConnection. We need to use the proper subclass

        # If we an existing connection exists using the same NSS database
        # there is no need to re-initialize. Pass thsi into the NSS
        # connection creator.
        dbdir = '/etc/pki/nssdb'
        no_init = self.__nss_initialized(dbdir)
        (major, minor, micro, releaselevel, serial) = sys.version_info
        if major == 2 and minor < 7:
            conn = NSSHTTPS(host, 443, dbdir=dbdir, no_init=no_init,
                            tls_version_min=api.env.tls_version_min,
                            tls_version_max=api.env.tls_version_max)
        else:
            conn = NSSConnection(host, 443, dbdir=dbdir, no_init=no_init,
                                 tls_version_min=api.env.tls_version_min,
                                 tls_version_max=api.env.tls_version_max)
        self.dbdir=dbdir
        conn.connect()
        return conn
コード例 #5
0
ファイル: rpc.py プロジェクト: AvidehST/freeipa
    def make_connection(self, host):
        host, self._extra_headers, x509 = self.get_host_info(host)
        # Python 2.7 changed the internal class used in xmlrpclib from
        # HTTP to HTTPConnection. We need to use the proper subclass

        if sys.version_info >= (2, 7):
            if self._connection and host == self._connection[0]:
                return self._connection[1]

        dbdir = getattr(context, 'nss_dir', paths.IPA_NSSDB_DIR)
        connection_dbdir = self.get_connection_dbdir()

        if connection_dbdir:
            # If an existing connection is already using the same NSS
            # database there is no need to re-initialize.
            no_init = dbdir == connection_dbdir

        else:
            # If the NSS database is already being used there is no
            # need to re-initialize.
            no_init = dbdir == ipapython.nsslib.current_dbdir

        if sys.version_info < (2, 7):
            conn = NSSHTTPS(host, 443, dbdir=dbdir, no_init=no_init)
        else:
            conn = NSSConnection(host, 443, dbdir=dbdir, no_init=no_init,
                                 tls_version_min=api.env.tls_version_min,
                                 tls_version_max=api.env.tls_version_max)
        self.dbdir=dbdir

        conn.connect()
        if sys.version_info < (2, 7):
            return conn
        else:
            self._connection = host, conn
            return self._connection[1]