/* * Copyright 2000, International Business Machines Corporation and others. * All Rights Reserved. * * This software has been released under the terms of the IBM Public * License. For details, see the LICENSE file in the top-level source * directory or online at http://www.openafs.org/dl/license10.html */ #include #include RCSID("$Header$"); #include #include #ifdef AFS_NT40_ENV #include #include #else #include #include #include #endif #include "kalog.h" /* for OpenLog() */ #include #include #ifdef HAVE_STRING_H #include #else #ifdef HAVE_STRINGS_H #include #endif #endif #ifdef HAVE_FCNTL_H #include #endif #ifdef AFS_AIX32_ENV #include #endif #include #include #include #include #include #include #include #include #include #include "kauth.h" #include "kautils.h" #include "kaserver.h" struct kadstats dynamic_statistics; struct ubik_dbase *KA_dbase; afs_int32 myHost = 0; afs_int32 verbose_track = 1; struct afsconf_dir *KA_conf; /* for getting cell info */ extern afs_int32 ubik_lastYesTime; extern afs_int32 ubik_nBuffers; int MinHours = 0; int npwSums = KA_NPWSUMS; /* needs to be variable sometime */ #include #if !defined(AFS_NT40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV) #undef vfprintf #define vfprintf(stream,fmt,args) _doprnt(fmt,args,stream) #endif static int debugOutput; /* check whether caller is authorized to manage RX statistics */ int KA_rxstat_userok(call) struct rx_call *call; { return afsconf_SuperUser(KA_conf, call, (char *)0); } afs_int32 es_Report(char *fmt, ...) { va_list pvar; if (debugOutput == 0) return 0; va_start (pvar, fmt); vfprintf (stderr, fmt, pvar); va_end(pvar); return 0; } static void initialize_dstats () { memset(&dynamic_statistics, 0, sizeof(dynamic_statistics)); dynamic_statistics.start_time = time(0); dynamic_statistics.host = myHost; } static int convert_cell_to_ubik (cellinfo, myHost, serverList) struct afsconf_cell *cellinfo; afs_int32 *myHost; afs_int32 *serverList; { int i; char hostname[64]; struct hostent *th; /* get this host */ gethostname(hostname,sizeof(hostname)); th = gethostbyname(hostname); if (!th) { ViceLog(0, ("kaserver: couldn't get address of this host.\n")); exit(1); } memcpy(myHost, th->h_addr, sizeof(afs_int32)); for (i=0; inumServers; i++) if (cellinfo->hostAddr[i].sin_addr.s_addr != *myHost) { /* omit my host from serverList */ *serverList++ = cellinfo->hostAddr[i].sin_addr.s_addr; } *serverList = 0; /* terminate list */ return 0; } static afs_int32 kvno_admin_key (rock, kvno, key) char *rock; afs_int32 kvno; struct ktc_encryptionKey *key; { return ka_LookupKvno (0, KA_ADMIN_NAME, KA_ADMIN_INST, kvno, key); /* we would like to start a Ubik transaction to fill the cache if that fails, but may deadlock as Rx is now organized. */ } /* initFlags: 0x01 Do not require authenticated connections. 0x02 Do not check the bos NoAuth flag 0x04 Use fast key expiration to test oldkey code. 0x08 Temporary flag allowing database inconsistency fixup */ #include "AFS_component_version_number.c" main (argc, argv) int argc; char *argv[]; { afs_int32 code; char *whoami = argv[0]; afs_int32 serverList[MAXSERVERS]; struct afsconf_cell cellinfo; char *cell; const char *cellservdb, *dbpath, *lclpath; int a; char arg[32]; char default_lclpath[AFSDIR_PATH_MAX]; int servers; int initFlags; int level; /* security level for Ubik */ afs_int32 i; char clones[MAXHOSTSPERCELL]; struct rx_service *tservice; struct rx_securityClass *sca[1]; struct rx_securityClass *scm[3]; extern int afsconf_ClientAuthSecure(); extern int afsconf_ServerAuth(); extern int afsconf_CheckAuth(); extern int rx_stackSize; extern struct rx_securityClass *rxnull_NewServerSecurityObject(); extern int KAA_ExecuteRequest(); extern int KAT_ExecuteRequest(); extern int KAM_ExecuteRequest(); extern int RXSTATS_ExecuteRequest(); #ifdef AFS_AIX32_ENV /* * The following signal action for AIX is necessary so that in case of a * crash (i.e. core is generated) we can include the user's data section * in the core dump. Unfortunately, by default, only a partial core is * generated which, in many cases, isn't too useful. */ struct sigaction nsa; sigemptyset(&nsa.sa_mask); nsa.sa_handler = SIG_DFL; nsa.sa_flags = SA_FULLDUMP; sigaction(SIGABRT, &nsa, NULL); sigaction(SIGSEGV, &nsa, NULL); #endif if (argc == 0) { usage: printf("Usage: kaserver [-noAuth] [-fastKeys] [-database ] " "[-localfiles ] [-minhours ] [-servers ] " /*" [-enable_peer_stats] [-enable_process_stats] " */ "[-help]\n"); exit(1); } #ifdef AFS_NT40_ENV /* initialize winsock */ if (afs_winsockInit()<0) { ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0],0); fprintf(stderr, "%s: Couldn't initialize winsock.\n", whoami); exit(1); } #endif /* Initialize dirpaths */ if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) { #ifdef AFS_NT40_ENV ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0); #endif fprintf(stderr,"%s: Unable to obtain AFS server directory.\n", argv[0]); exit(2); } cellservdb = AFSDIR_SERVER_ETC_DIRPATH; dbpath = AFSDIR_SERVER_KADB_FILEPATH; strcompose(default_lclpath, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/", AFSDIR_KADB_FILE, NULL); lclpath = default_lclpath; debugOutput = 0; servers = 0; initFlags = 0; level = rxkad_crypt; for (a=1; a