AFS
view release on metacpan or search on metacpan
/* printf("vos-create DEBUG-7 rovid %d \n", SvIV(rovid)); */
char buffer[256];
sprintf(buffer, "Given RO volume ID should be numeric.\n");
VSETCODE(EINVAL, buffer);
goto done;
}
/* printf("vos-create DEBUG-8 rovid %d \n", SvIV(rovid)); */
arovolid = &rovolid;
rovolid = SvIV(rovid);
/* printf("vos-create DEBUG-9 rovolid %d \n", rovolid); */
if (rovolid == 0) {
arovolid = NULL;
}
code = UV_CreateVolume3(tserver, pnum, name, quota, 0, 0, 0, 0, &volid, arovolid, &bkvolid);
#else
code = UV_CreateVolume2(tserver, pnum, name, quota, 0, 0, 0, 0, &volid);
#endif
if (code) {
#PrintDiagnostics("create", code);
SETCODE(code);
goto done;
}
SETCODE(0);
RETVAL = (int32)volid;
done:
;
}
OUTPUT:
RETVAL
int32
vos_backup(cstruct, name)
AFS::VOS cstruct
char *name
PREINIT:
int32 avolid, aserver, apart, vtype, code, err;
int32 buvolid, buserver, bupart, butype;
struct nvldbentry entry;
struct nvldbentry buentry;
CODE:
{
RETVAL = 0;
avolid = vsu_GetVolumeID(name, cstruct, &err);
if (avolid == 0) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "AFS::VOS: can't find volume ID or name '%s'\n", name);
VSETCODE(err ? err : ENOENT, buffer);
goto done;
}
code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
if (code) {
SETCODE(code);
goto done;
}
/* verify this is a readwrite volume */
if (vtype != RWVOL) {
char buffer[256];
sprintf(buffer, "%s not RW volume\n", name);
VSETCODE(-1, buffer);
goto done;
}
/* is there a backup volume already? */
if (entry.flags & BACK_EXISTS) {
/* yep, where is it? */
buvolid = entry.volumeId[BACKVOL];
code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
if (code) {
SETCODE(code);
goto done;
}
/* is it local? */
code = VLDB_IsSameAddrs(buserver, aserver, &err);
if (err) {
char buffer[256];
sprintf(buffer,
"Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
buserver);
VSETCODE(err, buffer);
goto done;
}
if (!code) {
char buffer[256];
sprintf(buffer, "FATAL ERROR: backup volume %u exists on server %u\n",
buvolid, buserver);
VSETCODE(-1, buffer);
goto done;
}
}
/* nope, carry on */
code = UV_BackupVolume(aserver, apart, avolid);
if (code) {
PrintDiagnostics("backup", code);
SETCODE(0);
goto done;
}
#fprintf(STDOUT, "Created backup volume for %s \n", name);
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vos_remove(cstruct, name, servername=NULL, parti=NULL)
AFS::VOS cstruct
char *name
{
int32 code;
char name[MAXKTCNAMELEN];
char inst[MAXKTCNAMELEN];
char cell[MAXKTCREALMLEN];
code = ka_ParseLoginName(login, name, inst, cell);
SETCODE(code);
if (code == 0) {
EXTEND(sp, 3);
PUSHs(sv_2mortal(newSVpv(name, strlen(name))));
PUSHs(sv_2mortal(newSVpv(inst, strlen(inst))));
PUSHs(sv_2mortal(newSVpv(cell, strlen(cell))));
}
}
void
afs_ka_StringToKey(str,cell)
char * str
char * cell
PPCODE:
{
struct ktc_encryptionKey *key;
SV *st;
key = (struct ktc_encryptionKey *) safemalloc(sizeof(*key));
ka_StringToKey(str, cell, key);
SETCODE(0);
EXTEND(sp, 1);
st = sv_newmortal();
sv_setref_pv(st, "AFS::KTC_EKEY", (void *) key);
PUSHs(st);
}
void
afs_ka_UserAthenticateGeneral(p,pass,life,flags,pwexpires=-1,reason=0)
AFS::KTC_PRINCIPAL p
char * pass
int32 life
int32 flags
int32 pwexpires
char * reason
PPCODE:
{
int32 code, pw = 255;
char *r;
code = ka_UserAuthenticateGeneral(flags,
p->name, p->instance, p->cell, pass, life, &pw, 0, &r);
if (pwexpires != -1)
sv_setiv(ST(4), (IV) pw);
if (reason)
sv_setpv(ST(5), r);
SETCODE(code);
EXTEND(sp, 1);
PUSHs(sv_2mortal(newSViv(code == 0)));
}
void
afs_ka_ReadPassword(prompt,verify=0,cell=0)
char * prompt
int32 verify
char * cell
PPCODE:
{
int32 code = 0;
struct ktc_encryptionKey *key;
SV *st;
if (cell && (cell[0] == '\0' || cell[0] == '0'))
cell = NULL;
if (cell == 0) {
cell = internal_GetLocalCell(&code);
if (code)
XSRETURN_UNDEF;
}
key = (struct ktc_encryptionKey *) safemalloc(sizeof(*key));
code = ka_ReadPassword(prompt, verify, cell, key);
if (code == 0) {
EXTEND(sp, 1);
st = sv_newmortal();
sv_setref_pv(st, "AFS::KTC_EKEY", (void *) key);
PUSHs(st);
XSRETURN(1);
}
else {
char buffer[256];
sprintf(buffer, "AFS::KTC_EKEY: ");
KSETCODE(code, buffer);
safefree(key);
XSRETURN_UNDEF;
}
}
void
afs_ka_UserReadPassword(prompt,reason=0)
char * prompt
char * reason
PPCODE:
{
int32 code;
char buffer[1024];
char *r;
code = ka_UserReadPassword(prompt, buffer, sizeof(buffer) - 1, &r);
SETCODE(code);
if (reason)
sv_setpv(ST(1), r);
if (code == 0) {
EXTEND(sp, 1);
PUSHs(sv_2mortal(newSVpv(buffer, strlen(buffer))));
}
}
void
afs_ka_GetAdminToken(p,key,lifetime,newt=1,reason=0)
AFS::KTC_PRINCIPAL p
AFS::KTC_EKEY key
int32 lifetime
int32 newt
char * reason
PPCODE:
{
int32 code;
struct ktc_token *t;
char *message;
t = (struct ktc_token *) safemalloc(sizeof(struct ktc_token));
code = ka_GetAdminToken(p->name, p->instance, p->cell, key, lifetime, t, newt);
SETCODE(code);
if (code == 0) {
SV *st;
EXTEND(sp, 1);
st = sv_newmortal();
sv_setref_pv(st, "AFS::KTC_TOKEN", (void *) t);
PUSHs(st);
}
( run in 1.696 second using v1.01-cache-2.11-cpan-39bf76dae61 )