Esempio n. 1
0
int default_acl_log_access(char *dec_user, char *service,
                           int req_type,
                           ci_sockaddr_t * client_address,
                           ci_sockaddr_t * server_address)
{

     access_entry_t *entry;
     acl_spec_t *spec, req_spec;
     entry = acl_log_access_list.access_entry_list;

     if (!entry)
          return CI_ACCESS_UNKNOWN;

     req_spec.username = dec_user;      /*dec_user always non null (required) */
     req_spec.servicename = service;
     req_spec.ci_request_type = req_type;
     req_spec.family = server_address->ci_sin_family;
     req_spec.port = server_address->ci_sin_port;
     acl_copy_inaddr(&req_spec.hserver_address, server_address->ci_sin_addr,
                     server_address->ci_inaddr_len);
     acl_copy_inaddr(&req_spec.hclient_address, client_address->ci_sin_addr,
                     client_address->ci_inaddr_len);


     while (entry) {
          spec = entry->spec;
          if (match_request(spec, &req_spec)) {
               return entry->type;
          }
          entry = entry->next;
     }
     return CI_ACCESS_UNKNOWN;
}
Esempio n. 2
0
void js_debug_resumerequest(JSContext *cx, jsrefcount rc, const char *file, unsigned long line)
{
	struct request_log *req;

	if(!initialized)
		initialize_request();
	pthread_mutex_lock(&req_mutex);
	req=match_request(cx);
	if(req==NULL) {
		strcpy(str,"Missing req in Resume\n");
		logstr();
		return;
	}
	if(!JS_IsInRequest(cx)) {
		sprintf(str,"Resume WITHOUT REQUEST after %s from %s:%lu at %s:%lu (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
	}
	switch(req->type) {
	case LAST_REQUEST_TYPE_SUSPEND:
		break;
	case LAST_REQUEST_TYPE_NONE:
	case LAST_REQUEST_TYPE_END:
	case LAST_REQUEST_TYPE_BEGIN:
	case LAST_REQUEST_TYPE_RESUME:
		sprintf(str,"Resume after %s from %s:%lu at %s:%lu (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
		logstr();
		break;
	}
	switch(JS_RequestDepth(cx)) {
	case 0:
	default:
		sprintf(str,"depth=%u at Resume after %s from %s:%lu at %s:%lu (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
		logstr();
		break;
	case 1:
		break;
	}
	switch(JS_SuspendDepth(cx)) {
	case 1:
	default:
		break;
	case 0:
		sprintf(str,"Suspend depth=%u at Resume after %s from %s:%lu at %s:%lu (%p)\n",JS_SuspendDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
		logstr();
		break;
	}


	req->type=LAST_REQUEST_TYPE_RESUME;
	req->file=file;
	req->line=line;
	pthread_mutex_unlock(&req_mutex);
	JS_ResumeRequest(cx, rc);
}
Esempio n. 3
0
jsrefcount js_debug_suspendrequest(JSContext *cx, const char *file, unsigned long line)
{
	struct request_log *req;
	jsrefcount ret;

	if(!initialized)
		initialize_request();
	pthread_mutex_lock(&req_mutex);
	req=match_request(cx);
	if(req==NULL) {
		strcpy(str,"Missing req in Suspend\n");
		logstr();
		return -1;
	}
	if(!JS_IsInRequest(cx)) {
		sprintf(str,"Suspend WITHOUT REQUEST after %s from %s:%lu at %s:%lu (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
	}
	switch(req->type) {
	case LAST_REQUEST_TYPE_BEGIN:
	case LAST_REQUEST_TYPE_RESUME:
		break;
	case LAST_REQUEST_TYPE_NONE:
		if(req->file==NULL)			/* Assumed to be a provided request */
			break;
	case LAST_REQUEST_TYPE_END:
	case LAST_REQUEST_TYPE_SUSPEND:
		sprintf(str,"Suspend after %s from %s:%lu at %s:%lu (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
		logstr();
		break;
	}
	switch(JS_RequestDepth(cx)) {
	case 0:
	default:
		sprintf(str,"depth=%u at Suspend after %s from %s:%lu at %s:%lu (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
		logstr();
		break;
	case 1:
		break;
	}

	req->type=LAST_REQUEST_TYPE_SUSPEND;
	req->file=file;
	req->line=line;
	ret=JS_SuspendRequest(cx);
	pthread_mutex_unlock(&req_mutex);
	return(ret);
}
Esempio n. 4
0
void js_debug_endrequest(JSContext *cx, const char *file, unsigned long line)
{
	struct request_log *req;

	if(!initialized)
		initialize_request();
	pthread_mutex_lock(&req_mutex);
	req=match_request(cx);
	if(req==NULL) {
		strcpy(str,"Missing req in End\n");
		logstr();
		return;
	}
	if(!JS_IsInRequest(cx)) {
		sprintf(str,"End WITHOUT REQUEST after %s from %s:%lu at %s:%lu (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
	}
	switch(req->type) {
	case LAST_REQUEST_TYPE_BEGIN:
		if(req->file) {
			if(strcmp(req->file, file) != 0 || line < req->line) {
				sprintf(str,"Suspicious End after %s from %s:%lu at %s:%lu (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
			}
			break;
		}
	case LAST_REQUEST_TYPE_RESUME:
		break;
	case LAST_REQUEST_TYPE_NONE:
	case LAST_REQUEST_TYPE_END:
	case LAST_REQUEST_TYPE_SUSPEND:
		sprintf(str,"End after %s from %s:%lu at %s:%lu (%p)\n",type_names[req->type],req->file,req->line,file,line,req->cx);
		logstr();
		break;
	}
	switch(JS_RequestDepth(cx)) {
	case 0:
	default:
		sprintf(str,"depth=%u at End after %s from %s:%lu at %s:%lu (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
		logstr();
		break;
	case 1:
		break;
	}
	switch(JS_SuspendDepth(cx)) {
	case 0:
		break;
	default:
		sprintf(str,"Suspend depth=%u at End after %s from %s:%lu at %s:%lu (%p)\n",JS_RequestDepth(cx),type_names[req->type],req->file,req->line,file,line,req->cx);
		logstr();
		break;
	}

	req->type=LAST_REQUEST_TYPE_END;
	req->file=file;
	req->line=line;
	JS_EndRequest(cx);
	if(JS_RequestDepth(cx)==0) {
		if(req->prev != NULL)
			req->prev->next=req->next;
		if(req->next != NULL)
			req->next->prev=req->prev;
		if(first_request==req) {
			if(req->prev != NULL)
				first_request=req->prev;
			else
				first_request=req->next;
		}
		free(req);
	}
	pthread_mutex_unlock(&req_mutex);
}