| 73 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 74 | 
   | 
 char* sock_comm(FILE *f_r, FILE *f_w, char *sendString){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 75 | 
   | 
         char *reply; | 
 
 
 
 
 
 
 
 
 | 76 | 
 + | 
         logmessage(LOG_DEBUG, "Sending %s",sendString); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 77 | 
   | 
         fprintf(f_w, "%s\n", sendString); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 78 | 
   | 
         fflush(f_w); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 79 | 
   | 
         reply=fpgetline(f_r); | 
 
 
 
 
 
 
 
 
 | 80 | 
 + | 
         if (reply!=NULL) logmessage(LOG_DEBUG, "Received %s", reply); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 | 
   | 
         /* Returns pointer to static buffer */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 82 | 
   | 
         return reply; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 83 | 
   | 
 }        | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 145 | 
   | 
                 return -1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 146 | 
   | 
         }        | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 147 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 | 146 | 
 – | 
         logmessage(LOG_DEBUG, "Sending STARTCONIG"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 148 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "STARTCONFIG"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 149 | 
   | 
         if ((reply==NULL) || (strncasecmp(reply, "OK", 2) != 0) ) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 150 | 
   | 
                 logmessage(LOG_ERR, "Server error on STARTCONFIG");      | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 151 | 
   | 
                 return -1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 152 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 153 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 153 | 
 – | 
         logmessage(LOG_DEBUG, "Sending LASTMODIFIED"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 154 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "LASTMODIFIED"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 155 | 
   | 
         if((reply== NULL) || (strncasecmp(reply, "ERROR", 5) ==0)){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 156 | 
   | 
                 logmessage(LOG_ERR, "Server error on LASTMODIFIED (%m)"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 161 | 
   | 
                 return -1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 162 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 163 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 164 | 
 – | 
         logmessage(LOG_DEBUG, "Sending FILELIST"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 164 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "FILELIST"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 165 | 
   | 
         if((reply== NULL) || (strncasecmp(reply, "ERROR", 5) ==0)){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 166 | 
   | 
                 logmessage(LOG_ERR, "Server error on FILELIST (%m)"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 171 | 
   | 
                 return -1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 172 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 173 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 175 | 
 – | 
         logmessage(LOG_DEBUG, "Sending FQDN"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 174 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "FQDN"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 175 | 
   | 
         if((reply== NULL) || (strncasecmp(reply, "ERROR", 5)==0)){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 176 | 
   | 
                 logmessage(LOG_ERR, "Server error on FQDN (%m)"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 181 | 
   | 
                 return -1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 182 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 183 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 186 | 
 – | 
         logmessage(LOG_DEBUG, "Sending FQDN"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 184 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "UDPUpdateTime"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 185 | 
   | 
         if(reply== NULL){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 186 | 
   | 
                 logmessage(LOG_ERR, "Server error (%m)"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 190 | 
   | 
                 ihost_state->udp_update_time=atoi(reply); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 191 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 192 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 | 196 | 
 – | 
         logmessage(LOG_DEBUG, "Sending TCPUpdateTime"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 193 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "TCPUpdateTime"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 194 | 
   | 
         if(reply== NULL){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 195 | 
   | 
                 logmessage(LOG_ERR, "Server error on TCPUpdateTime (%m)"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 199 | 
   | 
                 ihost_state->tcp_update_time=atoi(reply); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 200 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 201 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 206 | 
 – | 
         logmessage(LOG_DEBUG, "Sending ENDCONFIG"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 202 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "ENDCONFIG"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 203 | 
   | 
         if(reply== NULL){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 204 | 
   | 
                 logmessage(LOG_ERR, "Server error on ENDCONFIG (%m)"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 205 | 
   | 
                 return -1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 206 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 207 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 213 | 
 – | 
         logmessage(LOG_DEBUG, "Sending FILTER"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 208 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "FILTER"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 209 | 
   | 
         if((reply== NULL) || (strncasecmp(reply, "ERROR", 5)==0)){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 210 | 
   | 
                 logmessage(LOG_ERR, "Server error FILTER failed (%m)"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 235 | 
   | 
                 return -1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 236 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 237 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 244 | 
 – | 
         logmessage(LOG_DEBUG, "Sending END"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 238 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "END"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 239 | 
   | 
         if((reply== NULL) || (strncasecmp(reply, "ERROR", 5) ==0 )){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 240 | 
   | 
                 logmessage(LOG_ERR, "Server error on END (%m)"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 293 | 
   | 
                 return -1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 294 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 295 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 303 | 
 – | 
         logmessage(LOG_DEBUG, "Sending HEARTBEAT"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 296 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "HEARTBEAT"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 297 | 
   | 
         if ((reply==NULL) || (strncasecmp(reply, "ERROR", 5) == 0) ) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 298 | 
   | 
                 logmessage(LOG_ERR, "Server error on HEARTBEAT"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 299 | 
   | 
                 return -1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 300 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 301 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 310 | 
 – | 
         logmessage(LOG_DEBUG, "Sending CONFIG"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 302 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "CONFIG"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 303 | 
   | 
         if ((reply==NULL) || (strncasecmp(reply, "ERROR", 5) == 0) ) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 304 | 
   | 
                 logmessage(LOG_ERR, "Server error on CONFIG"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 305 | 
   | 
                 return -1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 306 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 307 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 317 | 
 – | 
         logmessage(LOG_DEBUG, "Sending %s", ihost_state->files_list); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 308 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, ihost_state->files_list); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 309 | 
   | 
         if ((reply==NULL) || (strncasecmp(reply, "OK", 2) != 0) ) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 310 | 
   | 
                 logmessage(LOG_ERR, "Server error on fileslist"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 311 | 
   | 
                 return -1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 312 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 313 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 324 | 
 – | 
         logmessage(LOG_DEBUG, "Sending %s", ihost_state->last_modified); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 314 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, ihost_state->last_modified); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 315 | 
   | 
         if (reply==NULL) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 316 | 
   | 
                 logmessage(LOG_ERR, "Server error NULL recieved on lastmodified"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 322 | 
   | 
                 exitcode=RECONFIGURE_RETURN_CODE; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 323 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 324 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 336 | 
 – | 
         logmessage(LOG_DEBUG,"Sending KEY"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 325 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "KEY"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 326 | 
   | 
         if ((reply==NULL) || (strncasecmp(reply, "ERROR", 5) == 0) ) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 327 | 
   | 
                 logmessage(LOG_ERR, "Server error on KEY"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 334 | 
   | 
                 return -1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 335 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 336 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 349 | 
 – | 
         logmessage(LOG_DEBUG,"Sending ENDHEARTBEAT"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 337 | 
   | 
         reply=sock_comm(fm_fd_r, fm_fd_w, "ENDHEARTBEAT"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 338 | 
   | 
         if((reply== NULL) || (strncasecmp(reply, "ERROR", 5) ==0 )){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 339 | 
   | 
                 logmessage(LOG_ERR, "Server error on ENDHEARTBEAT (%m)"); |