mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-22 23:11:11 -04:00
update access denied exceptions
This commit is contained in:
parent
c31aab2d64
commit
ebc95ffb9a
@ -120,8 +120,6 @@ namespace MediaBrowser.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <returns>System.Object.</returns>
|
/// <returns>System.Object.</returns>
|
||||||
/// <exception cref="System.ArgumentNullException">Path</exception>
|
|
||||||
/// <exception cref="System.ArgumentException"></exception>
|
|
||||||
public object Get(GetDirectoryContents request)
|
public object Get(GetDirectoryContents request)
|
||||||
{
|
{
|
||||||
var path = request.Path;
|
var path = request.Path;
|
||||||
@ -138,16 +136,8 @@ namespace MediaBrowser.Api
|
|||||||
return ToOptimizedSerializedResultUsingCache(GetNetworkShares(path).OrderBy(i => i.Path).ToList());
|
return ToOptimizedSerializedResultUsingCache(GetNetworkShares(path).OrderBy(i => i.Path).ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ToOptimizedSerializedResultUsingCache(GetFileSystemEntries(request).OrderBy(i => i.Path).ToList());
|
return ToOptimizedSerializedResultUsingCache(GetFileSystemEntries(request).OrderBy(i => i.Path).ToList());
|
||||||
}
|
}
|
||||||
catch (UnauthorizedAccessException)
|
|
||||||
{
|
|
||||||
// Don't throw the original UnauthorizedAccessException because it will cause a 401 response
|
|
||||||
throw new ApplicationException("Access to the path " + request.Path + " is denied.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public object Get(GetNetworkShares request)
|
public object Get(GetNetworkShares request)
|
||||||
{
|
{
|
||||||
|
@ -722,7 +722,7 @@ namespace MediaBrowser.Api.Library
|
|||||||
|
|
||||||
if (!item.CanDelete(user))
|
if (!item.CanDelete(user))
|
||||||
{
|
{
|
||||||
throw new UnauthorizedAccessException();
|
throw new SecurityException("Unauthorized access");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item is ILiveTvRecording)
|
if (item is ILiveTvRecording)
|
||||||
|
@ -521,12 +521,12 @@ namespace MediaBrowser.Api.LiveTv
|
|||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
throw new UnauthorizedAccessException("Anonymous live tv management is not allowed.");
|
throw new SecurityException("Anonymous live tv management is not allowed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.Policy.EnableLiveTvManagement)
|
if (!user.Policy.EnableLiveTvManagement)
|
||||||
{
|
{
|
||||||
throw new UnauthorizedAccessException("The current user does not have permission to manage live tv.");
|
throw new SecurityException("The current user does not have permission to manage live tv.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,6 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
|
|
||||||
InsecureApps9 = new[]
|
InsecureApps9 = new[]
|
||||||
{
|
{
|
||||||
"Unknown app",
|
|
||||||
"Windows Phone"
|
"Windows Phone"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -236,11 +236,6 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
file.Attributes |= FileAttributes.Hidden;
|
file.Attributes |= FileAttributes.Hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (UnauthorizedAccessException ex)
|
|
||||||
{
|
|
||||||
_logger.Error("Error saving image to {0}", ex, path);
|
|
||||||
throw new Exception(string.Format("Error saving image to {0}", path), ex);
|
|
||||||
}
|
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_libraryMonitor.ReportFileSystemChangeComplete(path, false);
|
_libraryMonitor.ReportFileSystemChangeComplete(path, false);
|
||||||
|
@ -879,6 +879,11 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
|
|
||||||
private void StartRefreshTimer()
|
private void StartRefreshTimer()
|
||||||
{
|
{
|
||||||
|
if (_disposed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
lock (_refreshTimerLock)
|
lock (_refreshTimerLock)
|
||||||
{
|
{
|
||||||
if (_refreshTimer == null)
|
if (_refreshTimer == null)
|
||||||
@ -1013,6 +1018,7 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
|
StopRefreshTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -196,7 +196,7 @@ namespace MediaBrowser.Providers.Subtitles
|
|||||||
|
|
||||||
if (!(loginResponse is MethodResponseLogIn))
|
if (!(loginResponse is MethodResponseLogIn))
|
||||||
{
|
{
|
||||||
throw new UnauthorizedAccessException("Authentication to OpenSubtitles failed.");
|
throw new Exception("Authentication to OpenSubtitles failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastLogin = DateTime.UtcNow;
|
_lastLogin = DateTime.UtcNow;
|
||||||
|
@ -92,7 +92,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
{typeof (FileNotFoundException), 404},
|
{typeof (FileNotFoundException), 404},
|
||||||
{typeof (DirectoryNotFoundException), 404},
|
{typeof (DirectoryNotFoundException), 404},
|
||||||
{typeof (SecurityException), 401},
|
{typeof (SecurityException), 401},
|
||||||
{typeof (UnauthorizedAccessException), 401}
|
{typeof (UnauthorizedAccessException), 500}
|
||||||
};
|
};
|
||||||
|
|
||||||
HostConfig.Instance.DebugMode = true;
|
HostConfig.Instance.DebugMode = true;
|
||||||
|
@ -611,11 +611,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var recordingEndDate = timer.EndDate.AddSeconds(timer.PostPaddingSeconds);
|
||||||
|
|
||||||
|
if (recordingEndDate <= DateTime.UtcNow)
|
||||||
|
{
|
||||||
|
_logger.Warn("Recording timer fired for timer {0}, Id: {1}, but the program has already ended.", timer.Name, timer.Id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var cancellationTokenSource = new CancellationTokenSource();
|
var cancellationTokenSource = new CancellationTokenSource();
|
||||||
|
|
||||||
if (_activeRecordings.TryAdd(timer.Id, cancellationTokenSource))
|
if (_activeRecordings.TryAdd(timer.Id, cancellationTokenSource))
|
||||||
{
|
{
|
||||||
await RecordStream(timer, cancellationTokenSource.Token).ConfigureAwait(false);
|
await RecordStream(timer, recordingEndDate, cancellationTokenSource.Token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
@ -628,22 +636,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RecordStream(TimerInfo timer, CancellationToken cancellationToken)
|
private async Task RecordStream(TimerInfo timer, DateTime recordingEndDate, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (timer == null)
|
if (timer == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("timer");
|
throw new ArgumentNullException("timer");
|
||||||
}
|
}
|
||||||
|
|
||||||
var mediaStreamInfo = await GetChannelStream(timer.ChannelId, null, CancellationToken.None);
|
|
||||||
var duration = (timer.EndDate - DateTime.UtcNow).Add(TimeSpan.FromSeconds(timer.PostPaddingSeconds));
|
|
||||||
|
|
||||||
HttpRequestOptions httpRequestOptions = new HttpRequestOptions()
|
|
||||||
{
|
|
||||||
Url = mediaStreamInfo.Path
|
|
||||||
};
|
|
||||||
|
|
||||||
var info = GetProgramInfoFromCache(timer.ChannelId, timer.ProgramId);
|
var info = GetProgramInfoFromCache(timer.ChannelId, timer.ProgramId);
|
||||||
|
|
||||||
var recordPath = RecordingPath;
|
var recordPath = RecordingPath;
|
||||||
|
|
||||||
if (info.IsMovie)
|
if (info.IsMovie)
|
||||||
@ -708,6 +709,20 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||||||
_recordingProvider.Add(recording);
|
_recordingProvider.Add(recording);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var mediaStreamInfo = await GetChannelStream(timer.ChannelId, null, CancellationToken.None);
|
||||||
|
|
||||||
|
// HDHR doesn't seem to release the tuner right away after first probing with ffmpeg
|
||||||
|
await Task.Delay(3000, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var duration = recordingEndDate - DateTime.UtcNow;
|
||||||
|
|
||||||
|
HttpRequestOptions httpRequestOptions = new HttpRequestOptions()
|
||||||
|
{
|
||||||
|
Url = mediaStreamInfo.Path
|
||||||
|
};
|
||||||
|
|
||||||
recording.Path = recordPath;
|
recording.Path = recordPath;
|
||||||
recording.Status = RecordingStatus.InProgress;
|
recording.Status = RecordingStatus.InProgress;
|
||||||
recording.DateLastUpdated = DateTime.UtcNow;
|
recording.DateLastUpdated = DateTime.UtcNow;
|
||||||
@ -715,8 +730,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
_logger.Info("Beginning recording.");
|
_logger.Info("Beginning recording.");
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
httpRequestOptions.BufferContent = false;
|
httpRequestOptions.BufferContent = false;
|
||||||
var durationToken = new CancellationTokenSource(duration);
|
var durationToken = new CancellationTokenSource(duration);
|
||||||
var linkedToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
|
var linkedToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
|
||||||
|
@ -29,6 +29,7 @@ using System.Globalization;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Controller.Net;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Session
|
namespace MediaBrowser.Server.Implementations.Session
|
||||||
{
|
{
|
||||||
@ -1276,7 +1277,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||||||
{
|
{
|
||||||
if (!_deviceManager.CanAccessDevice(user.Id.ToString("N"), request.DeviceId))
|
if (!_deviceManager.CanAccessDevice(user.Id.ToString("N"), request.DeviceId))
|
||||||
{
|
{
|
||||||
throw new UnauthorizedAccessException("User is not allowed access from this device.");
|
throw new SecurityException("User is not allowed access from this device.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1286,7 +1287,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||||||
{
|
{
|
||||||
EventHelper.FireEventIfNotNull(AuthenticationFailed, this, new GenericEventArgs<AuthenticationRequest>(request), _logger);
|
EventHelper.FireEventIfNotNull(AuthenticationFailed, this, new GenericEventArgs<AuthenticationRequest>(request), _logger);
|
||||||
|
|
||||||
throw new UnauthorizedAccessException("Invalid user or password entered.");
|
throw new SecurityException("Invalid user or password entered.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var token = await GetAuthorizationToken(user.Id.ToString("N"), request.DeviceId, request.App, request.AppVersion, request.DeviceName).ConfigureAwait(false);
|
var token = await GetAuthorizationToken(user.Id.ToString("N"), request.DeviceId, request.App, request.AppVersion, request.DeviceName).ConfigureAwait(false);
|
||||||
|
@ -9,6 +9,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Controller.Net;
|
||||||
using WebMarkupMin.Core;
|
using WebMarkupMin.Core;
|
||||||
using WebMarkupMin.Core.Minifiers;
|
using WebMarkupMin.Core.Minifiers;
|
||||||
using WebMarkupMin.Core.Settings;
|
using WebMarkupMin.Core.Settings;
|
||||||
@ -136,7 +137,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|||||||
// Don't allow file system access outside of the source folder
|
// Don't allow file system access outside of the source folder
|
||||||
if (!_fileSystem.ContainsSubPath(rootPath, fullPath))
|
if (!_fileSystem.ContainsSubPath(rootPath, fullPath))
|
||||||
{
|
{
|
||||||
throw new UnauthorizedAccessException();
|
throw new SecurityException("Access denied");
|
||||||
}
|
}
|
||||||
|
|
||||||
return fullPath;
|
return fullPath;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user