Author: spouliot
Date: 2005-03-24 08:33:17 -0500 (Thu, 24 Mar 2005)
New Revision: 42207

Modified:
   trunk/mcs/class/corlib/System/Activator.cs
   trunk/mcs/class/corlib/System/ChangeLog
   trunk/mcs/class/corlib/System/Console.cs
   trunk/mcs/class/corlib/System/MarshalByRefObject.cs
   trunk/mcs/class/corlib/System/RuntimeMethodHandle.cs
   trunk/mcs/class/corlib/System/TypedReference.cs
Log:
2005-03-24  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * Activator.cs: Now use the supplied evidences when loading 
        assemblies. Added LinkDemand for RemotingConfiguration on both
        GetObject methods.
        * Console.cs: Added Assert for UnmanagedCode on OpenStandard[Error|
        Input|Output] as they use a handle on a FileStream (which is
        restricted otherwise). Added Demand for UnmanagedCode for the
        Set[Error|In|Out] methods.
        * MarshalByRefObject.cs: Added LinkDemand for Infrastructure on 
        CreateObjRef, GetLifetimeService and InitializeLifetimeService.
        * RuntimeMethodHandle.cs: Added Demand for UnmanagedCode on 
        GetFunctionPointer method.
        * TypedReference.cs: Added LinkDemand for ReflectionPermission's
        MemberAccess on MakeTypedReference.



Modified: trunk/mcs/class/corlib/System/Activator.cs
===================================================================
--- trunk/mcs/class/corlib/System/Activator.cs  2005-03-24 13:19:07 UTC (rev 
42206)
+++ trunk/mcs/class/corlib/System/Activator.cs  2005-03-24 13:33:17 UTC (rev 
42207)
@@ -7,11 +7,8 @@
 //
 // (C) 2001 Nick Drochak II
 // (c) 2002 Ximian, Inc. (http://www.ximian.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // "Software"), to deal in the Software without restriction, including
@@ -37,6 +34,7 @@
 using System.Runtime.Remoting;
 using System.Runtime.Remoting.Activation;
 using System.Runtime.CompilerServices;
+using System.Security.Permissions;
 using System.Security.Policy;
 using System.Configuration.Assemblies;
 
@@ -91,15 +89,12 @@
                                activationAttributes, null);
                }
 
-               [MonoTODO ("security")]
                public static ObjectHandle CreateInstanceFrom (string 
assemblyFile, string typeName, bool ignoreCase,
                                                               BindingFlags 
bindingAttr, Binder binder, object [] args,
                                                               CultureInfo 
culture, object [] activationAttributes,
                                                               Evidence 
securityInfo)
                {
-                       //TODO: when Assembly implements security, use it.
-                       //Assembly assembly = Assembly.LoadFrom (assemblyFile, 
securityInfo);
-                       Assembly assembly = Assembly.LoadFrom (assemblyFile);
+                       Assembly assembly = Assembly.LoadFrom (assemblyFile, 
securityInfo);
                        if (assembly == null)
                                return null;
 
@@ -128,18 +123,15 @@
                                activationAttributes, null);
                }
 
-               [MonoTODO ("security")]
                public static ObjectHandle CreateInstance (string assemblyName, 
string typeName, bool ignoreCase,
                                                           BindingFlags 
bindingAttr, Binder binder, object [] args,
                                                           CultureInfo culture, 
object [] activationAttributes, Evidence securityInfo)
                {
-                       //TODO: when Assembly implements security, use it.
-                       //Assembly assembly = Assembly.Load (assemblyFile, 
securityInfo);
                        Assembly assembly = null;
                        if(assemblyName == null)
                                assembly = Assembly.GetCallingAssembly ();
                        else
-                               assembly = Assembly.Load (assemblyName);
+                               assembly = Assembly.Load (assemblyName, 
securityInfo);
                        Type type = assembly.GetType (typeName, true, 
ignoreCase);
                        object obj = CreateInstance (type, bindingAttr, binder, 
args, culture, activationAttributes);
                        return (obj != null) ? new ObjectHandle (obj) : null;
@@ -267,11 +259,13 @@
                        return ctor.Invoke (null);
                }
 
+               [SecurityPermission (SecurityAction.LinkDemand, 
RemotingConfiguration = true)]
                public static object GetObject (Type type, string url)
                {
                        return RemotingServices.Connect (type, url);
                }
 
+               [SecurityPermission (SecurityAction.LinkDemand, 
RemotingConfiguration = true)]
                public static object GetObject (Type type, string url, object 
state)
                {
                        return RemotingServices.Connect (type, url, state);

Modified: trunk/mcs/class/corlib/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System/ChangeLog     2005-03-24 13:19:07 UTC (rev 
42206)
+++ trunk/mcs/class/corlib/System/ChangeLog     2005-03-24 13:33:17 UTC (rev 
42207)
@@ -1,3 +1,19 @@
+2005-03-24  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * Activator.cs: Now use the supplied evidences when loading 
+       assemblies. Added LinkDemand for RemotingConfiguration on both
+       GetObject methods.
+       * Console.cs: Added Assert for UnmanagedCode on OpenStandard[Error|
+       Input|Output] as they use a handle on a FileStream (which is
+       restricted otherwise). Added Demand for UnmanagedCode for the
+       Set[Error|In|Out] methods.
+       * MarshalByRefObject.cs: Added LinkDemand for Infrastructure on 
+       CreateObjRef, GetLifetimeService and InitializeLifetimeService.
+       * RuntimeMethodHandle.cs: Added Demand for UnmanagedCode on 
+       GetFunctionPointer method.
+       * TypedReference.cs: Added LinkDemand for ReflectionPermission's
+       MemberAccess on MakeTypedReference.
+
 2005-03-14  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * Environment.cs: Fix CAS unit tests for NET_1_1.

Modified: trunk/mcs/class/corlib/System/Console.cs
===================================================================
--- trunk/mcs/class/corlib/System/Console.cs    2005-03-24 13:19:07 UTC (rev 
42206)
+++ trunk/mcs/class/corlib/System/Console.cs    2005-03-24 13:33:17 UTC (rev 
42207)
@@ -30,6 +30,7 @@
 //
 
 using System.IO;
+using System.Security.Permissions;
 using System.Text;
 
 namespace System
@@ -109,6 +110,11 @@
                        return OpenStandardError (0);
                }
 
+               // calling any FileStream constructor with an handle normally
+               // requires permissions UnmanagedCode permissions. In this 
+               // case we assert this permission so the console can be used
+               // in partial trust (i.e. without having UnmanagedCode).
+               [SecurityPermission (SecurityAction.Assert, UnmanagedCode = 
true)]
                public static Stream OpenStandardError (int bufferSize)
                {
                        try {
@@ -123,6 +129,11 @@
                        return OpenStandardInput (0);
                }
 
+               // calling any FileStream constructor with an handle normally
+               // requires permissions UnmanagedCode permissions. In this 
+               // case we assert this permission so the console can be used
+               // in partial trust (i.e. without having UnmanagedCode).
+               [SecurityPermission (SecurityAction.Assert, UnmanagedCode = 
true)]
                public static Stream OpenStandardInput (int bufferSize)
                {
                        try {
@@ -137,6 +148,11 @@
                        return OpenStandardOutput (0);
                }
 
+               // calling any FileStream constructor with an handle normally
+               // requires permissions UnmanagedCode permissions. In this 
+               // case we assert this permission so the console can be used
+               // in partial trust (i.e. without having UnmanagedCode).
+               [SecurityPermission (SecurityAction.Assert, UnmanagedCode = 
true)]
                public static Stream OpenStandardOutput (int bufferSize)
                {
                        try {
@@ -146,6 +162,7 @@
                        }
                }
 
+               [SecurityPermission (SecurityAction.Demand, UnmanagedCode = 
true)]
                public static void SetError (TextWriter newError)
                {
                        if (newError == null)
@@ -154,6 +171,7 @@
                        stderr = newError;
                }
 
+               [SecurityPermission (SecurityAction.Demand, UnmanagedCode = 
true)]
                public static void SetIn (TextReader newIn)
                {
                        if (newIn == null)
@@ -162,6 +180,7 @@
                        stdin = newIn;
                }
 
+               [SecurityPermission (SecurityAction.Demand, UnmanagedCode = 
true)]
                public static void SetOut (TextWriter newOut)
                {
                        if (newOut == null)

Modified: trunk/mcs/class/corlib/System/MarshalByRefObject.cs
===================================================================
--- trunk/mcs/class/corlib/System/MarshalByRefObject.cs 2005-03-24 13:19:07 UTC 
(rev 42206)
+++ trunk/mcs/class/corlib/System/MarshalByRefObject.cs 2005-03-24 13:33:17 UTC 
(rev 42207)
@@ -7,11 +7,8 @@
 //   Patrik Torstensson ([EMAIL PROTECTED])
 //
 // (C) Ximian, Inc.  http://www.ximian.com
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // "Software"), to deal in the Software without restriction, including
@@ -34,6 +31,7 @@
 
 using System.Threading;
 using System.Runtime.Remoting;
+using System.Security.Permissions;
 
 namespace System
 {
@@ -68,6 +66,7 @@
                        set { _identity = value; }
                }
 
+               [SecurityPermission (SecurityAction.LinkDemand, Infrastructure 
= true)]
                public virtual ObjRef CreateObjRef (Type type)
                {
                        // This method can only be called when this object has 
been marshalled
@@ -76,6 +75,7 @@
                        return _identity.CreateObjRef (type);
                }
 
+               [SecurityPermission (SecurityAction.LinkDemand, Infrastructure 
= true)]
                public object GetLifetimeService ()
                {
                        if (_identity == null)
@@ -83,6 +83,7 @@
                        else return _identity.Lease;
                }
 
+               [SecurityPermission (SecurityAction.LinkDemand, Infrastructure 
= true)]
                public virtual object InitializeLifetimeService ()
                {
                        return new System.Runtime.Remoting.Lifetime.Lease();

Modified: trunk/mcs/class/corlib/System/RuntimeMethodHandle.cs
===================================================================
--- trunk/mcs/class/corlib/System/RuntimeMethodHandle.cs        2005-03-24 
13:19:07 UTC (rev 42206)
+++ trunk/mcs/class/corlib/System/RuntimeMethodHandle.cs        2005-03-24 
13:33:17 UTC (rev 42207)
@@ -6,11 +6,8 @@
 //   Andreas Nahr ([EMAIL PROTECTED])
 //
 // (C) Ximian, Inc.  http://www.ximian.com
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // "Software"), to deal in the Software without restriction, including
@@ -34,6 +31,7 @@
 using System.Reflection;
 using System.Runtime.Serialization;
 using System.Runtime.CompilerServices;
+using System.Security.Permissions;
 
 namespace System
 {
@@ -77,12 +75,12 @@
                [MethodImpl (MethodImplOptions.InternalCall)]
                static extern IntPtr GetFunctionPointer (IntPtr m);
 
+               [SecurityPermission (SecurityAction.Demand, UnmanagedCode = 
true)]
                public IntPtr GetFunctionPointer ()
                {
                        return GetFunctionPointer (value);
                }
 
-
                public override bool Equals (object obj)
                {
                        if (obj == null || GetType () != obj.GetType ())

Modified: trunk/mcs/class/corlib/System/TypedReference.cs
===================================================================
--- trunk/mcs/class/corlib/System/TypedReference.cs     2005-03-24 13:19:07 UTC 
(rev 42206)
+++ trunk/mcs/class/corlib/System/TypedReference.cs     2005-03-24 13:33:17 UTC 
(rev 42207)
@@ -6,11 +6,8 @@
 //   Paolo Molaro ([EMAIL PROTECTED])
 //
 // (C) Ximian, Inc.  http://www.ximian.com
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // "Software"), to deal in the Software without restriction, including
@@ -33,6 +30,7 @@
 
 using System.Reflection;
 using System.Runtime.CompilerServices;
+using System.Security.Permissions;
 
 namespace System 
 {
@@ -62,6 +60,7 @@
 
                [MonoTODO]
                [CLSCompliant (false)]
+               [ReflectionPermission (SecurityAction.LinkDemand, MemberAccess 
= true)]
                public static TypedReference MakeTypedReference (object target, 
FieldInfo[] flds) 
                {
                        if (target == null) {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to