AFS
view release on metacpan or search on metacpan
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)) {
XSRETURN(1);
}
}
void
afs_ka_SingleServerConn(host,token,service,cell=0)
char * host
AFS::KTC_TOKEN token
int32 service
char * cell
PPCODE:
{
int32 code;
AFS__KAS server;
if (token == &the_null_token)
token = NULL;
code = ka_SingleServerConn(cell, host, service, token, &server);
SETCODE(code);
if (code == 0) {
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "AFS::KAS", (void *) server);
XSRETURN(1);
}
}
void
afs_ka_des_string_to_key(str)
char * str
PPCODE:
{
struct ktc_encryptionKey *key;
SV *st;
key = (struct ktc_encryptionKey *) safemalloc(sizeof(*key));
des_string_to_key(str, key);
SETCODE(0);
EXTEND(sp, 1);
st = sv_newmortal();
sv_setref_pv(st, "AFS::KTC_EKEY", (void *) key);
PUSHs(st);
}
int32
afs_setpag()
CODE:
{
int32 code;
code = setpag();
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
void
afs_expandcell(cell)
char * cell
PPCODE:
{
int32 code;
struct afsconf_cell info;
if (cell && (cell[0] == '\0' || cell[0] == '0'))
cell = NULL;
code = internal_GetCellInfo(cell, 0, &info);
if (code != 0) {
XSRETURN_UNDEF;
}
else {
SETCODE(code); /* fuer Fehler wird tiefer gesetzt... */
ST(0) = sv_newmortal();
sv_setpv(ST(0), info.name);
XSRETURN(1);
}
}
void
afs_localcell()
PPCODE:
{
int32 code;
char *cell;
cell = internal_GetLocalCell(&code);
if (! code) SETCODE(code); /* fuer Fehler wird tiefer gesetzt... */
ST(0) = sv_newmortal();
sv_setpv(ST(0), cell);
XSRETURN(1);
}
void
afs_getcellinfo(cell=0,ip=0)
char * cell
int32 ip
PPCODE:
{
int32 code;
struct afsconf_cell info;
if (cell && (cell[0] == '\0' || cell[0] == '0'))
cell = NULL;
code = internal_GetCellInfo(cell, 0, &info);
if (code != 0) {
XSRETURN_UNDEF;
}
else {
int i;
char *h;
SETCODE(code); /* fuer Fehler wird tiefer gesetzt... */
XPUSHs(sv_2mortal(newSVpv(info.name, strlen(info.name))));
for (i = 0; i < info.numServers; i++) {
if (ip == 1) {
h = (char *) inet_ntoa(info.hostAddr[i].sin_addr);
( run in 1.159 second using v1.01-cache-2.11-cpan-97f6503c9c8 )