Commit d80b1a98 authored by 's avatar
Browse files

Bug fixes, plus some necessary shutdown() calls and

error message propagation.


git-svn-id: file:///home/svn/mapi/trunk@540 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 636ca8b1
......@@ -157,7 +157,7 @@ void *request_handler(void *args)
int bytes_recvd = 0;
// Initialisations.
pthread_detach(pthread_self());
// pthread_detach(pthread_self());
/*
* CA socket init
......@@ -191,10 +191,10 @@ void *request_handler(void *args)
{
case POLICY_REQUEST:
req->opcode = POLICY_RESP;
// TODO -- find the policy and copy it in the packet
send_policy(mapid_socket, req);
if(send_policy(mapid_socket, req) == -1)
fprintf(stderr, "send_policy() failed.\n");
send(mapid_socket, req, sizeof(auth_msg_t), 0);
//send(mapid_socket, req, sizeof(auth_msg_t), 0);
break;
case AUTH_REQUEST:
sconnection = connect_to_CA(&CA_socket, &ssl_context, &remote_addr);
......@@ -227,7 +227,10 @@ void *request_handler(void *args)
term: free(req);
if(mapid_socket)
{
shutdown(mapid_socket, SHUT_RDWR);
close(mapid_socket);
}
if(CA_socket)
close(CA_socket);
if(sconnection)
......@@ -675,11 +678,19 @@ int send_policy(int mapid_socket, auth_msg_t *request)
char *policy = NULL;
int len = 0, nfunctions = 0;
auth_msg_t response;
memset(&response, 0, sizeof(auth_msg_t));
if(vos)
tmp_node = flist_head(vos);
else
{
// TODO: Send some error, or default policy, to mapid.
response.opcode = POLICY_NOTFOUND;
if(send(mapid_socket, &response, sizeof(auth_msg_t), 0) == -1)
{
perror("send");
return(-1);
}
return(-1);
}
......@@ -693,7 +704,12 @@ int send_policy(int mapid_socket, auth_msg_t *request)
else
{
// No policy specified for VO.
// TODO: Send error, or default one.
response.opcode = POLICY_NOTFOUND;
if(send(mapid_socket, &response, sizeof(auth_msg_t), 0) == -1)
{
perror("send");
return(-1);
}
return(-1);
}
......@@ -703,8 +719,13 @@ int send_policy(int mapid_socket, auth_msg_t *request)
if((policy = realloc(policy, len + strlen(tmp_node->data) + 2)) == NULL)
{
// TODO: Send an error to mapid.
fprintf(stderr, "send_policy(): Unable to allocate memory to store policy of VO %s.\n", vo_name);
response.opcode = POLICY_NOTFOUND;
if(send(mapid_socket, &response, sizeof(auth_msg_t), 0) == -1)
{
perror("send");
return(-1);
}
return(-1);
}
else
......@@ -715,15 +736,10 @@ int send_policy(int mapid_socket, auth_msg_t *request)
tmp_node = tmp_node->next;
}
fprintf(stderr, "VO: %s\tFunctions: %d\tString: %s\n", vo_name, nfunctions, policy);
/*
* Send policy attributes to mapid,
* then send the policy.
*/
auth_msg_t response;
memset(&response, 0, sizeof(auth_msg_t));
response.opcode = POLICY_ATTR;
strncpy(response.vo, vo->vo_name, MAX_DATA_SIZE);
memcpy(response.username, &nfunctions, sizeof(int));
......
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