Skip to content

Commit

Permalink
clusterd: Accept commands only from trusted hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed Jan 29, 2025
1 parent 185c5ad commit 2c17224
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clusterd/clusterd
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,12 @@ sub clp_rx_LSOF {

sub clp_rx_CMD {
my ($socket,@cmd)=@_;

unless (is_trusted_ip($socket->peerhost())) {
warn "reveived command from untrusted host ". $socket->peerhost(). "\n";
return;
}

my $pid=fork;
unless (defined $pid) {
warn"$!\n";
Expand Down Expand Up @@ -1224,6 +1230,8 @@ sub expand_hostconfig_hosts {

sub exec_at {
my ($host,@cmd)=@_;
is_trusted_ip($my_ip) or die "This command only works on a trusted host\n";

sync_cluster_pw() or die "$CLUSTER_PW_FILE: $!\n";
my $s=new IO::Socket::INET(PeerAddr=>$host,PeerPort=>$CLP_PORT);
unless (defined $s) {
Expand Down

0 comments on commit 2c17224

Please sign in to comment.