AFS

 view release on metacpan or  search on metacpan

src/AFS.xs  view on Meta::CPAN

#define SETCODE(code) set_code(code)
#define BSETCODE(code, msg) bv_set_code(code, msg)
#define VSETCODE(code, msg) bv_set_code(code, msg)
#define KSETCODE(code, msg) k_set_code(code, msg)
#define PSETCODE(msg) p_set_code(msg)

static int32 raise_exception = 0;

void safe_hv_store (HV* ahv,char * key ,int i ,SV * asv,int j) {
   if (! hv_store(ahv, key, i, asv, j)) {
       fprintf(stderr,"Panic ... internal error. hv_store failed.\n");
       exit(1);
   }
   return;
}

static void bv_set_code(code, msg)
    int32 code;
    const char *msg;
{
    SV *sv = get_sv("AFS::CODE", TRUE);

src/AFS.xs  view on Meta::CPAN

            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();

src/AFS.xs  view on Meta::CPAN

    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"); */

src/AFS.xs  view on Meta::CPAN


    if (aint32p > 1) {
        AV *av = (AV *) sv_2mortal((SV *) newAV());

        /* try to display all the parms */
        for (i = 0;; i++) {
            tp = buffer;
            code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
            if (code)
                break;
            /* fprintf(stderr, "    Command %d is '%s'\n", i+1, buffer); */
            av_push(av, newSVpv(buffer, strlen(buffer)));
        }
        safe_hv_store(stats, "command", 7, newRV_inc((SV *) (av)), 0);

        tp = buffer;
        code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
        if (!code) {
            /* Any type of failure is treated as not having a notifier program */
            /* printf("    Notifier  is '%s'\n", buffer); */
            safe_hv_store(stats, "notifier", 8, newSVpv(buffer, strlen(buffer)), 0);

src/AFS.xs  view on Meta::CPAN

    while (1) {
#ifdef AFS_PTHREAD_ENV
        sleep(5);
#else
        IOMGR_Sleep(5);
#endif /* AFS_PTHREAD_ENV*/
        tp = tbuffer;
        code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
        if (code)
            break;
        /* fprintf(stderr, "AFS::BOS: waiting for salvage to complete.\n"); */
    }
    if (code != BZNOENT) {
        char buffer[256];
        sprintf(buffer, "AFS::BOS: salvage failed (%s)\n", em(code));
        BSETCODE(code, buffer);
        goto done;
    }
    code = 0;

    /* now print the log file to the output file */
    /* fprintf(stderr, "AFS::BOS: salvage completed\n"); */
    if (aoutName || showlog) {
        fprintf(outFile, "SalvageLog:\n");
        tcall = rx_NewCall(aconn);
        /* MUST pass canonical (wire-format) salvager log path to bosserver */
        code = StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
        if (code) {
            rx_EndCall(tcall, code);
            goto done;
        }
        /* copy data */

src/AFS.xs  view on Meta::CPAN

            if ((aoverwrite == AFS_INC) || (aoverwrite == AFS_ABORT)) {
                char buffer[256];
                sprintf(buffer, "Volume does not exist; Will perform a full restore\n");
                VSETCODE(vcode, buffer);
            }
        }
        else if ((!ireadonly && Lp_GetRwIndex(&entry) == -1)     /* RW volume does not exist - do a full */
                 ||(ireadonly && !Lp_ROMatch(0, 0, &entry))) {   /* RO volume does not exist - do a full */
            restoreflags = RV_FULLRST;
            if ((aoverwrite == AFS_INC) || (aoverwrite == AFS_ABORT))
                fprintf(stderr, "%s Volume does not exist; Will perform a full restore\n",
                        ireadonly ? "RO" : "RW");

            if (avolid == 0) {
                avolid = entry.volumeId[voltype];
            }
            else if (entry.volumeId[voltype] != 0 && entry.volumeId[voltype] != avolid) {
                avolid = entry.volumeId[voltype];
            }
            aparentid = entry.volumeId[RWVOL];
        }

src/AFS.xs  view on Meta::CPAN

                    goto done;
                }

                /* Ask what to do */
                if (vol_elsewhere) {
                    char buffer[256];
                    sprintf(buffer,
                            "The volume %s %u already exists on a different server/part\n",
                            volname, entry.volumeId[voltype]);
                    VSETCODE(-1, buffer);
                    fprintf(stderr, "Do you want to do a full restore or abort? [fa](a): ");
                }
                else {
                    char buffer[256];
                    sprintf(buffer, "The volume %s %u already exists in the VLDB\n",
                            volname, entry.volumeId[voltype]);
                    VSETCODE(-1, buffer);
                    fprintf(stderr,
                            "Do you want to do a full/incremental restore or abort? [fia](a): ");
                }
                dc = c = getchar();
                while (!(dc == EOF || dc == '\n'))
                    dc = getchar();     /* goto end of line */
                if ((c == 'f') || (c == 'F'))
                    aoverwrite = AFS_FULL;
                else if ((c == 'i') || (c == 'I'))
                    aoverwrite = AFS_INC;
                else

src/AFS.xs  view on Meta::CPAN


            if (aoverwrite == AFS_ABORT) {
                char buffer[256];
                sprintf(buffer, "Volume exists; Aborting restore command\n");
                VSETCODE(-1, buffer);
                RETVAL = 0;
                goto done;
            }
            else if (aoverwrite == AFS_FULL) {
                restoreflags = RV_FULLRST;
                fprintf(stderr, "Volume exists; Will delete and perform full restore\n");
            }
            else if (aoverwrite == AFS_INC) {
                restoreflags = 0;
                if (vol_elsewhere) {
                    char buffer[256];
                    sprintf(buffer,
                            "%s volume %u already exists on a different server/part; not allowed\n",
                            ireadonly ? "RO" : "RW", avolid);
                    VSETCODE(-1, buffer);
                    RETVAL = 0;

src/AFS.xs  view on Meta::CPAN

            else
                sprintf(buffer, "AFS::VOS: partition %s does not exist on the server\n",
                        servername);
            VSETCODE(code ? code : -1, buffer);
            goto done;
        }
        code = VLDB_GetEntryByID(volid, -1, &entry);
        if (!code) {
            if (volid == entry.volumeId[RWVOL])
                backupid = entry.volumeId[BACKVOL];
            #fprintf(stderr,
            #        "Warning: Entry for volume number %u exists in VLDB (but we're zapping it anyway!)\n",
            #        volid);
        }
        if (zapbackupid) {
            volintInfo *pntr = (volintInfo *) 0;

            if (!backupid) {
                code = UV_ListOneVolume(server, part, volid, &pntr);
                if (!code) {
                    if (volid == pntr->parentID)

src/AFS.xs  view on Meta::CPAN

                av_push(av2, newSVpv(vllist->name, strlen(vllist->name)));
                fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n", vllist->name);
                totalFail++;
                continue;
            }
            /* printf("vos-backupsys DEBUG-19\n"); */
            if (aserver) {
                same = VLDB_IsSameAddrs(aserver, aserver1, &error);
                if (error) {
                    av_push(av2, newSVpv(vllist->name, strlen(vllist->name)));
                    fprintf(stderr,
                            "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
                            aserver, error);
                    totalFail++;
                    continue;
                }
            }
            /* printf("vos-backupsys DEBUG-20\n"); */
            if ((aserver && !same) || (apart && (apart != apart1))) {
                if (verbose) {
                    fprintf(STDOUT,

src/AFS.xs  view on Meta::CPAN

                }
                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 {

src/AFS.xs  view on Meta::CPAN

                sprintf(buffer, "Parameter only possible for MR-AFS fileserver.\n");
                BSETCODE(-1, buffer);
                goto done;
            }
        }

        if (all) {
            /* salvage whole enchilada */
            curGoal = GetServerGoal(self, "fs");
            if (curGoal == BSTAT_NORMAL) {
                fprintf(stderr, "AFS::BOS: shutting down fs.\n");
                code = BOZO_SetTStatus(self, "fs", BSTAT_SHUTDOWN);
                if (code) {
                    char buffer[256];
                    sprintf(buffer, "AFS::BOS: failed to stop 'fs' (%s)\n", em(code));
                    BSETCODE(code, buffer);
                    goto done;
                }
                code = BOZO_WaitAll(self);    /* wait for shutdown to complete */
                if (code) {
                    char buffer[256];
                    sprintf(buffer,
                            "AFS::BOS: failed to wait for file server shutdown, continuing.\n");
                    BSETCODE(code, buffer);
                }
            }
            /* now do the salvage operation */
            /* fprintf(stderr, "Starting salvage of everything.\n"); */
            rc = DoSalvage(self, (char *) 0, (char *) 0, outName, showlog, parallel, tmpDir,
                           orphans);
            if (curGoal == BSTAT_NORMAL) {
                /* fprintf(stderr, "AFS::BOS: restarting fs.\n"); */
                code = BOZO_SetTStatus(self, "fs", BSTAT_NORMAL);
                if (code) {
                    char buffer[256];
                    sprintf(buffer, "AFS::BOS: failed to restart 'fs' (%s)\n", em(code));
                    BSETCODE(code, buffer);
                    goto done;
                }
            }
            if (rc) {
                code = rc;

src/AFS.xs  view on Meta::CPAN

                 * file server.
                 */
                char buffer[256];
                sprintf(buffer, "AFS::BOS: can't interpret %s as partition ID.\n", partition);
                BSETCODE(-1, buffer);
                goto done;
            }
            curGoal = GetServerGoal(self, "fs");
            /* salvage a whole partition (specified by parms[1]) */
            if (curGoal == BSTAT_NORMAL) {
                /* fprintf(stderr, "AFS::BOS: shutting down fs.\n"); */
                code = BOZO_SetTStatus(self, "fs", BSTAT_SHUTDOWN);
                if (code) {
                    char buffer[256];
                    sprintf(buffer, "AFS::BOS: can't stop 'fs' (%s)\n", em(code));
                    BSETCODE(code, buffer);
                    goto done;
                }
                code = BOZO_WaitAll(self);    /* wait for shutdown to complete */
                if (code) {
                    char buffer[256];
                    sprintf(buffer,
                            "AFS::BOS: failed to wait for file server shutdown, continuing.\n");
                    BSETCODE(code, buffer);
                }
            }
            /* now do the salvage operation */
            /* fprintf(stderr, "Starting salvage of partition %s.\n", partition); */
            rc = DoSalvage(self, partition, (char *) 0,
                           outName, showlog, parallel, tmpDir, orphans);
            if (curGoal == BSTAT_NORMAL) {
                /* fprintf(stderr, "AFS::BOS: restarting fs.\n"); */
                code = BOZO_SetTStatus(self, "fs", BSTAT_NORMAL);
                if (code) {
                    char buffer[256];
                    sprintf(buffer, "AFS::BOS: failed to restart 'fs' (%s)\n", em(code));
                    BSETCODE(code, buffer);
                    goto done;
                }
            }
            if (rc) {
                code = rc;

src/AFS.xs  view on Meta::CPAN

            }
            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);

src/ppport.h  view on Meta::CPAN

PerlIO_flush||5.007003|
PerlIO_get_base||5.007003|
PerlIO_get_bufsiz||5.007003|
PerlIO_get_cnt||5.007003|
PerlIO_get_ptr||5.007003|
PerlIO_read||5.007003|
PerlIO_seek||5.007003|
PerlIO_set_cnt||5.007003|
PerlIO_set_ptrcnt||5.007003|
PerlIO_setlinebuf||5.007003|
PerlIO_stderr||5.007003|
PerlIO_stdin||5.007003|
PerlIO_stdout||5.007003|
PerlIO_tell||5.007003|
PerlIO_unread||5.007003|
PerlIO_write||5.007003|
Perl_signbit||5.009005|n
PoisonFree|5.009004||p
PoisonNew|5.009004||p
PoisonWith|5.009004||p
Poison|5.008000||p

src/ppport.h  view on Meta::CPAN

warn|||v
was_lvalue_sub|||
watch|||
whichsig_pvn||5.015004|
whichsig_pv||5.015004|
whichsig_sv||5.015004|
whichsig|||
win32_croak_not_implemented|||n
with_queued_errors|||
wrap_op_checker||5.015008|
write_to_stderr|||
xmldump_all_perl|||
xmldump_all|||
xmldump_attr|||
xmldump_eval|||
xmldump_form|||
xmldump_indent|||v
xmldump_packsubs_perl|||
xmldump_packsubs|||
xmldump_sub_perl|||
xmldump_sub|||



( run in 1.193 second using v1.01-cache-2.11-cpan-49f99fa48dc )