[Mono-list] Declarative security issues

Hinne Hettema h.hettema@auckland.ac.nz
Sun, 28 Jul 2002 11:40:49 +1200

This is a multi-part message in MIME format.

Content-Type: text/plain;
Content-Transfer-Encoding: 7bit

Hi all

I've 'discovered' that mcs seems to compile the declarative security options
into custom attributes. I'm wondering if this is intended behaviour or a
bug? I have a 'linux only' setup and cannot compile this under Windows with
csc, the idea would be to do this and see where the declsecurity structures
end up in the metadata (to smoke out possible bugs in the cs code itself.).

The behaviour is easily seen by compiling the attached code with mcs and
then running

monodis --customattr dst.exe

All the declsecurity commands show up as custom attributes:

Custom Attributes Table (1..3)
1: FieldDef: 2: instance void class
pe [corlib]System.Security.Permissions.SecurityAction) [2 1 named args: ( 01
00 54 0C 55 6E 72 65 73 74 72 69 63 74 65 64 01)]
2: MethodDef: 3: instance void class
luetype [corlib]System.Security.Permissions.SecurityAction) [2 1 named args:
( 01 00 54 0C 55 6E 72 65 73 74 72 69 63 74 65 64 01)]
3: MethodDef: 4: instance void class
type [corlib]System.Security.Permissions.SecurityAction) [2 1 named args:
( 01 00 54 0C 55 6E 72 65 73 74 72 69 63 74 65 64 01)]

Can someone enlighten me here? Thanks,


PS: I 'discovered' this while attempting to extend monodis (dump.c) to show
the declarative security, and my test code showed the tables up
empty--that's when I tried the --customattr trick. I pretty much got the
test code from the .NET Framework Security tome. I know the handling of the
declsecurity is not yet complete, but I sort of expected mcs to compile the
file 'correctly'. If someone can try this on Windows and tell me the result
that'd be nice.

Content-Type: application/octet-stream;
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;

using System;=0A=
using System.Security.Permissions;=0A=
class Hello=0A=
	string m_Datum;=0A=
	string MyProperty {=0A=
		[EnvironmentPermission(SecurityAction.Demand, Unrestricted=3Dtrue)]=0A=
		get { return m_Datum; }=0A=
		[RegistryPermission(SecurityAction.Demand, Unrestricted =3D true)]=0A=
		set {m_Datum =3D value; }=0A=
	public delegate void EventHandler();=0A=
	[method: FileIOPermission(SecurityAction.Demand, Unrestricted=3Dtrue)]=0A=
	public EventHandler MyEvent;=0A=
	public static void Main(string[] args)=0A=
		Console.WriteLine("mono:: is alive and well");=0A=