[pve-devel] [PATCH cluster 4/8] pvecm addnode: error out on interactive call

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Feb 22 16:59:07 CET 2017


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 at proxmox.com>
---
 data/PVE/CLI/pvecm.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/data/PVE/CLI/pvecm.pm b/data/PVE/CLI/pvecm.pm
index 294486f..c3f7905 100755
--- a/data/PVE/CLI/pvecm.pm
+++ b/data/PVE/CLI/pvecm.pm
@@ -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");
-- 
2.1.4





More information about the pve-devel mailing list