/***************************************************************************/ /* Module: $Id: getselect.c,v 1.4 1999/05/07 04:15:25 maf Exp $ /* Description: KarlBridge authentication system get their selection /* Author: maf /* Notes: /***************************************************************************/ /* $Log: */ #include "kbauth.h" #include #include #include #include #include #include GetSelection(db, serviceNo, ourIP) struct KbRemAuthDatabase *db; int *serviceNo; u_long ourIP; { int x; int knownServices; struct in_addr inaddr; unsigned int selection; char buf[80]; int lookup[MAXAUTHRECORDS]; knownServices = 0; inaddr.s_addr = ntohl(ourIP); printf("\n"); printf(" UNIVERSITY TECHNOLOGY SERVICES\n"); printf(" Network Authentication and Authorization Server\n\n\n"); printf(" This service enables you to use the resources available on the\n"); printf(" Internet. After entering a valid username and password for\n"); printf(" authentication, you can access network services such as e-mail\n"); printf(" and the world wide web.\n\n"); printf(" IMPORTANT. When you are ready to end your network session, please\n"); printf(" remember to disconnect to ensure that no subsequent user can access\n"); printf(" network resources under your identity for improper purposes.\n"); printf(" Disconnect by choosing \"D\" from the menu selections below.\n\n"); for (x = 0; db[x].ipLow != 0xFFFFFFFF; ++x) if ((ourIP >= db[x].ipLow) && (ourIP <= db[x].ipHigh)) lookup[knownServices ++] = x; if (!knownServices) { printf( "\n\nSorry, your host (%s) is not authorized for any services.\n", inet_ntoa(inaddr)); sleep(15); syslog(LOG_ERR, "No services for host %s", inet_ntoa(inaddr)); return 2; } printf("Choose one of the following:\n\n"); for (;;) { for (x = 0; x < knownServices; ++x) printf(" %d) \"%s\"\n", x+1, db[lookup[x]].serviceName); printf("\n"); printf(" D) Disconnect from all services.\n"); printf(" H) Help.\n"); printf(" E) Exit authentication service without disconnecting.\n"); printf("\nSelection ==> "); fflush(stdout); if (!fgets(buf, sizeof(buf), stdin)) return 1; if ((buf[0] == 'D') || (buf[0] == 'd')) selection = 1000 + 'D'; else if ((buf[0] == 'H') || (buf[0] == 'h')) selection = 1000 + 'H'; else if ((buf[0] == 'E') || (buf[0] == 'e')) selection = 1000 + 'E'; else { selection = atoi(buf); if (selection >= 1000) selection = 0; } if (((selection < 1000) && (selection > knownServices)) || (!selection)) { printf("Invalid selection.\n\n"); continue; } if (selection < 1000) { *serviceNo = lookup[selection - 1]; return 0; /* good */ } else { *serviceNo = selection; return 0; /* good */ } } } /* GetSelection */