]> git.proxmox.com Git - pve-cluster.git/commitdiff
pvecm addnode: error out on interactive call
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 22 Feb 2017 15:59:07 +0000 (16:59 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 28 Feb 2017 10:42:22 +0000 (11:42 +0100)
addnode is thought to be used by the `add` command only.
So check if STDIN or STOUT are connected to a tty and exit with an
error message if this is the case.
The force flag allows overwriting this check.

Fixes bug #294

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
data/PVE/CLI/pvecm.pm

index 294486f9480d2953590996697242979475aa13ea..c3f790567d7e0f9526504eb2e9a59e2439efedd1 100755 (executable)
@@ -301,6 +301,11 @@ __PACKAGE__->register_method ({
     code => sub {
        my ($param) = @_;
 
+       if (!$param->{force} && (-t STDIN || -t STDOUT)) {
+           die "error: `addnode` should not get called interactively!\nUse ".
+               "`pvecm add <cluster-node>` to add a node to a cluster!\n";
+       }
+
        PVE::Cluster::check_cfs_quorum();
 
        my $conf = PVE::Cluster::cfs_read_file("corosync.conf");