Commit 52ad871b authored by Elijah Grubb's avatar Elijah Grubb

Merge remote-tracking branch 'origin/master' into docker-entrypoint

parents ce34a36c b4679058
#!/usr/bin/perl -wT
#
# Copyright (c) 2000-2011, 2014, 2016 University of Utah and the Flux Group.
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -82,6 +82,7 @@ use libdb;
use libtestbed;
use Project;
use User;
use Brand;
# Protos
sub fatal($);
......@@ -227,8 +228,8 @@ fatal($@)
if (exists($xmlparse->{'attribute'}->{"portal"})) {
$portal = $xmlparse->{'attribute'}->{"portal"}->{'value'};
delete($xmlparse->{'attribute'}->{"portal"});
if (! ($portal eq "aptlab" || $portal eq "cloudlab" ||
$portal eq "phantomnet" || $portal eq "emulab")) {
my $brand = Brand->Create($portal);
if (!defined($brand)) {
fatal("Bad portal: $portal");
}
}
......
......@@ -1006,6 +1006,8 @@ else {
$rval == GENIRESPONSE_INSUFFICIENT_MEMORY ||
$rval == GENIRESPONSE_INSUFFICIENT_BANDWIDTH ||
$rval == GENIRESPONSE_NOSPACE ||
$rval == GENIRESPONSE_NO_CONNECT ||
$rval == GENIRESPONSE_MAPPING_IMPOSSIBLE ||
$rval == GENIRESPONSE_NO_MAPPING) {
AuditAbort()
if (!$debug);
......
......@@ -319,7 +319,7 @@ sub DoCreate()
if ($type eq "stdataset" && !defined($expires));
if (APT_Dataset->Lookup("$pid/$name")) {
fatal("Dataset already exists!");
UserError("Dataset already exists!");
}
# Check for expired certs and speaksfor.
......
......@@ -1916,15 +1916,16 @@ sub ExtendInternal($$$$$)
my $code = $response->code();
if ($code) {
($errcode,$errmsg) = ResponseErrorMessage($agg, $response);
if ($errcode == GENIRESPONSE_REFUSED) {
if ($code == GENIRESPONSE_REFUSED) {
# We want the user to see REFUSED.
$errmsg = "Extension refused at ".
$agg->GetAptAggregate()->name() . ": " .
$response->error();
$errcode = 1;
}
else {
($errcode,$errmsg) = ResponseErrorMessage($agg, $response);
}
goto bad;
}
}
......@@ -2002,7 +2003,17 @@ sub DoMaxExtensionInternal($$)
my $code = $response->code();
if ($code) {
($errcode,$errmsg) = ResponseErrorMessage($aggregate, $response);
if ($code == GENIRESPONSE_REFUSED) {
# We want the user to see REFUSED.
$errmsg = "No extension possible at ".
$aggregate->GetAptAggregate()->name() . ": " .
$response->error();
$errcode = $code;
}
else {
($errcode,$errmsg) =
ResponseErrorMessage($aggregate, $response);
}
goto bad;
}
my $max = str2time($result);
......@@ -2316,7 +2327,17 @@ sub DoRebootOrReload($)
if ($code != GENIRESPONSE_SUCCESS) {
$errcode = $code;
($exitcode, $errmsg) = ResponseErrorMessage($agg, $response);
if ($code == GENIRESPONSE_REFUSED) {
# We want the user to see REFUSED.
$errmsg = "Not able to $which at ".
$agg->GetAptAggregate()->name() . ": " .
$response->error();
$exitcode = 1;
}
else {
($exitcode, $errmsg) = ResponseErrorMessage($agg, $response);
}
next;
}
}
......
......@@ -4639,6 +4639,7 @@ outfiles="Makeconf GNUmakefile setversion \
os/frisbee.redux/GNUmakefile \
os/capture/GNUmakefile \
os/growdisk/GNUmakefile \
os/bootinfo/GNUmakefile \
os/zapdisk/GNUmakefile \
os/imagezip/GNUmakefile \
os/imagezip/libndz/GNUmakefile \
......
#
# Copyright (c) 2000-2017 University of Utah and the Flux Group.
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -327,6 +327,7 @@ outfiles="Makeconf GNUmakefile setversion \
os/frisbee.redux/GNUmakefile \
os/capture/GNUmakefile \
os/growdisk/GNUmakefile \
os/bootinfo/GNUmakefile \
os/zapdisk/GNUmakefile \
os/imagezip/GNUmakefile \
os/imagezip/libndz/GNUmakefile \
......
......@@ -29,7 +29,7 @@ SYSTEM := $(shell $(SRCDIR)/../../../tmcc/osstuff.sh -o)
IPERFVERSION = 2.0.2
ifeq ($(SYSTEM),Linux)
OSTAG=$(shell $(SRCDIR)/../../../tmcc/osstuff.sh -t)
ifeq ($(OSTAG),alpine)
ifneq (,$(filter $(OSTAG),alpine debian9))
IPERFVERSION = 2.0.10
# If 2.0.10, we have to disable 64-bit seq numbers; they mess up the
# client_hdr size in a backwards-incompat way.
......
#
# Copyright (c) 2000-2017 University of Utah and the Flux Group.
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -32,7 +32,7 @@ SYSTEM := $(shell uname -s)
include $(OBJDIR)/Makeconf
SUBDIRS = syncd dijkstra genhostsfile imagezip frisbee.redux capture
SUBDIRS = syncd dijkstra genhostsfile imagezip frisbee.redux capture bootinfo
ifeq ($(SYSTEM),FreeBSD)
SUBDIRS += growdisk
endif
......
#
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
SRCDIR = @srcdir@
TESTBED_SRCDIR = @top_srcdir@
OBJDIR = @top_builddir@
SUBDIR = $(subst $(TESTBED_SRCDIR)/,,$(SRCDIR))
include $(OBJDIR)/Makeconf
all: bootinfoclient
include $(TESTBED_SRCDIR)/GNUmakerules
CFLAGS += -Wall -I${OBJDIR} \
-DFALLBACK_HOST='"$(BOSSNODE)"' -DBOSSNODE='"$(BOSSNODE)"'
bootinfoclient: bootinfoclient.o bootinfo_version.o bootwhat.h
$(CC) $(LDSTATIC) $(CFLAGS) $(INCS) $(LIBS) \
-o bootinfoclient bootinfoclient.o bootinfo_version.o
bootinfo_version.c: bootinfoclient.c
echo >$@ "char build_info[] = \"Built `date +%d-%b-%Y` by `id -nu`@`hostname | sed 's/\..*//'`:`pwd`\";"
install:
subboss:
subboss-install:
client: all
client-install: client
$(INSTALL_PROGRAM) bootinfoclient $(DESTDIR)$(CLIENT_BINDIR)
clean:
rm -f *.o bootinfoclient
/*
* Copyright (c) 2000-2012 University of Utah and the Flux Group.
* Copyright (c) 2000-2018 University of Utah and the Flux Group.
*
* {{{EMULAB-LICENSE
*
......@@ -34,7 +34,6 @@
#include <err.h>
#include <errno.h>
#include "bootwhat.h"
#include "bootinfo.h"
#include "config.h"
int debug = 0;
......
#
# Copyright (c) 2000-2016 University of Utah and the Flux Group.
# Copyright (c) 2000-2016, 2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -59,7 +59,7 @@ LDFLAGS += $(LDSTATIC)
#
CFLAGS += -DETCDIR='"$(INSTALL_ETCDIR)"'
SSLFLAGS = -DWITHSSL
TMLIBS += -lssl -lcrypto
TMLIBS += -lssl -lcrypto -lz
ifeq ($(SYSTEM),Linux)
ifneq ($(LDSTATIC),)
......@@ -109,6 +109,9 @@ endif
ifeq ($(MDSUBDIR),debian8)
MDSUBDIR = ubuntu15
endif
ifeq ($(MDSUBDIR),debian9)
MDSUBDIR = ubuntu16
endif
# We don't want to have a dir named "arch"; that would be confusing.
# Hence archlinux.
ifeq ($(MDSUBDIR),arch)
......
#!/bin/sh
set -x
apt-get clean
rm -rf /var/lib/apt/lists/*
rm -f /tmp/apt-updated
rm -rf /tmp/* /var/tmp*
exit 0
#!/bin/sh
# system one time tasks
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
/etc/init.d/rcS
/etc/init.d/rmnologin
touch /etc/runit/stopit
chmod 0 /etc/runit/stopit
#!/bin/sh
#
# Run our service dir. We don't mess with runlevels; just run all the
# things.
#
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
if [ -f /etc/envvars ]; then
. /etc/envvars
fi
exec env - PATH=$PATH \
runsvdir -P /etc/service 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................'
#!/bin/sh
exec 2>&1
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
LAST=0
test -x /etc/runit/reboot && LAST=6
echo 'Waiting for services to stop...'
sv -w196 force-stop /etc/service/*
sv exit /etc/service/*
echo 'Shutdown...'
/etc/init.d/rc $LAST
#!/bin/sh
# Never run if systemd is running; it will do this.
[ -f /bin/systemctl ] && /bin/systemctl show-environment >/dev/null 2>&1 \
&& (touch /etc/service/pubsubd/down ; exit 0)
if [ -f /etc/init.d/pubsubd ]; then
exec /etc/init.d/pubsubd stop
else
touch /etc/service/pubsubd/down
fi
exit 0
#!/bin/sh
# Never run if systemd is running; it will do this.
[ -f /bin/systemctl ] && /bin/systemctl show-environment >/dev/null 2>&1 \
&& (touch /etc/service/pubsubd/down ; exit 0)
if [ -f /etc/init.d/pubsubd ]; then
/etc/init.d/pubsubd start
if [ ! $? -eq 0 ]; then
echo "Failed to start /etc/init.d/pubsubd: $?"
exit $?
fi
#
# runit expects the run file to continue execution until death.
#
while [ 1 -eq 1 ]; do
sleep 60
done
else
touch /etc/service/pubsubd/down
fi
exit 0
#!/bin/sh
# Never run if systemd is running; it will do this.
[ -f /bin/systemctl ] && /bin/systemctl show-environment >/dev/null 2>&1 && exit 0
. /etc/default/rsyslog
exec /usr/sbin/rsyslogd -n $RSYSLOGD_OPTIONS
#!/bin/sh
# Never run if systemd is running; it will do this.
[ -f /bin/systemctl ] && /bin/systemctl show-environment >/dev/null 2>&1 && exit 0
mkdir -p /var/run/sshd
exec /usr/sbin/sshd -D
#!/bin/sh
# Never run if systemd is running; it will do this.
[ -f /bin/systemctl ] && /bin/systemctl show-environment >/dev/null 2>&1 && exit 0
if [ -f /usr/local/etc/emulab/initscripts/tbprepare ]; then
exec /usr/local/etc/emulab/initscripts/tbprepare stop
fi
exit 0
#!/bin/sh
# Never run if systemd is running; it will do this.
[ -f /bin/systemctl ] && /bin/systemctl show-environment >/dev/null 2>&1 \
&& (touch /etc/service/testbed/down ; exit 0)
if [ -f /usr/local/etc/emulab/initscripts/testbed ]; then
exec /usr/local/etc/emulab/initscripts/testbed stop
fi
exit 0
#!/bin/sh
# Never run if systemd is running; it will do this.
[ -f /bin/systemctl ] && /bin/systemctl show-environment >/dev/null 2>&1 \
&& (touch /etc/service/testbed/down ; exit 0)
if [ -f /usr/local/etc/emulab/initscripts/testbed ]; then
/usr/local/etc/emulab/initscripts/testbed start
if [ ! $? -eq 0 ]; then
echo "Failed to start /usr/local/etc/emulab/initscripts/testbed: $?"
exit $?
fi
#
# runit expects the run file to continue execution until death.
#
while [ 1 -eq 1 ]; do
sleep 60
done
else
touch /etc/service/testbed/down
fi
exit 0
#!/bin/sh
export LANG=en_US.UTF-8
export LANGUAGE=en_US:en
export LC_ALL=en_US.UTF-8
export INITRD=no
export container=docker
export > /etc/envvars
exec /sbin/runit-init
#!/bin/sh
set -x
export DEBIAN_FRONTEND=noninteractive
[ ! -f /tmp/apt-updated ] && apt-get update && touch /tmp/apt-updated
exit 0
{
"HostConfig" : {
"SecurityOpt" : [ "seccomp=unconfined" ],
"Tmpfs" : {
"/run" : "",
"/run/lock":""
}
}
}
##
## Much of this is taken from
## https://github.com/tianon/dockerfiles/blob/master/sbin-init/ubuntu/upstart/14.1#0/Dockerfile
## . Reworked to use fewer RUN statements! Also removed a bit of ssh
## configuration that we handle by default in Emulabization, and removed
## the static root passwd.
##
# Generate some fake events and trigger runlevel 3.
ADD init-fake.conf /etc/init/fake-container-events.conf
# let Upstart know it's in a container
ENV container docker
# undo some leet hax of the base image
# generate a nice UTF-8 locale for our use
# remove some pointless services
# small fix for SSH in 13.10 (that's harmless everywhere else)
RUN rm /usr/sbin/policy-rc.d; \
rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl ; \
locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8 ; \
/usr/sbin/update-rc.d -f ondemand remove; \
for f in \
/etc/init/u*.conf \
/etc/init/mounted-dev.conf \
/etc/init/mounted-proc.conf \
/etc/init/mounted-run.conf \
/etc/init/mounted-tmp.conf \
/etc/init/mounted-var.conf \
/etc/init/hostname.conf \
/etc/init/networking.conf \
/etc/init/tty*.conf \
/etc/init/plymouth*.conf \
/etc/init/hwclock*.conf \
/etc/init/module*.conf\
; do \
dpkg-divert --local --rename --add "$f"; \
done; \
echo '# /lib/init/fstab: cleared out for bare-bones Docker' >/lib/init/fstab ; \
sed -ri 's/^session\s+required\s+pam_loginuid.so$/session optional pam_loginuid.so/' /etc/pam.d/sshd
# prepare for takeoff
CMD ["/sbin/init"]
#!/bin/sh
set -x
export DEBIAN_FRONTEND=noninteractive
apt-get install -y --no-install-suggests --no-install-recommends \
openssh-server rsyslog logrotate iproute2 iputils-ping net-tools sudo
## Permissions on these should be the same as the host, so preserve them.
#cp -p /tmp/src/ssh-host-keys/ssh_host* /etc/ssh/
## Install default SSH key for root and app.
mkdir -p /root/.ssh
chmod 700 /root/.ssh
chown root:root /root/.ssh
echo console >> /etc/securetty
exit 0
#!/bin/sh
#
# We expect several environment vars to be set:
# EMULABSRC -- points to the source tree, may be read-only
# PUBSUBSRC -- points to the pubsub source tree, may be read-only
# DESTDIR -- points to an empty read-write volume from the host
# (if unset, this will just install the clientside into the container root)
#
set -x
export DEBIAN_FRONTEND=noninteractive
apt-get install -y --no-install-suggests --no-install-recommends \
git ca-certificates \
gcc make libc-dev byacc libtool-bin libssl-dev 'g++' \
sudo python python-dev libpcap-dev libboost-dev wget patch flex ntp \
zlib1g-dev
if [ -z "$EMULABSRC" ]; then
echo "WARNING: missing EMULABSRC environment variable pointer to src; cloning!"
export EMULABSRC=/tmp/emulab-devel
cd /tmp
git clone https://gitlab.flux.utah.edu/emulab/emulab-devel $EMULABSRC
[ ! $? -eq 0 ] && exit 1
fi
if [ -z "$PUBSUBSRC" ]; then
echo "WARNING: missing PUBSUBSRC environment variable pointer to src; cloning!"
export PUBSUBSRC=/tmp/pubsub
cd /tmp
git clone https://gitlab.flux.utah.edu/emulab/pubsub $PUBSUBSRC
[ ! $? -eq 0 ] && exit 1
fi
#export CFLAGS="-static"
mkdir -p /tmp/pubsub.obj
cd /tmp/pubsub.obj
cp -pRv $PUBSUBSRC/* /tmp/pubsub.obj
./configure && make && make install
[ ! $? -eq 0 ] && exit 1
cd /tmp
rm -rf /tmp/pubsub.obj
#
# If we installed to a DESTDIR, well, we're going to need pubsub dropped
# into real root here too, for the clientside build. So copy it in if
# so.
#
if [ -n "$DESTDIR" ]; then
cp -pRv $DESTDIR/* /
fi
echo /usr/local/lib > /etc/ld.so.conf.d/pubsub.conf
ldconfig
mkdir -p /tmp/emulab.obj
cd /tmp/emulab.obj
export NONTP=1
$EMULABSRC/clientside/configure --with-TBDEFS=$EMULABSRC/defs-utahclient \
&& make client && make client-install \
&& make -C tmcc/linux docker-guest-install
[ ! $? -eq 0 ] && exit 1
cd /tmp
rm -rf /tmp/emulab.obj
#
# Create these traditional NFS mountpoints now. Scripts get unhappy
# about them if they're not there.
#
mkdir -p $DESTDIR/users $DESTDIR/proj $DESTDIR/groups $DESTDIR/share
exit 0
#!/bin/sh
#
# Builds the artifacts required for the core option (that is, the clientside).
#
if [ -n "$DESTDIR" ]; then
export DESTDIR="$DESTDIR/emulab-client-install"
mkdir -p $DESTDIR
fi
debian/prepare.sh && debian8/buildenv.sh && debian/cleanup.sh
exit $?
#!/bin/sh
set -x
export DEBIAN_FRONTEND=noninteractive
apt-get install -y --no-install-suggests --no-install-recommends \
ca-certificates sudo python wget patch nano file \
perl perl-modules libwww-perl psmisc tcsh zsh ksh rsync
#
# Create these traditional NFS mountpoints now. Scripts get unhappy
# about them if they're not there.
#
mkdir -p /users /proj /groups /share
exit 0
# fake some events needed for correct startup other services
description "In-Container Upstart Fake Events"
start on startup
script
rm -rf /var/run/*.pid
rm -rf /var/run/network/*
/sbin/initctl emit stopped JOB=udevtrigger --no-wait
/sbin/initctl emit started JOB=udev --no-wait
/sbin/initctl emit runlevel RUNLEVEL=3 --no-wait
end script
#!/bin/sh
mkdir -p /var/lock/subsys
echo -n 'testbed config: '
/usr/local/etc/emulab/rc/rc.testbed
if [ ! $? -eq 0 ]; then
echo "Failed to start /usr/local/etc/emulab/rc/rc.testbed: $?"
#touch /etc/service/testbed/down
exit $?
fi
touch /var/lock/subsys/testbed