home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / kerberosIV / krb / save_credentials.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-25  |  1.9 KB  |  57 lines

  1. /*
  2.  * $Source: /usr/src/kerberosIV/krb/RCS/save_credentials.c,v $
  3.  * $Author: kfall $
  4.  *
  5.  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
  6.  * of Technology.
  7.  *
  8.  * For copying and distribution information, please see the file
  9.  * <mit-copyright.h>.
  10.  */
  11.  
  12. #ifndef lint
  13. static char *rcsid_save_credentials_c =
  14. "$Header: /usr/src/kerberosIV/krb/RCS/save_credentials.c,v 4.10 90/06/25 20:57:18 kfall Exp $";
  15. #endif /* lint */
  16.  
  17. #include <mit-copyright.h>
  18. #include <stdio.h>
  19. #include <des.h>
  20. #include <krb.h>
  21.  
  22. /*
  23.  * This routine takes a ticket and associated info and calls
  24.  * tf_save_cred() to store them in the ticket cache.  The peer
  25.  * routine for extracting a ticket and associated info from the
  26.  * ticket cache is krb_get_cred().  When changes are made to
  27.  * this routine, the corresponding changes should be made
  28.  * in krb_get_cred() as well.
  29.  *
  30.  * Returns KSUCCESS if all goes well, otherwise an error returned
  31.  * by the tf_init() or tf_save_cred() routines.
  32.  */
  33.  
  34. save_credentials(service, instance, realm, session, lifetime, kvno,
  35.                  ticket, issue_date)
  36.     char *service;              /* Service name */
  37.     char *instance;             /* Instance */
  38.     char *realm;                /* Auth domain */
  39.     C_Block session;            /* Session key */
  40.     int lifetime;               /* Lifetime */
  41.     int kvno;                   /* Key version number */
  42.     KTEXT ticket;               /* The ticket itself */
  43.     long issue_date;            /* The issue time */
  44. {
  45.     int tf_status;   /* return values of the tf_util calls */
  46.  
  47.     /* Open and lock the ticket file for writing */
  48.     if ((tf_status = tf_init(TKT_FILE, W_TKT_FIL)) != KSUCCESS)
  49.     return(tf_status);
  50.  
  51.     /* Save credentials by appending to the ticket file */
  52.     tf_status = tf_save_cred(service, instance, realm, session,
  53.                  lifetime, kvno, ticket, issue_date);
  54.     (void) tf_close();
  55.     return (tf_status);
  56. }
  57.