Exemplo n.º 1
0
static void *
rotate(void *arg)
{
	logstr(GLOG_DEBUG, "rotate thread starting");

	if ((time(NULL) - *ctx->last_rotate) <= ctx->config.rotate_interval) {
		logstr(GLOG_DEBUG, "rotation not needed");
		return NULL;
	}

	/*      debug_print_ring_queue(ctx->filter, TRUE); */
	logstr(GLOG_DEBUG, "Now: %d Last: %d Max-diff %d", time(NULL), *(ctx->last_rotate),
	    ctx->config.rotate_interval * ctx->config.num_bufs);
	ACTIVATE_BLOOM_GUARD();
	if (time(NULL) - *(ctx->last_rotate) > ctx->config.rotate_interval * ctx->config.num_bufs) {
		zero_bloom_ring_queue(ctx->filter);
		*(ctx->last_rotate) = time(NULL);
		logstr(GLOG_INFO, "Max timediff exceeded. Zeroing whole bloom ring.");
	} else {
		*(ctx->last_rotate) += ctx->config.rotate_interval;
		ctx->filter = rotate_bloom_ring_queue(ctx->filter);
	}
	RELEASE_BLOOM_GUARD();
	logstr(GLOG_DEBUG, "rotation completed");
	return NULL;
}
Exemplo n.º 2
0
void
TWIN_DumpGdiObjects()
{
	HPEN	hPen;
	HBRUSH  hBrush;
        LPOBJHEAD	lpObjHead;
	int i;

	logstr(LF_DEBUG,"Dumping GDI Objects\n");
	for(i=0;i<SD_NUMCOLORS+1;i++) {
		hBrush = SysColorBrushes[i];
		if(hBrush && IsGDIObject(hBrush)) {
			logstr(LF_DEBUG,"deleting brush %d %x\n",i,hBrush);
			lpObjHead = GETGDIINFO(hBrush);
			lpObjHead->wRefCount = 0;
			DeleteObject(hBrush);
		}
	}
	for(i=0;i<SD_NUMCOLORS+1;i++) {
		hPen = SysColorPens[i];
		if(hPen && IsGDIObject(hPen)) {
			logstr(LF_DEBUG,"deleting pen %d %x\n",i,hPen);
			lpObjHead = GETGDIINFO(hPen);
			lpObjHead->wRefCount = 0;
			DeleteObject(hPen);
		}
	}
}
Exemplo n.º 3
0
/*****************************************************************
 * handle_sig() : signal handler for SIGCHLD, SIGTERM and SIGALRM
 *****************************************************************/
void handle_sig( int sig )
{
    char s[256];

    switch( sig ) {
      case SIGTERM:
	if( !child ) {
	    unlink(sz_pidfile);
	    sprintf( s, PROG_NAME" "PROG_VERSION" shutting down cleanly "
		     ": killing %d connections",con_cnt );
	    logstr(s,NULL);
	}
	exit(0);
	break;
      case SIGCHLD:
	while( waitpid(-1,NULL,WNOHANG) > 0 )
	    con_cnt--;
	break;
      case SIGALRM:
	if( child ) {
	    sprintf(s,"Connection closed (%s)",sz_error[ERR_NEGTIME]);
	    logstr(s,&ad_client);
	    exit(ERR_NEGTIME);
	}
	exit(0);
	break;
    }
}
Exemplo n.º 4
0
void
WinFreeCheck(LPVOID ptr,char *lparam, int wparam)
{
	MALLOCINFO *p,*l;

	for(p=lpMallocInfo; p; p = p->next) {
		if(p->data == ptr) {
			if(lpMallocInfo == p) {
				lpMallocInfo = p->next;
			} else {
				for(l=lpMallocInfo; l; l = l->next) {
					if(l->next == p) {
						l->next = p->next;
					}
				}
			}
        		logstr(LF_DEBUG,"%s:%d: WinFreeCheck: data=%x from=%s:%d %x %x\n",
			    lparam,wparam,
                	    ptr,
			    p->lparam,p->wparam,
			    p->flag,p->handle);
			WinFree(p);

			totalfree += p->size;
			totalfcalls++;
			break;
		}
	}
	if(p == 0) {
		logstr(LF_DEBUG,"*** ERROR *** WinFreeCheck: freeing %x %s:%d\n",
			ptr, lparam,wparam);
	}
		WinFree(ptr);
}
Exemplo n.º 5
0
int find_head_offset(char *upload_data)
{
	int head_offset=0 ;
	char *pStart=NULL;
	int iestr_offset=0;
	char *dquote;
	char *dquote1;
	
	if (upload_data==NULL) {
		//fprintf(stderr, "upload data is NULL\n");
		return -1;
	}
    if(strstr(upload_data, WINIE6_STR))
    {
       pStart = strstr(upload_data, WINIE6_STR);
       iestr_offset = 17;
	}
	else if(strstr(upload_data, GZ_STR))
    {
       pStart = strstr(upload_data, GZ_STR);
       iestr_offset = 22;
	}else if(strstr(upload_data, LINUXFX36_FWSTR))
	{
	   pStart = strstr(upload_data, LINUXFX36_FWSTR);
       iestr_offset = 26;
	}else if(strstr(upload_data, MACIE5_FWSTR))
	{
	  pStart = strstr(upload_data, MACIE5_FWSTR);
      iestr_offset = 14;
	}else if(strstr(upload_data, OPERA_FWSTR))
	{
	  pStart = strstr(upload_data, OPERA_FWSTR);
      iestr_offset = 16;
	}else if(strstr(upload_data, WIN64IE_FWSTR))
	{
	  pStart = strstr(upload_data, WIN64IE_FWSTR);
	  logstr("\nWIN64IE_FWSTR:");
	  logstr(WIN64IE_FWSTR);
      iestr_offset = 10;
	}else if(strstr(upload_data, "filename="))
	{
	    pStart = strstr(upload_data, "filename=");
        dquote =  strstr(pStart, "\"");
		if (dquote !=NULL) {
			dquote1 = strstr(dquote, LINE_FWSTR);
			if (dquote1!=NULL) {
				iestr_offset = 4;
				pStart = dquote1;
			}
			else {
				return -1;
			}
		}
	}
	
    //fprintf(stderr,"####%s:%d %d###\n",  __FILE__, __LINE__ , iestr_offset);
	head_offset = (int)(((unsigned long)pStart)-((unsigned long)upload_data)) + iestr_offset;
	//printf("<br>head_offset=%d \n",head_offset);
	return head_offset;
}
Exemplo n.º 6
0
void 
LoadExportsTable(MODULE_HEADERS *mp,PIMAGE_NT_HEADERS pNTHeader,char *ModuleName)
{
	PIMAGE_EXPORT_DIRECTORY exportDir;
	DWORD i;
	PDWORD functions;
	PWORD ordinals;
	PSTR *name;
	LPSTR fname;
        IMAGE_DATA_DIRECTORY    dir;

	logstr(lf_exports,"Exports of %s\n",ModuleName);

	// get the image_data_directory for exported symbols
	dir = pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT];

	// convert to pointer
	exportDir = MAKEPTR((PIMAGE_EXPORT_DIRECTORY),
		mp->BaseAddress,
		dir.VirtualAddress);

	// any functions at all?
	if (exportDir->NumberOfFunctions == 0)
	   return ;

	// create array of function addresses
	functions = MAKEPTR((PDWORD),mp->BaseAddress,
		exportDir->AddressOfFunctions);

	// create array of function ordinals
	ordinals =  MAKEPTR((PWORD),mp->BaseAddress,
		exportDir->AddressOfNameOrdinals);

	// create array of RVA's to function names
	name =      MAKEPTR((PSTR *),mp->BaseAddress,
		exportDir->AddressOfNames);
	
	// resort to straight line linear search
	// should/could we ignore comparing strings, until we
	// are in range?
	for ( i=0; i < exportDir->NumberOfNames; i++ )
	{
		// get the pointer to the name
		fname = MAKEPTR((LPSTR),mp->BaseAddress,*name);

	        logstr(lf_exports,"export %x %s\n",
			*ordinals,fname);

		// bump all the pointers
		functions++;	// function address
		ordinals++;	// function ordinal
		name++;		// function name
	}

	// the name is not in the module...
	return ;
}
Exemplo n.º 7
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);
}
Exemplo n.º 8
0
 void proxy_client_handler::on_connect(frog::generic::tcpsession_ptr session)
 {
     if (session)
     {
         logstr("%s - %s connected", session->localaddr().c_str(), session->remoteaddr().c_str());
         frog::generic::encoder out;
         out.begin(cmd_server_register);
         out.write_int(config::ref().get_servertype());
         out.end();
         session->send(&out);
     }
     else
     {
         logstr("cannot connect to proxy");
     }
 }
Exemplo n.º 9
0
LPVOID
WinMallocCheck(unsigned int size, char *lparam,int wparam,int flag, int handle)
{
	LPVOID   lpMemory;
	MALLOCINFO *p;

        lpMemory =  WinMalloc(size);

        logstr(LF_DEBUG,"%s:%d: WinMallocCheck data=%x size=%x %x %x\n",
		lparam,wparam,
                lpMemory,size,
		flag,handle);

	p = (MALLOCINFO *) WinMalloc(sizeof(MALLOCINFO));
	memset(p,0,sizeof(MALLOCINFO));

	p->next = lpMallocInfo;
	p->data = lpMemory;
	p->size = size;

	p->lparam = lparam;
	p->wparam = wparam;
	p->flag   = flag;
	p->handle = handle; 
	p->call   = totalacalls;
	
	lpMallocInfo = p;
	totalacalls++;

	totalalloc += size;

        return lpMemory;
}
Exemplo n.º 10
0
void
free_wrapper (void *mem)
{
  if (DEBUG)
    logstr ("freeing memory at %p\n", mem);
  free (mem);
}
Exemplo n.º 11
0
/*
 * logprg prints msg at log level of level
 * 
 * in:
 *    level - a level number consisted with LOG_LEVEL_T
 *    msg - a log message
 * out:
 *    log displayed on stdout
 */
void logprg ( LOG_LEVEL_T level, const char * msg ){

   char s[LOGMSGLEN];
   char * copy;
   char * start = (char *)msg;
   char * end;
   
   logstr ( s, level );
   /* first we search for end line characters */
   end = strchr ( start, '\n' );
   if ( end ){
      /* if found we need to erase them */
      copy = MALLOC ( strlen ( msg ) + 1 );
      while ( ( end = strchr ( start, '\n' )) ){
         /* end line chars erase */
         if ( start != end ){
            strncpy ( copy, start, end - start );
            copy [ end - start ] = '\0';
            printf ( "%s %s\n", s, copy );
         }
         start = end + 1;
      }
      FREE ( copy );
   } else {
      /* if not found simply display it */
      printf ( "%s %s\n", s, msg );
   }
}
Exemplo n.º 12
0
void
edict_unlink(edict_t *edict)
{
	int ret;
	poolresult_message_t message;

	ret = pthread_mutex_lock(&edict->reference.mx);
	assert(0 == ret);
	assert(edict->reference.count > 0);

	if (--edict->reference.count == 0) {
		/* last reference */
		if (edict->resultmq > 0)
			while (release_queue(edict->resultmq) < 0) {
				/* queue wasn't emtpy */
				logstr(GLOG_INSANE, "queue not empty, flushing");
				ret = get_msg_timed(edict->resultmq, &message, sizeof(message.result), -1);
				if (ret > 0) {
					assert(message.result);
					free((chkresult_t *)message.result);
					message.result = NULL;
				}
			}
		pthread_mutex_unlock(&edict->reference.mx);
		Free(edict);
	} else {
		pthread_mutex_unlock(&edict->reference.mx);
	}
}
Exemplo n.º 13
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);
}
Exemplo n.º 14
0
void 
DumpSectionTable(void *LoadAddress,PIMAGE_SECTION_HEADER section, unsigned cSections)
{
	unsigned j;

	logstr(lf_header,"Section Table %x %d\n",LoadAddress,cSections);
	
	logstr(lf_header,"  %02X %-8.8s  %s: %08X  VirtAddr:  %08X\n",
			cSections, section->Name, "VirtSize",
			section->Misc.VirtualSize, section->VirtualAddress);
	logstr(lf_header,"    raw data offs:   %08X  raw data size: %08X\n",
			section->PointerToRawData, section->SizeOfRawData );
	logstr(lf_header,"    relocation offs: %08X  relocations:   %08X\n",
			section->PointerToRelocations, section->NumberOfRelocations);
	logstr(lf_header,"    line # offs:     %08X  line #'s:      %08X\n",
			section->PointerToLinenumbers, section->NumberOfLinenumbers );
	logstr(lf_header,"    characteristics: %08X\n", section->Characteristics);

	for ( j=0; j < NUMBER_SECTION_CHARACTERISTICS; j++ )
	{
		if ( section->Characteristics & 
			SectionCharacteristics[j].flag )
			logstr(lf_header,"      %s\n", 
				SectionCharacteristics[j].name );
	}
}
Exemplo n.º 15
0
void
ExecEntryPoint(void *BaseAddress, PIMAGE_NT_HEADERS pNTHeader,char *ModuleName)
{
	int *fp;
	fp = MAKEPTR((int *), BaseAddress, 
			pNTHeader->OptionalHeader.AddressOfEntryPoint);
	logstr(lf_header,"execute: %s %x %x\n",
		ModuleName,pNTHeader->OptionalHeader.AddressOfEntryPoint, fp);
}
Exemplo n.º 16
0
void DumpHeader(PIMAGE_FILE_HEADER pImageFileHeader)
{
        UINT headerFieldWidth = 30;
        UINT i;
        char *szMachine;

        logstr(lf_header,"File Header\n");

        switch( pImageFileHeader->Machine )
        {
                case IMAGE_FILE_MACHINE_I386:   szMachine = "i386"; break;
                case IMAGE_FILE_MACHINE_I860:   szMachine = "i860"; break;
                case IMAGE_FILE_MACHINE_R3000:  szMachine = "R3000"; break;
                case IMAGE_FILE_MACHINE_R4000:  szMachine = "R4000"; break;
                case IMAGE_FILE_MACHINE_ALPHA:  szMachine = "alpha"; break;
                default:    szMachine = "unknown"; break;
        }

        logstr(lf_header,"  %-*s%04X (%s)\n", headerFieldWidth, "Machine:",
                                pImageFileHeader->Machine, szMachine);
        logstr(lf_header,"  %-*s%04X\n", headerFieldWidth, "Number of Sections:",
                                pImageFileHeader->NumberOfSections);
        logstr(lf_header2,"  %-*s%08X\n", headerFieldWidth, "TimeDateStamp:",
                                pImageFileHeader->TimeDateStamp);
        logstr(lf_header2,"  %-*s%08X\n", headerFieldWidth, "PointerToSymbolTable:",
                                pImageFileHeader->PointerToSymbolTable);
        logstr(lf_header2,"  %-*s%08X\n", headerFieldWidth, "NumberOfSymbols:",
                                pImageFileHeader->NumberOfSymbols);
        logstr(lf_header2,"  %-*s%04X\n", headerFieldWidth, "SizeOfOptionalHeader:",
                                pImageFileHeader->SizeOfOptionalHeader);

        logstr(lf_header,"  %-*s%04X\n", headerFieldWidth, "Characteristics:",
                                pImageFileHeader->Characteristics);

        for ( i=0; i < NUMBER_IMAGE_HEADER_FLAGS; i++ )
        {
                if ( pImageFileHeader->Characteristics &
                         ImageFileHeaderCharacteristics[i].flag )
                        logstr(lf_header,"    %s\n", ImageFileHeaderCharacteristics[i].name );
        }
	logstr(lf_header,"\n");
}
Exemplo n.º 17
0
/* Perform connection to server. */
void
server_connect (char *host)
{
  struct addrinfo *server = NULL, hints;
  int st, sock;

  memset (&hints, 0, sizeof (struct addrinfo));
  hints.ai_family   = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags    = 0;
  hints.ai_protocol = 0;

  sock = socket (AF_INET, SOCK_STREAM, 0);
  if (sock == -1)
    {
      logstr ("socket creation failed\n");
      goto err;
    }
  st = getaddrinfo (host, "6667", &hints, &server);
  if (st != 0)
    {
      logstr("failed to resolve hostname\n");
      goto err;
    }
  logstr ("hostname resolved\n");
  st = connect (sock, server->ai_addr, server->ai_addrlen);
  if (st == -1)
    {
      logstr("connection to server failed\n");
      goto err;
    }
  logstr ("connected\n");
  settings->socket = fdopen (sock, "r+");
  freeaddrinfo (server);
  
  return;
  
 err:
  if (server)
    freeaddrinfo (server);
  exit (EXIT_FAILURE);
}
Exemplo n.º 18
0
int
main (int argc, char *argv[])
{
  char		*l    = NULL;
  message_t	*cmsg = NULL;
  command_t	*ccmd = NULL;
  settings_t	 global_settings;

  settings		   = &global_settings;
  settings->execname	   = argv[0];
  settings->action_trigger = '`';	/* default trigger char */
  settings->verbose	   = false;
  settings->socket	   = NULL;
  
  logstr ("Radroach here\n");
  register_signals ();
  if (configure (argc, argv))
    exit (EXIT_FAILURE);
  logstr ("trusted users are: %s\n", settings->trusted);
  if (settings->aj_list)
    logstr ("channels to join: %s\n", settings->aj_list);
  server_connect (settings->host);
  setup ();
  plugins_load ("./plugins/");

  while ((l = sogetline ()) != NULL)
    {
      if (p_response (l))
	continue;
      cmsg = parsemsg (l);
      if (cmsg != NULL)
        {
          ccmd = parsecmd (cmsg->msg);
          if (ccmd != NULL)
            execute (cmsg, ccmd);
        }
      else
	free (l);
    }
  return EXIT_SUCCESS;
}
Exemplo n.º 19
0
void
helo_init(pool_limits_t *limits)
{
    thread_pool_t *pool;

    /* initialize the thread pool */
    logstr(GLOG_INFO, "initializing helo thread pool");
    pool = create_thread_pool("helo", &helo, limits, NULL);
    if (pool == NULL)
        daemon_fatal("create_thread_pool");

    register_check(pool, false);
}
Exemplo n.º 20
0
void
reverse_init(pool_limits_t *limits)
{
	thread_pool_t *pool;

	/* initialize the thread pool */
	logstr(GLOG_INFO, "initializing reverse thread pool");
	pool = create_thread_pool("reverse", &reverse, limits, NULL);
	if (pool == NULL)
		daemon_fatal("create_thread_pool");

	register_check(pool, false);
}
Exemplo n.º 21
0
void
spf_init(pool_limits_t *limits)
{
	thread_pool_t *pool;

	/* initialize the thread pool */
	logstr(GLOG_INFO, "initializing spf checker thread pool");
	pool = create_thread_pool("spf", &spfc, limits, NULL);
	if (pool == NULL)
		daemon_fatal("create_thread_pool");

	/* This is a definitive check */
	register_check(pool, true);
}
Exemplo n.º 22
0
/*
 * abortprg prints msg at a log level of LOGERROR and exits program with error code of err.
 *
 * in:
 *    pdata - main program data
 *    err - error code
 *    msg - error message
 * out:
 *    program abort and exit
 */
void abortprg ( pgsqldata * pdata, int err, const char * msg ){

   char h[LOGMSGLEN];

   /* Program aborting always generate ERROR message */
   logstr ( h, LOGERROR );
   printf ( "%s %s\n", h, msg );
   printf ( "%s Aborting!\n", h );

   if ( pdata->catdb )
      PQfinish ( pdata->catdb );
   freepdata ( pdata );
   exit (err);
}
Exemplo n.º 23
0
void Shader::printInfo(ShaderInfo info, GLuint posy)
{
  GLuint posx = 260;
  switch(info)
  {
  case SHADER_LOG:
    {
    if(!log)
    {
      glColor3f(GLfloat(0.3), GLfloat(1.0), GLfloat(0.3));
      GLHelper::getGLH()->glPrintf(false, posx, posy, "no log available");
      return;
    }
    glColor3f(GLfloat(1.0), GLfloat(0.3), GLfloat(0.3));
    std::string logstr(log);
    std::string message;
    for(int loc = logstr.find("\n", 0); loc != int(std::string::npos); )
    {
      message = logstr.substr(0, loc);
      GLHelper::getGLH()->glPrintf(false, posx, posy, "%s", message.c_str());
      logstr = logstr.substr(loc+1, logstr.size());
      loc = logstr.find("\n", 0);
      posy -= 20;
    }
    }
    break;
  case SHADER_SOURCE:
    {
      glColor3f(GLfloat(0.7), GLfloat(0.7), GLfloat(0.7));
      if(source)
      {
        std::string sourcestr(source);
        std::string message;
        for(int loc = sourcestr.find("\n", 0); loc != int(std::string::npos); )
        {
          message = sourcestr.substr(0, loc);
          GLHelper::getGLH()->glPrintf(false, posx, posy, "%s", message.c_str());
          sourcestr = sourcestr.substr(loc+1, sourcestr.size());
          loc = sourcestr.find("\n", 0);
          posy -= 20;
        }
      }
      else
        GLHelper::getGLH()->glPrintf(false, posx, posy, "source not loaded");
    }
    break;
  default:
    break;
  }
}
Exemplo n.º 24
0
/* We want to use the logging facility key=value to keep track of the
 * node ip address we use when we use the filesystem domain. This
 * will help us know that we are accessing the nodes in a balanced way.
 * (We access the filesystem nodes via a domain which resolves to many
 * A records or IP addrs; our mechanism chooses one of those A records (IP addr).
 * We know the address used because we capture the libcurl message
 * "Trying <ip addr>...". Kind of clunky since the message can change. Do
 * we have a better way?
 */
static void print_ipaddr_pair(char *msg) {
    // nodeaddr is global so it can be reused in later logging
    char *end;
    // msg+9 takes us past "  Trying ". We assume the ip addr starts there.
    strncpy(nodeaddr, msg + 9, LOGSTRSZ);
    nodeaddr[LOGSTRSZ - 1] = '\0'; // Just make sure it's null terminated
    // end finds the first two dots after the ip addr. We put a zero there
    // to turn the original string into just the IP addr.
    end = strstr(nodeaddr, "..");
    end[0] = '\0';
    // Change dots in addr to underscore for logging
    logstr(nodeaddr);
    // We print the key=value pair.
    log_print(LOG_INFO, SECTION_SESSION_DEFAULT, "Using filesystem_host=%s", nodeaddr);
}
Exemplo n.º 25
0
/* Executes apropriate function as parameters specify. */
void
execute (message_t * msg, command_t * cmd)
{
  unsigned int i;
  
  if (checkrights (msg))
    {
      logstr ("accepted command %s from %s (%s@%s)\n", cmd->action, msg->sender, msg->ident, msg->host);
      for (i = 0; i < plugin_count; i++)
	{
          /* bad performance impact. meh. */
	  if (!strcmp(plugins[i]->name, cmd->action))
          {
            logstr ("plugin %s matched\n", plugins[i]->name);
	    plugins[i]->execute (msg, cmd, 1);
          }
	  else
	    plugins[i]->execute (msg, cmd, 0);
	}
    }
  free (cmd->raw);
  free (cmd);
  msgfree (msg);
}
Exemplo n.º 26
0
int
reverse(thread_pool_t *info, thread_ctx_t *thread_ctx, edict_t *edict)
{
	chkresult_t *result;
	struct hostent *canonicalhost, *reversehost;

	grey_tuple_t *request;
	const char *client_address;
        char buf[INET_ADDRSTRLEN];
	const char *ptr;
	mseconds_t timelimit;

	request = (grey_tuple_t *)edict->job;
	client_address = request->client_address;
	assert(client_address);

	result = (chkresult_t *)Malloc(sizeof(chkresult_t));
	memset(result, 0, sizeof(*result));
	result->judgment = J_UNDEFINED;
	result->checkname = "reverse";

	timelimit = edict->timelimit;

	reversehost = Gethostbyaddr_str(client_address, timelimit);
	if (reversehost) {
                logstr(GLOG_INSANE, "client_address (%s) has a PTR record (%s)",
                        client_address, reversehost->h_name);
		canonicalhost = Gethostbyname(reversehost->h_name, timelimit);
		if (canonicalhost) {
			ptr = inet_ntop(AF_INET, canonicalhost->h_addr_list[0], buf, INET_ADDRSTRLEN);
			assert(ptr);
			logstr(GLOG_INSANE, "client_ip (%s) canonical (%s)",
				client_address, buf);
			if (strcmp(buf, client_address)) {
				logstr(GLOG_DEBUG, "client_address (%s) not canonical (%s)",
					client_address, buf);
				result->judgment = J_SUSPICIOUS;
				result->weight = 1; /* FIXME */
			}
		} else {
			logstr(GLOG_DEBUG, "No A for PTR for client_ip (%s)", client_address);
			result->judgment = J_SUSPICIOUS;
			result->weight = 1;
		}
	} else {
		logstr(GLOG_DEBUG, "client_ip (%s) has no PTR record", client_address);
		result->judgment = J_SUSPICIOUS;
		result->weight = 1;
	}

	send_result(edict, result);
	logstr(GLOG_DEBUG, "reverse returning");
	request_unlink(request);

	return 0;
}
Exemplo n.º 27
0
void *
malloc_wrapper (size_t size)
{
  void *mem;
  
  mem = malloc (size);
  if (mem == NULL)
    {
      fprintf (stderr, "%s: failed to allocate %d bytes, exiting",
	       settings->execname, (unsigned int) size);
      exit (EXIT_FAILURE);
    }
  if (DEBUG)
    logstr ("allocated %d bytes at %p\n", size, mem);
  return mem;
}
Exemplo n.º 28
0
/* Returns a line from irc server. */
char *
sogetline ()
{
  /* irc RFC specifies maximum message length of 512 chars, plus one for \0 */
  char buffer[513], *line;
  size_t len;

  if (feof (settings->socket) || ferror (settings->socket))
    return NULL;
  fgets (buffer, 513, settings->socket);
  len = strlen (buffer);
  line = malloc (len);
  strncpy (line, buffer, len);
  line[len - 1] = '\0';
  if (settings->verbose)
    logstr ("-> %s\n", line);
  return line;
}
Exemplo n.º 29
0
void
sighandler (int sig)
{
  switch (sig)
    {
    case SIGABRT:
      logstr ("\tSIGABRT\n");
      break;
    case SIGBUS:
      logstr ("\tSIGBUS\n");
      break;
    case SIGHUP:
      logstr ("\tSIGHUP\n");
      break;
    case SIGINT:
      logstr ("\tSIGINT\n");
      break;
    case SIGKILL:
      logstr ("\tSIGKILL\n");
      break;
    case SIGQUIT:
      logstr ("\tSIGQUIT\n");
      break;
    case SIGTERM:
      logstr ("\tSIGTERM\n");
      break;
    case 0:
      logstr ("exiting, goodbye\n");
      break;
    default:
      break;
    }

  if (settings->socket)
    {
      fclose (settings->socket);
      settings->socket = NULL;
    }
  plugins_unload ();
}
Exemplo n.º 30
0
LPVOID
WinReallocCheck(LPVOID ptr, unsigned int size, char *lparam, int wparam,int flag,int handle)
{
	LPVOID	lp;
	MALLOCINFO *p;

	for(p=lpMallocInfo; p; p = p->next) {
		if(p->data == ptr) {
			totalalloc -= p->size;
			break;
		}
	}

		lp = WinRealloc(ptr,size);

        logstr(LF_DEBUG,"%s:%d: WinReallocCheck: old data=%x new data=%x size=%x %x %x\n",
		lparam,wparam,
                ptr,lp,size,
		flag,handle);

	if(ptr == 0)
		return 0;

	if(lp) {
		p->size  = size;
	} else {
		p->size  = 0;
	}

	p->data  = lp;
	p->lparam = lparam;
	p->wparam = wparam;

	totalalloc += size;	
	return lp;
}