[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.

------=_NextPart_000_0013_01C2362B.9E9EDC20
Content-Type: text/plain;
	charset="iso-8859-1"
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
[corlib]System.Security.Permissions.FileIOPermissionAttribute::.ctor(valuety
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
[corlib]System.Security.Permissions.EnvironmentPermissionAttribute::.ctor(va
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
[corlib]System.Security.Permissions.RegistryPermissionAttribute::.ctor(value
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,
Regards

Hinne

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.

------=_NextPart_000_0013_01C2362B.9E9EDC20
Content-Type: application/octet-stream;
	name="dst.cs"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="dst.cs"

using System;=0A=
using System.Security.Permissions;=0A=
=0A=
class Hello=0A=
{=0A=
	string m_Datum;=0A=
=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=
	}=0A=
=0A=
	public delegate void EventHandler();=0A=
	[method: FileIOPermission(SecurityAction.Demand, Unrestricted=3Dtrue)]=0A=
	public EventHandler MyEvent;=0A=
=0A=
	public static void Main(string[] args)=0A=
	{=0A=
		Console.WriteLine("mono:: is alive and well");=0A=
	}=0A=
}
------=_NextPart_000_0013_01C2362B.9E9EDC20--