summaryrefslogtreecommitdiffstats
path: root/src/tests
Commit message (Expand)AuthorAgeFilesLines
* Remove reference to $(ISODELIB)Theodore Tso1995-03-028-8/+20
* .cvsingore file to suppress CVS's handling of the "configure" fileTheodore Tso1995-03-021-0/+1
* Added Ezra's test to see if you have a buggy resolver or notTheodore Tso1995-03-015-1/+153
* Remove ISODE_INCLUDE and ISODE_DEFS, replace check for -lsocket andTheodore Tso1995-03-012-4/+6
* Remove ISODE_INCLUDE, replace check for -lsocket and -lnsl withTheodore Tso1995-03-016-9/+18
* Avoid <krb5/...> includesJohn Gilmore1995-02-2817-44/+40
* Use $(LD) instead of $(CC) when linkingTheodore Tso1995-02-222-2/+6
* * kdc5_hammer.c Removed krb5_keytype, changed krb5_enctype toChris Provenzano1995-02-082-7/+10
* Add .cvsignore file so that cvs ignores the autoconf-built configure fileTheodore Tso1995-02-035-0/+5
* Add keytype parameterTheodore Tso1995-02-032-1/+6
* * Removed all narrow types and references to wide.h and narrow.hChris Provenzano1995-01-252-3/+5
* Removed all references to DECLARG and OLDDECLARG.Chris Provenzano1995-01-1312-455/+441
* Add magic numbers for keyblock structureTheodore Tso1994-11-192-0/+7
* Use the published interface to call krb5_string_to_key()Theodore Tso1994-11-082-5/+9
* Include the tag numbers for the krb5 application tags, since that'sTheodore Tso1994-11-023-52/+57
* Add the "-t option to krb5_encode_test, which causes it to use theTheodore Tso1994-11-025-15/+2335
* Conversion of autoconfigury to Autoconf V2Mark Eichin1994-10-265-17/+17
* Once more, with the current type!Theodore Tso1994-10-261-1/+1
* Added missing declaration for retval variableTheodore Tso1994-10-261-0/+1
* Allow kdc_hammer to be called on an arbitrary realmTheodore Tso1994-10-242-6/+22
* kdb5_verify.c: Check principals with correct realm nameTheodore Tso1994-10-243-16/+28
* kdb5_mkdums.c: Create principals with correct realm nameTheodore Tso1994-10-243-9/+21
* Do checks for depth = 5Theodore Tso1994-10-242-2/+7
* Exit with a non-zero exit status when the test suite detects any errorsTheodore Tso1994-10-194-10/+10
* Clear the kvno field when destroying encrypted dataTheodore Tso1994-10-192-0/+4
* Makefile.in: "make check" depends on krb5_decode_test andTheodore Tso1994-10-195-6/+34
* Clean up the test.out fileTheodore Tso1994-10-171-0/+4
* Add ISODE_DEFSTheodore Tso1994-10-152-0/+5
* Clean up the test.out fileTheodore Tso1994-10-141-1/+2
* Explicitly destroy the test database before reloading itTheodore Tso1994-10-071-1/+2
* Add general kadmin/kdb confidence checkTheodore Tso1994-10-072-0/+32
* Add a "make check" case which runs the test programsTheodore Tso1994-10-072-0/+10
* Allow master key to be passed in on the command line. Makes testingTheodore Tso1994-10-074-11/+67
* Add recursive "make check"Theodore Tso1994-10-072-0/+5
* Check to make sure key version number is 1, not 0Theodore Tso1994-10-062-1/+6
* Initialize all of the fields of the principal entryTheodore Tso1994-10-062-0/+10
* Add widen.h and narrow.h around declaration so that argument types areTheodore Tso1994-10-042-0/+7
* You can't use strcat to modify constant strings!Theodore Tso1994-10-043-6/+12
* Add magic number placeholder to statically initialized structuresTheodore Tso1994-10-012-0/+5
* configure now generates the makefileTheodore Tso1994-09-301-43/+0
* Relink executable if libraries changeTheodore Tso1994-09-309-10/+46
* get NULL from stdio for sunosMark Eichin1994-09-282-0/+5
* Fix typo which was causing krb5_encode_test.c to fail due to trying toTheodore Tso1994-09-212-1/+7
* index() -> strchr()Theodore Tso1994-09-152-1/+5
* Put the tests directory under autoconfTheodore Tso1994-09-158-0/+115
* Put the tests directory under autoconfTheodore Tso1994-09-155-383/+425
* Create database with key version number of 1Theodore Tso1994-09-152-2/+7
* stamp out rcs keywordsMark Eichin1994-08-187-49/+7
* checking in Harry's ASN.1 encoder tests. Will fix up laterTom Yu1994-08-0413-0/+2647
* folding in Harry's changesTom Yu1994-06-292-2/+5
Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)svc.c 1.41 87/10/13 Copyr 1984 Sun Micro"; #endif /* * svc.c, Server-side remote procedure call interface. * * There are two sets of procedures here. The xprt routines are * for handling transport handles. The svc routines handle the * list of service routines. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include <sys/errno.h> #include <gssrpc/rpc.h> #include <gssrpc/pmap_clnt.h> #include <stdio.h> #include <string.h> #include <errno.h> #ifdef FD_SETSIZE static SVCXPRT **xports; static int max_xport = 0; extern int gssrpc_svc_fdset_init; #else #define NOFILE 32 static SVCXPRT *xports[NOFILE]; #endif /* def FD_SETSIZE */ #define NULL_SVC ((struct svc_callout *)0) #define RQCRED_SIZE 400 /* this size is excessive */ /* * The services list * Each entry represents a set of procedures (an rpc program). * The dispatch routine takes request structs and runs the * apropriate procedure. */ static struct svc_callout { struct svc_callout *sc_next; rpcprog_t sc_prog; rpcprog_t sc_vers; void (*sc_dispatch)(); } *svc_head; static struct svc_callout *svc_find(rpcprog_t, rpcvers_t, struct svc_callout **); /* *************** SVCXPRT related stuff **************** */ /* * Activate a transport handle. */ void xprt_register(xprt) SVCXPRT *xprt; { register int sock = xprt->xp_sock; #ifdef FD_SETSIZE if (gssrpc_svc_fdset_init == 0) { FD_ZERO(&svc_fdset); gssrpc_svc_fdset_init++; } if (xports == NULL) { xports = (SVCXPRT **) mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *)); memset(xports, 0, FD_SETSIZE * sizeof(SVCXPRT *)); } if (sock < gssrpc__rpc_dtablesize()) { xports[sock] = xprt; FD_SET(sock, &svc_fdset); if (max_xport < sock) max_xport = sock; } #else if (sock < NOFILE) { xports[sock] = xprt; svc_fds |= (1 << sock); } #endif /* def FD_SETSIZE */ } /* * De-activate a transport handle. */ void xprt_unregister(xprt) SVCXPRT *xprt; { register int sock = xprt->xp_sock; #ifdef FD_SETSIZE if ((sock < gssrpc__rpc_dtablesize()) && (xports[sock] == xprt)) { xports[sock] = (SVCXPRT *)0; FD_CLR(sock, &svc_fdset); if (max_xport <= sock) { while ((max_xport > 0) && xports[max_xport] == 0) max_xport--; } } #else if ((sock < NOFILE) && (xports[sock] == xprt)) { xports[sock] = (SVCXPRT *)0; svc_fds &= ~(1 << sock); } #endif /* def FD_SETSIZE */ } /* ********************** CALLOUT list related stuff ************* */ /* * Add a service program to the callout list. * The dispatch routine will be called when a rpc request for this * program number comes in. */ bool_t svc_register(xprt, prog, vers, dispatch, protocol) SVCXPRT *xprt; rpcprog_t prog; rpcvers_t vers; void (*dispatch)(); int protocol; { struct svc_callout *prev; register struct svc_callout *s; if ((s = svc_find(prog, vers, &prev)) != NULL_SVC) { if (s->sc_dispatch == dispatch) goto pmap_it; /* he is registering another xptr */ return (FALSE); } s = (struct svc_callout *)mem_alloc(sizeof(struct svc_callout)); if (s == (struct svc_callout *)0) { return (FALSE); } s->sc_prog = prog; s->sc_vers = vers; s->sc_dispatch = dispatch; s->sc_next = svc_head; svc_head = s; pmap_it: /* now register the information with the local binder service */ if (protocol) { return (pmap_set(prog, vers, protocol, xprt->xp_port)); } return (TRUE); } /* * Remove a service program from the callout list. */ void svc_unregister(prog, vers) rpcprog_t prog; rpcvers_t vers; { struct svc_callout *prev; register struct svc_callout *s; if ((s = svc_find(prog, vers, &prev)) == NULL_SVC) return; if (prev == NULL_SVC) { svc_head = s->sc_next; } else { prev->sc_next = s->sc_next; } s->sc_next = NULL_SVC; mem_free((char *) s, (u_int) sizeof(struct svc_callout)); /* now unregister the information with the local binder service */ (void)pmap_unset(prog, vers); } /* * Search the callout list for a program number, return the callout * struct. */ static struct svc_callout * svc_find(prog, vers, prev) rpcprog_t prog; rpcvers_t vers; struct svc_callout **prev; { register struct svc_callout *s, *p; p = NULL_SVC; for (s = svc_head; s != NULL_SVC; s = s->sc_next) { if ((s->sc_prog == prog) && (s->sc_vers == vers)) goto done; p = s; } done: *prev = p; return (s); } /* ******************* REPLY GENERATION ROUTINES ************ */ /* * Send a reply to an rpc request */ bool_t svc_sendreply(xprt, xdr_results, xdr_location) register SVCXPRT *xprt; xdrproc_t xdr_results; caddr_t xdr_location; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_ACCEPTED; rply.acpted_rply.ar_verf = xprt->xp_verf; rply.acpted_rply.ar_stat = SUCCESS; rply.acpted_rply.ar_results.where = xdr_location; rply.acpted_rply.ar_results.proc = xdr_results; return (SVC_REPLY(xprt, &rply)); } /* * No procedure error reply */ void svcerr_noproc(xprt) register SVCXPRT *xprt; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_ACCEPTED; rply.acpted_rply.ar_verf = xprt->xp_verf; rply.acpted_rply.ar_stat = PROC_UNAVAIL; SVC_REPLY(xprt, &rply); } /* * Can't decode args error reply */ void svcerr_decode(xprt) register SVCXPRT *xprt; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_ACCEPTED; rply.acpted_rply.ar_verf = xprt->xp_verf; rply.acpted_rply.ar_stat = GARBAGE_ARGS; SVC_REPLY(xprt, &rply); } /* * Some system error */ void svcerr_systemerr(xprt) register SVCXPRT *xprt; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_ACCEPTED; rply.acpted_rply.ar_verf = xprt->xp_verf; rply.acpted_rply.ar_stat = SYSTEM_ERR; SVC_REPLY(xprt, &rply); } /* * Authentication error reply */ void svcerr_auth(xprt, why) SVCXPRT *xprt; enum auth_stat why; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_DENIED; rply.rjcted_rply.rj_stat = AUTH_ERROR; rply.rjcted_rply.rj_why = why; SVC_REPLY(xprt, &rply); } /* * Auth too weak error reply */ void svcerr_weakauth(xprt) SVCXPRT *xprt; { svcerr_auth(xprt, AUTH_TOOWEAK); } /* * Program unavailable error reply */ void svcerr_noprog(xprt) register SVCXPRT *xprt; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_ACCEPTED; rply.acpted_rply.ar_verf = xprt->xp_verf; rply.acpted_rply.ar_stat = PROG_UNAVAIL; SVC_REPLY(xprt, &rply); } /* * Program version mismatch error reply */ void svcerr_progvers(xprt, low_vers, high_vers) register SVCXPRT *xprt; rpcvers_t low_vers; rpcvers_t high_vers; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_ACCEPTED; rply.acpted_rply.ar_verf = xprt->xp_verf; rply.acpted_rply.ar_stat = PROG_MISMATCH; rply.acpted_rply.ar_vers.low = low_vers; rply.acpted_rply.ar_vers.high = high_vers; SVC_REPLY(xprt, &rply); } /* ******************* SERVER INPUT STUFF ******************* */ /* * Get server side input from some transport. * * Statement of authentication parameters management: * This function owns and manages all authentication parameters, specifically * the "raw" parameters (msg.rm_call.cb_cred and msg.rm_call.cb_verf) and * the "cooked" credentials (rqst->rq_clntcred). * However, this function does not know the structure of the cooked * credentials, so it make the following assumptions: * a) the structure is contiguous (no pointers), and * b) the cred structure size does not exceed RQCRED_SIZE bytes. * In all events, all three parameters are freed upon exit from this routine. * The storage is trivially management on the call stack in user land, but * is mallocated in kernel land. */ void svc_getreq(rdfds) int rdfds; { #ifdef FD_SETSIZE fd_set readfds; int i, mask; FD_ZERO(&readfds); for (i=0, mask=1; rdfds; i++, mask <<=1) { if (rdfds & mask) FD_SET(i, &readfds); rdfds &= ~mask; } svc_getreqset(&readfds); #else int readfds = rdfds & svc_fds; svc_getreqset(&readfds); #endif /* def FD_SETSIZE */ } void svc_getreqset(readfds) #ifdef FD_SETSIZE fd_set *readfds; { #else int *readfds; { int readfds_local = *readfds; #endif /* def FD_SETSIZE */ enum xprt_stat stat; struct rpc_msg msg; int prog_found; rpcvers_t low_vers; rpcvers_t high_vers; struct svc_req r; register SVCXPRT *xprt; register int sock; bool_t no_dispatch; caddr_t rawcred, rawverf, cookedcred; rawcred = mem_alloc(MAX_AUTH_BYTES); rawverf = mem_alloc(MAX_AUTH_BYTES); cookedcred = mem_alloc(RQCRED_SIZE); if (rawcred == NULL || rawverf == NULL || cookedcred == NULL) return; msg.rm_call.cb_cred.oa_base = rawcred; msg.rm_call.cb_verf.oa_base = rawverf; r.rq_clntcred = cookedcred; #ifdef FD_SETSIZE for (sock = 0; sock <= max_xport; sock++) { if (FD_ISSET(sock, readfds)) { /* sock has input waiting */ xprt = xports[sock]; #else for (sock = 0; readfds_local != 0; sock++, readfds_local >>= 1) { if ((readfds_local & 1) != 0) { /* sock has input waiting */ xprt = xports[sock]; #endif /* def FD_SETSIZE */ /* now receive msgs from xprtprt (support batch calls) */ do { if (SVC_RECV(xprt, &msg)) { /* now find the exported program and call it */ register struct svc_callout *s; enum auth_stat why; r.rq_xprt = xprt; r.rq_prog = msg.rm_call.cb_prog; r.rq_vers = msg.rm_call.cb_vers; r.rq_proc = msg.rm_call.cb_proc; r.rq_cred = msg.rm_call.cb_cred; no_dispatch = FALSE; /* first authenticate the message */ why=gssrpc__authenticate(&r, &msg, &no_dispatch); if (why != AUTH_OK) { svcerr_auth(xprt, why); goto call_done; } else if (no_dispatch) { goto call_done; } /* now match message with a registered service*/ prog_found = FALSE; low_vers = (rpcvers_t) -1L; high_vers = 0; for (s = svc_head; s != NULL_SVC; s = s->sc_next) { if (s->sc_prog == r.rq_prog) { if (s->sc_vers == r.rq_vers) { (*s->sc_dispatch)(&r, xprt); goto call_done; } /* found correct version */ prog_found = TRUE; if (s->sc_vers < low_vers) low_vers = s->sc_vers; if (s->sc_vers > high_vers) high_vers = s->sc_vers; } /* found correct program */ } /* * if we got here, the program or version * is not served ... */ if (prog_found) svcerr_progvers(xprt, low_vers, high_vers); else svcerr_noprog(xprt); /* Fall through to ... */ } call_done: if ((stat = SVC_STAT(xprt)) == XPRT_DIED){ SVC_DESTROY(xprt); break; } } while (stat == XPRT_MOREREQS); } } mem_free(rawcred, MAX_AUTH_BYTES); mem_free(rawverf, MAX_AUTH_BYTES); mem_free(cookedcred, RQCRED_SIZE); }