[2105] in Kerberos

home help back first fref pref prev next nref lref last post

Re: AFS calls from C code

daemon@ATHENA.MIT.EDU (Joseph_Jackson@transarc.com)
Wed Aug 19 12:32:22 1992

Date: 19 Aug 92 07:40:27 GMT
From: Joseph_Jackson@transarc.com
To: kerberos@shelby.Stanford.EDU

Perhaps the program below is what you're looking for?  It will
implement something similar to the "pagsh" and "klog" combination.
I'll include the Makefile followed by the single source file.

If you have additional questions, you might consider talking to your
local AFS Site Contacts.  They have direct access to Transarc's
AFS Product Support group and can submit questions on your behalf.

Joe Jackson,
AFS Product Support,
Transarc Corp.

_______________________________________________________________
Makefile:

PROGRAMS=afs-auth

# AFSDIR = /afs/transarc.com/product/afs/3.1b/@sys
AFSDIR = /usr/afsws
AFSLIBDIR = $(AFSDIR)/lib
AFSLIBS = -L$(AFSLIBDIR) -L$(AFSLIBDIR)/afs  -lkauth -lprot -lubik \
		-lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err \
		$(AFSLIBDIR)/afs/util.a
INCLUDES = -I$(AFSDIR)/include

LDFLAGS = $(AFSLIBS)
CFLAGS = $(INCLUDES) -g -D_NO_PROTO

all: $(PROGRAMS)

.c: ; $(CC) $(CFLAGS) $@.c $(LDFLAGS) -o $@


_______________________________________________________
afs-auth.c:

#include <afs/kautils.h>
  
  struct greet_info {
    char          *name;        /* user name */
    char          *password;     /* user password */
    char          *string;       /* random string */
  };

int try_to_login();

main(argc, argv)
     int argc;
     char **argv;
{
  int code;
  struct greet_info test_greet;
  static char name[128], password[128];
  
  memset(name,NULL,sizeof(name));
  memset(password,NULL,sizeof(password));
  
  printf("Enter AFS User Name: ");
  if( !gets(name) ){
    printf("Unable to grab name from stdin\n");
    perror("Error message returned");
    exit(1);
  }
  printf("Enter Password: ");
  if ( !gets(password) ){
    printf("Unable to grab password from stdin\n");
    perror("Error message returned");
    exit(1);
  }
  
  test_greet.name = name;
  test_greet.password = password;
  
  code = try_to_login(&test_greet);
  
  system ("/usr/ucb/groups;/usr/afsws/bin/tokens");

  return code;
}

int try_to_login (test_g)
     struct greet_info *test_g;
{
  
  int code;
  char *reason;
  
  printf("\nName: %s\nPassword: %s\n", test_g->name, test_g->password);
  
  code = ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION+KA_USERAUTH_DOSETPAG,
				    test_g->name,
				    (char *) 0,  /* instance */
				    (char *) 0,  /* realm */
				    test_g->password,
				    0,           /* lifetime, default */
				    0, 0,        /* spares */
				    &reason);
  
  if (code != 0)
    printf("AFS Verify failed because %s\n", reason);
  else
    printf("Verify succeeded\n");
  
  return code;
}

home help back first fref pref prev next nref lref last post