Exemple #1
0
int
main(int argc, char *argv[])
{
    int rc;
    afs_status_t st = 0;
    struct rx_connection *conn;
    char *srvrName;
    long srvrPort;
    void *cellHandle;
    afs_CMCellName_t cellName;

    ParseArgs(argc, argv, &srvrName, &srvrPort);

    rc = afsclient_Init(&st);
    if (!rc) {
	fprintf(stderr, "afsclient_Init, status %d\n", st);
	exit(1);
    }

    rc = afsclient_NullCellOpen(&cellHandle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_NullCellsOpen, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CMStatOpenPort(cellHandle, srvrName, srvrPort, &conn, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CMStatOpenPort, status %d\n", st);
	exit(1);
    }

    rc = util_CMLocalCell(conn, cellName, &st);
    if (!rc) {
	fprintf(stderr, "util_CMLocalCell, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CMStatClose(conn, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CMStatClose, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CellClose(cellHandle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CellClose, status %d\n", st);
	exit(1);
    }

    printf("\n");
    printf("Client %s (port %ld) is in cell %s\n", srvrName, srvrPort,
	   cellName);
    printf("\n");

    exit(0);
}
Exemple #2
0
int
main(int argc, char *argv[])
{
    int rc;
    afs_status_t st = 0;
    struct rx_connection *conn;
    char *srvrName;
    long srvrPort;
    void *cellHandle;
    afs_RPCStatsState_t state;

    ParseArgs(argc, argv, &srvrName, &srvrPort);

    rc = afsclient_Init(&st);
    if (!rc) {
	fprintf(stderr, "afsclient_Init, status %d\n", st);
	exit(1);
    }

    rc = afsclient_NullCellOpen(&cellHandle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_NullCellOpen, status %d\n", st);
	exit(1);
    }

    rc = afsclient_RPCStatOpenPort(cellHandle, srvrName, srvrPort, &conn,
				   &st);
    if (!rc) {
	fprintf(stderr, "afsclient_RPCStatOpenPort, status %d\n", st);
	exit(1);
    }

    rc = util_RPCStatsStateGet(conn, RXSTATS_QueryPeerRPCStats, &state, &st);
    if (!rc) {
	fprintf(stderr, "util_RPCStatsStateGet, status %d\n", st);
	exit(1);
    }

    rc = afsclient_RPCStatClose(conn, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_RPCStatClose, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CellClose(cellHandle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CellClose, status %d\n", st);
	exit(1);
    }

    printf("\n");
    printf("Peer RPC stats are ");
    switch (state) {
    case AFS_RPC_STATS_DISABLED:
	printf("disabled\n");
	break;
    case AFS_RPC_STATS_ENABLED:
	printf("enabled\n");
	break;
    default:
	printf("INVALID\n");
	break;
    }
    printf("\n");

    exit(0);
}
Exemple #3
0
/*
 * cfg_CellServDbEnumerate() -- Enumerate database machines known to the
 *     specified database or fileserver machine.  Enumeration is returned
 *     as a multistring.
 */
int ADMINAPI
cfg_CellServDbEnumerate(const char *fsDbHost,	/* fileserver or database host */
			char **cellName,	/* cell name for cellDbHosts */
			char **cellDbHosts,	/* cell database hosts */
			afs_status_p st)
{				/* completion status */
    int rc = 1;
    afs_status_t tst2, tst = 0;

    /* validate parameters */

    if (fsDbHost == NULL || *fsDbHost == '\0') {
	tst = ADMCFGHOSTNAMENULL;
    } else if (cellName == NULL) {
	tst = ADMCFGCELLNAMENULL;
    } else if (cellDbHosts == NULL) {
	tst = ADMCFGCELLDBHOSTSNULL;
    }

    /* enumerate server CellServDB on specified host, along with cell name */

    if (tst == 0) {
	void *cellHandle;
	void *bosHandle;
	char dbhostName[MAXHOSTSPERCELL][BOS_MAX_NAME_LEN];
	char dbhostCell[BOS_MAX_NAME_LEN];
	int dbhostCount = 0;

	if (!afsclient_NullCellOpen(&cellHandle, &tst2)) {
	    tst = tst2;
	} else {
	    if (!bos_ServerOpen(cellHandle, fsDbHost, &bosHandle, &tst2)) {
		tst = tst2;
	    } else {
		void *dbIter;

		if (!bos_HostGetBegin(bosHandle, &dbIter, &tst2)) {
		    tst = tst2;
		} else {
		    for (dbhostCount = 0;; dbhostCount++) {
			char dbhostNameTemp[BOS_MAX_NAME_LEN];

			if (!bos_HostGetNext(dbIter, dbhostNameTemp, &tst2)) {
			    /* no more entries (or failure) */
			    if (tst2 != ADMITERATORDONE) {
				tst = tst2;
			    }
			    break;
			} else if (dbhostCount >= MAXHOSTSPERCELL) {
			    /* more entries than expected */
			    tst = ADMCFGCELLSERVDBTOOMANYENTRIES;
			    break;
			} else {
			    strcpy(dbhostName[dbhostCount], dbhostNameTemp);
			}
		    }

		    if (!bos_HostGetDone(dbIter, &tst2)) {
			tst = tst2;
		    }

		    if (tst == 0) {
			/* got database servers; now get cell name */
			if (!bos_CellGet(bosHandle, dbhostCell, &tst2)) {
			    tst = tst2;
			}
		    }
		}

		if (!bos_ServerClose(bosHandle, &tst2)) {
		    tst = tst2;
		}
	    }

	    if (!afsclient_CellClose(cellHandle, &tst2)) {
		tst = tst2;
	    }
	}

	if (tst == 0) {
	    /* return database hosts to caller */
	    int i;
	    size_t bufSize = 0;

	    for (i = 0; i < dbhostCount; i++) {
		bufSize += strlen(dbhostName[i]) + 1;
	    }
	    bufSize++;		/* end multistring */

	    *cellDbHosts = (char *)malloc(bufSize);

	    if (*cellDbHosts == NULL) {
		tst = ADMNOMEM;
	    } else {
		char *bufp = *cellDbHosts;

		for (i = 0; i < dbhostCount; i++) {
		    strcpy(bufp, dbhostName[i]);
		    bufp += strlen(bufp) + 1;
		}
		*bufp = '\0';
	    }

	    /* return cell name to caller */
	    if (tst == 0) {
		*cellName = (char *)malloc(strlen(dbhostCell) + 1);

		if (*cellName == NULL) {
		    free(*cellDbHosts);
			*cellDbHosts = NULL;
		    tst = ADMNOMEM;
		} else {
		    strcpy(*cellName, dbhostCell);
		}
	    }
	}
    }

    if (tst != 0) {
	/* indicate failure */
	rc = 0;
    }
    if (st != NULL) {
	*st = tst;
    }
    return rc;
}
Exemple #4
0
int
main(int argc, char *argv[])
{
    int rc;
    afs_status_t st = 0;
    struct rx_connection *conn;
    char *srvrName;
    long srvrPort;
    void *cellHandle;
    afs_ClientConfig_t config;

    ParseArgs(argc, argv, &srvrName, &srvrPort);

    rc = afsclient_Init(&st);
    if (!rc) {
	fprintf(stderr, "afsclient_Init, status %d\n", st);
	exit(1);
    }

    rc = afsclient_NullCellOpen(&cellHandle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_NullCellsOpen, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CMStatOpenPort(cellHandle, srvrName, srvrPort, &conn, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CMStatOpenPort, status %d\n", st);
	exit(1);
    }

    rc = util_CMClientConfig(conn, &config, &st);
    if (!rc) {
	fprintf(stderr, "util_CMClientConfig, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CMStatClose(conn, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CMStatClose, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CellClose(cellHandle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CellClose, status %d\n", st);
	exit(1);
    }


    printf("\nClient configuration for %s (port %ld):\n\n", srvrName,
	   srvrPort);
    printf("    clientVersion:  %d\n", config.clientVersion);
    printf("    serverVersion:  %d\n", config.serverVersion);
    printf("    nChunkFiles:    %d\n", config.c.config_v1.nChunkFiles);
    printf("    nStatCaches:    %d\n", config.c.config_v1.nStatCaches);
    printf("    nDataCaches:    %d\n", config.c.config_v1.nDataCaches);
    printf("    nVolumeCaches:  %d\n", config.c.config_v1.nVolumeCaches);
    printf("    firstChunkSize: %d\n", config.c.config_v1.firstChunkSize);
    printf("    otherChunkSize: %d\n", config.c.config_v1.otherChunkSize);
    printf("    cacheSize:      %d\n", config.c.config_v1.cacheSize);
    printf("    setTime:        %d\n", config.c.config_v1.setTime);
    printf("    memCache:       %d\n", config.c.config_v1.memCache);
    printf("\n");

    exit(0);
}
Exemple #5
0
int
main(int argc, char *argv[])
{
    int rc;
    afs_status_t st = 0;
    struct rx_connection *conn;
    char *srvrName;
    long srvrPort;
    void *cellHandle;
    afs_CMListCell_t cellInfo;
    void *iterator;
    afs_uint32 taddr;
    int i;

    ParseArgs(argc, argv, &srvrName, &srvrPort);

    rc = afsclient_Init(&st);
    if (!rc) {
	fprintf(stderr, "afsclient_Init, status %d\n", st);
	exit(1);
    }

    rc = afsclient_NullCellOpen(&cellHandle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_NullCellsOpen, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CMStatOpenPort(cellHandle, srvrName, srvrPort, &conn, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CMStatOpenPort, status %d\n", st);
	exit(1);
    }

    rc = util_CMListCellsBegin(conn, &iterator, &st);
    if (!rc) {
	fprintf(stderr, "util_CMListCellsBegin, status %d\n", st);
	exit(1);
    }

    printf("\n");
    while (util_CMListCellsNext(iterator, &cellInfo, &st)) {
	printf("Cell %s on hosts", cellInfo.cellname);
	for (i = 0; i < UTIL_MAX_CELL_HOSTS && cellInfo.serverAddr[i]; i++) {
	    taddr = cellInfo.serverAddr[i];
	    printf(" %d.%d.%d.%d", (taddr >> 24) & 0xff, (taddr >> 16) & 0xff,
		   (taddr >> 8) & 0xff, taddr & 0xff);
	}
	printf("\n");
    }
    if (st != ADMITERATORDONE) {
	fprintf(stderr, "util_CMListCellsNext, status %d\n", st);
	exit(1);
    }
    printf("\n");

    rc = util_CMListCellsDone(iterator, &st);
    if (!rc) {
	fprintf(stderr, "util_CMListCellsDone, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CMStatClose(conn, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CMStatClose, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CellClose(cellHandle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CellClose, status %d\n", st);
	exit(1);
    }

    exit(0);
}
int
main(int argc, char *argv[])
{
    int rc;
    afs_status_t st = 0;
    struct rx_connection *conn;
    char *srvrName;
    long srvrPort;
    void *cellHandle;
    afs_CMServerPref_t prefs;
    void *iterator;
    afs_uint32 taddr;

    ParseArgs(argc, argv, &srvrName, &srvrPort);

    rc = afsclient_Init(&st);
    if (!rc) {
	fprintf(stderr, "afsclient_Init, status %d\n", st);
	exit(1);
    }

    rc = afsclient_NullCellOpen(&cellHandle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_NullCellOpen, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CMStatOpenPort(cellHandle, srvrName, srvrPort, &conn, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CMStatOpenPort, status %d\n", st);
	exit(1);
    }

    rc = util_CMGetServerPrefsBegin(conn, &iterator, &st);
    if (!rc) {
	fprintf(stderr, "util_CMGetServerPrefsBegin, status %d\n", st);
	exit(1);
    }

    printf("\n");
    while (util_CMGetServerPrefsNext(iterator, &prefs, &st)) {
	taddr = prefs.ipAddr;
	printf("%d.%d.%d.%d\t\t\t%d\n", (taddr >> 24) & 0xff,
	       (taddr >> 16) & 0xff, (taddr >> 8) & 0xff, taddr & 0xff,
	       prefs.ipRank);
    }
    if (st != ADMITERATORDONE) {
	fprintf(stderr, "util_CMGetServerPrefsNext, status %d\n", st);
	exit(1);
    }
    printf("\n");

    rc = util_CMGetServerPrefsDone(iterator, &st);
    if (!rc) {
	fprintf(stderr, "util_CMGetServerPrefsDone, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CMStatClose(conn, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CMStatClose, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CellClose(cellHandle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CellClose, status %d\n", st);
	exit(1);
    }

    exit(0);
}
Exemple #7
0
/*
 * cfgutil_HostNameGetCellServDbAlias() -- Get alias for given host name
 *     as listed in the server CellServDB on the specified host.  If no
 *     alias is found then hostNameAlias is set to the empty string.
 *
 *     Note: hostNameAlias is presumed to be a buffer of size MAXHOSTCHARS.
 *
 * RETURN CODES: 1 success, 0 failure
 */
int
cfgutil_HostNameGetCellServDbAlias(const char *fsDbHost, const char *hostName,
                                   char *hostNameAlias, afs_status_p st)
{
    int rc = 1;
    afs_status_t tst2, tst = 0;
    void *cellHandle;
    void *bosHandle;

    if (!afsclient_NullCellOpen(&cellHandle, &tst2)) {
        tst = tst2;
    } else {
        if (!bos_ServerOpen(cellHandle, fsDbHost, &bosHandle, &tst2)) {
            tst = tst2;
        } else {
            void *dbIter;

            if (!bos_HostGetBegin(bosHandle, &dbIter, &tst2)) {
                tst = tst2;
            } else {
                short dbhostDone = 0;
                short dbhostFound = 0;

                while (!dbhostDone) {
                    short isAlias;

                    if (!bos_HostGetNext(dbIter, hostNameAlias, &tst2)) {
                        /* no more entries (or failure) */
                        if (tst2 != ADMITERATORDONE) {
                            tst = tst2;
                        }
                        dbhostDone = 1;

                    } else if (!cfgutil_HostNameIsAlias
                               (hostName, hostNameAlias, &isAlias, &tst2)) {
                        tst = tst2;
                        dbhostDone = 1;

                    } else if (isAlias) {
                        dbhostFound = 1;
                        dbhostDone = 1;
                    }
                }

                if (!dbhostFound) {
                    *hostNameAlias = '\0';
                }

                if (!bos_HostGetDone(dbIter, &tst2)) {
                    tst = tst2;
                }
            }

            if (!bos_ServerClose(bosHandle, &tst2)) {
                tst = tst2;
            }
        }

        if (!afsclient_CellClose(cellHandle, &tst2)) {
            tst = tst2;
        }
    }

    if (tst != 0) {
        /* indicate failure */
        rc = 0;
    }
    if (st != NULL) {
        *st = tst;
    }
    return rc;
}
Exemple #8
0
int
main(int argc, char *argv[])
{
    int rc;
    afs_status_t st = 0;
    struct rx_connection *conn;
    char *srvrName;
    long srvrPort;
    void *cellHandle;
    void *iterator;
    afs_RPCStats_t stats;
    char ifName[128];
    char role[8];
    const char **funcList;
    int funcListLen;
    int index;

    ParseArgs(argc, argv, &srvrName, &srvrPort);

    rc = afsclient_Init(&st);
    if (!rc) {
	fprintf(stderr, "afsclient_Init, status %d\n", st);
	exit(1);
    }

    rc = afsclient_NullCellOpen(&cellHandle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_NullCellOpen, status %d\n", st);
	exit(1);
    }

    rc = afsclient_RPCStatOpenPort(cellHandle, srvrName, srvrPort, &conn,
				   &st);
    if (!rc) {
	fprintf(stderr, "afsclient_RPCStatOpenPort, status %d\n", st);
	exit(1);
    }

    rc = util_RPCStatsGetBegin(conn, RXSTATS_RetrieveProcessRPCStats,
			       &iterator, &st);
    if (!rc) {
	fprintf(stderr, "util_RPCStatsGetBegin, status %d\n", st);
	exit(1);
    }

    while (util_RPCStatsGetNext(iterator, &stats, &st)) {
	index = stats.s.stats_v1.func_index;

	if (index == 0) {
	    GetPrintStrings(&stats, ifName, role, &funcList, &funcListLen);
	    printf("\nProcess RPC stats for %s accessed as a %s\n\n", ifName,
		   role);
	}

	if (index >= funcListLen) {
	    printf("    Function index %d\n", index);
	} else {
	    printf("    %s\n", funcList[index]);
	}

	if (stats.s.stats_v1.invocations != 0) {
	    printf("\tinvoc %"AFS_UINT64_FMT
		   " bytes_sent %"AFS_UINT64_FMT
		   " bytes_rcvd %"AFS_UINT64_FMT"\n",
		   stats.s.stats_v1.invocations,
		   stats.s.stats_v1.bytes_sent,
		   stats.s.stats_v1.bytes_rcvd);
	    printf("\tqsum %d.%06d qsqr %d.%06d"
		   " qmin %d.%06d qmax %d.%06d\n",
		   stats.s.stats_v1.queue_time_sum.sec,
		   stats.s.stats_v1.queue_time_sum.usec,
		   stats.s.stats_v1.queue_time_sum_sqr.sec,
		   stats.s.stats_v1.queue_time_sum_sqr.usec,
		   stats.s.stats_v1.queue_time_min.sec,
		   stats.s.stats_v1.queue_time_min.usec,
		   stats.s.stats_v1.queue_time_max.sec,
		   stats.s.stats_v1.queue_time_max.usec);
	    printf("\txsum %d.%06d xsqr %d.%06d"
		   " xmin %d.%06d xmax %d.%06d\n",
		   stats.s.stats_v1.execution_time_sum.sec,
		   stats.s.stats_v1.execution_time_sum.usec,
		   stats.s.stats_v1.execution_time_sum_sqr.sec,
		   stats.s.stats_v1.execution_time_sum_sqr.usec,
		   stats.s.stats_v1.execution_time_min.sec,
		   stats.s.stats_v1.execution_time_min.usec,
		   stats.s.stats_v1.execution_time_max.sec,
		   stats.s.stats_v1.execution_time_max.usec);
	} else {
	    printf("\tNever invoked\n");
	}
    }
    if (st != ADMITERATORDONE) {
	fprintf(stderr, "util_RPCStatsGetNext, status %d\n", st);
	exit(1);
    }
    printf("\n");

    rc = util_RPCStatsGetDone(iterator, &st);
    if (!rc) {
	fprintf(stderr, "util_RPCStatsGetDone, status %d\n", st);
	exit(1);
    }

    rc = afsclient_RPCStatClose(conn, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_RPCStatClose, status %d\n", st);
	exit(1);
    }

    rc = afsclient_CellClose(cellHandle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_CellClose, status %d\n", st);
	exit(1);
    }

    exit(0);
}
Exemple #9
0
/*
 * cfg_HostSetAfsPrincipal() -- Put AFS server principal (afs) key in
 *     host's KeyFile; principal is created if it does not exist.
 *
 *     If first server host in cell, passwd must be initial password for
 *     the afs principal; the afs principal is created.
 *
 *     If additional server host, passwd can be specified or NULL; the
 *     afs principal must already exist by definition.  If passwd is NULL
 *     then an attempt is made to fetch the afs key.  If the key fetch fails
 *     because pre 3.5 database servers are in use (which will only return a
 *     key checksum) then the function fails with a return status of
 *     ADMCFGAFSKEYNOTAVAILABLE; in this case the function should be called
 *     again with passwd specified.  If passwd is specified (not NULL) but the
 *     password key fails a checksum comparison with the current afs key
 *     then the function fails with a return status of ADMCFGAFSPASSWDINVALID.
 *
 * ASSUMPTIONS: Client configured and BOS server started; if first host in
 *     cell then Authentication server must be started as well.
 */
int ADMINAPI
cfg_HostSetAfsPrincipal(void *hostHandle,	/* host config handle */
			short isFirst,	/* first server in cell flag */
			const char *passwd,	/* afs initial password */
			afs_status_p st)
{				/* completion status */
    int rc = 1;
    afs_status_t tst2, tst = 0;
    cfg_host_p cfg_host = (cfg_host_p) hostHandle;

    /* validate parameters */

    if (!cfgutil_HostHandleValidate(cfg_host, &tst2)) {
	tst = tst2;
    } else if ((isFirst && passwd == NULL)
	       || (passwd != NULL && *passwd == '\0')) {
	tst = ADMCFGPASSWDNULL;
    }

    /* put afs key in host's KeyFile */

    if (tst == 0) {
	kas_identity_t afsIdentity;
	kas_encryptionKey_t afsKey;
	int afsKvno = 0;

	strcpy(afsIdentity.principal, "afs");
	afsIdentity.instance[0] = '\0';

	if (isFirst) {
	    /* create afs principal */
	    if (!kas_PrincipalCreate
		(cfg_host->cellHandle, NULL, &afsIdentity, passwd, &tst2)
		&& tst2 != KAEXIST) {
		/* failed to create principal (and not because existed) */
		tst = tst2;
	    }
	}

	if (tst == 0) {
	    /* retrive afs principal information to verify or obtain key */
	    kas_principalEntry_t afsEntry;

	    if (!kas_PrincipalGet
		(cfg_host->cellHandle, NULL, &afsIdentity, &afsEntry,
		 &tst2)) {
		tst = tst2;
	    } else {
		if (passwd != NULL) {
		    /* password given; form key and verify as most recent */
		    kas_encryptionKey_t passwdKey;
		    unsigned int passwdKeyCksum;

		    if (!kas_StringToKey
			(cfg_host->cellName, passwd, &passwdKey, &tst2)
			|| !kas_KeyCheckSum(&passwdKey, &passwdKeyCksum,
					    &tst2)) {
			/* failed to form key or key checksum */
			tst = tst2;

		    } else if (passwdKeyCksum != afsEntry.keyCheckSum) {
			/* passwd string does not generate most recent key;
			 * check if passwd string embeds key directly.
			 */
			if (KasKeyEmbeddedInString(passwd, &passwdKey)) {
			    /* passwd string embeds kas key */
			    if (!kas_KeyCheckSum
				(&passwdKey, &passwdKeyCksum, &tst2)) {
				tst = tst2;
			    } else if (passwdKeyCksum != afsEntry.keyCheckSum) {
				/* passwd string does not embed valid key */
				tst = ADMCFGAFSPASSWDINVALID;
			    }
			} else {
			    /* passwd string does NOT embed key */
			    tst = ADMCFGAFSPASSWDINVALID;
			}
		    }

		    if (tst == 0) {
			/* passwd seems to generate/embed most recent key */
			afsKey = passwdKey;
			afsKvno = afsEntry.keyVersion;
		    }

		} else {
		    /* password NOT given; check if key retrieved since
		     * pre 3.5 database servers only return key checksum
		     */
		    if (KasKeyIsZero(&afsEntry.key)) {
			tst = ADMCFGAFSKEYNOTAVAILABLE;
		    } else {
			afsKey = afsEntry.key;
			afsKvno = afsEntry.keyVersion;
		    }
		}
	    }
	}

	if (tst == 0) {
	    /* add key to host's KeyFile; RPC must be unauthenticated;
	     * bosserver is presumed to be in noauth mode.
	     */
	    void *cellHandle, *bosHandle;

	    if (!afsclient_NullCellOpen(&cellHandle, &tst2)) {
		tst = tst2;
	    } else {
		if (!bos_ServerOpen
		    (cellHandle, cfg_host->hostName, &bosHandle, &tst2)) {
		    tst = tst2;
		} else {
		    if (!bos_KeyCreate(bosHandle, afsKvno, &afsKey, &tst2)
			&& tst2 != BZKEYINUSE) {
			/* failed to add key (and not because existed) */
			tst = tst2;
		    }

		    if (!bos_ServerClose(bosHandle, &tst2)) {
			tst = tst2;
		    }
		}

		if (!afsclient_CellClose(cellHandle, &tst2)) {
		    tst = tst2;
		}
	    }
	}
    }

    if (tst != 0) {
	rc = 0;
    }
    if (st != NULL) {
	*st = tst;
    }
    return rc;
}