std::pair generate_krb_ticket_from_machine_keytab()

in auth/kerberos/src/krb.cpp [25:95]


std::pair<int, std::string> generate_krb_ticket_from_machine_keytab( std::string domain_name,
                                                                     CF_logger& cf_logger )
{
    std::pair<int, std::string> result;

    result = Util::is_hostname_cmd_present();
    if ( result.first != 0 )
    {
        cf_logger.logger( LOG_ERR, result.second.c_str() );
        return result;
    }

    result = Util::is_hostname_cmd_present();
    if ( result.first != 0 )
    {
        cf_logger.logger( LOG_ERR, result.second.c_str() );
        return result;
    }

    result = Util::is_realm_cmd_present();
    if ( result.first != 0 )
    {
        cf_logger.logger( LOG_ERR, result.second.c_str() );
        return result;
    }

    result = Util::is_kinit_cmd_present();
    if ( result.first != 0 )
    {
        cf_logger.logger( LOG_ERR, result.second.c_str() );
        return result;
    }

    result = Util::is_ldapsearch_cmd_present();
    if ( result.first != 0 )
    {
        cf_logger.logger( LOG_ERR, result.second.c_str() );
        return result;
    }

    result = Util::is_decode_exe_present();
    if ( result.first != 0 )
    {
        cf_logger.logger( LOG_ERR, result.second.c_str() );
        return result;
    }

    /**
     ** Machine principal is of the format 'EC2AMAZ-Q5VJZQ$'@CONTOSO.COM
     **/
    std::pair<int, std::string> machine_principal =
        Util::get_machine_principal( domain_name, cf_logger );
    if ( result.first != 0 )
    {
        std::cerr << "ERROR: " << __func__ << ":" << __LINE__ << " invalid machine principal"
                  << std::endl;
        std::string err_msg = "ERROR: invalid machine principal";
        cf_logger.logger( LOG_ERR, err_msg.c_str() );
        result = std::make_pair( -1, err_msg );
        return result;
    }

    result = Util::execute_kinit_in_domain_joined_case( machine_principal.second );
    if ( result.first != 0 )
    {
        cf_logger.logger( LOG_ERR, result.second.c_str() );
        return result;
    }

    return result;
}