diff --git a/CHANGELOG.md b/CHANGELOG.md index 331e03a..3036117 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## [Unreleased] +## [0.10.1] - 2021-02-10 +### Fixed +- Single admin user can no longer be deleted (so there is always a user) +- fixed incompatibility to glibc 2.32 by linking dynamic on linux +- Moved from alpine to ubuntu docker image base, to prevent factorio not running correctly ## [0.10.0] - 2021-02-10 ### Added diff --git a/Makefile b/Makefile index a64a561..173131c 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ factorio-server-manager-linux: @echo "Building Backend - Linux" @mkdir -p factorio-server-manager @cd src; \ - CGO_ENABLED=1 GO111MODULE=on GOOS=linux GOARCH=amd64 go build -ldflags="-extldflags=-static" -o ../factorio-server-manager/factorio-server-manager . + CGO_ENABLED=1 GO111MODULE=on GOOS=linux GOARCH=amd64 go build -o ../factorio-server-manager/factorio-server-manager . factorio-server-manager-windows: @echo "Building Backend - Windows" diff --git a/docker/Dockerfile b/docker/Dockerfile index 21ecb41..4c405f8 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,15 +1,15 @@ # Glibc is required for Factorio Server binaries to run -FROM frolvlad/alpine-glibc +FROM ubuntu ENV FACTORIO_VERSION=stable \ - MANAGER_VERSION=0.10.0 \ + MANAGER_VERSION=0.10.1 \ RCON_PASS="" VOLUME /opt/fsm-data /opt/factorio/saves /opt/factorio/mods /opt/factorio/config EXPOSE 80/tcp 34197/udp -RUN apk add --no-cache curl tar xz unzip jq +RUN apt-get update && apt-get install -y curl tar xz unzip jq && rm -rf /var/lib/apt/lists/* WORKDIR /opt diff --git a/docker/Dockerfile-local b/docker/Dockerfile-local index 4213a79..b2e14ea 100644 --- a/docker/Dockerfile-local +++ b/docker/Dockerfile-local @@ -1,5 +1,5 @@ # Glibc is required for Factorio Server binaries to run -FROM frolvlad/alpine-glibc +FROM ubuntu ENV FACTORIO_VERSION=latest \ RCON_PASS="" @@ -8,7 +8,7 @@ VOLUME /opt/fsm-data /opt/factorio/saves /opt/factorio/mods /opt/factorio/config EXPOSE 80/tcp 34197/udp -RUN apk add --no-cache curl tar xz unzip jq +RUN apt-get update && apt-get install -y curl tar xz-utils unzip jq && rm -rf /var/lib/apt/lists/* WORKDIR /opt diff --git a/src/api/auth.go b/src/api/auth.go index 4dd5604..93d402b 100644 --- a/src/api/auth.go +++ b/src/api/auth.go @@ -2,6 +2,7 @@ package api import ( "encoding/base64" + "errors" "log" "net/http" @@ -102,6 +103,21 @@ func (a *Auth) checkPassword(username, password string) error { } func (a *Auth) deleteUser(username string) error { + adminUsers := []User{} + adminQuery := a.db.Find(&User{}).Where(&User{Role: "admin"}).Find(&adminUsers) + if adminQuery.Error != nil { + log.Printf("Error retrieving admin user list from database: %s", adminQuery.Error) + return adminQuery.Error + } + + for _, user := range adminUsers { + if user.Username == username { + if adminQuery.RowsAffected == 1 { + return errors.New("cannot delete single admin user") + } + } + } + result := a.db.Model(&User{}).Where(&User{Username: username}).Delete(&User{}) if result.Error != nil { log.Printf("Error deleting user from database: %s", result.Error) diff --git a/src/factorio/saves.go b/src/factorio/saves.go index 01051b8..f4e31b2 100644 --- a/src/factorio/saves.go +++ b/src/factorio/saves.go @@ -76,6 +76,7 @@ func CreateSave(filePath string) (string, error) { cmdOutput, err := exec.Command(config.FactorioBinary, args...).Output() if err != nil { log.Printf("Error in creating Factorio save: %s", err) + log.Println(string(cmdOutput)) return "", err }