Skip to content

Commit

Permalink
Merge branch 'premaster'
Browse files Browse the repository at this point in the history
  • Loading branch information
mfthomps committed Jan 4, 2023
2 parents fcc3661 + bce9599 commit 68adb34
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 11 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ The installation script and the update-designer.sh script set environment variab
so you may want to logout/login, or start a new bash shell before using Labtainers the
first time.

January 4, 2022
- Containers using systemd were failing on newer systemd present in Ubuntu 22
- Add --zone parameter to google cloud scripts, with value derived from the set\_defaults script.
December 21, 2022
- Fix xforge results criteria to not expect pathname, and add check to see if POST issued to edit profile. And fix attacker
http server to run from the home directory.

December 19, 2022
- Add strace lab to introduce system call tracing.
- X11 DISPLAY value was incorrect if multiple devices in the /tmp/.X11-unix directory.
Expand Down
Binary file modified docs/student/labtainer-student.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/student/labtainer-student.tex
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ \subsection{Google Cloud Platform}
\end{verbatim}

\item Once logged into the Google Cloud with default region/zone defined, run the create\_vm.sh (or create\_vm.ps1 for windows) script, passing in a user ID.
The ID can be any name, e.g.,
The ID can be any name without special characters, e.g.,
\begin{verbatim}
./create_vm.sh myname
\end{verbatim}
Expand Down
2 changes: 1 addition & 1 deletion google/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ to initialize your client.
In the following command examples, use "ps1" instead of "sh" when using PowerShell.

Once logged into the Google Cloud, run the create_vm.sh (or create_vm.ps1 for windows) script, passing in a user ID.
The ID can be any name, e.g.,
The ID can be any name without special characters, e.g.,
./create_vm.sh myname

One Linux/Mac, you will be prompted for an ssh passphase, leave it blank. On Windows, ignore the warnings
Expand Down
3 changes: 2 additions & 1 deletion google/create_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ if [ "$#" -ne 1 ]; then
fi
user_id=$1
vm_name=$user_id-labtainervm
zone=$(./findzone.sh)
gcloud compute instances create $vm_name --image=https://www.googleapis.com/compute/v1/projects/labtainers/global/images/labtainervm5 \
--metadata-from-file=user-data=user_config.txt
gcloud compute disks resize $vm_name --size 30G -q
gcloud compute disks resize $vm_name --size 30G --zone=$zone -q
# instances fail ssh until settled
./waitup.sh $user_id 2>/dev/null
echo "Check keys"
Expand Down
3 changes: 2 additions & 1 deletion google/delete_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ if [ "$#" -ne 1 ]; then
fi
user_id=$1
vm_name=$user_id-labtainervm
gcloud -q compute instances delete $vm_name
zone=$(./findzone.sh)
gcloud -q compute instances delete $vm_name --zone=$zone
3 changes: 3 additions & 0 deletions google/findzone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
result=$(cat set_defaults.sh | grep -v "#" | awk -F"=" '{print($3)}')
echo $result | awk '{$1=$1};NF'
3 changes: 2 additions & 1 deletion google/getip.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
vm=$1
result=$(gcloud compute instances describe $vm --format='get(networkInterfaces[0].accessConfigs[0].natIP)')
zone=$(./findzone.sh)
result=$(gcloud compute instances describe $vm --zone=$zone --format='get(networkInterfaces[0].accessConfigs[0].natIP)')
if [ -z "${result}" ]; then
echo "FAIL"
else
Expand Down
2 changes: 2 additions & 0 deletions google/set_defaults.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#gcloud compute project-info add-metadata \
# --metadata google-compute-default-region=us-west1,google-compute-default-zone=xxxxest1-b
gcloud compute project-info add-metadata \
--metadata google-compute-default-region=us-west1,google-compute-default-zone=us-west1-b
3 changes: 2 additions & 1 deletion google/start_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if [ "$#" -ne 1 ]; then
fi
user_id=$1
vm_name=$user_id-labtainervm
gcloud -q compute instances start $vm_name
zone=$(./findzone.sh)
gcloud -q compute instances start $vm_name --zone=$zone
./waitup.sh $user_id
./waitdone.sh $user_id
3 changes: 2 additions & 1 deletion google/stop_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ if [ "$#" -ne 1 ]; then
fi
user_id=$1
vm_name=$user_id-labtainervm
gcloud -q compute instances stop $vm_name
zone=$(./findzone.sh)
gcloud -q compute instances stop $vm_name --zone=$zone
9 changes: 6 additions & 3 deletions scripts/labtainer-student/bin/labutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ def CreateSingleContainer(labtainer_config, start_config, container, lab_path, m
logger.debug("getDockerIPAddr result (%s)" % docker0_IPAddr)
volume=''
ubuntu_systemd = isUbuntuSystemd(new_image_name, labtainer_config)
logger.debug('wtf, over, ubuntu_systemd is %s' % ubuntu_systemd)
if ubuntu_systemd is not None:
osTypeMap[container.image_name] = ubuntu_systemd
if ubuntu_systemd == 'ubuntu20':
Expand All @@ -585,22 +586,24 @@ def CreateSingleContainer(labtainer_config, start_config, container, lab_path, m
else:
shm = ''
if container.script == '' or ubuntu_systemd is not None:
#logger.debug('Container %s is systemd or has script empty <%s>' % (new_image_name, container.script))
logger.debug('Container %s is systemd or has script empty <%s>' % (new_image_name, container.script))
''' a systemd container, centos or ubuntu? '''
if ubuntu_systemd == 'ubuntu16':
''' A one-off run to set some internal values. This is NOT what runs the lab container '''
#volume='--security-opt seccomp=confined --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro'
volume='--security-opt seccomp=unconfined --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro'
cmd = 'docker run --rm --privileged -v /:/host %s setup' % new_image_name
logger.debug('cmd is %s' % cmd)
logger.debug('ubuntu16 cmd is %s' % cmd)
ps = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE,stderr=subprocess.PIPE)
output = ps.communicate()
logger.debug('back from docker run, output %s' % (output[0].decode('utf-8')))
if len(output[1]) > 0:
logger.debug('back from docker run, error %s' % (output[1].decode('utf-8')))
volume = ''
elif ubuntu_systemd == 'ubuntu20':
volume = volume + " -v /sys/fs/cgroup:/sys/fs/cgroup:ro "
#volume = volume + " -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host --tmpfs=/run/lock --tmpfs=/run "
volume = volume + " -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host --tmpfs=/run/lock --tmpfs=/run "
logger.debug('volume is %s' % volume)
if container.x11.lower() == 'yes':
#volume = '-e DISPLAY -v /tmp/.Xll-unix:/tmp/.X11-unix --net=host -v$HOME/.Xauthority:/home/developer/.Xauthority'
#volume = volume+' --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw"'
Expand Down

0 comments on commit 68adb34

Please sign in to comment.