krb5_get_error_message() and krb5_free_error_message() functions

Muthuramalingam Narayanan muthuramalingam.narayanan at us.abb.com
Thu Jun 24 15:54:26 EDT 2010


Hi I am writing code to create the ticket, below is my code i am getting 
below error.

Can some give soluton for this problem.


Thu Jun 24 15:52:32 2010 : KERBEROS ::::: Error Function Create ticket 
Name -1765328378= :::::











    const char *inst = NULL;
    char *principal = NULL;

    krb5_error_code kerr = 0;
    krb5_context    ctx;
    krb5_principal  client;
    krb5_creds      creds;
    krb5_creds*     ccreds = NULL;
    krb5_ccache     cache;
    krb5_kdc_rep    *reply ;
    char *srealm = NULL;
    krb5_get_init_creds_opt *kopts;

    krb5_address **my_addresses;
    krb5_deltat life_secs;




    if(ccreds == NULL) {
        ccreds = (krb5_creds*) malloc (sizeof(krb5_creds));
    }

    memset (ccreds, 0, sizeof(krb5_creds));
    memset (&creds, 0, sizeof(krb5_creds));
    //strcpy(principal,"sadmin");
    principal="sadmin";



       LogSysInfo("krbRenew5", LERROR,  "Calll the Init context \n" );
       if((kerr = krb5_init_context(&ctx)) != 0) {
          LogSysInfo("krbRenew5", LERROR,  "Error while creating 
krb5_init_context. Error code = %d\n", kerr);
          return(kerr);
       }
       LogSysInfo("krbRenew5", LERROR,  " Success the Init context \n");

       /* Get an handle to the credentials cache... */
       if((kerr = krb5_cc_default(ctx, &cache)) != 0 ) {
          LogSysInfo( "krbRenew6", LERROR, "Error while calling 
krb5_cc_default. error code = %d\n", kerr);
          krb5_free_context(ctx);
          return(kerr);
       }
       LogSysInfo("krbRenew5", LERROR,  " Success the cache\n");


        kerr = krb5_parse_name(ctx, PRINC, &client);
        if (kerr !=0)
          {

          LogSysInfo("krbRenew5", LERROR,  " Failure the parse \n");

          }
          LogSysInfo("krbRenew5", LERROR,  " Success the parse\n");
/*

        kerr = krb5_get_init_creds_password( ctx, &creds, client, 
PASS,NULL,0,0,NULL,kopts);
        if (kerr !=0)
          {

          LogSysInfo("krbRenew5", LERROR,  " Failure the Init Creds PASS 
\n");

          }
          LogSysInfo("krbRenew5", LERROR,  " Success the Init Creds 
PASS\n");
*/
      char* name;
      krb5_unparse_name( ctx, client, &name);

      LogSysInfo("krbRenew11", LINFO, "KERBEROS ::::: Client Name = %s 
::::: \n", (char *)name);


        if ((kerr = krb5_get_default_realm(ctx, &realm)) != 0) {
           LogSysInfo ("krbRenew8", LERROR, "Error while calling 
krb5_get_default_realm. error code = %d\n", kerr);
           krb5_free_principal(ctx, client);
           krb5_cc_close(ctx, cache);
           krb5_free_context(ctx);
           return(kerr);
       }

       strcpy((char *)principalName, (char *)KRB5_TGS_NAME);
       strcat((char *)principalName, "/");
       strcat((char *)principalName, (char *)realm);



       //free(realm);

       if ((kerr = krb5_parse_name(ctx, (char *)principalName, 
&creds.server)) != 0) {
          LogSysInfo("krbRenew10", LERROR, "Error while calling 
krb5_parse_name. error code = %d\n", kerr);
          krb5_free_principal(ctx, client);
          krb5_cc_close(ctx, cache);
          krb5_free_context(ctx);
          return(kerr);
      }

      //char* name;
      //krb5_unparse_name( ctx, client, &name);

      LogSysInfo("krbRenew11", LINFO, "KERBEROS ::::: Client Name = %s 
::::: \n", (char *)name);

        if ((kerr = krb5_parse_name(ctx, name, &creds.client)) != 0) {
          LogSysInfo("krbRenew12", LERROR, "Error while calling 
krb5_parse_name. error code = %d\n", kerr);
          krb5_free_principal(ctx, client);
          krb5_cc_close(ctx, cache);
          krb5_free_context(ctx);
          return(kerr);
      }
       LogSysInfo("krbRenew9", LINFO, "KERBEROS ::::: Principal Name = %s 
::::: \n", (char *)principalName);

       LogSysInfo("krbRenew5", LERROR,  " Build  the Principal = \n");
       if (kerr = krb5_build_principal(ctx,&client,
                        strlen(realm),realm,realm, "krbtgt", (const char 
*) NULL
                                        )) {
           LogSysInfo ("krbRenew8", LERROR, "Error while calling 
krb5_get_default_realm. error code = %d\n", kerr);
        return 1;
           }

             LogSysInfo("krbRenew11", LINFO, "KERBEROS ::::: Function 
Create ticket  Name = ::::: \n");
            life_secs = 60 * 60;

            kerr = krb5_get_init_creds_opt_alloc(ctx, &kopts);
            if (kerr != 0)
            {

          if (kerr != 0)
            {
             LogSysInfo("krbRenew11", LINFO, "KERBEROS ::::: Error 
Function Create ticket  Name %d= ::::: \n",kerr);
             return(kerr);
            }
            krb5_get_init_creds_opt_set_tkt_life(kopts, life_secs);




            kerr = krb5_get_init_creds_password(ctx, &creds, client,
                                              PASS, NULL, NULL,
                                              0, NULL,
                                              kopts);
            if (kerr != 0)
            {
             LogSysInfo("krbRenew11", LINFO, "KERBEROS ::::: Error 
Function Create ticket  Name %d= ::::: \n",kerr);
             return(kerr);

            }

             //LogSysInfo("krbRenew11", LINFO, "KERBEROS ::::: Function 
Create ticket  Name = :::::%s \n",kopts);
             LogSysInfo("krbRenew11", LINFO, "KERBEROS ::::: Function 
Create ticket  Name = :::::\n");\










Thanks in Advance

Muthu N


More information about the krbdev mailing list