JamfHelper not displaying message

dmw3
Contributor III

Hi all, when have a script that pauses a VM VirtualBox if it is on a restricted list, JamfHelper should put up a message as to why the VM is paused to the user, but this does not appear. Any help appreciated.

#!/usr/bin/perl
#
$allowed = "044a0644-8766-432a-a055-3857417f223b:189b0146-ea8a-469c-b055-2909f57fc832:6d9d641f-9e89-40a1-ad28-a7eb0a9a9c84:fdec5285-fa7b-4874-b525-2cb53561610b:975741ca-39c3-4949-95dc-760bfcda9a01:78ba6035-29ff-4dc9-89d0-4220382a9b42:e03b6405-7725-4523-8ae0-ec7c227fbdbc:c67204c6-a138-4bcc-a5f5-371f1d104d13:4a7ba6d3-da6d-4032-8dfc-26ce08162de0";

$VBM = "/Applications/VirtualBox.app/Contents/MacOS/VBoxManage";
$JAMFHELP = "/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper";
$KALI = "4a7ba6d3-da6d-4032-8dfc-26ce08162de0";
$KALIWARN = "You are not permitted to run the Kali Linux VM while connected to the University network. Disconnect this machine from the network, and then you can resume the VM manually.";
$VMWARN = "You are attempting to run a virtual machine which has not been approved for use in this unit, Do not create nor import virtual machines of your own. Consult with the lecturer if you wish to discuss this.";


while (1)
{

    # check network and kali state - pause kali if the network is up
    # since we don't want to compromise the UTas network

    $response = `$VBM showvminfo $KALI | /usr/bin/grep State`;
    ($dummy, $kalistate, $dummy2) = split /s+/, $response;

    $hostname = `/usr/bin/uname -n`;
    chomp $hostname;
    $hostaddr = gethostbyname $hostname;
    ($a, $b, $c, $d) = unpack('C4', $hostaddr);
    $subnet = "$a.$b.$c";

    $netstate = "down";
    $netstate = "up" if (($subnet eq "10.36.12") || ($subnet eq "10.36.144"));

    if (($netstate eq "up") && ($kalistate eq "running"))
    {
        system "$VBM controlvm $KALI pause";
        system "$JAMFHELP -windowType utility -heading `Kali VM has been suspended` -description $KALIWARN -timeout 5";
    }
    else
    {
        print "clear
";
    }

    # now check all VMs
    # power off any running VMs we don't recognise
    @vms = `$VBM list vms`;
    foreach $vm (@vms)
    {
        ($dummy, $uuid) = split /{/, $vm;
        chop $uuid;
        chop $uuid;
#       print "$uuid
";

        $response = `$VBM showvminfo $uuid | /usr/bin/grep State`;
        ($dummy, $vmstate, $dummy2) = split /s+/, $response;
        if (($vmstate eq "running") && (!($allowed =~ $uuid)))
        {
            system "$VBM controlvm $uuid poweroff";
            system "$JAMFHELP -windowType utility -heading `Your VM has been shut down` -description $VMWARN -timeout 5";
        }
    }
    sleep 3;
}
1 REPLY 1

bvrooman
Valued Contributor

It looks like you have backticks (`) in the lines which call jamfHelper instead of single quotes ('). Perhaps that's the issue?