For an example to help some tool writers here at Argonne I wrote the 
following example program.   It gives an example (but more importantly the 
link and compile stuff in the Makefile) that does work on the SGI machines we 
have here running AFS.  If you're writing a program that wants to verify AFS 
passwords for its own purposes, this might be useful to you.

I would also remind people that the documentation for the AFS API specs are
in /afs/grand.central.org/darpa/doc/afs/specs/progint/*/*.ps as Postscript
files ready for printing.

Anyway, shar file follows:

#!/bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #!/bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#       Makefile
#       tryka.c
# This archive created: Wed Mar  8 10:41:40 1995
export PATH; PATH=/bin:$PATH
if test -f 'Makefile'
then
        echo shar: over-writing existing file "'Makefile'"
fi
cat << \SHAR_EOF > 'Makefile'
LIBS=/usr/vice/etc/afsauthlib.so /usr/vice/etc/afskauthlib.so
INCDIRS=-I/usr/afsws/include
CFLAGS=$(INCDIRS)

all: tryka

tryka.o: tryka.c Makefile

tryka: tryka.o
        cc tryka.o $(CFLAGS) $(LIBS) -o tryka -rpath /usr/vice/etc
SHAR_EOF
if test -f 'tryka.c'
then
        echo shar: over-writing existing file "'tryka.c'"
fi
cat << \SHAR_EOF > 'tryka.c'
#include <stdio.h>
#include <afs/kauth.h>
#include <afs/kautils.h>
#include <afs/auth.h>

main(argc,argv)
int argc;
char **argv;
{
        char inlogin[128];
        char prompt[150];
        char inpasswd[MAXKTCNAMELEN];
        char *reason;
        int ret;

        printf("Hello!  Enter login name-->");
        gets(inlogin);

        sprintf(prompt,"Enter Kerberos password for %s-->",inlogin);

        ret=ka_UserReadPassword(prompt,inpasswd,MAXKTCNAMELEN,&reason);

        if(ret!=0) {
                fprintf(stderr,"ka_UserReadPassword failed:%s\n",reason);
                exit(-1);
        } 

        ret=ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION,
                                                inlogin,
                                                "",
                                                "",
                                                inpasswd,
                                                0,
                                                0,
                                                0,
                                                &reason);

        if(ret) {
                printf("Can't agree with password:%s\n",
                        reason);
        } else 
                printf("Password correct.\n");
}
SHAR_EOF
#       End of shell archive
exit 0

Reply via email to