File nodebrain-0.9.03-messages.patch of Package nodebrain

diff --exclude .git -rupN nodebrain-nbX/lib/nbcmd.c nodebrain-nbY/lib/nbcmd.c
--- nodebrain-nbX/lib/nbcmd.c	2014-12-20 23:46:35.007994568 -0500
+++ nodebrain-nbY/lib/nbcmd.c	2014-12-20 23:51:47.472323005 -0500
@@ -2313,6 +2313,7 @@ static int nbCmdParse(nbCELL context,cha
 //                       
 //            Note: need to finish verb tree
 
+void nbPlus(nbCELL context,char *cursor,int cmdopt);
 void nbCmd(nbCELL context,char *cursor,unsigned char cmdopt){ 
   NB_Stem *stem=context->object.type->stem;
   char symid,verb[256],*cursave;
diff --exclude .git -rupN nodebrain-nbX/lib/nbmedulla.c nodebrain-nbY/lib/nbmedulla.c
--- nodebrain-nbX/lib/nbmedulla.c	2014-12-20 23:46:35.012994605 -0500
+++ nodebrain-nbY/lib/nbmedulla.c	2014-12-21 01:09:15.046755738 -0500
@@ -924,6 +924,13 @@ int nbMedullaProcessWriter(void *session
     }
   size=buf->free-buf->page;
   len=write(process->putfile,buf->page,size);
+  if(len<0){
+    fprintf(stderr,"nbMedullaProcessWriter: unable to right - %s",strerror(errno));
+    close(process->putfile);
+    process->putfile=-1;
+    if(process->putQueue!=NULL) process->putQueue=nbMedullaQueueClose(process->putQueue);
+    return(1);  // request disable
+    }
   if(process->putQueue->putbuf==process->putQueue->getbuf){
     process->putQueue->putbuf=NULL;
     process->putQueue->getbuf=NULL;
@@ -1066,9 +1073,11 @@ int nbMedullaProcessReadBlocking(nbPROCE
         }
       else{
         sent=nbMedullaQueuePut(process->logQueue,buffer,len);
+        if(sent<0) fprintf(stderr,"[%d} Unexpected return code %d writing to stdin",process->pid,sent);
         len=nbMedullaQueueGet(process->logQueue,buffer,sizeof(buffer));
         while(len>=0){
           rc=(process->logger)(process,process->pid,process->session,buffer);
+          if(rc) fprintf(stderr,"[%d] Unexpected return code %d from stderr logger",process->pid,rc);
           len=nbMedullaQueueGet(process->logQueue,buffer,sizeof(buffer));
           }
         }
@@ -1213,13 +1222,17 @@ int nbMedullaFileReader(NB_MedullaFile *
       fprintf(stderr,"nbMedullaFileReader read errno=%d\n",errno);
       return(1);
       }
-    else have=nbMedullaQueuePut(medfile->queue,medfile->buffer,medfile->len);
+    else{
+      have=nbMedullaQueuePut(medfile->queue,medfile->buffer,medfile->len);
+      if(have<0) fprintf(stderr,"nbMedullaFileReader: Unexpected return code %d from nbMedullaQueuePut",have);
+      }
     //fprintf(stderr,"have=%d medfile len=%d\n",have,medfile->len);
     len=nbMedullaQueueGet(medfile->queue,medfile->buffer,sizeof(medfile->buffer));
     //fprintf(stderr,"queue get len=%d\n",len);
     while(len>=0){
       //fprintf(stderr,"calling consumer:%s\n",medfile->buffer);
       rc=(consumer)(session,medfile->buffer);
+      if(rc) fprintf(stderr,"Unexpected return code %d from medulla file consumer\n",rc);
       len=nbMedullaQueueGet(medfile->queue,medfile->buffer,sizeof(medfile->buffer));
       }
     }
@@ -1283,10 +1296,12 @@ int nbMedullaProcessReader(void *session
     return(1);  // end of file
     }
   sent=nbMedullaQueuePut(process->getQueue,buffer,len);
+  if(sent<0) fprintf(stderr,"[%d] Error writing to process stdin\n",process->pid);
   len=nbMedullaQueueGet(process->getQueue,buffer,sizeof(buffer));
   while(len>=0){
     //fprintf(stderr,"calling consumer:%s\n",buffer);
     rc=(process->consumer)(process,process->pid,process->session,buffer);
+    if(rc<0) fprintf(stderr,"[%d] Unexpected return code %d from consumer",process->pid,rc);
     len=nbMedullaQueueGet(process->getQueue,buffer,sizeof(buffer));
     }
   //fprintf(stderr,"[%d] nbMedullaProcessReader fildes=%d returning\n",process->pid,fildes);
@@ -1337,11 +1352,15 @@ int nbMedullaProcessLogger(void *session
     }
   //fprintf(stderr,"buffer[%d]: %s\n",len,buffer);
   sent=nbMedullaQueuePut(process->logQueue,buffer,len);
+  if(sent<len){
+    fprintf(stderr,"[%d] Error writing to process stdin\n",process->pid);
+    }
   //fprintf(stderr,"sent [%d] to queue\n",sent);
   len=nbMedullaQueueGet(process->logQueue,buffer,sizeof(buffer));
   while(len>=0){
     //fprintf(stderr,"calling logger[%d]:%s\n",len,buffer);
     rc=(process->logger)(process,process->pid,process->session,buffer);
+    if(rc<0) fprintf(stderr,"[%d] Unexpected return code %d from logger",process->pid,rc);
     len=nbMedullaQueueGet(process->logQueue,buffer,sizeof(buffer));
     }
   //fprintf(stderr,"queue msg len %d\n",len);
diff --exclude .git -rupN nodebrain-nbX/lib/nbmsg.c nodebrain-nbY/lib/nbmsg.c
--- nodebrain-nbX/lib/nbmsg.c	2014-12-20 23:46:35.015994626 -0500
+++ nodebrain-nbY/lib/nbmsg.c	2014-12-20 23:52:08.655486868 -0500
@@ -2175,14 +2175,14 @@ void nbMsgProducerUdpRead(nbCELL context
 */
 int nbMsgLogProduce(nbCELL context,nbMsgLog *msglog,uint32_t maxfilesize){
   char filename[256];
-  unsigned char  node;
+  // unsigned char  node; //2014-12-20 eat - not referenced
   DIR *dir;
   struct dirent *ent;
   int fd;
   int len;
 
   //fprintf(stderr,"nbMsgLogProduce: called with maxfilesize=%u\n",maxfilesize);
-  node=msglog->node;
+  // node=msglog->node;
   if(!(msglog->state&NB_MSG_STATE_LOGEND)){
     outMsg(0,'E',"nbMsgLogProduce: Message log not in end-of-log state - cabal \"%s\" node %d",msglog->cabal,msglog->node);
     return(-1);
@@ -2654,7 +2654,7 @@ unsigned char *nbMsgCacheStomp(nbCELL co
   nbMsgCacheSubscriber *msgsub;
   unsigned char *msgqrec,*msgqstop;
   int qmsglen;
-  int looking=1;
+  // int looking=1; // 2014-12-20 eat - not referenced - investigate
 
   msgqrec=msgcache->end;   // start at end
   msgqstop=msgqrec+1+msglen;  // where new entry would stop
@@ -2714,7 +2714,7 @@ unsigned char *nbMsgCacheStomp(nbCELL co
               nbLogMsg(context,0,'E',"nbMsgCacheStomp: Message too large for message cache buffer - make cache size 256KB or more");
               return(NULL);
               }
-            looking=0;
+            // looking=0; // 2014-12-20 eat - not referenced
             }
           msgcache->start=msgcache->bufferStart;
           }
@@ -3615,7 +3615,7 @@ int nbMsgCabalEnable(nbCELL context,nbMs
   int connected;      // -1 - found no connected or connecting peer, 0 - found connecting peer, 1 - found connected peer 
   int expirationTime;
   int preferred=1;    // assume we are in a prefered state
-  int satisfied=1;    // assume we are in a satisfied state (used for ring topology only)
+  // int satisfied=1;    // assume we are in a satisfied state (used for ring topology only)
   time_t utime;
 
   if(msgTrace){
@@ -3725,7 +3725,7 @@ int nbMsgCabalEnable(nbCELL context,nbMs
           else preferred=0;
           }
         }
-      if(connected<1) satisfied=0;
+      if(connected<1); //  satisfied=0; // 2014-12-20 eat - not referenced
       else{  // continue through list of nodes and disconnect any less prefered connection we initiated
         for(;msgnode!=msgcabal->node;msgnode=msgnode->next){
           if(msgnode->type&NB_MSG_NODE_TYPE_HUB && msgnode->type&NB_MSG_NODE_TYPE_CLIENT){
@@ -3765,7 +3765,7 @@ int nbMsgCabalEnable(nbCELL context,nbMs
           else preferred=0;
           }
         }
-      if(connected<1) satisfied=0;
+      if(connected<1); //  satisfied=0; // 2014-12-20 eat - not referenced
       else{  // continue through list of nodes and disconnect any less prefered connection we initiated
         for(;msgnode!=msgcabal->node;msgnode=msgnode->prior){
           if(msgnode->type&NB_MSG_NODE_TYPE_HUB && msgnode->type&NB_MSG_NODE_TYPE_SERVER){
diff --exclude .git -rupN nodebrain-nbX/lib/nbparse.c nodebrain-nbY/lib/nbparse.c
--- nodebrain-nbX/lib/nbparse.c	2014-12-20 23:46:35.017994642 -0500
+++ nodebrain-nbY/lib/nbparse.c	2014-12-20 23:52:18.245561051 -0500
@@ -1157,7 +1157,7 @@ NB_Object *nbParseCell(NB_Term *context,
   struct TYPE *type;
   char symid,*cursave;
   int conditionalState=0;  // 8 - decided, 4 - true, 2 - false, 1 - unknown
-  NB_Object *cobject=NULL; // conditional condition object
+  //NB_Object *cobject=NULL; // conditional condition object
 
   if(parseTrace) outMsg(0,'T',"nbParseCell(%d): called [%s].",level,*cursor);
   if(level==7) lobject=nbParseObject(context,cursor);
@@ -1254,7 +1254,7 @@ NB_Object *nbParseCell(NB_Term *context,
             return(NULL);
             }
           NB_Conditional *conditional=NULL;
-          cobject=lobject;
+          // cobject=lobject; // 2014-12-20 eat - not referenced
           switch(symid){
             case '2':  // true
               conditionalState|=4;
diff --exclude .git -rupN nodebrain-nbX/lib/nbproxy.c nodebrain-nbY/lib/nbproxy.c
--- nodebrain-nbX/lib/nbproxy.c	2014-12-20 23:46:35.018994650 -0500
+++ nodebrain-nbY/lib/nbproxy.c	2014-12-20 23:52:34.511686870 -0500
@@ -484,6 +484,7 @@ static void nbProxyReader(nbCELL context
 
 static int nbProxyForwardProducer(nbCELL context,nbProxy *proxy,void *handle){
   nbProxyPage *page;
+  int rc;
 
   nbLogMsg(context,0,'T',"nbProxyForwardProducer: called proxy=%p other=%p",proxy,proxy->other);
   page=nbProxyGetPage(context,proxy->other);
@@ -494,7 +495,11 @@ static int nbProxyForwardProducer(nbCELL
     }
   nbLogMsg(context,0,'T',"nbProxyForwardProducer: putting page(s) to self");
   while(page){
-    nbProxyPutPage(context,proxy,page);
+    rc=nbProxyPutPage(context,proxy,page);
+    if(rc<0){
+      nbLogMsg(context,0,'T',"nbProxyForwardProducer: nbProxyPutPage returned %s",rc);
+      return(rc);
+      }
     page=nbProxyGetPage(context,proxy->other);
     }
   nbLogMsg(context,0,'T',"nbProxyForwardProducer: returning");
@@ -510,6 +515,10 @@ static int nbProxyForwardConsumer(nbCELL
   if(!page) return(0);
   nbLogMsg(context,0,'T',"nbProxyForwardConsumer: have page");
   rc=nbProxyPutPage(context,proxy->other,page);
+  if(rc<0){
+    nbLogMsg(context,0,'T',"nbProxyForwardConsumer: nbProxyPutPage returned %s",rc);
+    return(rc);
+    }
   nbLogMsg(context,0,'T',"nbProxyForwardConsumer: returning");
   return(0);
   }
diff --exclude .git -rupN nodebrain-nbX/lib/nbrule.c nodebrain-nbY/lib/nbrule.c
--- nodebrain-nbX/lib/nbrule.c	2014-12-20 23:46:35.020994665 -0500
+++ nodebrain-nbY/lib/nbrule.c	2014-12-20 23:52:50.692812028 -0500
@@ -929,7 +929,7 @@ void nbRuleSolve(NB_Term *term){
   NB_Term **termP;
   NB_Hash *hash;
   int v;
-  struct ACTION *action;
+  // struct ACTION *action; // 2014-12-20 eat - was set but not referenced
   struct COND *cond;
 /* 2014-01-26 eat
   NB_TreeIterator treeIterator;
@@ -942,7 +942,7 @@ void nbRuleSolve(NB_Term *term){
   if(type==condTypeOnRule || type==condTypeWhenRule){
     cond=((struct COND *)term->def);
     if(cond->cell.object.value!=nb_Unknown) return;
-    action=cond->right;
+    // action=cond->right;
     if(trace){
       outPut("Solving: ");
       nbTermShowItem(term);
diff --exclude .git -rupN nodebrain-nbX/lib/nbsource.c nodebrain-nbY/lib/nbsource.c
--- nodebrain-nbX/lib/nbsource.c	2014-12-20 23:46:35.021994672 -0500
+++ nodebrain-nbY/lib/nbsource.c	2014-12-20 23:52:58.780874585 -0500
@@ -117,6 +117,10 @@ int nbSourceIgnoreTil(nbCELL context,FIL
     if(*buf=='%' && *(buf+1)!=' '){
       cursor=buf+1;
       symid=nbParseSymbol(ident,sizeof(ident),&cursor);
+      if(symid!='t'){
+        outMsg(0,'E',"Directive not recognized - expecting term after %% at-->%s",buf+1);
+        return(-1);
+        }
       if(strcmp(ident,"if")==0){
         directive=nbSourceIgnoreTil(context,file,buf,1);
         if(directive!=1) return(directive);  /* should be 0 or -1 */
diff --exclude .git -rupN nodebrain-nbX/lib/nbspine.c nodebrain-nbY/lib/nbspine.c
--- nodebrain-nbX/lib/nbspine.c	2014-12-20 23:46:35.021994672 -0500
+++ nodebrain-nbY/lib/nbspine.c	2014-12-20 23:53:13.603989234 -0500
@@ -323,8 +323,10 @@ nbCHILD nbChildOpen(int options,int uid,
       //if(uid!=0) setuid(uid); // set user id if requested
       // 2014-12-06 eat - always do them together
       if(uid!=0 || gid!=0){
-        setgid(gid);
-        setuid(uid);
+        if(setgroups(0,NULL) || setgid(gid) || setuid(uid)){
+          fprintf(stderr,"Attempt to switch user or group failed - terminating\n");
+          exit(NB_EXITCODE_FAIL);
+          }
         }
       }
 
diff --exclude .git -rupN nodebrain-nbX/module/netflow/nb_netflow.c nodebrain-nbY/module/netflow/nb_netflow.c
--- nodebrain-nbX/module/netflow/nb_netflow.c	2014-12-20 23:46:35.039994805 -0500
+++ nodebrain-nbY/module/netflow/nb_netflow.c	2014-12-20 23:54:02.851370106 -0500
@@ -726,6 +726,7 @@ static void partialSum(nbCELL context,ch
 /*
 *  Display volume sum table
 */
+/* 2014-12-20 not currently referenced
 static void displaySum(nbCELL context,char *title,struct NB_MOD_NETFLOW_VOLUME *volume,int n,double min){
   int i;
 
@@ -739,6 +740,7 @@ static void displaySum(nbCELL context,ch
     volume++;
     }
   }
+*/
 
 /*
 *  Display variation distribution
diff --exclude .git -rupN nodebrain-nbX/module/servant/nb_servant.c nodebrain-nbY/module/servant/nb_servant.c
--- nodebrain-nbX/module/servant/nb_servant.c	2014-12-20 23:46:35.047994864 -0500
+++ nodebrain-nbY/module/servant/nb_servant.c	2014-12-20 23:54:37.506638099 -0500
@@ -184,7 +184,13 @@ static int servantCommand(nbCELL context
     nbLogMsg(context,0,'E',"Servant not started - auto start not yet supported");
     return(1);
     }
-  else len=nbMedullaProcessPut(servant->process,msgbuf);
+  else{
+    len=nbMedullaProcessPut(servant->process,msgbuf);
+    if(len<0){
+      nbLogMsg(context,0,'E',"Unexpected return code from nbMedullaProcessPut - %d",len);
+      return(-1);
+      }
+    }
   return(0);
   }
 
diff --exclude .git -rupN nodebrain-nbX/module/udp/nb_udp.c nodebrain-nbY/module/udp/nb_udp.c
--- nodebrain-nbX/module/udp/nb_udp.c	2014-12-20 23:46:35.055994923 -0500
+++ nodebrain-nbY/module/udp/nb_udp.c	2014-12-21 01:06:15.429386424 -0500
@@ -489,7 +489,7 @@ static int clientDisable(nbCELL context,
 *
 *    <node>[(<args>)][:<text>]
 */
-static int *clientCommand(nbCELL context,void *skillHandle,NB_MOD_Client *client,nbCELL arglist,char *text){
+static int clientCommand(nbCELL context,void *skillHandle,NB_MOD_Client *client,nbCELL arglist,char *text){
   char buffer[NB_BUFSIZE],*cursor=buffer;
   int len,sent;
 
@@ -506,6 +506,10 @@ static int *clientCommand(nbCELL context
   cursor+=strlen(cursor);
   len=cursor-buffer;
   sent=send(client->socket,buffer,len,0);
+  if(sent!=len){
+    nbLogMsg(context,0,'E',"clientCommand: send returned length of %d - expecting %d",sent,len);
+    return(-1);
+    }
   return(0);
   }
 
diff --exclude .git -rupN nodebrain-nbX/nb.pc.in nodebrain-nbY/nb.pc.in
--- nodebrain-nbX/nb.pc.in	2014-12-20 23:46:35.057994939 -0500
+++ nodebrain-nbY/nb.pc.in	2014-12-21 03:09:21.418922835 -0500
@@ -6,7 +6,7 @@ includedir=@includedir@
 Name: NodeBrain
 Description: A rule engine for state and event monitoring
 Version: @VERSION@
-Requires.private: edit openssl pcre
+Requires.private: libedit openssl pcre
 Libs: -L${libdir} @LIBS@ -lnb 
 Cflags: -I${includedir}