Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.

Upgrade from Ubuntu 14.04 (Trusty) to Ubuntu 16.04 (Xenial) #601

Merged
merged 6 commits into from Dec 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM ubuntu:trusty
LABEL maintainer="Boik Su <boik@tdohacker.org>"
FROM ubuntu:xenial

ENV HOME /root

Expand All @@ -10,9 +9,11 @@ ARG TYPE=self
ARG KEY
ARG CRT

ENV HHVM_DISABLE_NUMA true

WORKDIR $HOME
COPY . $HOME
RUN chown www-data:www-data $HOME

RUN apt-get update && apt-get -y install sudo apt-utils
RUN ./extra/provision.sh -m $MODE -c $TYPE -k $KEY -C $CRT -D $DOMAIN -e $EMAIL -s `pwd` --docker
CMD ["./extra/service_startup.sh"]
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box = "ubuntu/xenial64"
config.vm.network "private_network", ip: "10.10.10.5"
config.vm.hostname = "FacebookCTF-Dev"
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile-multi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box = "ubuntu/xenial64"
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"

# MySQL Server
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile-single
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box = "ubuntu/xenial64"
config.vm.network "private_network", ip: "10.10.10.5"
config.vm.hostname = "facebookCTF-Dev"
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
Expand Down
4 changes: 2 additions & 2 deletions extra/cache/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM ubuntu:trusty
LABEL maintainer="Boik Su <boik@tdohacker.org>"
FROM ubuntu:xenial

ENV HOME /root

Expand All @@ -13,5 +12,6 @@ ARG CRT
WORKDIR $HOME
COPY . $HOME

RUN apt-get update && apt-get -y install sudo apt-utils
RUN ./extra/provision.sh -m $MODE -c $TYPE -k $KEY -C $CRT -D $DOMAIN -e $EMAIL -s `pwd` --docker --multiple-servers --server-type cache
CMD ["./extra/cache/cache_startup.sh"]
6 changes: 4 additions & 2 deletions extra/hhvm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM ubuntu:trusty
LABEL maintainer="Boik Su <boik@tdohacker.org>"
FROM ubuntu:xenial

ENV HOME /root

Expand All @@ -10,8 +9,11 @@ ARG TYPE=self
ARG KEY
ARG CRT

ENV HHVM_DISABLE_NUMA true

WORKDIR $HOME
COPY . $HOME

RUN apt-get update && apt-get -y install sudo apt-utils
RUN ./extra/provision.sh -m $MODE -c $TYPE -k $KEY -C $CRT -D $DOMAIN -e $EMAIL -s `pwd` --docker --multiple-servers --server-type hhvm --mysql-server mysql --cache-server cache
CMD ["./extra/hhvm/hhvm_startup.sh"]
3 changes: 2 additions & 1 deletion extra/hhvm/hhvm_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

set -e

service hhvm restart
chown -R www-data:www-data /var/www/fbctf
sudo -u www-data service hhvm restart

while true; do
if [[ -e /var/run/hhvm/sock ]]; then
Expand Down
15 changes: 5 additions & 10 deletions extra/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function install_unison() {
function repo_osquery() {
log "Adding osquery repository keys"
sudo DEBIAN_FRONTEND=noninteractive apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1484120AC4E9F8A1A577AEEE97A80C63C9D8B80B
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository "deb [arch=amd64] https://osquery-packages.s3.amazonaws.com/trusty trusty main"
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository "deb [arch=amd64] https://pkg.osquery.io/deb deb main"
}

function install_mysql() {
Expand Down Expand Up @@ -229,16 +229,14 @@ function install_hhvm() {

package software-properties-common

log "Adding HHVM key"
log "Adding HHVM keys"
sudo DEBIAN_FRONTEND=noninteractive apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
sudo DEBIAN_FRONTEND=noninteractive apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xB4112585D386EB94

log "Adding HHVM repo"
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main"
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository "deb http://dl.hhvm.com/ubuntu xenial-lts-3.21 main"

package_repo_update

log "Installing HHVM"
# Installing the package so the dependencies are installed too
package hhvm

log "Enabling HHVM to start by default"
Expand Down Expand Up @@ -274,7 +272,7 @@ function hhvm_performance() {
cat "$__config" | sed "s|$__oldrepo|$__repofile|g" | sudo tee "$__config"
sudo hhvm-repo-mode enable "$__path"
sudo chown www-data:www-data "$__repofile"
sudo service hhvm start
sudo service hhvm restart
}

function install_composer() {
Expand All @@ -288,9 +286,6 @@ function install_composer() {
}

function install_nodejs() {
log "Removing node.js legacy version"
sudo DEBIAN_FRONTEND=noninteractive apt-get remove --purge nodejs -y

log "Downloading and setting node.js version 6.x repo information"
dl_pipe "https://deb.nodesource.com/setup_6.x" | sudo -E bash -

Expand Down
4 changes: 2 additions & 2 deletions extra/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM ubuntu:trusty
LABEL maintainer="Boik Su <boik@tdohacker.org>"
FROM ubuntu:xenial

ENV HOME /root

Expand All @@ -13,5 +12,6 @@ ARG CRT
WORKDIR $HOME
COPY . $HOME

RUN apt-get update && apt-get -y install sudo apt-utils
RUN ./extra/provision.sh -m $MODE -c $TYPE -k $KEY -C $CRT -D $DOMAIN -e $EMAIL -s `pwd` --docker --multiple-servers --server-type mysql
CMD ["./extra/mysql/mysql_startup.sh"]
4 changes: 4 additions & 0 deletions extra/mysql/mysql_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

set -e

chown -R mysql:mysql /var/lib/mysql
chown -R mysql:mysql /var/run/mysqld
chown -R mysql:mysql /var/log/mysql

service mysql restart

while true; do
Expand Down
5 changes: 2 additions & 3 deletions extra/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM ubuntu:trusty
LABEL maintainer="Boik Su <boik@tdohacker.org>"
FROM ubuntu:xenial

ENV HOME /root

Expand All @@ -12,7 +11,7 @@ ARG CRT

WORKDIR $HOME
COPY . $HOME
RUN chown www-data:www-data $HOME

RUN apt-get update && apt-get -y install sudo apt-utils
RUN ./extra/provision.sh -m $MODE -c $TYPE -k $KEY -C $CRT -D $DOMAIN -e $EMAIL -s `pwd` --docker --multiple-servers --server-type nginx --hhvm-server hhvm
CMD ["./extra/nginx/nginx_startup.sh"]
1 change: 1 addition & 0 deletions extra/nginx/nginx_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if [[ -e /root/tmp/certbot.sh ]]; then
/bin/bash /root/tmp/certbot.sh
fi

chown -R www-data:www-data /var/www/fbctf
service nginx restart

while true; do
Expand Down
8 changes: 3 additions & 5 deletions extra/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ fi

# If multiple servers are being utilized, ensure provision was called from the "nginx" or "hhvm" servers
if [[ "$MULTIPLE_SERVERS" == false || "$SERVER_TYPE" = "nginx" || $SERVER_TYPE = "hhvm" ]]; then
package language-pack-en

if [[ "$UPDATE" == true ]] ; then
log "Updating repo"
Expand All @@ -265,7 +264,6 @@ fi
log "Installing HHVM"
install_hhvm "$CTF_PATH" "$HHVM_CONFIG_PATH" "$MULTIPLE_SERVERS"

# Install Composer
log "Installing Composer"
install_composer "$CTF_PATH"
log "Installing Composer in /usr/bin"
Expand Down Expand Up @@ -359,10 +357,10 @@ if [[ "$MULTIPLE_SERVERS" == false || "$SERVER_TYPE" = "mysql" ]]; then
# Configuration for MySQL
if [[ "$MULTIPLE_SERVERS" == true ]] && [[ "$SERVER_TYPE" = "mysql" ]]; then
# This is required in order to generate password hash (since HHVM is not being installed)
package php5-cli
package php7.0-cli

sudo sed -e '/^bind-address/ s/^#*/#/' -i /etc/mysql/my.cnf
sudo sed -e '/^skip-external-locking/ s/^#*/#/' -i /etc/mysql/my.cnf
sudo sed -e '/^bind-address/ s/^#*/#/' -i /etc/mysql/mysql.conf.d/mysqld.cnf
sudo sed -e '/^skip-external-locking/ s/^#*/#/' -i /etc/mysql/mysql.conf.d/mysqld.cnf
fi

# Database creation
Expand Down
7 changes: 6 additions & 1 deletion extra/service_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ if [[ -e /var/run/hhvm/sock ]]; then
rm -f /var/run/hhvm/sock
fi

service hhvm restart
chown -R mysql:mysql /var/lib/mysql
chown -R mysql:mysql /var/run/mysqld
chown -R mysql:mysql /var/log/mysql
chown -R www-data:www-data /var/www/fbctf

sudo -u www-data service hhvm restart
service nginx restart
service mysql restart
service memcached restart
Expand Down
2 changes: 1 addition & 1 deletion src/models/Progressive.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private static function progressiveFromRow(
$progressive = array();
$result =
await $db->queryf(
'SELECT * FROM progressive_log GROUP BY team_name, iteration ORDER BY points ASC',
'SELECT MAX(id) as id, MAX(ts) as ts, team_name, MAX(points) as points, iteration FROM progressive_log GROUP BY team_name, iteration, id ORDER BY points ASC',
);
foreach ($result->mapRows() as $row) {
$progressive[$row->get('team_name')][] =
Expand Down
16 changes: 14 additions & 2 deletions src/models/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,13 @@ private static function sessionFromRow(Map<string, string> $row): Session {
$sessions = array();
$cached_sessions = array();
/* HH_IGNORE_ERROR[4053]: HHVM doesn't beleive there is a getAllKeys() method, there is... */
$mc_keys = $mc->getAllKeys();
//$mc_keys = $mc->getAllKeys();
/* Memcached::getAllKeys() is not working in HHVM 3.21 - For now we will flush Memcache in place of the call.
* Flushing the cache will be slower and will negatively impact performance.
* As soon as getAllKeys() regains support in HHVM, or the functionality it replaced, this should be updated.
*/
$mc_keys = array();
self::flushMCCluster();
$all_sessions = preg_grep(
'/'.self::$MC_KEY.self::$MC_KEYS->get('SESSIONS').'/',
$mc_keys,
Expand Down Expand Up @@ -492,7 +498,13 @@ public static function invalidateMCSessions(?string $key = null): void {
$key = str_replace(' ', '', $key);
if ($key === null) {
/* HH_IGNORE_ERROR[4053]: HHVM doesn't beleive there is a getAllKeys() method, there is... */
$mc_keys = $mc->getAllKeys();
//$mc_keys = $mc->getAllKeys();
/* Memcached::getAllKeys() is not working in HHVM 3.21 - For now we will flush Memcache in place of the call.
* Flushing the cache will be slower and will negatively impact performance.
* As soon as getAllKeys() regains support in HHVM, or the functionality it replaced, this should be updated.
*/
$mc_keys = array();
self::flushMCCluster();
$all_sessions = preg_grep(
'/'.self::$MC_KEY.self::$MC_KEYS->get('SESSIONS').'/',
$mc_keys,
Expand Down
2 changes: 2 additions & 0 deletions tests/_files/seed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,15 @@
<column>team_id</column>
<column>created_ts</column>
<column>last_access_ts</column>
<column>last_page_access</column>
<row>
<value>1</value>
<value>cookie</value>
<value>data</value>
<value>1</value>
<value>2015-04-24 17:15:23</value>
<value>2016-04-24 17:15:23</value>
<value>index</value>
</row>
</table>
<table name="registration_tokens">
Expand Down