diff --git a/Snowflake.Data/Configuration/EasyLoggingConfigParser.cs b/Snowflake.Data/Configuration/EasyLoggingConfigParser.cs index b247037ba..c1d75ee72 100644 --- a/Snowflake.Data/Configuration/EasyLoggingConfigParser.cs +++ b/Snowflake.Data/Configuration/EasyLoggingConfigParser.cs @@ -108,19 +108,17 @@ private void CheckIfValidPermissions(FileStream fileStream, string filePath) #if NET8_0_OR_GREATER var unixFileMode = File.GetUnixFileMode(fileStream.SafeFileHandle); - var hasPermissions = !(((UnixFileMode.GroupWrite | UnixFileMode.OtherWrite) & unixFileMode) != 0); + var hasGroupOrOtherWritePermissions = (((UnixFileMode.GroupWrite | UnixFileMode.OtherWrite) & unixFileMode) != 0); #else var entitlements = FileAccessPermissions.GroupWrite | FileAccessPermissions.OtherWrite; - var hasPermissions = !_unixOperations.CheckFileHasAnyOfPermissions(filePath, entitlements); + var hasGroupOrOtherWritePermissions = _unixOperations.CheckFileHasAnyOfPermissions(filePath, entitlements); #endif - if (hasPermissions) + if (hasGroupOrOtherWritePermissions) { - return; + var errorMessage = $"Error due to other users having permission to modify the config file: {filePath}"; + s_logger.Error(errorMessage); + throw new Exception(errorMessage); } - - var errorMessage = $"Error due to other users having permission to modify the config file: {filePath}"; - s_logger.Error(errorMessage); - throw new Exception(errorMessage); } } }