From d702427ad1f224428d458b7810f560c4a1ea2a55 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 27 Apr 2019 00:23:23 -0700 Subject: [PATCH] compiler_vm: update server scripts --- modules/compiler_vm/compiler_vm_server.pl | 29 +++++++++++++---------- modules/compiler_vm/compiler_watchdog.pl | 2 +- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/modules/compiler_vm/compiler_vm_server.pl b/modules/compiler_vm/compiler_vm_server.pl index f6098f9d..5bfb1f90 100755 --- a/modules/compiler_vm/compiler_vm_server.pl +++ b/modules/compiler_vm/compiler_vm_server.pl @@ -7,15 +7,13 @@ use warnings; use strict; +use English; use File::Basename; use JSON; my $USERNAME = 'compiler'; my $USE_LOCAL = defined $ENV{'CC_LOCAL'}; -# uncomment the following if installed to the virtual machine -# use constant MOD_DIR => '/usr/local/share/compiler_vm/languages'; - use constant MOD_DIR => '/usr/local/share/compiler_vm/languages'; use lib MOD_DIR; @@ -108,25 +106,32 @@ sub run_server { } if ($pid == 0) { - my ($uid, $gid) = (getpwnam $USERNAME)[2, 3]; + my ($uid, $gid, $home) = (getpwnam $USERNAME)[2, 3, 7]; if (not $uid and not $gid) { print "Could not find user $USERNAME: $!\n"; exit; } if ($compile_in->{'persist-key'}) { + system ("rm -rf \"/home/compiler/$compile_in->{'persist-key'}\""); system("mount /dev/vdb1 /root/factdata"); - system("mkdir /root/factdata/$compile_in->{'persist-key'}"); - system("cp -R -p /root/factdata/$compile_in->{'persist-key'}/* /home/compiler/"); + system("mkdir -p \"/root/factdata/$compile_in->{'persist-key'}\""); + system("cp -R -p \"/root/factdata/$compile_in->{'persist-key'}\" \"/home/compiler/$compile_in->{'persist-key'}\""); } system("chmod -R 755 /home/compiler"); - system("chown -R compiler /home/compiler/*"); - system("chgrp -R compiler /home/compiler/*"); + system("chown -R compiler /home/compiler"); + system("chgrp -R compiler /home/compiler"); system("rm -rf /home/compiler/prog*"); + system("pkill -u compiler"); - $( = $gid; - $< = $uid; + $ENV{USER} = $USERNAME; + $ENV{LOGNAME} = $USERNAME; + $ENV{HOME} = $home; + + $GID = $gid; + $EGID = "$gid $gid"; + $EUID = $UID = $uid; my $result = interpret(%$compile_in); @@ -142,9 +147,9 @@ sub run_server { if ($compile_in->{'persist-key'}) { system("id"); - system("cp -R -p /home/compiler/* /root/factdata/$compile_in->{'persist-key'}/"); + system("cp -R -p \"/home/compiler/$compile_in->{'persist-key'}\" \"/root/factdata/$compile_in->{'persist-key'}\""); system("umount /root/factdata"); - system ("rm -rf /home/compiler/*"); + system ("rm -rf \"/home/compiler/$compile_in->{'persist-key'}\""); } exit; diff --git a/modules/compiler_vm/compiler_watchdog.pl b/modules/compiler_vm/compiler_watchdog.pl index 397e2cf3..40196ced 100755 --- a/modules/compiler_vm/compiler_watchdog.pl +++ b/modules/compiler_vm/compiler_watchdog.pl @@ -100,7 +100,7 @@ sub execute { next; } - if($line =~ m/^Reading symbols from.*done\.$/) { + if($line =~ m/^Reading symbols from/) { gdb $in, "break gdb\n"; gdb $in, "list main,9001\n";