Thanks alot Roland

I now have a program which I believe should work; it obtains MIT kerberos keys 
straight from the database fine. I have quoted directly from your program (as 
below), but I'm unable to get a ticket as either "admin" (who is allowed to 
change the ka db or myself, ccprl (who isn't). I get an error as follows (the 
admin prinicple is currently hardcoded in).

ccprl@xdm039% ./decode_key
ka_ParseLoginName 0
name: admin
inst:
cell: pegasus.cranfield.ac.uk
password for admin:
ka_GetAdminToken 180490
./decode_key: request packet in error getting admin token
can't get admin token

The second last line is the message reported by com_err, but I'm not sure if 
I'm using it properly. I'm using the same password as for kas, which works 
fine...

ccprl@xdm039% kas -admin admin
Administrator's (admin) Password:
ka> exa ccprl

User data for ccprl
  key (0) cksum is 3811557988, last cpw: no date
  entry never expires.  Max ticket lifetime 25.00 hours.
  last mod on Fri Jul 15 12:42:02 1994 by admin
ka> ccprl@xdm039%

BTW, although my Kerberos server is *not* an AFS client, I want to put 
CellServDB and ThisCell in a dummy /usr/vice/etc and run this binary from 
there; I get the same error regardless of whether I run it on an AFS client or 
not. Will I run into any problems doing so?

Any thoughts? The code fragment I'm using for authentication follows...

Peter Lister                             Email: [EMAIL PROTECTED]
Computer Centre, Cranfield University    Voice: +44 234 754200 ext 2828
Cranfield, Bedfordshire MK43 0AL UK        Fax: +44 234 750875
-- Just call me Ramesses Niblick the Third Kerplunk Kerplunk Thribble --

  struct ktc_encryptionKey mykey ;
  struct ktc_token token ;
  char buffer [ MAXKTCNAMELEN * 3 + 40 ] ;
  char cell [ MAXKTCNAMELEN ] ;
  char * local_cell ;
  Principal me ;

  code = ka_Init ( 0 ) ;
  local_cell = ka_LocalCell ( ) ;

  code = ka_ParseLoginName ( "admin" , me . name, me . instance , cell ) ;

#ifdef DEBUG
  printf ( "ka_ParseLoginName %d\n" , code ) ;
#endif
  if ( code )
    crash_and_burn ( "can't parse admin name" ) ;
  if ( cell [0] == '\0' )
    strcpy ( cell , local_cell ) ;

#ifdef DEBUG
  printf ( "name: %s\ninst: %s\ncell: %s\n" , me . name, me . instance , cell 
) ;
#endif

  sprintf ( buffer , "password for %s: " , "admin" ) ;
  code = ka_ReadPassword ( buffer , 0 , cell , & mykey ) ;
  if ( code )
    crash_and_burn ( "can't read password" ) ;

  code = ka_GetAdminToken ( me . name , me . instance , cell , & mykey , 300 , 
& token , 1 ) ;
  memset ( ( char * ) & mykey , 0 , sizeof ( mykey ) ) ;
#ifdef DEBUG
  printf ( "ka_GetAdminToken %d\n" , code ) ;
#endif
  if ( code )
  {
    com_err ( argv [ 0 ] , code , "getting admin token" ) ;
    exit ( 1 ) ;
  }


Reply via email to