Пример #1
0
    def __init__(self, verbose=False):
        self.curl = which('curl')
        if self.curl is None:
            LOG.exception("curl is required, please install and rerun")
            sys.exit(1)

        # We will change to handle certs later
        self.basecmd = self.curl + ' -k'
        LOG.info("Checking security status")
        self.security_enabled = check_security()
        self.verbose = verbose

        if self.security_enabled:
            self.basecmd = self.basecmd + ' --negotiate -u :'

        if self.verbose:
            self.basecmd = self.basecmd + ' -v'
        else:
            self.basecmd = self.basecmd + ' -s'
Пример #2
0
def check_security():
    from hadoop import conf
    hdfs_config = conf.HDFS_CLUSTERS['default']
    security_enabled = False
    if hdfs_config.SECURITY_ENABLED.get():
        KLIST = which('klist')
        if KLIST is None:
            logging.exception("klist is required, please install and rerun")
            sys.exit(1)
        klist_cmd = '%s | grep "Default principal"' % KLIST
        klist_check = subprocess.Popen(klist_cmd,
                                       shell=True,
                                       stdout=subprocess.PIPE)
        klist_princ = klist_check.communicate()[0].split(': ')[1]
        if not 'hue/' in klist_princ:
            logging.exception("klist failed, please contact support: %s" %
                              klist_princ)
            sys.exit(1)
        logging.info("Security enabled using principal: %s" % klist_princ)
        logging.info("You can imitate by running following export:")
        logging.info("OSRUN: export KRB5CCNAME=%s" % os.environ['KRB5CCNAME'])
        security_enabled = True

    return security_enabled