From 6071f4e96d956e2d5789fe606599c3dca8ffbf87 Mon Sep 17 00:00:00 2001 From: Thomas Wouters Date: Thu, 20 Jan 2022 18:46:47 +0100 Subject: [PATCH 1/3] Fix config directory permission validation Directories were reported as read-only as soon as the effective uid didn't the match directory owner. Rewrite permission validation to properly support UNIX permissions. Does not support for Access Control Lists. Fixes #87 --- utils/utils_custom.go | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/utils/utils_custom.go b/utils/utils_custom.go index 90253d60..bf9324ab 100644 --- a/utils/utils_custom.go +++ b/utils/utils_custom.go @@ -22,19 +22,35 @@ func DirWritable(path string) (bool, error) { return false, errors.New("path isn't a directory") } - if info.Mode().Perm()&(1<<(uint(7))) == 0 { - return false, errors.New("write permission bit is not set on this file for user") - } - var stat syscall.Stat_t if err = syscall.Stat(path, &stat); err != nil { return false, errors.New("unable to get stat") } - if uint32(os.Geteuid()) != stat.Uid { - return false, errors.New("user doesn't have permission to write to this directory") + if uint32(os.Geteuid()) == stat.Uid { + if info.Mode().Perm()&(1<<7) != 0 { + // owner matches and has write permissions + return true, nil + } else { + return false, errors.New("owner doesn't have write permissions for this path") + } } - return true, nil + + if uint32(os.Getegid()) == stat.Gid { + if info.Mode().Perm()&(1<<4) != 0 { + // group matches and has write permissions + return true, nil + } else { + return false, errors.New("group doesn't have write permissions for this path") + } + } + + if info.Mode().Perm()&(1<<1) != 0 { + // all users have write permissions + return true, nil + } + + return false, errors.New("user doesn't have write permissions for this path") } func Ping(address string, secondsTimeout int) (int64, error) { From 4996b87d03580e5de745b072db9d91d075804e4e Mon Sep 17 00:00:00 2001 From: Adam Boutcher Date: Tue, 25 Jan 2022 11:11:28 +0000 Subject: [PATCH 2/3] Version bump --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index d070d29d..482d5d86 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.90.79 +0.90.80 From f504deda3a1b8527115e01807625410a6e11168b Mon Sep 17 00:00:00 2001 From: Adam Boutcher Date: Wed, 26 Jan 2022 16:49:42 +0000 Subject: [PATCH 3/3] Updated Changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dc37530..08a08ecc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 0.90.80 (01-26-2022) +- Fixed permissions on /app directory - Thanks twouters + # 0.90.79 (01-24-2022) - Updated Russian Language - Thanks meatlayer - Docker file fix for BASE_PATH and health checks - Thanks michaelkrieger