mirror of https://github.com/lidarr/Lidarr
New: Prevent Boot Loop if Config file Unauthorized access. (#554)
* New: Prevent Boot Loop if Config file Unauthorized access. * Update NzbDroneLogger.cs
This commit is contained in:
parent
e914ca86dc
commit
0596215358
|
@ -93,15 +93,15 @@ namespace NzbDrone.Common.Instrumentation
|
|||
if (updateClient)
|
||||
{
|
||||
dsn = RuntimeInfo.IsProduction
|
||||
? "https://40210a1318dd4182840c17230a1bef36:2432a6c304964372ac878179c6511811@sentry.io/209545"
|
||||
: "https://edab7530cf9544dba1f86ac28aa0110b:b84a1425fc304f0188ef968576fe9690@sentry.io/227247";
|
||||
? "https://f9238e093c75412b9351f80668a3a87c:a9392d355bd64cad80780a5279d9af82@sentry.io/209545"
|
||||
: "https://28faaa7023384031b29e38d3be74fa11:829cdc25ebd34ad5a8c16aca920cb5b0@sentry.io/227247";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dsn = RuntimeInfo.IsProduction
|
||||
? "https://40210a1318dd4182840c17230a1bef36:2432a6c304964372ac878179c6511811@sentry.io/209545"
|
||||
: "https://edab7530cf9544dba1f86ac28aa0110b:b84a1425fc304f0188ef968576fe9690@sentry.io/227247";
|
||||
? "https://f9238e093c75412b9351f80668a3a87c:a9392d355bd64cad80780a5279d9af82@sentry.io/209545"
|
||||
: "https://28faaa7023384031b29e38d3be74fa11:829cdc25ebd34ad5a8c16aca920cb5b0@sentry.io/227247";
|
||||
}
|
||||
|
||||
var target = new SentryTarget(dsn)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace NzbDrone.Core.Configuration
|
||||
{
|
||||
public class AccessDeniedConfigFileException : NzbDroneException
|
||||
{
|
||||
public AccessDeniedConfigFileException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public AccessDeniedConfigFileException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -340,14 +340,27 @@ namespace NzbDrone.Core.Configuration
|
|||
{
|
||||
throw new InvalidConfigFileException($"{_configFile} is corrupt is invalid. Please delete the config file and Lidarr will recreate it.", ex);
|
||||
}
|
||||
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
throw new AccessDeniedConfigFileException($"Lidarr does not have access to config file: {_configFile}. Please fix permissions", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveConfigFile(XDocument xDoc)
|
||||
{
|
||||
lock (Mutex)
|
||||
try
|
||||
{
|
||||
_diskProvider.WriteAllText(_configFile, xDoc.ToString());
|
||||
lock (Mutex)
|
||||
{
|
||||
_diskProvider.WriteAllText(_configFile, xDoc.ToString());
|
||||
}
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
throw new AccessDeniedConfigFileException($"Lidarr does not have access to config file: {_configFile}. Please fix permissions", ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private string GenerateApiKey()
|
||||
|
|
|
@ -141,6 +141,7 @@
|
|||
<Compile Include="Configuration\Events\ConfigFileSavedEvent.cs" />
|
||||
<Compile Include="Configuration\Events\ConfigSavedEvent.cs" />
|
||||
<Compile Include="Configuration\IConfigService.cs" />
|
||||
<Compile Include="Configuration\AccessDeniedConfigFileException.cs" />
|
||||
<Compile Include="Configuration\InvalidConfigFileException.cs" />
|
||||
<Compile Include="Configuration\RescanAfterRefreshType.cs" />
|
||||
<Compile Include="Configuration\ResetApiKeyCommand.cs" />
|
||||
|
|
|
@ -54,6 +54,10 @@ namespace NzbDrone.Host
|
|||
{
|
||||
throw new LidarrStartupException(ex);
|
||||
}
|
||||
catch (AccessDeniedConfigFileException ex)
|
||||
{
|
||||
throw new LidarrStartupException(ex);
|
||||
}
|
||||
catch (TerminateApplicationException ex)
|
||||
{
|
||||
Logger.Info(ex.Message);
|
||||
|
|
Loading…
Reference in New Issue