AFS
view release on metacpan or search on metacpan
sprintf(buffer, "VLDB: no permission access for call\n");
break;
case VOLSERREAD_DUMPERROR:
sprintf(buffer, "VOLSER: Problems encountered in reading the dump file !\n");
break;
case VOLSERDUMPERROR:
sprintf(buffer, "VOLSER: Problems encountered in doing the dump !\n");
break;
case VOLSERATTACH_ERROR:
sprintf(buffer, "VOLSER: Could not attach the volume\n");
break;
case VOLSERDETACH_ERROR:
sprintf(buffer, "VOLSER: Could not detach the volume\n");
break;
case VOLSERILLEGAL_PARTITION:
sprintf(buffer, "VOLSER: encountered illegal partition number\n");
break;
case VOLSERBAD_ACCESS:
sprintf(buffer, "VOLSER: permission denied, not a super user\n");
break;
case VOLSERVLDB_ERROR:
sprintf(buffer, "VOLSER: error detected in the VLDB\n");
break;
case VOLSERBADNAME:
sprintf(buffer, "VOLSER: error in volume name\n");
break;
case VOLSERVOLMOVED:
sprintf(buffer, "VOLSER: volume has moved\n");
break;
case VOLSERBADOP:
sprintf(buffer, "VOLSER: illegal operation\n");
break;
case VOLSERBADRELEASE:
sprintf(buffer, "VOLSER: release could not be completed\n");
break;
case VOLSERVOLBUSY:
sprintf(buffer, "VOLSER: volume is busy\n");
break;
case VOLSERNO_MEMORY:
sprintf(buffer, "VOLSER: volume server is out of memory\n");
break;
case VOLSERNOVOL:
sprintf(buffer,
"VOLSER: no such volume - location specified incorrectly or volume does not exist\n");
break;
case VOLSERMULTIRWVOL:
sprintf(buffer,
"VOLSER: multiple RW volumes with same ID, one of which should be deleted\n");
break;
case VOLSERFAILEDOP:
sprintf(buffer, "VOLSER: not all entries were successfully processed\n");
break;
default:
sprintf(buffer, "Unknown ERROR code\n");
break;
}
return 0;
}
#ifdef AFS_PTHREAD_ENV
void IOMGR_Sleep (seconds)
int seconds;
{
double i,j;
croak("DEBUG: IOMGR_Sleep not available ...\nPlease inform the author...");
j = 0.0;
i = 1.0/j;
}
void clock_UpdateTime ()
{
double i,j;
croak("DEBUG: clock_UpdateTime not available ...\nPlease inform the author.. .");
j = 0.0;
i = 1.0/j;
}
int clock_haveCurrentTime ()
{
double i,j;
croak("DEBUG: clock_haveCurrentTime not available...\nPlease inform the auth or...");
j = 0.0;
i = 1.0/j;
return 1;
}
#endif /* AFS_PTHREAD_ENV*/
static int32 not_here(s)
char *s;
{
croak("%s not implemented on this architecture or under this AFS version", s);
return -1;
}
int PrintDiagnostics(astring, acode)
char *astring;
afs_int32 acode;
{
if (acode == EACCES) {
fprintf(STDERR, "You are not authorized to perform the 'vos %s' command (%d)\n",
astring, acode);
}
else {
fprintf(STDERR, "Error in vos %s command.\n", astring);
PrintError("", acode);
}
return 0;
}
/* end of error handling macros */
/* general helper functions */
static struct afsconf_dir *cdir = NULL;
static char *config_dir = NULL;
static int32 internal_GetConfigDir()
{
if (cdir == NULL) {
}
static char *internal_GetLocalCell(code)
int32 *code;
{
static char localcell[MAXCELLCHARS] = "";
if (localcell[0]) {
*code = 0;
}
else {
*code = internal_GetConfigDir();
if (*code)
return NULL;
*code = afsconf_GetLocalCell(cdir, localcell, sizeof(localcell));
if (*code) {
char buffer[256];
sprintf(buffer, "GetLocalCell: Can't determine local cell name");
PSETCODE(buffer);
return NULL;
}
}
return localcell;
}
static void stolower(s)
char *s;
{
while (*s) {
if (isupper(*s))
*s = tolower(*s);
s++;
}
}
/* return 1 if name is all '-' or digits. Used to remove orphan
entries from ACls */
static int32 name_is_numeric(name)
char *name;
{
if (*name != '-' && !isdigit(*name))
return 0;
else
name++;
while (*name) {
if (!isdigit(*name))
return 0;
name++;
}
return 1; /* name is (most likely numeric) */
}
/* end of general helper functions */
/* helper functions for PTS class: */
static struct ubik_client *internal_pts_new(code, sec, cell)
int32 *code;
int32 sec;
char *cell;
{
struct rx_connection *serverconns[MAXSERVERS];
struct rx_securityClass *sc = NULL;
struct ktc_token token;
struct afsconf_cell info;
/* tpf nog 03/29/99
* caused by changes in ubikclient.c,v 2.20 1996/12/10
* and in ubikclient.c,v 2.24 1997/01/21
* struct ubik_client *client; */
struct ubik_client *client = 0;
struct ktc_principal prin;
int32 i;
*code = internal_GetConfigDir();
if (*code == 0)
*code = internal_GetCellInfo(cell, "afsprot", &info);
if (*code)
return NULL;
if (!rx_initialized) {
/* printf("pts DEBUG rx_Init\n"); */
*code = rx_Init(0);
if (*code) {
char buffer[256];
sprintf(buffer, "AFS::PTS: could not initialize Rx (%d)\n", *code);
BSETCODE(code, buffer);
return NULL;
}
rx_initialized = 1;
}
if (sec > 0) {
strcpy(prin.cell, info.name);
prin.instance[0] = 0;
strcpy(prin.name, "afs");
*code = ktc_GetToken(&prin, &token, sizeof(token), NULL);
if (*code) {
if (sec == 2) {
char buffer[256];
sprintf(buffer, "AFS::PTS: failed to get token for service AFS (%d)\n", *code);
BSETCODE(code, buffer);
return NULL; /* we want security or nothing */
}
sec = 0;
}
else {
sc = (struct rx_securityClass *) rxkad_NewClientSecurityObject
(rxkad_clear, &token.sessionKey, token.kvno,
token.ticketLen, token.ticket);
}
}
if (sec == 0)
sc = (struct rx_securityClass *) rxnull_NewClientSecurityObject();
else
sec = 2;
bzero(serverconns, sizeof(serverconns));
for (i = 0; i < info.numServers; i++) {
serverconns[i] = rx_NewConnection(info.hostAddr[i].sin_addr.s_addr,
info.hostAddr[i].sin_port, PRSRV, sc, sec);
}
*code = ubik_ClientInit(serverconns, &client);
if (*code) {
char buffer[256];
sprintf(buffer, "AFS::PTS: Can't initialize ubik connection to Protection server (%d)\n", *code);
BSETCODE(code, buffer);
return NULL;
}
*code = rxs_Release(sc);
return client;
}
static int32 internal_pr_name(server, id, name)
int32 id;
struct ubik_client *server;
char *name;
{
namelist lnames;
idlist lids;
register int32 code;
lids.idlist_len = 1;
lids.idlist_val = (int32 *) safemalloc(sizeof(int32));
*lids.idlist_val = id;
lnames.namelist_len = 0;
lnames.namelist_val = NULL;
code = ubik_Call(PR_IDToName, server, 0, &lids, &lnames);
if (lnames.namelist_val) {
strncpy(name, (char *) lnames.namelist_val, PR_MAXNAMELEN);
if (lnames.namelist_val)
free(lnames.namelist_val);
}
if (lids.idlist_val)
safefree(lids.idlist_val);
return code;
}
static int32 internal_pr_id(server, name, id, anon)
struct ubik_client *server;
char *name;
int32 *id;
int32 anon;
{
namelist lnames;
idlist lids;
int32 code;
if (convert_numeric_names && name_is_numeric(name)) {
*id = atoi(name);
return 0;
}
lids.idlist_len = 0;
lids.idlist_val = 0;
lnames.namelist_len = 1;
lnames.namelist_val = (prname *) safemalloc(PR_MAXNAMELEN);
stolower(name);
strncpy((char *) lnames.namelist_val, name, PR_MAXNAMELEN);
code = ubik_Call(PR_NameToID, server, 0, &lnames, &lids);
case CDOT | CSTAR:
curlp = lp;
while (*lp++);
goto star;
case CCHR | CSTAR:
curlp = lp;
while (*lp++ == *ep);
ep++;
goto star;
case CCL | CSTAR:
case NCCL | CSTAR:
curlp = lp;
while (cclass(ep, *lp++, ep[-1] == (CCL | CSTAR)));
ep += *ep;
goto star;
star:
do {
lp--;
if (rv = advance(lp, ep))
return (rv);
} while (lp > curlp);
return (0);
default:
return (-1);
}
}
static int
backref(register int i, register char *lp)
{
register char *bp;
bp = braslist[i];
while (*bp++ == *lp++)
if (bp >= braelist[i])
return (1);
return (0);
}
static int
cclass(register char *set, register char c, int af)
{
register int n;
if (c == 0)
return (0);
n = *set++;
while (--n)
if (*set++ == c)
return (af);
return (!af);
}
/* copy taken from <src/ubik/uinit.c> OpenAFS-1.4.14.1 */
static afs_int32
internal_ugen_ClientInit(int noAuthFlag, const char *confDir, char *cellName, afs_int32 sauth,
struct ubik_client **uclientp, int (*secproc) (),
char *funcName, afs_int32 gen_rxkad_level,
afs_int32 maxservers, char *serviceid, afs_int32 deadtime,
afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
{
afs_int32 code, scIndex, i;
struct afsconf_cell info;
struct afsconf_dir *tdir;
struct ktc_principal sname;
struct ktc_token ttoken;
struct rx_securityClass *sc;
/* This must change if VLDB_MAXSERVERS becomes larger than MAXSERVERS */
static struct rx_connection *serverconns[MAXSERVERS];
char cellstr[64];
if (!rx_initialized) {
/* printf("ugen DEBUG rx_Init\n"); */
code = rx_Init(0);
if (code) {
char buffer[256];
sprintf(buffer, "%s: could not initialize rx.\n", funcName);
VSETCODE(code, buffer);
return (code);
}
rx_initialized = 1;
}
rx_SetRxDeadTime(deadtime);
if (sauth) { /* -localauth */
tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
if (!tdir) {
char buffer[256];
sprintf(buffer,
"%s: Could not process files in configuration directory (%s).\n",
funcName, AFSDIR_SERVER_ETC_DIRPATH);
code = -1;
VSETCODE(code, buffer);
return (code);
}
code = afsconf_ClientAuth(tdir, &sc, &scIndex); /* sets sc,scIndex */
if (code) {
afsconf_Close(tdir);
char buffer[256];
sprintf(buffer,
"%s: Could not get security object for -localAuth\n",
funcName);
VSETCODE(code, buffer);
return (code);
}
code = afsconf_GetCellInfo(tdir, tdir->cellName, serviceid, &info);
if (code) {
afsconf_Close(tdir);
char buffer[256];
sprintf(buffer,
"%s: can't find cell %s's hosts in %s/%s\n",
funcName, cellName, AFSDIR_SERVER_ETC_DIRPATH,
AFSDIR_CELLSERVDB_FILE);
VSETCODE(code, buffer);
return (code);
}
} else { /* not -localauth */
tdir = afsconf_Open(confDir);
if (!tdir) {
char buffer[256];
sprintf(buffer,
"%s: Could not process files in configuration directory (%s).\n",
funcName, confDir);
code = -1;
VSETCODE(code, buffer);
return (code);
}
if (!cellName) {
code = afsconf_GetLocalCell(tdir, cellstr, sizeof(cellstr));
if (code) {
char buffer[256];
sprintf(buffer,
"%s: can't get local cellname, check %s/%s\n",
funcName, confDir, AFSDIR_THISCELL_FILE);
VSETCODE(code, buffer);
return (code);
}
cellName = cellstr;
}
code = afsconf_GetCellInfo(tdir, cellName, serviceid, &info);
if (code) {
char buffer[256];
sprintf(buffer,
"%s: can't find cell %s's hosts in %s/%s\n",
funcName, cellName, confDir, AFSDIR_CELLSERVDB_FILE);
VSETCODE(code, buffer);
return (code);
}
if (noAuthFlag) /* -noauth */
scIndex = 0;
else { /* not -noauth */
strcpy(sname.cell, info.name);
sname.instance[0] = 0;
strcpy(sname.name, "afs");
code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
if (code) { /* did not get ticket */
fprintf(stderr,
"%s: Could not get afs tokens, running unauthenticated.\n",
funcName);
scIndex = 0;
} else { /* got a ticket */
scIndex = 2;
if ((ttoken.kvno < 0) || (ttoken.kvno > 256)) {
fprintf(stderr,
"%s: funny kvno (%d) in ticket, proceeding\n",
funcName, ttoken.kvno);
}
}
}
char buffer[256];
switch (scIndex) {
case 0:
sc = rxnull_NewClientSecurityObject();
break;
case 2:
sc = rxkad_NewClientSecurityObject(gen_rxkad_level,
&ttoken.sessionKey,
ttoken.kvno, ttoken.ticketLen,
ttoken.ticket);
break;
default:
sprintf(buffer, "%s: unsupported security index %d\n",
funcName, scIndex);
code = 1;
VSETCODE(code, buffer);
return (code);
break;
}
}
afsconf_Close(tdir);
if (secproc) /* tell UV module about default authentication */
(*secproc) (sc, scIndex);
if (server) {
serverconns[0] = rx_NewConnection(server, port,
usrvid, sc, scIndex);
} else {
if (info.numServers > maxservers) {
char buffer[256];
sprintf(buffer,
"%s: info.numServers=%d (> maxservers=%d)\n",
funcName, info.numServers, maxservers);
code = 1;
VSETCODE(code, buffer);
return (code);
}
for (i = 0; i < info.numServers; i++) {
serverconns[i] =
rx_NewConnection(info.hostAddr[i].sin_addr.s_addr,
info.hostAddr[i].sin_port, usrvid,
sc, scIndex);
}
}
/* Are we just setting up connections, or is this really ubik stuff? */
if (uclientp) {
*uclientp = 0;
code = ubik_ClientInit(serverconns, uclientp);
if (code) {
char buffer[256];
sprintf(buffer, "%s: ubik client init failed.\n", funcName);
VSETCODE(code, buffer);
return (code);
}
}
return 0;
}
/* copy taken from <src/volser/vsutils.c> OpenAFS-1.4.14.1 */
static afs_int32
internal_vsu_ClientInit(int noAuthFlag, const char *confDir, char *cellName, afs_int32 sauth,
struct ubik_client **uclientp, int (*secproc)())
{
return internal_ugen_ClientInit(noAuthFlag, confDir, cellName, sauth, uclientp,
secproc, "internal_vsu_ClientInit", vsu_rxkad_level,
VLDB_MAXSERVERS, AFSCONF_VLDBSERVICE, 90,
0, 0, USER_SERVICE_ID);
}
/* end of helper functions for VOS && VLDB class */
/* helper functions for VOS class: */
#ifndef OpenAFS
void vsu_SetCrypt(cryptflag)
int cryptflag;
{
if (cryptflag) {
vsu_rxkad_level = rxkad_crypt;
}
else {
vsu_rxkad_level = rxkad_auth;
}
}
#endif
int32 GetVolumeInfo(volid, server, part, voltype, rentry)
afs_int32 volid, *server, *part, *voltype;
register struct nvldbentry *rentry;
{
afs_int32 vcode;
int i, index = -1;
vcode = VLDB_GetEntryByID(volid, -1, rentry);
if (vcode) {
char buffer[256];
sprintf(buffer, "Could not fetch the entry for volume %u from VLDB \n", volid);
VSETCODE(vcode, buffer);
return (vcode);
}
MapHostToNetwork(rentry);
if (volid == rentry->volumeId[ROVOL]) {
*voltype = ROVOL;
for (i = 0; i < rentry->nServers; i++) {
if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL) &&
!(rentry->serverFlags[i] & RO_DONTUSE))
index = i;
}
if (index == -1) {
char buffer[256];
sprintf(buffer, "RO volume is not found in VLDB entry for volume %u\n",
volid);
VSETCODE(-1, buffer);
return -1;
}
*server = rentry->serverNumber[index];
*part = rentry->serverPartition[index];
return 0;
}
index = Lp_GetRwIndex(rentry);
if (index == -1) {
char buffer[256];
sprintf(buffer, "RW Volume is not found in VLDB entry for volume %u\n", volid);
}
else {
safe_hv_store(stats, "inUse", 5, newSVpv("Off-line", 8), 0);
(*a_totalNotOKP)++;
}
MapPartIdIntoName(a_partID, pname);
strcpy(hostname, (char *) hostutil_GetNameByINet(a_servID));
safe_hv_store(stats, "server", 6, newSVpv(hostname, strlen((char *) hostname)), 0);
safe_hv_store(stats, "partition", 9, newSVpv(pname, strlen(pname)), 0);
safe_hv_store(stats, "parentID", 8, newSViv(a_xInfoP->parentID), 0);
safe_hv_store(stats, "cloneID", 7, newSViv(a_xInfoP->cloneID), 0);
safe_hv_store(stats, "backupID", 8, newSViv(a_xInfoP->backupID), 0);
safe_hv_store(stats, "maxquota", 8, newSViv(a_xInfoP->maxquota), 0);
safe_hv_store(stats, "creationDate", 12, newSViv(a_xInfoP->creationDate), 0);
#ifdef OpenAFS /* copy taken from <src/volser/vos.c> OpenAFS-1.2.11 FULL_LISTVOL_SWITCH*/
safe_hv_store(stats, "copyDate", 8, newSViv(a_xInfoP->copyDate), 0);
if (!a_xInfoP->backupDate)
safe_hv_store(stats, "backupDate", 10, newSVpv("Never", 5), 0);
else
safe_hv_store(stats, "backupDate", 10, newSViv(a_xInfoP->backupDate), 0);
if (a_xInfoP->accessDate)
safe_hv_store(stats, "accessDate", 10, newSViv(a_xInfoP->accessDate), 0);
#endif
if (!a_xInfoP->updateDate) {
safe_hv_store(stats, "updateDate", 10, newSVpv("Never", 5), 0);
}
else {
safe_hv_store(stats, "updateDate", 10, newSViv(a_xInfoP->updateDate), 0);
}
safe_hv_store(stats, "dayUse", 6, newSViv(a_xInfoP->dayUse), 0);
safe_hv_store(stat1, "samenet", 7,
newSViv(a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]), 0);
safe_hv_store(stat1, "samenetauth", 11,
newSViv(a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]), 0);
safe_hv_store(stat1, "diffnet", 7,
newSViv(a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]), 0);
safe_hv_store(stat1, "diffnetauth", 11,
newSViv(a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]), 0);
safe_hv_store(stats, "Reads", 5, newRV_inc((SV *) (stat1)), 0);
safe_hv_store(stat2, "samenet", 7,
newSViv(a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]), 0);
safe_hv_store(stat2, "samenetauth", 11,
newSViv(a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]), 0);
safe_hv_store(stat2, "diffnet", 7,
newSViv(a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]), 0);
safe_hv_store(stat2, "diffnetauth", 11,
newSViv(a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]), 0);
safe_hv_store(stats, "Writes", 6, newRV_inc((SV *) (stat2)), 0);
safe_hv_store(stat3, "fileSameAuthor", 12,
newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0]), 0);
safe_hv_store(stat3, "fileDiffAuthor", 12,
newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0]), 0);
safe_hv_store(stat3, "dirSameAuthor", 11,
newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0]), 0);
safe_hv_store(stat3, "dirDiffAuthor", 11,
newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]), 0);
safe_hv_store(stats, "0-60sec", 7, newRV_inc((SV *) (stat3)), 0);
safe_hv_store(stat4, "fileSameAuthor", 12,
newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1]), 0);
safe_hv_store(stat4, "fileDiffAuthor", 12,
newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1]), 0);
safe_hv_store(stat4, "dirSameAuthor", 11,
newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1]), 0);
safe_hv_store(stat4, "dirDiffAuthor", 11,
newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]), 0);
safe_hv_store(stats, "1-10min", 7, newRV_inc((SV *) (stat4)), 0);
safe_hv_store(stat5, "fileSameAuthor", 12,
newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2]), 0);
safe_hv_store(stat5, "fileDiffAuthor", 12,
newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2]), 0);
safe_hv_store(stat5, "dirSameAuthor", 11,
newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2]), 0);
safe_hv_store(stat5, "dirDiffAuthor", 11,
newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]), 0);
safe_hv_store(stats, "10min-1hr", 9, newRV_inc((SV *) (stat5)), 0);
safe_hv_store(stat6, "fileSameAuthor", 12,
newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3]), 0);
safe_hv_store(stat6, "fileDiffAuthor", 12,
newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3]), 0);
safe_hv_store(stat6, "dirSameAuthor", 11,
newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3]), 0);
safe_hv_store(stat6, "dirDiffAuthor", 11,
newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]), 0);
safe_hv_store(stats, "1hr-1day", 8, newRV_inc((SV *) (stat6)), 0);
safe_hv_store(stat7, "fileSameAuthor", 12,
newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4]), 0);
safe_hv_store(stat7, "fileDiffAuthor", 12,
newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4]), 0);
safe_hv_store(stat7, "dirSameAuthor", 11,
newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4]), 0);
safe_hv_store(stat7, "dirDiffAuthor", 11,
newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]), 0);
safe_hv_store(stats, "1day-1wk", 8, newRV_inc((SV *) (stat7)), 0);
safe_hv_store(stat8, "fileSameAuthor", 12,
newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5]), 0);
safe_hv_store(stat8, "fileDiffAuthor", 12,
newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5]), 0);
safe_hv_store(stat8, "dirSameAuthor", 11,
newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5]), 0);
safe_hv_store(stat8, "dirDiffAuthor", 11,
newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]), 0);
safe_hv_store(stats, ">1wk", 4, newRV_inc((SV *) (stat8)), 0);
} /*Volume status OK */
else if (a_xInfoP->status == VBUSY) {
(*a_totalBusyP)++;
qPut(&busyHead, a_xInfoP->volid);
} /*Busy volume */
else {
(*a_totalNotOKP)++;
qPut(¬okHead, a_xInfoP->volid);
} /*Screwed volume */
} /*myXDisplayFormat */
int base;
total = 0; /* initialize things */
/* skip over leading spaces */
while ((tc = *as)) {
if (tc != ' ' && tc != '\t')
break;
}
/* compute the base */
if (*as == '0') {
as++;
if (*as == 'x' || *as == 'X') {
base = 16;
as++;
}
else
base = 8;
}
else
base = 10;
/* compute the # itself */
while ((tc = *as)) {
if (!ismeta(tc, base))
return -1;
total *= base;
total += getmeta(tc);
as++;
}
*aval = total;
return 0;
}
#endif
/* keep those lines small */
static char *em(acode)
afs_int32 acode;
{
if (acode == -1)
return "communications failure (-1)";
else if (acode == -3)
return "communications timeout (-3)";
else
return (char *) error_message(acode);
}
static struct rx_connection *internal_bos_new(code, hostname, localauth, noauth, aencrypt,
tname)
int32 *code;
char *hostname;
int localauth;
int noauth;
int aencrypt;
char *tname;
{
struct hostent *th;
register struct rx_connection *tconn;
struct rx_securityClass *sc[3];
int scIndex;
afs_int32 addr;
int encryptLevel;
struct ktc_principal sname;
struct ktc_token ttoken;
/* printf("bos DEBUG-1: %s \n", cdir); */
th = (struct hostent *) hostutil_GetHostByName(hostname);
if (!th) {
char buffer[256];
sprintf(buffer, "AFS::BOS: can't find address for host '%s'\n", hostname);
*code = -1;
BSETCODE(code, buffer);
/* printf("bos DEBUG-1: %s\n", buffer); */
return NULL;
}
/* Copy(th->h_addr, &addr, sizeof(afs_int32), afs_int32); */
Copy(th->h_addr, &addr, th->h_length, char);
/* get tokens for making authenticated connections */
if (!rx_initialized) {
/* printf("bos DEBUG rx_Init\n"); */
*code = rx_Init(0);
if (*code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: could not initialize rx (%d)\n", *code);
BSETCODE(code, buffer);
/* printf("bos DEBUG-2\n"); */
return NULL;
}
}
rx_initialized = 1;
*code = ka_Init(0);
if (*code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: could not initialize ka (%d)\n", *code);
BSETCODE(code, buffer);
/* printf("bos DEBUG-3\n"); */
return NULL;
}
if (localauth)
internal_GetServerConfigDir();
else
internal_GetConfigDir();
/* printf("bos DEBUG-2: %s\n", cdir->name); */
if (!cdir) {
*code = errno;
SETCODE(code);
/* printf("bos DEBUG-4\n"); */
return NULL;
}
struct afsconf_cell info;
/* next call expands cell name abbrevs for us and handles looking up
* local cell */
*code = internal_GetCellInfo(tname, (char *) 0, &info);
if (*code) {
char buffer[256];
sprintf(buffer, "AFS::BOS %d (can't find cell '%s' in cell database)",
*code, (tname ? tname : "<default>"));
BSETCODE(code, buffer);
/* printf("bos DEBUG-5\n"); */
return NULL;
}
strcpy(sname.cell, info.name);
sname.instance[0] = 0;
strcpy(sname.name, "afs");
sc[0] = (struct rx_securityClass *) rxnull_NewClientSecurityObject();
sc[1] = 0;
sc[2] = (struct rx_securityClass *) NULL;
scIndex = 0;
if (!noauth) { /* not -noauth */
if (localauth) { /* -localauth */
*code = afsconf_GetLatestKey(cdir, 0, 0);
if (*code)
fprintf(stderr, "AFS::BOS %d (getting key from local KeyFile)", *code);
else {
if (aencrypt)
*code = afsconf_ClientAuthSecure(cdir, &sc[2], &scIndex);
else
*code = afsconf_ClientAuth(cdir, &sc[2], &scIndex);
if (*code)
fprintf(stderr, "AFS::BOS %d (calling ClientAuth)", *code);
else if (scIndex != 2) /* this shouldn't happen */
sc[scIndex] = sc[2];
}
}
else { /* not -localauth, check for tickets */
*code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
if (*code == 0) {
/* have tickets, will travel */
if (ttoken.kvno >= 0 && ttoken.kvno <= 256);
else {
fprintf(stderr,
"AFS::BOS: funny kvno (%d) in ticket, proceeding\n",
ttoken.kvno);
}
/* kerberos tix */
if (aencrypt)
encryptLevel = rxkad_crypt;
else
encryptLevel = rxkad_clear;
sc[2] = (struct rx_securityClass *)
rxkad_NewClientSecurityObject
(encryptLevel, &ttoken.sessionKey,
ttoken.kvno, ttoken.ticketLen, ttoken.ticket);
scIndex = 2;
}
else
fprintf(stderr, "AFS::BOS %d (getting tickets)", *code);
}
if ((scIndex == 0) || (sc[scIndex] == 0)) {
fprintf(stderr, "AFS::BOS: running unauthenticated\n");
scIndex = 0;
}
}
tconn = rx_NewConnection(addr, htons(AFSCONF_NANNYPORT), 1, sc[scIndex], scIndex);
if (!tconn) {
char buffer[256];
sprintf(buffer, "AFS::BOS: could not create rx connection\n");
*code = -1;
BSETCODE(code, buffer);
/* printf("bos DEBUG-7\n"); */
return NULL;
}
rxs_Release(sc[scIndex]);
return tconn;
}
static int DoStat(stats, aname, aconn, aint32p, firstTime)
HV *stats;
IN char *aname;
IN register struct rx_connection *aconn;
IN int aint32p;
IN int firstTime; /* true iff first instance in cmd */
{
afs_int32 temp;
char buffer[500];
register afs_int32 code;
register afs_int32 i;
struct bozo_status istatus;
char *tp;
char *is1, *is2, *is3, *is4; /* instance strings */
char info[255];
tp = buffer;
code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
if (code) {
char buf[256];
sprintf(buf, "AFS::BOS: failed to get instance info for '%s' (%s)\n",
aname, em(code));
BSETCODE(code, buf);
return -1;
}
if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS)) {
char buf[256];
sprintf(buf, "Bosserver reports inappropriate access on server directories\n");
BSETCODE(-1, buf);
}
/*printf("Instance %s, ", aname); */
if (aint32p) {
/* printf("(type is %s) ", buffer); */
PPCODE:
{
if (!verb) {
verb = newSViv(0);
}
if (!timeout) {
timeout = newSViv(90);
}
if (!noauth) {
noauth = newSViv(0);
}
if (!localauth) {
localauth = newSViv(0);
}
if (!crypt) {
crypt = newSViv(0);
}
if (tcell && (tcell[0] == '\0' || tcell[0] == '0'))
tcell = NULL;
if ((verb) && (!SvIOKp(verb))) {
char buffer[256];
sprintf(buffer, "Flag \"verb\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
}
verbose = SvIV(verb);
if ((timeout) && (!SvIOKp(timeout))) {
char buffer[256];
sprintf(buffer, "Flag \"timeout\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
}
itimeout = SvIV(timeout);
if ((noauth) && (!SvIOKp(noauth))) {
char buffer[256];
sprintf(buffer, "Flag \"noauth\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
}
inoauth = SvIV(noauth);
if ((localauth) && (!SvIOKp(localauth))) {
char buffer[256];
sprintf(buffer, "Flag \"localauth\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
}
ilocalauth = SvIV(localauth);
if ((crypt) && (!SvIOKp(crypt))) {
char buffer[256];
sprintf(buffer, "Flag \"crypt\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
}
icrypt = SvIV(crypt);
/* Initialize the ubik_client connection */
rx_SetRxDeadTime(itimeout); /* timeout seconds inactivity before declared dead */
cstruct = (struct ubik_client *) 0;
if (icrypt) /* -crypt specified */
vsu_SetCrypt(1);
code = internal_vsu_ClientInit((inoauth != 0),
AFSDIR_CLIENT_ETC_DIRPATH, tcell, ilocalauth,
&cstruct, UV_SetSecurity);
if (code == 0) {
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "AFS::VOS", (void *) cstruct);
XSRETURN(1);
}
else {
XSRETURN_UNDEF;
}
}
int32
vos__DESTROY(self)
AFS::VOS self
PREINIT:
int32 code;
CODE:
{
code = ubik_ClientDestroy((struct ubik_client *) self);
/* printf("DEBUG-23 %d \n", code); */
SETCODE(code);
/* printf("DEBUG-24 \n"); */
RETVAL = (code == 0);
/* printf("DEBUG-25 \n"); */
}
OUTPUT:
RETVAL
void
vos_status(cstruct, aserver)
AFS::VOS cstruct
char *aserver
PREINIT:
afs_int32 server, code;
transDebugInfo *pntr;
afs_int32 count;
char buffer[256];
CODE:
{
server = GetServer(aserver);
if (!server) {
sprintf(buffer, "AFS::VOS: host '%s' not found in host table\n", aserver);
VSETCODE(-1, buffer);
XSRETURN_UNDEF;
}
code = UV_VolserStatus(server, &pntr, &count);
if (code) {
PrintDiagnostics("status", code);
SETCODE(1);
XSRETURN_UNDEF;
}
ST(0) = sv_newmortal();
SETCODE(0);
"Volume does not exist on server %s as indicated by the VLDB\n",
hostutil_GetNameByINet(aserver));
}
}
else {
sprintf(buffer, "examine");
}
if (pntr)
free(pntr);
VSETCODE(code, buffer);
XSRETURN_UNDEF;
}
else {
foundserv = 1;
MapPartIdIntoName(apart, apartName);
/* safe_hv_store(volinfo, "name", 4, newSVpv(name, strlen((char *) name)), 0); */
safe_hv_store(volinfo, "partition", 9, newSVpv(apartName, strlen((char *) apartName)), 0);
VolumeStats(volinfo, pntr, &entry, aserver, apart, voltype);
if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
/* The VLDB says there is no backup volume yet we found one on disk */
char buffer[256];
sprintf(buffer, "Volume %s does not exist in VLDB\n", name);
if (pntr)
free(pntr);
VSETCODE(ENOENT, buffer);
XSRETURN_UNDEF;
}
}
if (pntr)
free(pntr);
} while (voltype == ROVOL);
SETCODE(0);
ST(0) = sv_2mortal(newRV_inc((SV *) volinfo));
XSRETURN(1);
}
MODULE = AFS PACKAGE = AFS::VLDB PREFIX = vldb_
AFS::VLDB
vldb_new(class=0, verb=0, timeout=90, noauth=0, localauth=0, tcell=NULL, crypt=0)
char * class
int verb
int timeout
int noauth
int localauth
char * tcell
int crypt
PREINIT:
int32 code = -1;
extern int verbose;
PPCODE:
{
if (tcell && (tcell[0] == '\0' || tcell[0] == '0'))
tcell = NULL;
/* Initialize the ubik_client connection */
rx_SetRxDeadTime(timeout); /* timeout seconds inactivity before declared dead */
cstruct = (struct ubik_client *) 0;
verbose = verb;
if (crypt) /* -crypt specified */
vsu_SetCrypt(1);
code = internal_vsu_ClientInit((noauth != 0),
AFSDIR_CLIENT_ETC_DIRPATH, tcell, localauth,
&cstruct, UV_SetSecurity);
if (code == 0) {
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "AFS::VLDB", (void *) cstruct);
XSRETURN(1);
}
else
XSRETURN_UNDEF;
}
int32
vldb__DESTROY(self)
AFS::VLDB self
PREINIT:
int32 code = 0;
CODE:
{
code = ubik_ClientDestroy(self);
/* printf("DEBUG-23 %d \n", code); */
SETCODE(code);
/* printf("DEBUG-24 \n"); */
RETVAL = (code == 0);
/* printf("DEBUG-25 \n"); */
}
OUTPUT:
RETVAL
int32
vldb_addsite(cstruct, server, partition, id, roid=NULL, valid=0)
AFS::VLDB cstruct
char *server
char *partition
char *id
char *roid
int valid
PREINIT:
int32 code = 1;
CODE:
{
afs_int32 avolid, aserver, apart, err, arovolid=0;
char avolname[VOLSER_MAXVOLNAME + 1];
if (roid && (roid[0] == '\0' || roid[0] == '0'))
roid = NULL;
RETVAL = 0;
/* printf("vldb_addsite DEBUG-1 server %s part %s Vol/Id %s RO-Vol/ID %s ValID %d \n", server, partition, id, roid, valid); */
#ifdef OpenAFS_1_4
vsu_ExtractName(avolname, id);
#else
strcpy(avolname, id);
#endif
/* printf("vldb_addsite DEBUG-2 id %s avolname %s \n", id, avolname); */
avolid = vsu_GetVolumeID(avolname, cstruct, &err);
/* printf("vldb_addsite DEBUG-3 Vol-Nam %s Vol-ID %d \n", avolname, avolid); */
if (avolid == 0) {
OUTPUT:
RETVAL
int32
bos_setcellname(self, name)
AFS::BOS self
char *name
PREINIT:
int32 code = 0;
CODE:
{
not_here("AFS::BOS::setcellname");
code = BOZO_SetCellName(self, name);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to set cell (%s)\n", em(code));
BSETCODE(code, buffer);
}
}
OUTPUT:
RETVAL
void
bos_listkeys(self, showkey=0)
AFS::BOS self
int showkey
PREINIT:
afs_int32 i, kvno, code = 0;
struct ktc_encryptionKey tkey;
struct bozo_keyInfo keyInfo;
int everWorked = 0;
char index[5];
HV *list = (HV*)sv_2mortal((SV*)newHV());
PPCODE:
{
for (i = 0;; i++) {
HV *key = (HV *) sv_2mortal((SV *) newHV());
code = BOZO_ListKeys(self, i, &kvno, &tkey, &keyInfo);
if (code)
break;
everWorked = 1;
/* first check if key is returned */
if ((!ka_KeyIsZero((char *) &tkey, sizeof(tkey))) && showkey) {
/* ka_PrintBytes ((char *)&tkey, sizeof(tkey)); */
safe_hv_store(key, "key", 3, newSVpv((char *) &tkey, sizeof(tkey)), 0);
}
else {
if (keyInfo.keyCheckSum == 0) { /* shouldn't happen */
/* printf ("key version is %d\n", kvno); */
}
else {
safe_hv_store(key, "keyCheckSum", 11, newSVuv(keyInfo.keyCheckSum), 0);
}
}
sprintf(index, "%d", kvno);
safe_hv_store(list, index, strlen(index), newRV_inc((SV *) (key)), 0);
} /* for loop */
if (everWorked) {
/* fprintf(stderr, "Keys last changed on %d.\n", keyInfo.mod_sec); */
EXTEND(sp, 2);
PUSHs(sv_2mortal(newSViv(keyInfo.mod_sec)));
PUSHs(newRV_inc((SV *) (list)));
}
if (code != BZDOM) {
char buffer[256];
sprintf(buffer, "AFS::BOS: %s error encountered while listing keys\n", em(code));
BSETCODE(code, buffer);
}
else {
code = 0;
}
if (everWorked) {
XSRETURN(2);
}
else {
XSRETURN_EMPTY;
hv_undef(list);
}
}
int32
bos_getrestricted(self)
AFS::BOS self
CODE:
{
#ifdef BOS_RESTRICTED_MODE
int32 val, code;
RETVAL = 0;
code = BOZO_GetRestrictedMode(self, &val);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to get restricted mode (%s)\n", em(code));
BSETCODE(code, buffer);
}
RETVAL = val;
#else
RETVAL = 0;
not_here("AFS::BOS::getrestricted");
#endif
}
OUTPUT:
RETVAL
int32
bos_setrestricted(self, mode)
AFS::BOS self
char *mode
CODE:
{
#ifdef BOS_RESTRICTED_MODE
int32 val, code;
util_GetInt32(mode, &val);
code = BOZO_SetRestrictedMode(self, val);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to set restricted mode (%s)\n", em(code));
BSETCODE(code, buffer);
}
RETVAL = (code == 0);
#else
else {
/* salvage individual volume (don't shutdown fs first), just use
* single-shot cron bnode. Must leave server running when using this
* option, since salvager will ask file server for the volume */
afs_int32 err;
const char *confdir;
confdir = (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH);
code = internal_vsu_ClientInit( /* noauth */ 1, confdir, tmpname,
/* server auth */ 0, &cstruct, (int (*)()) 0);
if (code == 0) {
newID = vsu_GetVolumeID(volume, cstruct, &err);
if (newID == 0) {
char buffer[256];
sprintf(buffer, "AFS::BOS: can't interpret %s as volume name or ID\n",
volume);
BSETCODE(-1, buffer);
goto done;
}
sprintf(tname, "%u", newID);
}
else {
char buffer[256];
sprintf(buffer,
"AFS::BOS: can't initialize volume system client (code %d), trying anyway.\n",
code);
BSETCODE(code, buffer);
strncpy(tname, volume, sizeof(tname));
}
if (volutil_GetPartitionID(partition) < 0) {
/* can't parse volume ID, so complain before shutting down
* file server.
*/
char buffer[256];
sprintf(buffer, "AFS::BOS: can't interpret %s as partition ID.\n", partition);
BSETCODE(-1, buffer);
goto done;
}
/* fprintf(stderr, "Starting salvage of volume %d on partition %s.\n",
newID, partition); */
rc = DoSalvage(self, partition, tname, outName, showlog, parallel, tmpDir, orphans);
if (rc) {
code = rc;
goto done;
}
}
code = 0;
SETCODE(code);
done:
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
MODULE = AFS PACKAGE = AFS::PTS PREFIX = pts_
AFS::PTS
pts__new(class=0, sec=1, cell=0)
char * class
int32 sec
char * cell
PREINIT:
int32 code = -1;
AFS__PTS server;
PPCODE:
{
if (cell && (cell[0] == '\0' || cell[0] == '0'))
cell = NULL;
server = internal_pts_new(&code, sec, cell);
# SETCODE(code); wird tiefer gesetzt...
if (code == 0) {
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "AFS::PTS", (void *) server);
XSRETURN(1);
}
else
XSRETURN_UNDEF;
}
int32
pts__DESTROY(server)
AFS::PTS server
CODE:
{
int32 code;
/* printf("pts DEBUG ubik_ClientDestroy\n"); */
code = ubik_ClientDestroy(server);
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
void
pts_id(server,object,anon=1)
AFS::PTS server
SV * object
int32 anon
PPCODE:
{
if (!SvROK(object)) {
int32 code, id;
char *name;
name = (char *) SvPV(object, PL_na);
code = internal_pr_id(server, name, &id, anon);
ST(0) = sv_newmortal();
SETCODE(code);
if (code == 0)
sv_setiv(ST(0), id);
XSRETURN(1);
}
else if (SvTYPE(SvRV(object)) == SVt_PVAV) {
int32 code, id;
int i, len;
AV *av;
SV *sv;
char *name;
STRLEN namelen;
namelist lnames;
idlist lids;
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
lnames.namelist_len = len + 1;
lnames.namelist_val = (prname *) safemalloc(PR_MAXNAMELEN * (len + 1));
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
( run in 1.141 second using v1.01-cache-2.11-cpan-39bf76dae61 )