Commit 47c6919b authored by 's avatar
Browse files

Added authentication related code in cmd_authenticate (mapid.c)

Modified authentication test a bit. It still doesn't compile by default.

Added some VOd code to handle policies. More to come soon.


git-svn-id: file:///home/svn/mapi/trunk@525 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent aff89d15
......@@ -48,7 +48,7 @@ int main(int argc, char *argv[])
while(1)
{
dres = (struct dmapi_results*) mapi_read_results(fd,fid);
/* dres = (struct dmapi_results*) mapi_read_results(fd,fid);
for (i=0; i<dres->cnt; i++){
if(*((int*)dres->res[i].result)==0){
printf("host %s: ",dres->res[i].host_dev);
......@@ -60,7 +60,8 @@ int main(int argc, char *argv[])
{
usleep(10);
}
}
}*/
sleep(2);
}
mapi_close_flow(fd);
......
......@@ -1802,6 +1802,7 @@ static void cmd_authenticate(int fd, int pid, unsigned char *data, int sock)
success:
/*
* TODO: Check fd's interface against the list taken from CA.
* TODO: Add anonymization functions based on policy.
*/
{
......@@ -1809,6 +1810,28 @@ success:
int function_id;
mapidrv *drv;
int nfunctions;
/*
* Form a policy request for VOd.
*/
t.opcode = 0x05;
memset(t.username, 0, MAX_DATA_SIZE);
memset(t.password, 0, MAX_DATA_SIZE);
if(send(_socket, &t, sizeof(auth_msg_t), 0) == -1)
{
perror("send");
goto failure; // XXX Oh really?
}
if(recv(_socket, &t, sizeof(auth_msg_t), 0) == -1)
{
perror("recv");
goto failure;
}
memcpy(&nfunctions, t.username, sizeof(int));
// Find the driver.
if((drv = get_drv(fd)) == NULL)
{
......@@ -1818,17 +1841,19 @@ success:
mapidrv_apply_function = get_drv_funct(drv->handle, "mapidrv_apply_function");
/*
* Loop nfunctions times,
* get the functions and apply them.
*/
memset(&buf, 0, sizeof(struct mapiipcbuf));
strcpy(buf.function, "ANONYMIZE");
strcpy((char*)buf.data, "IP,SRC_IP,ZERO");
function_id = mapidrv_apply_function(drv->devid, fd, 1, buf.function, buf.data);
fprintf(stderr, "function_id : %d\n", function_id);
}
close(_socket);
qbuf.cmd = AUTHENTICATE_ACK;
qbuf.mtype = get_id(fd);
qbuf.fd = fd;
......
......@@ -677,7 +677,7 @@ int send_policy(int mapid_socket, auth_msg_t *request)
vo_info_t *vo = NULL;
char *policy = NULL;
int len = 0;
int len = 0, nfunctions = 0;
if(vos)
tmp_node = flist_head(vos);
......@@ -703,6 +703,8 @@ int send_policy(int mapid_socket, auth_msg_t *request)
while(tmp_node)
{
nfunctions++;
if((policy = realloc(policy, len + strlen(tmp_node->data) + 2)) == NULL)
{
// TODO: Send an error to mapid.
......@@ -717,8 +719,21 @@ int send_policy(int mapid_socket, auth_msg_t *request)
tmp_node = tmp_node->next;
}
fprintf(stderr, "VO: %s\tString: %s\n", vo_name, policy);
fprintf(stderr, "VO: %s\tFunctions: %d\tString: %s\n", vo_name, nfunctions, policy);
// TODO: Send policy to mapid.
auth_msg_t response;
memset(&response, 0, sizeof(auth_msg_t));
strncpy(response.vo, vo->vo_name, MAX_DATA_SIZE);
memcpy(response.username, &nfunctions, sizeof(int));
if(send(mapid_socket, &response, sizeof(auth_msg_t), 0) == -1)
{
perror("send");
return(-1);
}
return(0);
}
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment