summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <35781042+pbuetow@users.noreply.github.com>2020-12-29 09:48:56 +0000
committerGitHub <noreply@github.com>2020-12-29 09:48:56 +0000
commit0fe3c8708634cc59d61bf47bd909ef0111f0d56a (patch)
treec9f0dfa884927079de309b68c48224f4b0f00d0d
parent495e9f38220a6d448b15882a235e7a9c21f21d18 (diff)
parent0099a7ab9e1d28300c69c3b50b4ebe1cde9a8cbc (diff)
Merge pull request #20 from snonux/develop
Make CGo dependencies optional (e.g. Linux ACL support)
-rw-r--r--.gitignore11
-rw-r--r--LICENSE.DataDog.zstd27
-rw-r--r--Makefile14
-rw-r--r--README.md2
-rw-r--r--doc/drun.gifbin1668728 -> 0 bytes
-rw-r--r--doc/installation.md20
-rw-r--r--doc/licenses.md11
-rw-r--r--doc/quickstart.md6
-rw-r--r--docker/Dockerfile18
-rw-r--r--docker/Makefile10
-rw-r--r--docker/README.md5
-rw-r--r--docker/dtail.json39
-rwxr-xr-xdocker/spindown.sh9
-rwxr-xr-xdocker/spinup.sh9
-rw-r--r--go.mod2
-rw-r--r--go.sum130
-rw-r--r--internal/clients/handlers/withcancel.go24
-rw-r--r--internal/io/fs/permissions/permission.go2
-rw-r--r--internal/io/fs/permissions/permission_linuxacl.c (renamed from internal/io/fs/permissions/permission_linux.c)4
-rw-r--r--internal/io/fs/permissions/permission_linuxacl.go (renamed from internal/io/fs/permissions/permission_linux.go)4
-rw-r--r--internal/io/fs/permissions/permission_linuxacl.h (renamed from internal/io/fs/permissions/permission_linux.h)2
-rw-r--r--internal/io/fs/permissions/permission_test.go2
-rw-r--r--internal/server/background/background.go126
23 files changed, 315 insertions, 162 deletions
diff --git a/.gitignore b/.gitignore
index 79c20cf..c9e8333 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,14 @@
*_proprietary.go
+<<<<<<< HEAD
cache/
log/
+tags
+=======
+/cache/
+/log/
+/dtail
+/dgrep
+/dcat
+/dmap
+/dserver
+>>>>>>> 7ee0121afed3e7cab6457142f70e411020ab2b21
diff --git a/LICENSE.DataDog.zstd b/LICENSE.DataDog.zstd
new file mode 100644
index 0000000..345c1eb
--- /dev/null
+++ b/LICENSE.DataDog.zstd
@@ -0,0 +1,27 @@
+Simplified BSD License
+
+Copyright (c) 2016, Datadog <info@datadoghq.com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Makefile b/Makefile
index c8e5a12..6d85347 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,21 @@
GO ?= go
all: test build
build:
+ifndef USE_ACL
${GO} build -o dserver ./cmd/dserver/main.go
+else
+ ${GO} build -tags linuxacl -o dserver ./cmd/dserver/main.go
+endif
${GO} build -o dcat ./cmd/dcat/main.go
${GO} build -o dgrep ./cmd/dgrep/main.go
${GO} build -o dmap ./cmd/dmap/main.go
${GO} build -o dtail ./cmd/dtail/main.go
install:
+ifndef USE_ACL
${GO} install ./cmd/dserver/main.go
+else
+ ${GO} install -tags linuxacl ./cmd/dserver/main.go
+endif
${GO} install ./cmd/dcat/main.go
${GO} install ./cmd/dgrep/main.go
${GO} install ./cmd/dmap/main.go
@@ -17,7 +25,7 @@ clean:
test -f $$cmd && rm $$cmd; \
done
vet:
- find . -type d | while read dir; do \
+ find . -type d | egrep -v '(./samples|./log|./doc)' | while read dir; do \
echo ${GO} vet $$dir; \
${GO} vet $$dir; \
done
@@ -28,4 +36,8 @@ lint:
golint $$dir; \
done
test:
+ifndef USE_ACL
${GO} test ./... -v
+else
+ ${GO} test -tags linuxacl ./... -v
+endif
diff --git a/README.md b/README.md
index 69d3153..d65d124 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ More
* [How to contribute](CONTRIBUTING.md)
* [Code of conduct](CODE_OF_CONDUCT.md)
-* [License](LICENSE)
+* [Licenses](doc/licenses.md)
Credits
=======
diff --git a/doc/drun.gif b/doc/drun.gif
deleted file mode 100644
index a3efeed..0000000
--- a/doc/drun.gif
+++ /dev/null
Binary files differ
diff --git a/doc/installation.md b/doc/installation.md
index 6f946c4..6bf17b0 100644
--- a/doc/installation.md
+++ b/doc/installation.md
@@ -7,6 +7,26 @@ The following installation guide has been tested successfully on CentOS 7. You m
Please check the [Quick Starting Guide](quickstart.md) for instructions how to compile DTail. It is recommended to automate the build process via your build pipeline (e.g. produce a deployable RPM via Jenkins). You don't have to use ``go get...`` to compile and install the binaries. You can also clone the repository and use ``make`` instead.
+## Linux ACL support
+
+This is optional but it gives you better security. On Linux you have the option to compile `dserver` with File System Access Control List support. For that you need:
+
+### 1. Install the `libacl` development library. On RHEL, CentOS and Fedora it would be
+
+```console
+% sudo dnf install libacl-devel -y
+```
+
+### 2. Enable ACL via a Go build flag
+
+Set the `USE_ACL` environment variable before invoking the make command.
+
+```console
+% export USE_ACL=yes
+```
+
+Alternatively you could just add `-tags linuxacl` to the Go compiler.
+
# Install it
It is recommended to automate all the installation process outlined here. You could use a configuration management system such as Puppet, Chef or Ansible. However, that relies heavily on how your infrastructure is managed and is out of scope of this documentation.
diff --git a/doc/licenses.md b/doc/licenses.md
new file mode 100644
index 0000000..83a94e7
--- /dev/null
+++ b/doc/licenses.md
@@ -0,0 +1,11 @@
+Licenses
+========
+
+DTails main license is [Apache 2.0](../LICENSE). Further 3rd party licenses are:
+
+## DataDog zstd compression library
+
+Not included in DTail repository but imported automatically on build.
+
+* URL: https://github.com/DataDog/zstd
+* License: [Simplified BSD](../LICENSE.DataDog.zstd)
diff --git a/doc/quickstart.md b/doc/quickstart.md
index 6baedbb..f1ac000 100644
--- a/doc/quickstart.md
+++ b/doc/quickstart.md
@@ -7,12 +7,6 @@ This guide assumes that you know how to generate and configure a public/private
# Install it
-On Linux you need to install the libacl development library for file system ACL permission support in `dserver`. On RHEL, CentOS and Fedora it would be
-
-```console
-% sudo dnf install libacl-devel -y
-```
-
To compile and install all DTail binaries directly from GitHub run:
```console
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..8632832
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,18 @@
+# This builds a container running DTail server
+# The container can be used for developing and testing
+# Purposes
+
+FROM fedora:33
+RUN mkdir -p /etc/dserver /var/run/dserver/ /var/log/dserver
+
+ADD ./dtail.json /etc/dserver/dtail.json
+ADD ./dserver /usr/local/bin/dserver
+
+RUN useradd dserver
+RUN chown -R dserver /var/run/dserver /var/log/dserver
+USER dserver
+
+WORKDIR /var/run/dserver
+EXPOSE 2222/tcp
+
+CMD ["/usr/local/bin/dserver", "-relaxedAuth", "-cfg", "/etc/dserver/dtail.json"]
diff --git a/docker/Makefile b/docker/Makefile
new file mode 100644
index 0000000..029adf6
--- /dev/null
+++ b/docker/Makefile
@@ -0,0 +1,10 @@
+all:
+ cp ../dserver .
+ docker build . -t dserver:develop
+ rm ./dserver
+run:
+ docker run -p 2222:2222 dserver:develop
+spinup:
+ ./spinup.sh 10
+spindown:
+ ./spindown.sh 10
diff --git a/docker/README.md b/docker/README.md
new file mode 100644
index 0000000..4d7e610
--- /dev/null
+++ b/docker/README.md
@@ -0,0 +1,5 @@
+# Docker
+
+The files in here are used for local development purposes only. E.g. you can
+build a dserver Docker container, create multiple instances of it and then
+mass connect to them via dtail client.
diff --git a/docker/dtail.json b/docker/dtail.json
new file mode 100644
index 0000000..d923101
--- /dev/null
+++ b/docker/dtail.json
@@ -0,0 +1,39 @@
+{
+ "Client": {},
+ "Server": {
+ "SSHBindAddress": "0.0.0.0",
+ "MaxConcurrentCats": 2,
+ "MaxConcurrentTails": 50,
+ "MaxConnections": 50,
+ "MapreduceLogFormat" : "default",
+ "HostKeyFile" : "cache/ssh_host_key",
+ "HostKeyBits" : 2048,
+ "Permissions": {
+ "Default": [
+ "readfiles:^/.*$",
+ "runcommands:^/.*$"
+ ],
+ "Users": {
+ "pbuetow": [
+ "readfiles:^/.*$",
+ "runcommands:^/.*$"
+ ],
+ "jblake": [
+ "readfiles:^/tmp/foo.log$",
+ "readfiles:^/.*$",
+ "readfiles:!^/tmp/bar.log$",
+ "runcommands:!^/.*$"
+ ]
+ }
+ }
+ },
+ "Common": {
+ "LogDir" : "/var/log/dserver",
+ "CacheDir" : "cache",
+ "TmpDir" : "tmp",
+ "LogStrategy": "daily",
+ "SSHPort": 2222,
+ "DebugEnable": true,
+ "ExperimentalFeaturesEnable": false
+ }
+}
diff --git a/docker/spindown.sh b/docker/spindown.sh
new file mode 100755
index 0000000..73ed059
--- /dev/null
+++ b/docker/spindown.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+declare -i NUM_INSTANCES=$1
+declare -i BASE_PORT=2222
+
+for (( i=0; i < $NUM_INSTANCES; i++ )); do
+ port=$[ BASE_PORT + i + 1 ]
+ docker stop dserver-serv$i
+done
diff --git a/docker/spinup.sh b/docker/spinup.sh
new file mode 100755
index 0000000..3890ce6
--- /dev/null
+++ b/docker/spinup.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+declare -i NUM_INSTANCES=$1
+declare -i BASE_PORT=2222
+
+for (( i=0; i < $NUM_INSTANCES; i++ )); do
+ port=$[ BASE_PORT + i + 1 ]
+ docker run -d --name dserver-serv$i --hostname serv$i -p $port:2222 dserver:develop
+done
diff --git a/go.mod b/go.mod
index c19efe7..b52ed7a 100644
--- a/go.mod
+++ b/go.mod
@@ -4,6 +4,8 @@ go 1.15
require (
github.com/DataDog/zstd v1.4.5
+ github.com/google/go-licenses v0.0.0-20201026145851-73411c8fa237 // indirect
+ github.com/ribice/glice v0.0.0-20190726034412-e55bb973f127 // indirect
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d // indirect
diff --git a/go.sum b/go.sum
index c423bb0..cea5ef1 100644
--- a/go.sum
+++ b/go.sum
@@ -1,9 +1,109 @@
+cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/zstd v1.4.4 h1:+IawcoXhCBylN7ccwdwf8LOH2jKq7NavGpEPanrlTzE=
github.com/DataDog/zstd v1.4.4/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
+github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
+github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
+github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
+github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
+github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
+github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
+github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
+github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
+github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
+github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
+github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
+github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
+github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
+github.com/google/go-licenses v0.0.0-20201026145851-73411c8fa237 h1:qmrsmPqL7jK5f7dwLc4oDBZu/3pzB19tvhnP4TngNYY=
+github.com/google/go-licenses v0.0.0-20201026145851-73411c8fa237/go.mod h1:g1VOUGKZYIqe8lDq2mL7plhAWXqrEaGUs7eIjthN1sk=
+github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
+github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
+github.com/google/licenseclassifier v0.0.0-20190926221455-842c0d70d702 h1:nVgx26pAe6l/02mYomOuZssv28XkacGw/0WeiTVorqw=
+github.com/google/licenseclassifier v0.0.0-20190926221455-842c0d70d702/go.mod h1:qsqn2hxC+vURpyBRygGUuinTO42MFRLcsmQ/P8v94+M=
+github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
+github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
+github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
+github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
+github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
+github.com/keighl/metabolize v0.0.0-20150915210303-97ab655d4034 h1:1ijjWJbbN7za3tZ7eXUO5fVcC9ogGYShQh+zM6YiCYE=
+github.com/keighl/metabolize v0.0.0-20150915210303-97ab655d4034/go.mod h1:xxAJtNhpzBtSWAYybYGKfMFYx71aqCyNe/8FraO/1ac=
+github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
+github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
+github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
+github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
+github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
+github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc=
+github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
+github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
+github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
+github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
+github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/olekukonko/tablewriter v0.0.1 h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88=
+github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
+github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k=
+github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
+github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
+github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
+github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
+github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
+github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
+github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/ribice/glice v0.0.0-20190726034412-e55bb973f127 h1:aPRzxUKZHVD58hD5CY9M3TAM1wJYZSww/VxCzLFzQfk=
+github.com/ribice/glice v0.0.0-20190726034412-e55bb973f127/go.mod h1:p4S+fsfJ+wO7Cexs43Ub6bcvj2zotI5XwY67Pu0WvvY=
+github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
+github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
+github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
+github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
+github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s=
+github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
+github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
+github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
+github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
+github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
+github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
+github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
+github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
+github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
+golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 h1:sKJQZMuxjOAR/Uo2LBfU90onWEf1dF4C+0hPJCc9Mpc=
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de h1:ikNHVSjEfnvz6sxdSPCaPt572qowuyMDMJLLm3Db3ig=
@@ -17,13 +117,26 @@ golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPI
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI=
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4=
+golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA=
+golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191119060738-e882bf8e40c2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200812155832-6a926be9bd1d h1:QQrM/CCYEzTs91GZylDCQjGHudbPTxF/1fvXdVh5lMo=
golang.org/x/sys v0.0.0-20200812155832-6a926be9bd1d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -34,6 +147,23 @@ golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXR
golang.org/x/term v0.0.0-20201207232118-ee85cb95a76b h1:a0ErnNnPKmhDyIXQvdZr+Lq8dc8xpMeqkF8y5PgQU4Q=
golang.org/x/term v0.0.0-20201207232118-ee85cb95a76b/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
+golang.org/x/tools v0.0.0-20191118222007-07fc4c7f2b98/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7 h1:EBZoQjiKKPaLbPrbpssUfuHtwM6KV/vb4U85g/cigFY=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
+gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
+gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
+gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
+gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
+gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
+gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/internal/clients/handlers/withcancel.go b/internal/clients/handlers/withcancel.go
deleted file mode 100644
index 7c9cf4e..0000000
--- a/internal/clients/handlers/withcancel.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package handlers
-
-import "context"
-
-type withCancel struct {
- ctx context.Context
- done chan struct{}
-}
-
-// WithCancel sets and returns the context used.
-func (w *withCancel) WithCancel(ctx context.Context) (context.Context, context.CancelFunc) {
- cancelCtx, cancel := context.WithCancel(ctx)
- w.ctx = cancelCtx
-
- return cancelCtx, cancel
-}
-
-func (w *withCancel) Done() <-chan struct{} {
- return w.done
-}
-
-func (w *withCancel) shutdown() {
- close(w.done)
-}
diff --git a/internal/io/fs/permissions/permission.go b/internal/io/fs/permissions/permission.go
index 0ed4f17..cc5dd9b 100644
--- a/internal/io/fs/permissions/permission.go
+++ b/internal/io/fs/permissions/permission.go
@@ -1,4 +1,4 @@
-// +build !linux
+// +build !linuxacl
package permissions
diff --git a/internal/io/fs/permissions/permission_linux.c b/internal/io/fs/permissions/permission_linuxacl.c
index cd10525..86b1185 100644
--- a/internal/io/fs/permissions/permission_linux.c
+++ b/internal/io/fs/permissions/permission_linuxacl.c
@@ -1,4 +1,6 @@
-#include "permission_linux.h"
+// +build linuxacl
+
+#include "permission_linuxacl.h"
#ifdef DEBUG
void debug_print_checker(struct permission_checker *pc) {
diff --git a/internal/io/fs/permissions/permission_linux.go b/internal/io/fs/permissions/permission_linuxacl.go
index bbc039b..7d2d7ca 100644
--- a/internal/io/fs/permissions/permission_linux.go
+++ b/internal/io/fs/permissions/permission_linuxacl.go
@@ -1,7 +1,9 @@
+// +build linuxacl
+
package permissions
/*
-#include "permission_linux.h"
+#include "permission_linuxacl.h"
#cgo LDFLAGS: -L. -lacl
*/
import "C"
diff --git a/internal/io/fs/permissions/permission_linux.h b/internal/io/fs/permissions/permission_linuxacl.h
index a2c266e..52dadcf 100644
--- a/internal/io/fs/permissions/permission_linux.h
+++ b/internal/io/fs/permissions/permission_linuxacl.h
@@ -1,3 +1,5 @@
+// +build linuxacl
+
#ifndef PERMISSION_LINUX_H
#define PERMISSION_LINUX_H
diff --git a/internal/io/fs/permissions/permission_test.go b/internal/io/fs/permissions/permission_test.go
index d415ac2..c0ef038 100644
--- a/internal/io/fs/permissions/permission_test.go
+++ b/internal/io/fs/permissions/permission_test.go
@@ -1,4 +1,4 @@
-// +build linux
+// +build linuxacl
package permissions
diff --git a/internal/server/background/background.go b/internal/server/background/background.go
deleted file mode 100644
index 3907448..0000000
--- a/internal/server/background/background.go
+++ /dev/null
@@ -1,126 +0,0 @@
-package background
-
-import (
- "context"
- "errors"
- "fmt"
- "strings"
- "sync"
-
- "github.com/mimecast/dtail/internal/io/logger"
-)
-
-type job struct {
- cancel context.CancelFunc
- wg *sync.WaitGroup
-}
-
-// Background specifies a job or command run in background on server side.
-// This does not require an active DTail client SSH connection/session.
-type Background struct {
- mutex *sync.Mutex
- jobs map[string]job
-}
-
-// New returns a new background manager.
-func New() Background {
- return Background{
- jobs: make(map[string]job),
- mutex: &sync.Mutex{},
- }
-}
-
-// Add a background job.
-func (b Background) Add(userName, jobName string, cancel context.CancelFunc, wg *sync.WaitGroup) error {
- key := b.key(userName, jobName)
- logger.Debug("background", "Add", key)
-
- b.mutex.Lock()
- defer b.mutex.Unlock()
-
- if _, ok := b.jobs[key]; ok {
- return errors.New("job already exists")
- }
-
- b.jobs[key] = job{cancel, wg}
-
- // Clean up background job database.
- go func() {
- wg.Wait()
- b.cancel(key)
- }()
-
- return nil
-}
-
-// Cancel a background job.
-func (b Background) Cancel(userName, jobName string) error {
- key := b.key(userName, jobName)
- logger.Debug("background", "Cancel", key)
-
- return b.cancel(key)
-}
-
-func (b Background) cancel(key string) error {
- job, ok := b.get(key)
- logger.Debug("background", "cancel", key, job, ok)
-
- if !ok {
- return errors.New("no job to cancel")
- }
-
- logger.Debug("background", "cancel", "run job.cancel()")
- job.cancel()
- logger.Debug("background", "cancel", "run job.wg.Wait()")
- job.wg.Wait()
- logger.Debug("background", "cancel", "run b.delete(key)")
- b.delete(key)
-
- return nil
-}
-
-// ListJobsC returns a channel listing all jobs of the given user.
-func (b Background) ListJobsC(userName string) <-chan string {
- logger.Debug("background", "ListJobC", userName)
-
- ch := make(chan string)
-
- go func() {
- defer close(ch)
-
- b.mutex.Lock()
- defer b.mutex.Unlock()
-
- for k := range b.jobs {
- logger.Debug("ListJobsC", k, userName)
- if strings.HasPrefix(k, fmt.Sprintf("%s.", userName)) {
- ch <- k
- }
- }
- }()
-
- return ch
-}
-
-func (b Background) get(key string) (job, bool) {
- logger.Debug("background", "get", key)
-
- b.mutex.Lock()
- defer b.mutex.Unlock()
-
- job, ok := b.jobs[key]
- return job, ok
-}
-
-func (b Background) delete(key string) {
- logger.Debug("background", "delete", key)
-
- b.mutex.Lock()
- defer b.mutex.Unlock()
-
- delete(b.jobs, key)
-}
-
-func (Background) key(userName, jobName string) string {
- return fmt.Sprintf("%s.%s", userName, jobName)
-}