Change Permission to Parameter
This commit is contained in:
parent
4fcbb143dd
commit
2897a29400
4 changed files with 20 additions and 22 deletions
|
@ -8,8 +8,8 @@ using System.Text;
|
|||
|
||||
namespace Ryujinx.HLE.HOS.Services.Bsd
|
||||
{
|
||||
[Service("bsd:s", true, (int)BsdServicePermissionLevel.System)]
|
||||
[Service("bsd:u", true, (int)BsdServicePermissionLevel.User)]
|
||||
[Service("bsd:s", true)]
|
||||
[Service("bsd:u", false)]
|
||||
class IClient : IpcService
|
||||
{
|
||||
private static Dictionary<WsaError, LinuxError> _errorMap = new Dictionary<WsaError, LinuxError>
|
||||
|
@ -96,7 +96,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
|
|||
{0, 0}
|
||||
};
|
||||
|
||||
private BsdServicePermissionLevel _permissionLevel;
|
||||
private bool _isPrivileged;
|
||||
|
||||
private List<BsdSocket> _sockets = new List<BsdSocket>();
|
||||
|
||||
|
@ -104,7 +104,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
|
|||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
public IClient(ServiceCtx context, int permission)
|
||||
public IClient(ServiceCtx context, bool isPrivileged)
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
|
|||
{ 27, DuplicateSocket }
|
||||
};
|
||||
|
||||
_permissionLevel = (BsdServicePermissionLevel)permission;
|
||||
_isPrivileged = isPrivileged;
|
||||
}
|
||||
|
||||
private LinuxError ConvertError(WsaError errorCode)
|
||||
|
@ -207,7 +207,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
|
|||
{
|
||||
return WriteBsdResult(context, -1, LinuxError.EPROTONOSUPPORT);
|
||||
}
|
||||
else if ((type == SocketType.Seqpacket || type == SocketType.Raw) && _permissionLevel == BsdServicePermissionLevel.User)
|
||||
else if ((type == SocketType.Seqpacket || type == SocketType.Raw) && !_isPrivileged)
|
||||
{
|
||||
if (domain != AddressFamily.InterNetwork || type != SocketType.Raw || protocol != ProtocolType.Icmp)
|
||||
{
|
||||
|
@ -1173,7 +1173,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
|
|||
LinuxError errno = LinuxError.ENOENT;
|
||||
int newSockFd = -1;
|
||||
|
||||
if (_permissionLevel == BsdServicePermissionLevel.System)
|
||||
if (_isPrivileged)
|
||||
{
|
||||
errno = LinuxError.EBADF;
|
||||
|
||||
|
|
|
@ -7,11 +7,11 @@ using static Ryujinx.HLE.HOS.ErrorCode;
|
|||
|
||||
namespace Ryujinx.HLE.HOS.Services.Friend
|
||||
{
|
||||
[Service("friend:a", true, (int)FriendServicePermissionLevel.Admin)]
|
||||
[Service("friend:m", true, (int)FriendServicePermissionLevel.Manager)]
|
||||
[Service("friend:s", true, (int)FriendServicePermissionLevel.System)]
|
||||
[Service("friend:u", true, (int)FriendServicePermissionLevel.User)]
|
||||
[Service("friend:v", true, (int)FriendServicePermissionLevel.Overlay)]
|
||||
[Service("friend:a", FriendServicePermissionLevel.Admin)]
|
||||
[Service("friend:m", FriendServicePermissionLevel.Manager)]
|
||||
[Service("friend:s", FriendServicePermissionLevel.System)]
|
||||
[Service("friend:u", FriendServicePermissionLevel.User)]
|
||||
[Service("friend:v", FriendServicePermissionLevel.Overlay)]
|
||||
class IServiceCreator : IpcService
|
||||
{
|
||||
private FriendServicePermissionLevel _permissionLevel;
|
||||
|
@ -20,7 +20,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
|
|||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
public IServiceCreator(ServiceCtx context, int permission)
|
||||
public IServiceCreator(ServiceCtx context, FriendServicePermissionLevel permissionLevel)
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
|
|||
{ 2, CreateDaemonSuspendSessionService }, // 4.0.0+
|
||||
};
|
||||
|
||||
_permissionLevel = (FriendServicePermissionLevel)permission;
|
||||
_permissionLevel = permissionLevel;
|
||||
}
|
||||
|
||||
// CreateFriendService() -> object<nn::friends::detail::ipc::IFriendService>
|
||||
|
|
|
@ -6,14 +6,12 @@ namespace Ryujinx.HLE.HOS.Services
|
|||
public class ServiceAttribute : Attribute
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly bool UsePermission;
|
||||
public readonly int Permission;
|
||||
public readonly object Parameter;
|
||||
|
||||
public ServiceAttribute(string name, bool usePermission = false, int permission = 0)
|
||||
public ServiceAttribute(string name, object parameter = null)
|
||||
{
|
||||
Name = name;
|
||||
UsePermission = usePermission;
|
||||
Permission = permission;
|
||||
Name = name;
|
||||
Parameter = parameter;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -90,8 +90,8 @@ namespace Ryujinx.HLE.HOS.Services.Sm
|
|||
{
|
||||
ServiceAttribute serviceAttribute = (ServiceAttribute)type.GetCustomAttributes().First(service => ((ServiceAttribute)service).Name == name);
|
||||
|
||||
session.ClientSession.Service = serviceAttribute.UsePermission ? (IpcService)Activator.CreateInstance(type, context, serviceAttribute.Permission)
|
||||
: (IpcService)Activator.CreateInstance(type, context);
|
||||
session.ClientSession.Service = serviceAttribute.Parameter != null ? (IpcService)Activator.CreateInstance(type, context, serviceAttribute.Parameter)
|
||||
: (IpcService)Activator.CreateInstance(type, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue