From 673c51cea34691cb619cdf8d9c4a8aa6f59be105 Mon Sep 17 00:00:00 2001 From: neingeist Date: Wed, 23 Mar 2011 13:45:09 +0100 Subject: [PATCH] initial commit --- virssh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 virssh diff --git a/virssh b/virssh new file mode 100755 index 0000000..1f923fa --- /dev/null +++ b/virssh @@ -0,0 +1,27 @@ +#!/usr/bin/perl +use strict; +use warnings; + +my $logtag = $0; +my $vm = $ARGV[0]; +my $SSH_ORIGINAL_COMMAND = $ENV{"SSH_ORIGINAL_COMMAND"} || ""; + +if ($SSH_ORIGINAL_COMMAND =~ /^sudo virsh (list|console $vm|destroy $vm|shutdown $vm|start $vm( --console)?)$/s) { + system("logger", "-t", "$logtag", "Allowing command \"$SSH_ORIGINAL_COMMAND\""); + exec $SSH_ORIGINAL_COMMAND +} else { + system("logger", "-t", "$logtag", "ALERT: NOT allowing command \"$SSH_ORIGINAL_COMMAND\""); + print STDERR "ALERT: NOT allowing command \"$SSH_ORIGINAL_COMMAND\"\n"; + print STDERR <