home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / protocol / kerberos / 600 < prev    next >
Encoding:
Text File  |  1992-08-19  |  3.1 KB  |  118 lines

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!mips!sdd.hp.com!zaphod.mps.ohio-state.edu!uwm.edu!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!jj1h+
  2. From: Joseph_Jackson@transarc.com
  3. Newsgroups: comp.protocols.kerberos
  4. Subject: Re: AFS calls from C code
  5. Message-ID: <IeYahfn0Bwwc06B6J7@transarc.com>
  6. Date: 19 Aug 92 07:40:27 GMT
  7. Article-I.D.: transarc.IeYahfn0Bwwc06B6J7
  8. References: <9208190055.AA38026@cs90code.csv-tgsc.amex-trs.com>
  9. Organization: Carnegie Mellon, Pittsburgh, PA
  10. Lines: 105
  11. In-Reply-To: <9208190055.AA38026@cs90code.csv-tgsc.amex-trs.com>
  12.  
  13. Perhaps the program below is what you're looking for?  It will
  14. implement something similar to the "pagsh" and "klog" combination.
  15. I'll include the Makefile followed by the single source file.
  16.  
  17. If you have additional questions, you might consider talking to your
  18. local AFS Site Contacts.  They have direct access to Transarc's
  19. AFS Product Support group and can submit questions on your behalf.
  20.  
  21. Joe Jackson,
  22. AFS Product Support,
  23. Transarc Corp.
  24.  
  25. _______________________________________________________________
  26. Makefile:
  27.  
  28. PROGRAMS=afs-auth
  29.  
  30. # AFSDIR = /afs/transarc.com/product/afs/3.1b/@sys
  31. AFSDIR = /usr/afsws
  32. AFSLIBDIR = $(AFSDIR)/lib
  33. AFSLIBS = -L$(AFSLIBDIR) -L$(AFSLIBDIR)/afs  -lkauth -lprot -lubik \
  34.         -lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err \
  35.         $(AFSLIBDIR)/afs/util.a
  36. INCLUDES = -I$(AFSDIR)/include
  37.  
  38. LDFLAGS = $(AFSLIBS)
  39. CFLAGS = $(INCLUDES) -g -D_NO_PROTO
  40.  
  41. all: $(PROGRAMS)
  42.  
  43. .c: ; $(CC) $(CFLAGS) $@.c $(LDFLAGS) -o $@
  44.  
  45.  
  46. _______________________________________________________
  47. afs-auth.c:
  48.  
  49. #include <afs/kautils.h>
  50.   
  51.   struct greet_info {
  52.     char          *name;        /* user name */
  53.     char          *password;     /* user password */
  54.     char          *string;       /* random string */
  55.   };
  56.  
  57. int try_to_login();
  58.  
  59. main(argc, argv)
  60.      int argc;
  61.      char **argv;
  62. {
  63.   int code;
  64.   struct greet_info test_greet;
  65.   static char name[128], password[128];
  66.   
  67.   memset(name,NULL,sizeof(name));
  68.   memset(password,NULL,sizeof(password));
  69.   
  70.   printf("Enter AFS User Name: ");
  71.   if( !gets(name) ){
  72.     printf("Unable to grab name from stdin\n");
  73.     perror("Error message returned");
  74.     exit(1);
  75.   }
  76.   printf("Enter Password: ");
  77.   if ( !gets(password) ){
  78.     printf("Unable to grab password from stdin\n");
  79.     perror("Error message returned");
  80.     exit(1);
  81.   }
  82.   
  83.   test_greet.name = name;
  84.   test_greet.password = password;
  85.   
  86.   code = try_to_login(&test_greet);
  87.   
  88.   system ("/usr/ucb/groups;/usr/afsws/bin/tokens");
  89.  
  90.   return code;
  91. }
  92.  
  93. int try_to_login (test_g)
  94.      struct greet_info *test_g;
  95. {
  96.   
  97.   int code;
  98.   char *reason;
  99.   
  100.   printf("\nName: %s\nPassword: %s\n", test_g->name, test_g->password);
  101.   
  102.   code = ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION+KA_USERAUTH_DOSETPAG,
  103.                     test_g->name,
  104.                     (char *) 0,  /* instance */
  105.                     (char *) 0,  /* realm */
  106.                     test_g->password,
  107.                     0,           /* lifetime, default */
  108.                     0, 0,        /* spares */
  109.                     &reason);
  110.   
  111.   if (code != 0)
  112.     printf("AFS Verify failed because %s\n", reason);
  113.   else
  114.     printf("Verify succeeded\n");
  115.   
  116.   return code;
  117. }
  118.