Changeset 577
- Timestamp:
- May 1, 2022, 12:24:37 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.ac
r572 r577 12 12 dnl start 13 13 dnl 14 AM_INIT_AUTOMAKE(samhain, 4.4. 7)14 AM_INIT_AUTOMAKE(samhain, 4.4.8) 15 15 AC_DEFINE([SAMHAIN], 1, [Application is samhain]) 16 16 AC_CANONICAL_HOST -
trunk/docs/Changelog
r576 r577 1 4.4.7: 1 4.4.8: 2 * new server option Alias=alias@hostname (based on 3 patch by A. Hofland) 4 5 4.4.7 (07-03-2022): 2 6 * fix compile error on MacOS 3 7 * disable dnmalloc for gcc 11 (regexec does not work) -
trunk/include/sh_cat.h
r525 r577 229 229 MSG_TCP_EBGN, 230 230 231 MSG_TCP_CREG, 231 MSG_TCP_CREG, 232 MSG_TCP_AREG, 232 233 MSG_TCP_FAUTH, 233 234 MSG_TCP_TIMOUT, -
trunk/include/sh_string.h
r265 r577 68 68 * lengths in 'lengths'. 69 69 * A single delimiter will return two empty fields. 70 * The returned array is allocated memory, and its fields 71 * are modified parts of the 'line' parameter. 70 72 */ 71 73 char ** split_array(char *line, unsigned int * nfields, … … 78 80 * An empty string will return zero fields. 79 81 * If nfields < actual fields, last string will be remainder. 82 * The returned array is allocated memory, and its fields 83 * are modified parts of the 'line' parameter. 80 84 */ 81 85 char ** split_array_ws(char *line, unsigned int * nfields, size_t * lengths); -
trunk/include/sh_xfer.h
r481 r577 84 84 void sh_xfer_html_write(void); 85 85 86 /* register an alias 87 */ 88 int sh_xfer_register_alias (const char * str); 89 86 90 /* register a client 87 91 */ -
trunk/src/sh_cat.c
r525 r577 225 225 226 226 { MSG_TCP_CREG, SH_ERR_ALL, TCP, N_("msg=\"Registered %s, salt %s, verifier %s\"")}, 227 { MSG_TCP_AREG, SH_ERR_ALL, TCP, N_("msg=\"Registered %s, hostname %s\"")}, 227 228 { MSG_TCP_FAUTH, SH_ERR_INFO, TCP, N_("msg=\"Force authentication\" host=\"%s\"")}, 228 229 … … 569 570 570 571 { MSG_TCP_CREG, SH_ERR_ALL, TCP, N_("msg=<Registered %s, salt %s, verifier %s>")}, 572 { MSG_TCP_AREG, SH_ERR_ALL, TCP, N_("msg=<Registered %s, hostname %s>")}, 571 573 { MSG_TCP_FAUTH, SH_ERR_INFO, TCP, N_("msg=<Force authentication>, client=<%s>")}, 572 574 -
trunk/src/sh_readconf.c
r550 r577 1148 1148 { N_("setserverinterface"), SH_SECTION_SRV, SH_SECTION_MISC, 1149 1149 sh_xfer_set_interface }, 1150 { N_("alias"), SH_SECTION_CLIENTS, SH_SECTION_NONE, 1151 sh_xfer_register_alias }, 1150 1152 { N_("client"), SH_SECTION_CLIENTS, SH_SECTION_NONE, 1151 1153 sh_xfer_register_client }, -
trunk/src/sh_xfer_server.c
r575 r577 419 419 */ 420 420 421 typedef struct client_alias { 422 char * alias; 423 char * hostname; 424 } alias_t; 425 421 426 #include "zAVLTree.h" 422 427 … … 435 440 436 441 /* Function to return the key for indexing 437 * the argument 442 * the argument (for the client list) 438 443 */ 439 444 zAVLKey sh_avl_key (void const * arg) … … 444 449 445 450 zAVLTree * all_clients = NULL; 451 452 /* Function to return the key for indexing 453 * the argument (for the aliases list) 454 */ 455 zAVLKey sh_avl_alias (void const * arg) 456 { 457 const alias_t * sa = (const alias_t *) arg; 458 return (zAVLKey) sa->alias; 459 } 460 461 zAVLTree * all_aliases = NULL; 446 462 447 463 void sh_xfer_html_write() … … 470 486 471 487 472 /* the destructor 488 /* the destructor (client list item) 473 489 */ 474 490 void free_client(void * inptr) … … 490 506 SH_FREE(here); 491 507 SL_RET0(_("free_client")); 508 } 509 510 /* the destructor (alias list item) 511 */ 512 void free_alias(void * inptr) 513 { 514 alias_t * here; 515 516 SL_ENTER(_("free_alias")); 517 if (inptr == NULL) 518 SL_RET0(_("free_alias")); 519 else 520 here = (alias_t *) inptr; 521 522 if (here->alias != NULL) 523 SH_FREE(here->alias); 524 if (here->hostname != NULL) 525 SH_FREE(here->hostname); 526 SH_FREE(here); 527 SL_RET0(_("free_alias")); 528 } 529 530 int sh_xfer_register_alias (const char * str) 531 { 532 alias_t * newalias; 533 alias_t * testalias; 534 535 const char * ptr; 536 int sepnum = 0; 537 int sep = 0; 538 register int i = 0; 539 int siz_str = 0; 540 541 SL_ENTER(_("sh_xfer_register_alias")); 542 543 ptr = str; 544 while (*ptr) { 545 if (*ptr == '@' && sepnum < 1) 546 { 547 sep = i; 548 ++sepnum; 549 } 550 ++ptr; ++i; 551 } 552 553 if (all_aliases == NULL) 554 { 555 all_aliases = zAVLAllocTree (sh_avl_alias, zAVL_KEY_STRING); 556 if (all_aliases == NULL) 557 { 558 (void) safe_logger (0, 0, NULL); 559 aud__exit(FIL__, __LINE__, EXIT_FAILURE); 560 } 561 } 562 563 if ((sepnum == 1) && (sep > 0) && (i > (sep + 1))) 564 { 565 newalias = SH_ALLOC (sizeof(alias_t)); 566 newalias->alias = SH_ALLOC (sep+1); 567 newalias->hostname = SH_ALLOC (sl_strlen(str)-sep); 568 569 /* truncate */ 570 sl_strlcpy(newalias->alias, &str[0], sep+1); 571 sh_tolower(newalias->alias); 572 573 /* truncate */ 574 sl_strlcpy(newalias->hostname, &str[sep+1], sl_strlen(str)-sep); 575 sh_tolower(newalias->hostname); 576 577 testalias = (alias_t *) zAVLSearch (all_aliases, newalias->alias); 578 579 if (testalias != NULL) 580 { 581 /* keep the alias but replace the hostname with the new one */ 582 SH_FREE(testalias->hostname); 583 siz_str = strlen (newalias->hostname) + 1; 584 testalias->hostname = SH_ALLOC (siz_str); 585 sl_strlcpy(testalias->hostname, newalias->hostname, siz_str); 586 587 free_alias(newalias); 588 SL_RETURN( 0, _("sh_xfer_register_alias")); 589 } 590 else 591 { 592 if (0 == zAVLInsert (all_aliases, newalias)) 593 { 594 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_AREG, 595 newalias->alias, 596 newalias->hostname); 597 SL_RETURN( 0, _("sh_xfer_register_alias")); 598 } 599 } 600 } 601 SL_RETURN (-1, _("sh_xfer_register_alias")); 492 602 } 493 603 … … 1053 1163 client_t * search_register(sh_conn_t * conn, int pos) 1054 1164 { 1165 alias_t * this_alias; 1055 1166 client_t * this_client; 1056 1167 char peer_ip[SH_IP_BUF]; … … 1086 1197 { 1087 1198 sl_strlcpy(peer_name, peer_ip, MAXHOSTNAMELEN + 1); 1199 } 1200 else 1201 { 1202 this_alias = zAVLSearch(all_aliases, peer_name); 1203 if (this_alias) 1204 { 1205 sl_strlcpy(peer_name, this_alias->hostname, MAXHOSTNAMELEN + 1); 1206 } 1088 1207 } 1089 1208 … … 3375 3494 sh_xfer_mark_dead (); 3376 3495 3496 /* free the aliases list */ 3497 zAVLFreeTree (all_aliases, free_alias); 3498 all_aliases = NULL; 3499 3377 3500 reset_count_dev_console(); 3378 3501 reset_count_dev_time(); -
trunk/test/testrun_2g.sh
r551 r577 204 204 UUID=$(uuidgen) 205 205 mv ./file.delta file.${SH_LOCALHOST}.${UUID} 206 cp file.${SH_LOCALHOST}.${UUID} "./file.${ALTHOST}.${UUID}" 206 if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ] 207 then 208 cp file.${SH_LOCALHOST}.${UUID} "./file.${ALTHOST}.${UUID}" 209 fi 207 210 208 211 # … … 223 226 fi 224 227 228 NHOSTS=1 229 225 230 ./yulectl -c "DELTA:${UUID}" ${SH_LOCALHOST} 226 231 if [ $? -ne 0 ]; then … … 229 234 return 1 230 235 fi 231 ./yulectl -c "DELTA:${UUID}" ${ALTHOST} 232 if [ $? -ne 0 ]; then 233 [ -z "$verbose" ] || log_msg_fail "yulectl (2)"; 234 kill $PROC_S; kill $PROC_Y; 235 return 1 236 fi 236 237 if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ] 238 then 239 ./yulectl -c "DELTA:${UUID}" ${ALTHOST} 240 NHOSTS=2 241 if [ $? -ne 0 ]; then 242 [ -z "$verbose" ] || log_msg_fail "yulectl (2)"; 243 kill $PROC_S; kill $PROC_Y; 244 return 1 245 fi 246 fi 247 237 248 NR=$( ./yulectl -c LIST | grep ${UUID} | grep -v grep | wc -l ) 238 if [ $NR -ne 2]; then249 if [ $NR -ne $NHOSTS ]; then 239 250 [ -z "$verbose" ] || log_msg_fail "yulectl (3)"; 240 251 [ -z "$verbose" ] || ./yulectl -c LIST … … 249 260 done 250 261 # 251 NR=$( ./yulectl -c LIST | grep ${UUID} | grep -v grep | wc -l ) 262 NR=$( ./yulectl -c LISTALL | grep ${UUID} | grep SENT | grep -v grep | wc -l ) 263 # NR=$( ./yulectl -c LIST | grep ${UUID} | grep -v grep | wc -l ) 252 264 if [ $NR -ne 1 ]; then 253 265 [ -z "$verbose" ] || log_msg_fail "yulectl (4)"; … … 330 342 else 331 343 mv ./file.delta file.${SH_LOCALHOST}.${UUID} 332 cp file.${SH_LOCALHOST}.${UUID} "./file.${ALTHOST}.${UUID}" 344 if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ] 345 then 346 cp file.${SH_LOCALHOST}.${UUID} "./file.${ALTHOST}.${UUID}" 347 fi 333 348 fi 334 349 [ -z "$verbose" ] || log_msg_ok "... DeltaDB copied as file.${SH_LOCALHOST}.${UUID} ..."; … … 351 366 fi 352 367 368 NHOSTS=1 369 353 370 ./yulectl -c "DELTA:${UUID}" ${SH_LOCALHOST} 354 371 if [ $? -ne 0 ]; then … … 357 374 return 1 358 375 fi 359 ./yulectl -c "DELTA:${UUID}" ${ALTHOST} 360 if [ $? -ne 0 ]; then 361 [ -z "$verbose" ] || log_msg_fail "yulectl (2)"; 362 kill $PROC_S; kill $PROC_Y; 363 return 1 364 fi 376 377 if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ] 378 then 379 ./yulectl -c "DELTA:${UUID}" ${ALTHOST} 380 NHOSTS=2 381 if [ $? -ne 0 ]; then 382 [ -z "$verbose" ] || log_msg_fail "yulectl (2)"; 383 kill $PROC_S; kill $PROC_Y; 384 return 1 385 fi 386 fi 387 365 388 NR=$( ./yulectl -c LIST | grep ${UUID} | grep -v grep | wc -l ) 366 if [ $NR -ne 2]; then389 if [ $NR -ne $NHOSTS ]; then 367 390 [ -z "$verbose" ] || log_msg_fail "yulectl (3)"; 368 391 [ -z "$verbose" ] || ./yulectl -c LIST … … 378 401 done 379 402 # 380 NR=$( ./yulectl -c LIST | grep ${UUID}| grep -v grep | wc -l )403 NR=$( ./yulectl -c LISTALL | grep ${UUID} | grep SENT | grep -v grep | wc -l ) 381 404 if [ $NR -ne 1 ]; then 382 [ -z "$verbose" ] || log_msg_fail "yulectl (4) ";405 [ -z "$verbose" ] || log_msg_fail "yulectl (4): ${UUID}"; 383 406 [ -z "$verbose" ] || ./yulectl -c LISTALL 384 kill $PROC_S; kill $PROC_Y; 385 return 1 386 fi 387 [ -z "$verbose" ] || OLINE=$( ./yulectl -c LIST | grep ${UUID} ) 407 [ -z "$verbose" ] || echo "(now just LIST)" 408 [ -z "$verbose" ] || ./yulectl -c LIST 409 kill $PROC_S; kill $PROC_Y; 410 return 1 411 fi 412 [ -z "$verbose" ] || OLINE=$( ./yulectl -c LISTALL | grep ${UUID} ) 388 413 [ -z "$verbose" ] || echo "${OLINE}" 389 414 … … 607 632 chmod 644 ./file.${SH_LOCALHOST} 608 633 609 cp ./testrc_2 "./rc.${ALTHOST}" 610 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null 611 chmod 644 ./rc.${ALTHOST} 612 chmod 644 ./file.${ALTHOST} 634 if [ "x${SH_LOCALHOST}" != "x${ALTHOST}" ] 635 then 636 cp ./testrc_2 "./rc.${ALTHOST}" 637 cp ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null 638 chmod 644 ./rc.${ALTHOST} 639 chmod 644 ./file.${ALTHOST} 640 fi 613 641 } 614 642
Note:
See TracChangeset
for help on using the changeset viewer.