254 | | if (!(pidFile = fopen("/var/run/renetcol.pid", "r"))) { |
255 | | syslog (LOG_ERR, "error during /var/run/renetcol.pid opening : %s\n", |
256 | | strerror(errno)); |
257 | | exit(1); |
258 | | } else { |
259 | | fgets(line, 256, pidFile); |
260 | | if (sscanf(line, "%u", &pid)==0) |
261 | | syslog(LOG_ERR,"sscanf : %s", strerror(errno)); |
262 | | renetcolPID = pid; |
263 | | } |
264 | | fclose(pidFile); |
265 | | if (renetcolPID==0){ |
266 | | syslog(LOG_INFO, "PID null"); |
| 273 | /* get PID SMP1 */ |
| 274 | if (!(pidFile = fopen("/var/run/renetcolSMP1.pid", "r"))) { |
| 275 | syslog (LOG_ERR, "error during /var/run/renetcolSMP1.pid opening : %s\n", |
| 276 | strerror(errno)); |
| 277 | exit(1); |
| 278 | } else { |
| 279 | fgets(line, 256, pidFile); |
| 280 | if (sscanf(line, "%u", &pid)==0) |
| 281 | syslog(LOG_ERR,"sscanf : %s", strerror(errno)); |
| 282 | renetcolSMP1PID = pid; |
| 283 | } |
| 284 | fclose(pidFile); |
| 285 | if (renetcolSMP1PID==0){ |
| 286 | syslog(LOG_INFO, "PID SMP1 null"); |
268 | | if (kill(renetcolPID, SIGUSR1)<0) |
269 | | syslog(LOG_ERR, "I can't send SIGUSR1 to renetcol process : %s", |
270 | | strerror(errno)); |
| 288 | if (kill(renetcolSMP1PID, SIGUSR1)<0) |
| 289 | syslog(LOG_ERR, "I can't send SIGUSR1 to renetcolSMP1 process : %s", strerror(errno)); |
| 290 | } |
| 291 | /* get PID SMP2 */ |
| 292 | if (!(pidFile = fopen("/var/run/renetcolSMP2.pid", "r"))) { |
| 293 | syslog (LOG_ERR, "error during /var/run/renetcolSMP2.pid opening : %s\n", |
| 294 | strerror(errno)); |
| 295 | exit(1); |
| 296 | } else { |
| 297 | fgets(line, 256, pidFile); |
| 298 | if (sscanf(line, "%u", &pid)==0) |
| 299 | syslog(LOG_ERR,"sscanf : %s", strerror(errno)); |
| 300 | renetcolSMP2PID = pid; |
| 301 | } |
| 302 | fclose(pidFile); |
| 303 | if (renetcolSMP2PID==0){ |
| 304 | syslog(LOG_INFO, "PID SMP2 null"); |
| 305 | }else{ |
| 306 | if (kill(renetcolSMP2PID, SIGUSR1)<0) |
| 307 | syslog(LOG_ERR, "I can't send SIGUSR1 to renetcolSMP2 process : %s", strerror(errno)); |
| 308 | } |
| 309 | /* get PID SMP3 */ |
| 310 | if (!(pidFile = fopen("/var/run/renetcolSMP3.pid", "r"))) { |
| 311 | syslog (LOG_ERR, "error during /var/run/renetcolSMP3.pid opening : %s\n", |
| 312 | strerror(errno)); |
| 313 | exit(1); |
| 314 | } else { |
| 315 | fgets(line, 256, pidFile); |
| 316 | if (sscanf(line, "%u", &pid)==0) |
| 317 | syslog(LOG_ERR,"sscanf : %s", strerror(errno)); |
| 318 | renetcolSMP3PID = pid; |
| 319 | } |
| 320 | fclose(pidFile); |
| 321 | if (renetcolSMP3PID==0){ |
| 322 | syslog(LOG_INFO, "PID SMP3 null"); |
| 323 | }else{ |
| 324 | if (kill(renetcolSMP3PID, SIGUSR1)<0) |
| 325 | syslog(LOG_ERR, "I can't send SIGUSR1 to renetcolSMP3 process : %s", strerror(errno)); |
| 326 | } |
| 327 | /* get PID SMP4 */ |
| 328 | if (!(pidFile = fopen("/var/run/renetcolSMP4.pid", "r"))) { |
| 329 | syslog (LOG_ERR, "error during /var/run/renetcolSMP4.pid opening : %s\n", |
| 330 | strerror(errno)); |
| 331 | exit(1); |
| 332 | } else { |
| 333 | fgets(line, 256, pidFile); |
| 334 | if (sscanf(line, "%u", &pid)==0) |
| 335 | syslog(LOG_ERR,"sscanf : %s", strerror(errno)); |
| 336 | renetcolSMP4PID = pid; |
| 337 | } |
| 338 | fclose(pidFile); |
| 339 | if (renetcolSMP4PID==0){ |
| 340 | syslog(LOG_INFO, "PID SMP4 null"); |
| 341 | }else{ |
| 342 | if (kill(renetcolSMP4PID, SIGUSR1)<0) |
| 343 | syslog(LOG_ERR, "I can't send SIGUSR1 to renetcolSMP4 process : %s", strerror(errno)); |
349 | | if ((myQueue = msgget(myKey, 0)) == -1){ |
| 432 | if ((myQueueSMP1 = msgget(myKeySMP1, 0)) == -1){ |
| 433 | syslog(LOG_ERR, "msgget : %s", strerror(errno)); |
| 434 | exit(1); |
| 435 | } |
| 436 | if ((myKeySMP2 = ftok(keyIdSMP2, 0))== -1){ |
| 437 | syslog(LOG_ERR, "ftok : %s", strerror(errno)); |
| 438 | exit(1); |
| 439 | } |
| 440 | if ((myQueueSMP2 = msgget(myKeySMP2, 0)) == -1){ |
| 441 | syslog(LOG_ERR, "msgget : %s", strerror(errno)); |
| 442 | exit(1); |
| 443 | } |
| 444 | if ((myKeySMP3 = ftok(keyIdSMP3, 0))== -1){ |
| 445 | syslog(LOG_ERR, "ftok : %s", strerror(errno)); |
| 446 | exit(1); |
| 447 | } |
| 448 | if ((myQueueSMP3 = msgget(myKeySMP3, 0)) == -1){ |
| 449 | syslog(LOG_ERR, "msgget : %s", strerror(errno)); |
| 450 | exit(1); |
| 451 | } |
| 452 | if ((myKeySMP4 = ftok(keyIdSMP4, 0))== -1){ |
| 453 | syslog(LOG_ERR, "ftok : %s", strerror(errno)); |
| 454 | exit(1); |
| 455 | } |
| 456 | if ((myQueueSMP4 = msgget(myKeySMP4, 0)) == -1){ |
395 | | if (tmp->id == rulesID){ |
396 | | s = sendMessage(tmp->host->sockId, myText, sizeof(myMsg.text), |
397 | | tmp->host->hostAddressPtr); |
398 | | } |
399 | | } |
400 | | } else if (12==*((unsigned short*)&buffer2)){ |
401 | | buffer4[0]= *(myText+i); i++; |
402 | | buffer4[1]= *(myText+i); i++; |
403 | | buffer4[2]= *(myText+i); i++; |
404 | | buffer4[3]= *(myText+i); i++; |
405 | | renetcolPID = *((pid_t *)&buffer4); |
406 | | if (!(pidFile = fopen("/var/run/renetcol.pid", "w"))) { |
407 | | syslog (LOG_ERR, "error during /var/run/renetcol.pid opening : %s\n", |
408 | | strerror(errno)); |
409 | | exit(1); |
410 | | } else { |
411 | | if (fprintf(pidFile, "%u", renetcolPID)==0) |
412 | | syslog(LOG_ERR,"fprintf : %s", strerror(errno)); |
413 | | } |
414 | | fclose(pidFile); |
415 | | } else if (13==*((unsigned short*)&buffer2)){ |
| 502 | if (tmp->id == rulesID){ |
| 503 | s = sendMessage(tmp->host->sockId, myTextSMP1, sizeof(myMsgSMP1.text), |
| 504 | tmp->host->hostAddressPtr); |
| 505 | } |
| 506 | } |
| 507 | } else if (12==*((unsigned short*)&buffer2)){ |
| 508 | buffer4[0]= *(myTextSMP1+i); i++; |
| 509 | buffer4[1]= *(myTextSMP1+i); i++; |
| 510 | buffer4[2]= *(myTextSMP1+i); i++; |
| 511 | buffer4[3]= *(myTextSMP1+i); i++; |
| 512 | renetcolSMP1PID = *((pid_t *)&buffer4); |
| 513 | if (!(pidFile = fopen("/var/run/renetcolSMP1.pid", "w"))) { |
| 514 | syslog (LOG_ERR, "error during /var/run/renetcolSMP1.pid opening : %s\n", |
| 515 | strerror(errno)); |
| 516 | exit(1); |
| 517 | } else { |
| 518 | if (fprintf(pidFile, "%u", renetcolSMP1PID)==0) |
| 519 | syslog(LOG_ERR,"fprintf : %s", strerror(errno)); |
| 520 | } |
| 521 | fclose(pidFile); |
| 522 | } else if (13==*((unsigned short*)&buffer2)){ |
| 528 | |
| 529 | myTextSMP2 = msgRcv(myQueueSMP2, &myMsgSMP2, type); |
| 530 | buffer2[0]= *(myTextSMP2+i); i++; |
| 531 | buffer2[1]= *(myTextSMP2+i); i++; |
| 532 | typeMsg = *((unsigned short *)&buffer2); |
| 533 | if (1==typeMsg){ |
| 534 | /* we send the template definition to all the known destination */ |
| 535 | tmp = rulesListPtr; |
| 536 | for ( ; tmp; tmp=tmp->next) { |
| 537 | s = sendMessage(tmp->host->sockId, myTextSMP2, sizeof(myMsgSMP2.text), |
| 538 | tmp->host->hostAddressPtr); |
| 539 | } |
| 540 | } else if (14==*((unsigned short*)&buffer2)){ |
| 541 | buffer4[0]= *(myTextSMP2+i); i++; |
| 542 | buffer4[1]= *(myTextSMP2+i); i++; |
| 543 | buffer4[2]= *(myTextSMP2+i); i++; |
| 544 | buffer4[3]= *(myTextSMP2+i); i++; |
| 545 | renetcolSMP2PID = *((pid_t *)&buffer4); |
| 546 | if (!(pidFile = fopen("/var/run/renetcolSMP2.pid", "w"))) { |
| 547 | syslog (LOG_ERR, "error during /var/run/renetcolSMP2.pid opening : %s\n", |
| 548 | strerror(errno)); |
| 549 | exit(1); |
| 550 | } else { |
| 551 | if (fprintf(pidFile, "%u", renetcolSMP2PID)==0) |
| 552 | syslog(LOG_ERR,"fprintf : %s", strerror(errno)); |
| 553 | } |
| 554 | fclose(pidFile); |
| 555 | } else if (13==*((unsigned short*)&buffer2)){ |
| 556 | initConfSender(); |
| 557 | } else { |
| 558 | syslog(LOG_ERR,"message type undefined for this queue SMP2"); |
| 559 | } |
| 560 | i=0; |
| 561 | |
| 562 | myTextSMP3 = msgRcv(myQueueSMP3, &myMsgSMP3, type); |
| 563 | buffer2[0]= *(myTextSMP3+i); i++; |
| 564 | buffer2[1]= *(myTextSMP3+i); i++; |
| 565 | typeMsg = *((unsigned short *)&buffer2); |
| 566 | if (1==typeMsg){ |
| 567 | /* we send the template definition to all the known destination */ |
| 568 | tmp = rulesListPtr; |
| 569 | for ( ; tmp; tmp=tmp->next) { |
| 570 | s = sendMessage(tmp->host->sockId, myTextSMP3, sizeof(myMsgSMP3.text), |
| 571 | tmp->host->hostAddressPtr); |
| 572 | } |
| 573 | } else if (15==*((unsigned short*)&buffer2)){ |
| 574 | buffer4[0]= *(myTextSMP3+i); i++; |
| 575 | buffer4[1]= *(myTextSMP3+i); i++; |
| 576 | buffer4[2]= *(myTextSMP3+i); i++; |
| 577 | buffer4[3]= *(myTextSMP3+i); i++; |
| 578 | renetcolSMP3PID = *((pid_t *)&buffer4); |
| 579 | if (!(pidFile = fopen("/var/run/renetcolSMP3.pid", "w"))) { |
| 580 | syslog (LOG_ERR, "error during /var/run/renetcolSMP3.pid opening : %s\n", |
| 581 | strerror(errno)); |
| 582 | exit(1); |
| 583 | } else { |
| 584 | if (fprintf(pidFile, "%u", renetcolSMP3PID)==0) |
| 585 | syslog(LOG_ERR,"fprintf : %s", strerror(errno)); |
| 586 | } |
| 587 | fclose(pidFile); |
| 588 | } else if (13==*((unsigned short*)&buffer2)){ |
| 589 | initConfSender(); |
| 590 | } else { |
| 591 | syslog(LOG_ERR,"message type undefined for this queue SMP3"); |
| 592 | } |
| 593 | i=0; |
| 594 | |
| 595 | myTextSMP4 = msgRcv(myQueueSMP4, &myMsgSMP4, type); |
| 596 | buffer2[0]= *(myTextSMP4+i); i++; |
| 597 | buffer2[1]= *(myTextSMP4+i); i++; |
| 598 | typeMsg = *((unsigned short *)&buffer2); |
| 599 | if (1==typeMsg){ |
| 600 | /* we send the template definition to all the known destination */ |
| 601 | tmp = rulesListPtr; |
| 602 | for ( ; tmp; tmp=tmp->next) { |
| 603 | s = sendMessage(tmp->host->sockId, myTextSMP4, sizeof(myMsgSMP4.text), |
| 604 | tmp->host->hostAddressPtr); |
| 605 | } |
| 606 | } else if (16==*((unsigned short*)&buffer2)){ |
| 607 | buffer4[0]= *(myTextSMP4+i); i++; |
| 608 | buffer4[1]= *(myTextSMP4+i); i++; |
| 609 | buffer4[2]= *(myTextSMP4+i); i++; |
| 610 | buffer4[3]= *(myTextSMP4+i); i++; |
| 611 | renetcolSMP4PID = *((pid_t *)&buffer4); |
| 612 | if (!(pidFile = fopen("/var/run/renetcolSMP4.pid", "w"))) { |
| 613 | syslog (LOG_ERR, "error during /var/run/renetcolSMP4.pid opening : %s\n", |
| 614 | strerror(errno)); |
| 615 | exit(1); |
| 616 | } else { |
| 617 | if (fprintf(pidFile, "%u", renetcolSMP4PID)==0) |
| 618 | syslog(LOG_ERR,"fprintf : %s", strerror(errno)); |
| 619 | } |
| 620 | fclose(pidFile); |
| 621 | } else if (13==*((unsigned short*)&buffer2)){ |
| 622 | initConfSender(); |
| 623 | } else { |
| 624 | syslog(LOG_ERR,"message type undefined for this queue SMP4"); |
| 625 | } |
| 626 | i=0; |