|
Lines 551-556
Link Here
|
| 551 |
xfree(cctx); |
551 |
xfree(cctx); |
| 552 |
} |
552 |
} |
| 553 |
|
553 |
|
|
|
554 |
static inline int |
| 555 |
client_process_control_answer( Buffer *m, int allowed, int client_fd ) |
| 556 |
{ |
| 557 |
buffer_clear(m); |
| 558 |
buffer_put_int(m, allowed); |
| 559 |
buffer_put_int(m, getpid()); |
| 560 |
if (ssh_msg_send(client_fd, /* version */1, m) == -1) { |
| 561 |
error("%s: client msg_send failed", __func__); |
| 562 |
close(client_fd); |
| 563 |
buffer_free(m); |
| 564 |
return -1; |
| 565 |
} |
| 566 |
return 0; |
| 567 |
} |
| 568 |
|
| 554 |
static void |
569 |
static void |
| 555 |
client_process_control(fd_set * readset) |
570 |
client_process_control(fd_set * readset) |
| 556 |
{ |
571 |
{ |
|
Lines 564-569
Link Here
|
| 564 |
u_int len, env_len, command, flags; |
579 |
u_int len, env_len, command, flags; |
| 565 |
uid_t euid; |
580 |
uid_t euid; |
| 566 |
gid_t egid; |
581 |
gid_t egid; |
|
|
582 |
char *command_arg; |
| 567 |
|
583 |
|
| 568 |
/* |
584 |
/* |
| 569 |
* Accept connection on control socket |
585 |
* Accept connection on control socket |
|
Lines 611-616
Link Here
|
| 611 |
allowed = 1; |
627 |
allowed = 1; |
| 612 |
command = buffer_get_int(&m); |
628 |
command = buffer_get_int(&m); |
| 613 |
flags = buffer_get_int(&m); |
629 |
flags = buffer_get_int(&m); |
|
|
630 |
command_arg=buffer_get_string(&m, 0); |
| 614 |
|
631 |
|
| 615 |
buffer_clear(&m); |
632 |
buffer_clear(&m); |
| 616 |
|
633 |
|
|
Lines 630-643
Link Here
|
| 630 |
/* FALLTHROUGH */ |
647 |
/* FALLTHROUGH */ |
| 631 |
case SSHMUX_COMMAND_ALIVE_CHECK: |
648 |
case SSHMUX_COMMAND_ALIVE_CHECK: |
| 632 |
/* Reply for SSHMUX_COMMAND_TERMINATE and ALIVE_CHECK */ |
649 |
/* Reply for SSHMUX_COMMAND_TERMINATE and ALIVE_CHECK */ |
| 633 |
buffer_clear(&m); |
650 |
if( client_process_control_answer(&m, allowed, client_fd) ) |
| 634 |
buffer_put_int(&m, allowed); |
651 |
return; |
| 635 |
buffer_put_int(&m, getpid()); |
652 |
buffer_free(&m); |
| 636 |
if (ssh_msg_send(client_fd, /* version */1, &m) == -1) { |
653 |
close(client_fd); |
| 637 |
error("%s: client msg_send failed", __func__); |
654 |
return; |
| 638 |
close(client_fd); |
655 |
case SSHMUX_COMMAND_RFADD: |
| 639 |
buffer_free(&m); |
656 |
debug2("%s: RFADD: %s", __func__, command_arg); |
|
|
657 |
if( client_process_control_answer(&m, allowed, client_fd) ) |
| 658 |
return; |
| 659 |
{ |
| 660 |
Forward fwd; |
| 661 |
if (parse_forward(&fwd, command_arg)) |
| 662 |
channel_request_remote_forwarding |
| 663 |
(fwd.listen_host, fwd.listen_port, |
| 664 |
fwd.connect_host, fwd.connect_port); |
| 665 |
else |
| 666 |
logit("Bad forwarding specification."); |
| 667 |
} |
| 668 |
buffer_free(&m); |
| 669 |
close(client_fd); |
| 670 |
return; |
| 671 |
case SSHMUX_COMMAND_RFCANCEL: |
| 672 |
debug2("%s: RFCANCEL: %s", __func__, command_arg); |
| 673 |
if( client_process_control_answer(&m, allowed, client_fd) ) |
| 640 |
return; |
674 |
return; |
|
|
675 |
{ |
| 676 |
int cancel_port = 0; |
| 677 |
char *cancel_host = hpdelim(&command_arg); |
| 678 |
if (command_arg != NULL) { |
| 679 |
cancel_port = a2port(command_arg); |
| 680 |
cancel_host = cleanhostname(cancel_host); |
| 681 |
} else { |
| 682 |
cancel_port = a2port(cancel_host); |
| 683 |
cancel_host = NULL; |
| 684 |
} |
| 685 |
if (cancel_port == 0) { |
| 686 |
logit("Bad forwarding close port"); |
| 687 |
buffer_free(&m); |
| 688 |
close(client_fd); |
| 689 |
return; |
| 690 |
} |
| 691 |
channel_request_rforward_cancel(cancel_host, |
| 692 |
cancel_port); |
| 641 |
} |
693 |
} |
| 642 |
buffer_free(&m); |
694 |
buffer_free(&m); |
| 643 |
close(client_fd); |
695 |
close(client_fd); |
|
Lines 650-664
Link Here
|
| 650 |
} |
702 |
} |
| 651 |
|
703 |
|
| 652 |
/* Reply for SSHMUX_COMMAND_OPEN */ |
704 |
/* Reply for SSHMUX_COMMAND_OPEN */ |
| 653 |
buffer_clear(&m); |
705 |
if( client_process_control_answer(&m, allowed, client_fd) ) |
| 654 |
buffer_put_int(&m, allowed); |
|
|
| 655 |
buffer_put_int(&m, getpid()); |
| 656 |
if (ssh_msg_send(client_fd, /* version */1, &m) == -1) { |
| 657 |
error("%s: client msg_send failed", __func__); |
| 658 |
close(client_fd); |
| 659 |
buffer_free(&m); |
| 660 |
return; |
706 |
return; |
| 661 |
} |
|
|
| 662 |
|
707 |
|
| 663 |
if (!allowed) { |
708 |
if (!allowed) { |
| 664 |
error("Refused control connection"); |
709 |
error("Refused control connection"); |