Skip to content

Commit

Permalink
Do not run as root in debian package. (Velocidex#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
scudette authored Oct 15, 2019
1 parent ea3c1d2 commit 5a60b1e
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions bin/debian.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ RestartSec=120
LimitNOFILE=20000
Environment=LANG=en_US.UTF-8
ExecStart=%s --config %s frontend
User=velociraptor
Group=velociraptor
[Install]
WantedBy=multi-user.target
Expand Down Expand Up @@ -185,7 +187,7 @@ func doServerDeb() {
deb.SetArchitecture("amd64")
deb.SetMaintainer("Velocidex Innovations")
deb.SetMaintainerEmail("support@velocidex.com")
deb.SetHomepage("https://docs.velociraptor.velocidex.com")
deb.SetHomepage("https://www.velocidex.com/docs")
deb.SetShortDescription("Velociraptor server deployment.")

config_path := "/etc/velociraptor/server.config.yaml"
Expand All @@ -199,10 +201,27 @@ func doServerDeb() {

// Just a simple bare bones deb.
if !*server_debian_command_with_monitoring {
deb.AddControlExtraString("postinst", `
filestore_path := config_obj.Datastore.Location
deb.AddControlExtraString("postinst", fmt.Sprintf(`
if ! getent group velociraptor >/dev/null; then
addgroup --system velociraptor
fi
if ! getent user velociraptor >/dev/null; then
adduser --system --home /etc/velociraptor/ --no-create-home \
--ingroup velociraptor velociraptor --shell /bin/false \
--gecos "Velociraptor Server"
fi
# Make the filestore path accessible to the user.
mkdir -p '%s'
chown -R velociraptor:velociraptor '%s' /etc/velociraptor/
chmod -R go-r /etc/velociraptor/
setcap CAP_SYS_RESOURCE,CAP_NET_BIND_SERVICE=+eip /usr/local/bin/velociraptor
/bin/systemctl enable velociraptor_server
/bin/systemctl start velociraptor_server
`)
`, filestore_path, filestore_path))

deb.AddControlExtraString("prerm", `
/bin/systemctl disable velociraptor_server
Expand Down

0 comments on commit 5a60b1e

Please sign in to comment.