/* * report on whether a particular id is locked or not... * has to get some dirt from ubik. * We multiply the actual number of permitted attempts by two because * klog tries to authenticate twice when the password is bogus: once * with the ka_string_to_key, and once with des_string_to_key, for * Kerberos compatibility. It's easier to frob here than to explain * to users/admins. * RETURNS: time when the ID will be unlocked, or 0 if it's not locked. */ int kaux_islocked(afs_int32 to, u_int attempts, u_int locktime) { extern int ubeacon_Debug(), ubeacon_AmSyncSite(); unsigned int nfailures, myshare; afs_uint32 lasttime; struct ubik_debug beaconinfo; /* if attempts is 0, that means there's no limit, so the id * can't ever be locked... */ if (!attempts) return 0; kaux_read(to, &nfailures, &lasttime); ubeacon_Debug(&beaconinfo); attempts = attempts * 2; myshare = attempts / beaconinfo.nServers; if (ubeacon_AmSyncSite()) myshare += attempts % beaconinfo.nServers; if (!myshare) { return -1; } else if ((nfailures < myshare) || (locktime && lasttime + locktime < time(0))) { return 0; } else if (locktime == 0) { /* infinite */ return -1; } else { return (lasttime + locktime); } }
/*! * \brief Handle basic network debug command. This is the global state dumper. */ afs_int32 SVOTE_Debug(struct rx_call * rxcall, struct ubik_debug * aparm) { int i; /* fill in the basic debug structure. Note the the RPC protocol transfers, * integers in host order. */ aparm->now = FT_ApproxTime(); aparm->lastYesTime = vote_globals.ubik_lastYesTime; aparm->lastYesHost = ntohl(vote_globals.lastYesHost); aparm->lastYesState = vote_globals.lastYesState; aparm->lastYesClaim = vote_globals.lastYesClaim; aparm->lowestHost = ntohl(vote_globals.lowestHost); aparm->lowestTime = vote_globals.lowestTime; aparm->syncHost = ntohl(vote_globals.syncHost); aparm->syncTime = vote_globals.syncTime; memcpy(&aparm->syncVersion, &vote_globals.ubik_dbVersion, sizeof(struct ubik_version)); memcpy(&aparm->syncTid, &vote_globals.ubik_dbTid, sizeof(struct ubik_tid)); /* fill in all interface addresses of myself in hostbyte order */ for (i = 0; i < UBIK_MAX_INTERFACE_ADDR; i++) aparm->interfaceAddr[i] = ntohl(ubik_host[i]); aparm->amSyncSite = beacon_globals.ubik_amSyncSite; ubeacon_Debug(aparm); udisk_Debug(aparm); ulock_Debug(aparm); /* Get the recovery state. The label of the database may not have * been written yet but set the flag so udebug behavior remains. * Defect 9477. */ aparm->recoveryState = urecovery_state; if ((urecovery_state & UBIK_RECSYNCSITE) && (urecovery_state & UBIK_RECFOUNDDB) && (urecovery_state & UBIK_RECHAVEDB)) { aparm->recoveryState |= UBIK_RECLABELDB; } aparm->activeWrite = (ubik_dbase->flags & DBWRITING); aparm->tidCounter = ubik_dbase->tidCounter; if (ubik_currentTrans) { aparm->currentTrans = 1; if (ubik_currentTrans->type == UBIK_WRITETRANS) aparm->writeTrans = 1; else aparm->writeTrans = 0; } else { aparm->currentTrans = 0; } aparm->epochTime = version_globals.ubik_epochTime; return 0; }
/*! * \brief Handle basic network debug command. This is the global state dumper. */ afs_int32 SVOTE_DebugOld(struct rx_call * rxcall, struct ubik_debug_old * aparm) { /* fill in the basic debug structure. Note the the RPC protocol transfers, * integers in host order. */ aparm->now = FT_ApproxTime(); aparm->lastYesTime = ubik_lastYesTime; aparm->lastYesHost = ntohl(lastYesHost); aparm->lastYesState = lastYesState; aparm->lastYesClaim = lastYesClaim; aparm->lowestHost = ntohl(lowestHost); aparm->lowestTime = lowestTime; aparm->syncHost = ntohl(syncHost); aparm->syncTime = syncTime; aparm->amSyncSite = ubik_amSyncSite; ubeacon_Debug((ubik_debug *)aparm); udisk_Debug((ubik_debug *)aparm); ulock_Debug((ubik_debug *)aparm); /* Get the recovery state. The label of the database may not have * been written yet but set the flag so udebug behavior remains. * Defect 9477. */ aparm->recoveryState = urecovery_state; if ((urecovery_state & UBIK_RECSYNCSITE) && (urecovery_state & UBIK_RECFOUNDDB) && (urecovery_state & UBIK_RECHAVEDB)) { aparm->recoveryState |= UBIK_RECLABELDB; } memcpy(&aparm->syncVersion, &ubik_dbVersion, sizeof(struct ubik_version)); memcpy(&aparm->syncTid, &ubik_dbTid, sizeof(struct ubik_tid)); aparm->activeWrite = (ubik_dbase->flags & DBWRITING); aparm->tidCounter = ubik_dbase->tidCounter; if (ubik_currentTrans) { aparm->currentTrans = 1; if (ubik_currentTrans->type == UBIK_WRITETRANS) aparm->writeTrans = 1; else aparm->writeTrans = 0; } else { aparm->currentTrans = 0; } aparm->epochTime = ubik_epochTime; return 0; }