From 6debb6d352d3a31d247acf66faadf7e35b3197e7 Mon Sep 17 00:00:00 2001 From: Jason Gauci Date: Wed, 25 Dec 2019 18:28:13 -0800 Subject: [PATCH 1/8] update debian changelog --- deployment/debian/debian_SOURCE/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/deployment/debian/debian_SOURCE/changelog b/deployment/debian/debian_SOURCE/changelog index 3e225c8a7..e92bb85a7 100644 --- a/deployment/debian/debian_SOURCE/changelog +++ b/deployment/debian/debian_SOURCE/changelog @@ -1,3 +1,9 @@ +et (6.0.5-##DISTRO##1) ##DISTRO##; urgency=medium + + * Various compatibility fixes + + -- Jason Gauci Mon, 14 Oct 2019 16:36:51 -0800 + et (6.0.4-##DISTRO##2) ##DISTRO##; urgency=medium * Fix bug in et.service From 534f258799ac7361264e5adc3445100a648db77f Mon Sep 17 00:00:00 2001 From: Jason Gauci Date: Mon, 30 Dec 2019 14:47:28 -0800 Subject: [PATCH 2/8] more deployment changes --- deployment/arch.Dockerfile | 6 +++--- deployment/debian/Vagrantfile | 11 ++++++++--- deployment/debian/build_all_deb.sh | 6 +++--- deployment/fedora.Dockerfile | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/deployment/arch.Dockerfile b/deployment/arch.Dockerfile index c5b510ece..fa3d19de0 100644 --- a/deployment/arch.Dockerfile +++ b/deployment/arch.Dockerfile @@ -2,7 +2,7 @@ FROM archlinux:latest LABEL maintainer="Jason Gauci (jgmath2000@gmail.com)" RUN pacman -Syu --noconfirm -RUN pacman -Syu --noconfirm jq git base-devel sudo go openssh +RUN pacman -Syu --noconfirm jq git base-devel sudo go openssh emacs RUN useradd builduser RUN passwd -d builduser RUN printf 'builduser ALL=(ALL) ALL\n' | tee -a /etc/sudoers # Allow the builduser passwordless sudo @@ -25,9 +25,9 @@ RUN git config --global user.email "foo@bar.com" # Not needed for github RUN git config --global user.name "Foo Bar" WORKDIR /home/builduser -RUN git clone https://aur.archlinux.org/eternalterminal.git arch_et +RUN git clone ssh://aur@aur.archlinux.org/eternalterminal.git arch_et -RUN git clone --branch release git@github.com:MisterTea/EternalTerminal.git +RUN git clone --branch `curl https://api.github.com/repos/mistertea/EternalTerminal/releases/latest | jq '.tag_name' | sed 's/"//g'` git@github.com:MisterTea/EternalTerminal.git RUN mkdir -p EternalTerminal/build WORKDIR /home/builduser/EternalTerminal/build RUN cmake .. diff --git a/deployment/debian/Vagrantfile b/deployment/debian/Vagrantfile index 892a8bf55..be1ae5898 100644 --- a/deployment/debian/Vagrantfile +++ b/deployment/debian/Vagrantfile @@ -12,12 +12,12 @@ Vagrant.configure("2") do |config| # Every Vagrant development environment requires a box. You can search for # boxes at https://vagrantcloud.com/search. - config.vm.box = "debian/stretch64" + config.vm.box = "debian/buster64" config.ssh.shell = "sh" config.vm.provider "virtualbox" do |v| v.memory = 2048 - v.cpus = 4 + v.cpus = 8 end # Disable automatic box update checking. If you disable this, then @@ -75,7 +75,9 @@ Vagrant.configure("2") do |config| # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the # documentation for more information about their specific syntax and use. config.vm.provision "shell", privileged: true, inline: <<-SHELL - apt update && apt install -y build-essential git curl devscripts aptly dput jq libsodium-dev libprotobuf-dev protobuf-compiler cmake libutempter-dev debhelper dh-systemd pbuilder ubuntu-dev-tools openssh-server qemu qemu-user-static debootstrap binfmt-support + apt update + DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" upgrade + apt install -y build-essential git curl devscripts aptly dput jq libsodium-dev libprotobuf-dev protobuf-compiler cmake libutempter-dev debhelper git-lfs dh-systemd pbuilder ubuntu-dev-tools openssh-server qemu qemu-user-static debootstrap binfmt-support SHELL config.vm.provision "shell", privileged: false, inline: <<-SHELL @@ -84,8 +86,11 @@ SHELL git config --global user.name "Jason Gauci" sudo chmod -R 0700 ~/.gnupg ~/.ssh + git lfs install echo "PBUILDERSATISFYDEPENDSCMD=/usr/lib/pbuilder/pbuilder-satisfydepends-apt" > ~/.pbuilderrc + echo "default-cache-ttl 34560000 +max-cache-ttl 34560000" > ~/.gnupg/gpg-agent.conf ssh-keyscan github.com >> ~/.ssh/known_hosts git clone --branch release git@github.com:MisterTea/EternalTerminal.git diff --git a/deployment/debian/build_all_deb.sh b/deployment/debian/build_all_deb.sh index 378867f1e..8da4c9160 100644 --- a/deployment/debian/build_all_deb.sh +++ b/deployment/debian/build_all_deb.sh @@ -3,7 +3,7 @@ set -x wget `curl https://api.github.com/repos/mistertea/EternalTerminal/releases/latest | jq '.tarball_url' | sed 's/"//g'` -O `curl https://api.github.com/repos/mistertea/EternalTerminal/releases/latest | jq '.tag_name' | sed 's/"//g' | sed 's/et-v/et_/g' | sed 's/$/.orig.tar.gz/g'` -for distro in `distro-info --supported | grep -v experimental`; do +for distro in `distro-info --supported | grep -v experimental | grep -v sid`; do rm -Rf EternalTerminal/debian cp -Rf debian_SOURCE EternalTerminal/debian sed -i "s/##DISTRO##/${distro}/g" EternalTerminal/debian/changelog @@ -23,11 +23,11 @@ for distro in `distro-info --supported | grep -v experimental`; do pbuilder-dist ${distro} arm64 update pbuilder-dist ${distro} arm64 build *.dsc - aptly repo add et-${distro} ~/pbuilder/${distro}*_result/*.deb + aptly repo add -force-replace=true et-${distro} ~/pbuilder/${distro}*_result/*.deb aptly publish drop ${distro} || true aptly publish repo et-${distro} done -rsync -raz --delete --progress ~/.aptly/public/* ~/github/debian-et/debian-source/ +rsync -raz --delete --progress ~/.aptly/public/* ~/debian-et/debian-source/ echo "Go to ~/debian-et/ and push the new packages." diff --git a/deployment/fedora.Dockerfile b/deployment/fedora.Dockerfile index e9ffbadee..d37066199 100644 --- a/deployment/fedora.Dockerfile +++ b/deployment/fedora.Dockerfile @@ -5,7 +5,7 @@ WORKDIR /root RUN mkdir .ssh COPY id_rsa .ssh/ COPY id_rsa.pub .ssh/ -RUN chmod 0400 .ssh/id_rsa +RUN chmod -R 0700 ~/.ssh ENV KRB5_TRACE="/dev/stdout kinit jjg@FEDORAPROJECT.ORG" From 8e5c0546b21fe8e2b8719267e4b3c13b8e335aa6 Mon Sep 17 00:00:00 2001 From: Jason Gauci Date: Wed, 8 Jan 2020 16:50:05 -0800 Subject: [PATCH 3/8] Create FUNDING.yml --- .github/FUNDING.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..e865cfb48 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: MisterTea From 10640e828c74e6c8bb701ecd18692a9ab6364259 Mon Sep 17 00:00:00 2001 From: Jason Gauci Date: Sat, 25 Jan 2020 12:36:40 -0800 Subject: [PATCH 4/8] Fix port flag on etserver (#272) --- src/terminal/TerminalServerMain.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/terminal/TerminalServerMain.cpp b/src/terminal/TerminalServerMain.cpp index a4e466c16..2746851f2 100644 --- a/src/terminal/TerminalServerMain.cpp +++ b/src/terminal/TerminalServerMain.cpp @@ -116,6 +116,10 @@ int main(int argc, char **argv) { serverFifo = result["serverfifo"].as(); } + if (result.count("port")) { + port = result["port"].as(); + } + GOOGLE_PROTOBUF_VERIFY_VERSION; srand(1); From 010db68fbfc737e4aa550f01bd9d80f4c8a496e8 Mon Sep 17 00:00:00 2001 From: Mateus Caruccio Date: Sat, 25 Jan 2020 17:37:05 -0300 Subject: [PATCH 5/8] Missing CentOS dep protobuf-lite-devel (#273) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 915f4286a..3c70762d1 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Install dependencies: sudo yum -y install epel-release sudo yum install cmake3 sudo yum install boost-devel libsodium-devel ncurses-devel protobuf-devel \ -protobuf-compiler cmake gflags-devel +protobuf-compiler cmake gflags-devel protobuf-lite-devel ``` Download and install from source: From 09beb28874f50e1979813bb151ad61e55bf9dc23 Mon Sep 17 00:00:00 2001 From: Jason Gauci Date: Tue, 11 Feb 2020 10:55:37 -0800 Subject: [PATCH 6/8] rev ubuntu build --- deployment/debian/debian_SOURCE/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/deployment/debian/debian_SOURCE/changelog b/deployment/debian/debian_SOURCE/changelog index e92bb85a7..30802b38c 100644 --- a/deployment/debian/debian_SOURCE/changelog +++ b/deployment/debian/debian_SOURCE/changelog @@ -1,3 +1,9 @@ +et (6.0.5-##DISTRO##2) ##DISTRO##; urgency=medium + + * Add arm64 build on Ubuntu + + -- Jason Gauci Sat, 25 Jan 2020 16:36:51 -0800 + et (6.0.5-##DISTRO##1) ##DISTRO##; urgency=medium * Various compatibility fixes From 7f38ca5d6527ec1d9c00d3b70b7b2c4d93a643bc Mon Sep 17 00:00:00 2001 From: Jason Gauci Date: Fri, 14 Feb 2020 10:53:12 -0800 Subject: [PATCH 7/8] Create passkey on server side (#280) * Create passkey on server side * remove python2 from os/x CI * Support new clients connecting to old servers --- .circleci/config.yml | 2 +- src/base/Headers.hpp | 16 +++++++++ src/terminal/SshSetupHandler.cpp | 50 +++++++++-------------------- src/terminal/TerminalMain.cpp | 16 +++++++-- src/terminal/UserTerminalRouter.cpp | 1 - 5 files changed, 47 insertions(+), 38 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index eb34460fc..f2cf593cd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -104,7 +104,7 @@ jobs: command: mkdir -p ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config - run: name: Install system dependencies - command: brew upgrade python@2 python; brew install cmake; brew install protobuf libsodium gflags + command: brew remove python@2; brew upgrade python; brew install cmake; brew install protobuf libsodium gflags - checkout - run: name: Init submodules diff --git a/src/base/Headers.hpp b/src/base/Headers.hpp index 22aaa1b43..e73da3a6b 100644 --- a/src/base/Headers.hpp +++ b/src/base/Headers.hpp @@ -78,6 +78,8 @@ inline std::ostream& operator<<(std::ostream& os, #include "ThreadPool.h" +#include + using namespace std; namespace google {} @@ -199,6 +201,20 @@ inline bool waitOnSocketData(int fd) { return FD_ISSET(fd, &fdset); } +inline string genRandomAlphaNum(int len) { + static const char alphanum[] = + "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + string s(len, '\0'); + + for (int i = 0; i < len; ++i) { + s[i] = alphanum[randombytes_uniform(sizeof(alphanum) - 1)]; + } + + return s; +} + } // namespace et inline bool operator==(const google::protobuf::MessageLite& msg_a, diff --git a/src/terminal/SshSetupHandler.cpp b/src/terminal/SshSetupHandler.cpp index 338835b41..c6e9dd762 100644 --- a/src/terminal/SshSetupHandler.cpp +++ b/src/terminal/SshSetupHandler.cpp @@ -4,20 +4,6 @@ #include namespace et { -string genRandom(int len) { - static const char alphanum[] = - "0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz"; - string s(len, '\0'); - - for (int i = 0; i < len; ++i) { - s[i] = alphanum[randombytes_uniform(sizeof(alphanum) - 1)]; - } - - return s; -} - string genCommand(const string &passkey, const string &id, const string &clientTerm, const string &user, bool kill, const string &command_prefix, const string &options) { @@ -46,8 +32,12 @@ string SshSetupHandler::SetupSsh(const string &user, const string &host, // Default to xterm-256color clientTerm = envString; } - string passkey = genRandom(32); - string id = genRandom(16); + string passkey = genRandomAlphaNum(32); + string id = genRandomAlphaNum(16); + + id[0] = id[1] = id[2] = 'X'; // For compatibility with old servers that do + // not generate their own keys + string cmdoptions{"--verbose=" + std::to_string(vlevel)}; if (!serverFifo.empty()) { cmdoptions += " --serverfifo=" + serverFifo; @@ -112,15 +102,9 @@ string SshSetupHandler::SetupSsh(const string &user, const string &host, } auto idpasskey = sshBuffer.substr(passKeyIndex + 10, 16 + 1 + 32); auto idpasskey_splited = split(idpasskey, '/'); - string returned_id = idpasskey_splited[0]; - string returned_passkey = idpasskey_splited[1]; - if (returned_id == id && returned_passkey == passkey) { - LOG(INFO) << "etserver started"; - } else { - LOG(FATAL) << "client/server idpasskey doesn't match: " << id - << " != " << returned_id << " or " << passkey - << " != " << returned_passkey; - } + id = idpasskey_splited[0]; + passkey = idpasskey_splited[1]; + LOG(INFO) << "etserver started"; } catch (const runtime_error &err) { cout << "Error initializing connection" << err.what() << endl; } @@ -163,21 +147,19 @@ string SshSetupHandler::SetupSsh(const string &user, const string &host, idpasskey.erase(idpasskey.find_last_not_of(" \n\r\t") + 1); idpasskey = idpasskey.substr(0, 16 + 1 + 32); auto idpasskey_splited = split(idpasskey, '/'); - string returned_id = idpasskey_splited[0]; - string returned_passkey = idpasskey_splited[1]; - if (returned_id == id && returned_passkey == passkey) { - LOG(INFO) << "jump client started."; - } else { - LOG(FATAL) << "client/server idpasskey doesn't match: " << id - << " != " << returned_id << " or " << passkey - << " != " << returned_passkey; - } + id = idpasskey_splited[0]; + passkey = idpasskey_splited[1]; } catch (const runtime_error &err) { cout << "Error initializing connection" << err.what() << endl; } } } } + + if (id.length() == 0 || passkey.length() == 0) { + LOG(FATAL) << "Somehow missing id or passkey: " << id.length() << " " + << passkey.length(); + } return id + "/" + passkey; } } // namespace et diff --git a/src/terminal/TerminalMain.cpp b/src/terminal/TerminalMain.cpp index 0526d9345..dd95990ed 100644 --- a/src/terminal/TerminalMain.cpp +++ b/src/terminal/TerminalMain.cpp @@ -103,8 +103,20 @@ int main(int argc, char** argv) { exit(1); } auto tokens = split(stdinData, '_'); - idpasskey = tokens[0]; - FATAL_FAIL(setenv("TERM", tokens[1].c_str(), 1)); + if (tokens.size() == 2) { + idpasskey = tokens[0]; + if (idpasskey.substr(0, 3) == std::string("XXX")) { + // New client connecting to new server, throw away passkey and + // regenerate + string passkey = genRandomAlphaNum(32); + string id = genRandomAlphaNum(16); + idpasskey = id + string("/") + passkey; + } + + FATAL_FAIL(setenv("TERM", tokens[1].c_str(), 1)); + } else { + LOG(FATAL) << "Invalid number of tokens: " << tokens.size(); + } } else { string idpasskey = result["idpasskey"].as(); if (result.count("idpasskeyfile")) { diff --git a/src/terminal/UserTerminalRouter.cpp b/src/terminal/UserTerminalRouter.cpp index a11e50343..f2c3da00b 100644 --- a/src/terminal/UserTerminalRouter.cpp +++ b/src/terminal/UserTerminalRouter.cpp @@ -36,7 +36,6 @@ IdKeyPair UserTerminalRouter::acceptNewConnection() { LOG(FATAL) << "Got an invalid packet header: " << int(packet.getHeader()); } TerminalUserInfo tui = stringToProto(packet.getPayload()); - VLOG(1) << "Got id/passkey: " << tui.id() << "/" << tui.passkey(); tui.set_fd(terminalFd); idInfoMap[tui.id()] = tui; return IdKeyPair({tui.id(), tui.passkey()}); From fafa18dee604dc67554287604020117045786950 Mon Sep 17 00:00:00 2001 From: Jason Gauci Date: Fri, 14 Feb 2020 19:40:20 -0800 Subject: [PATCH 8/8] v6.0.6 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfc0c8ccf..acd3fcc2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.0.2) -project (EternalTCP VERSION 6.0.5) +project (EternalTCP VERSION 6.0.6) SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH}) FIND_PACKAGE(Sanitizers)