Exemple #1
0
int
ArgusInitializeAuthentication (struct ARGUS_INPUT *input)
{
   int retn = 1;

#ifdef ARGUS_SASL
   struct sockaddr_in localaddr, remoteaddr;
   int salen, fd = input->fd;
   char *localhostname = NULL;

   if ((retn = sasl_client_init(RaCallBacks)) != SASL_OK)
      ArgusLog (LOG_ERR, "ArgusInitializeAuthentication() sasl_client_init %d", retn);

   localhostname = ArgusCalloc (1, 1024);
   gethostname(localhostname, 1024);
   if (!strchr (localhostname, '.')) {
      strcat (localhostname, ".");
      getdomainname (&localhostname[strlen(localhostname)], 1024 - strlen(localhostname));
   }

   if ((retn = sasl_client_new("argus", localhostname, NULL, SASL_SECURITY_LAYER, &input->sasl_conn)) != SASL_OK)
      ArgusLog (LOG_ERR, "ArgusInitializeAuthentication() sasl_client_new %d", retn);
   
   /* set external properties here
   sasl_setprop(input->sasl_conn, SASL_SSF_EXTERNAL, &extprops); */
   
   /* set required security properties here
   sasl_setprop(input->sasl_conn, SASL_SEC_PROPS, &secprops); */
   
   /* set ip addresses */
   salen = sizeof(localaddr);
   if (getsockname(fd, (struct sockaddr *)&localaddr, &salen) < 0)
      perror("getsockname");

   salen = sizeof(remoteaddr); 
   if (getpeername(fd, (struct sockaddr *)&remoteaddr, &salen) < 0)
      perror("getpeername");

   if ((retn = sasl_setprop(input->sasl_conn, SASL_IP_LOCAL, &localaddr)) != SASL_OK)
      ArgusLog (LOG_ERR, "ArgusInitializeAuthentication() error setting localaddr %d", retn);

   if ((retn = sasl_setprop(input->sasl_conn, SASL_IP_REMOTE, &remoteaddr)) != SASL_OK)
      ArgusLog (LOG_ERR, "ArgusInitializeAuthentication() error setting remoteaddr %d", retn);

   retn = 1;
#endif 

#ifdef ARGUSDEBUG
   ArgusDebug (2, "ArgusInitializeAuthentication () returning %d\n", retn);
#endif 

   return (retn);
}
Exemple #2
0
void
RaArgusInputComplete (struct ArgusInput *input)
{
   struct ArgusRecordStruct *nsr;
   struct ArgusWfileStruct *wfile = NULL;
   char buf[MAXSTRLEN];
   int count, label, i, fd;
 
   if (ArgusSorter->ArgusReplaceMode) {
      if (ArgusParser->ArgusWfileList == NULL)
         ArgusParser->ArgusWfileList = ArgusNewList();
 
      if ((count = ArgusSorter->ArgusRecordQueue->count) > 0) {
         if (!(ArgusParser->ArgusRandomSeed))
            srandom(ArgusParser->ArgusRandomSeed);

         srandom (ArgusParser->ArgusRealTime.tv_usec);
         label = random() % 100000;
 
         bzero(buf, sizeof(buf));
         snprintf (buf, MAXSTRLEN, "%s.tmp%d", input->filename, label);
         if ((fd = open(buf, O_CREAT|O_EXCL, input->statbuf.st_mode)) < 0)
            ArgusLog (LOG_ERR, "open %s error: %s", buf, strerror(errno));
 
         close(fd);
 
         if ((wfile = (struct ArgusWfileStruct *) ArgusCalloc (1, sizeof (*wfile))) != NULL) {
            ArgusPushFrontList(ArgusParser->ArgusWfileList, (struct ArgusListRecord *)wfile, ARGUS_NOLOCK);
            wfile->filename  = strdup(buf);
 
         } else
            ArgusLog (LOG_ERR, "setArgusWfile, ArgusCalloc %s", strerror(errno));
 
         ArgusSortQueue (ArgusSorter, ArgusSorter->ArgusRecordQueue);
 
         for (i = 0, count = ArgusSorter->ArgusRecordQueue->count; i < count; i++)
            RaSendArgusRecord ((struct ArgusRecordStruct *)ArgusSorter->ArgusRecordQueue->array[i]);
 
         while ((nsr = (struct ArgusRecordStruct *) ArgusPopQueue(ArgusSorter->ArgusRecordQueue, ARGUS_NOLOCK)) != NULL)
            ArgusDeleteRecordStruct(ArgusParser, nsr);
 
         rename (wfile->filename, input->filename);
         fclose (wfile->fd);
         ArgusDeleteList (ArgusParser->ArgusWfileList, ARGUS_WFILE_LIST);
         ArgusParser->ArgusWfileList = NULL;
 
         if (ArgusParser->Vflag)
            ArgusLog(LOG_INFO, "file %s sorted", input->filename);
      }
   }
}