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.lampre...@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


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to