PROFILE = net_1_1
all: pinvoke1.exe pinvoke2.exe pinvoke3.exe \
- sucs1.exe sucs2.exe sucs3.exe sucs4.exe
+ sucs1.exe sucs2.exe sucs3.exe sucs4.exe \
+ selfassert.exe selfdeny.exe selfpermit.exe
aot: pinvoke1.exe.so pinvoke2.exe.so pinvoke3.exe.so \
- sucs1.exe.so sucs2.exe.so sucs3.exe.so sucs4.exe.so
+ sucs1.exe.so sucs2.exe.so sucs3.exe.so sucs4.exe.so \
+ selfassert.exe.so selfdeny.exe.so selfpermit.exe.so
FULLTRUST_TEST_FILES = pinvoke1 pinvoke2 pinvoke3 \
- sucs1 sucs2 sucs3 sucs4
+ sucs1 sucs2 sucs3 sucs4 \
+ selfassert selfdeny selfpermit
UNHANDLED_TEST_FILES =
Notes
- With Mono runtime the native function getuid is called in libc
- With MS runtime the native function GetTickCount is called in kernel32.dll
+
+
+** Self
+
+Stack walk starts at the caller frame - i.e. the current frame is ignored. The
+self*.cs tests ensure that the walk starts at the right frame (or at least
+that it ignore the caller frame).
+
+selfassert.cs Deny on caller, Assert and Demand on callee. Assert is
+ ignored, Demand is executed and fail on caller's Deny.
+selfdeny.cs Deny and Demand on the same frame. Deny is ignored. Demand is
+ executed (stack walk).
+selfpermit.cs PermitOnly Unmanaged, Demand ControlAppDomain. PermitOnly is
+ ignored and Demand (for ControlAppDomain) succeed.
--- /dev/null
+using System;
+using System.Security;
+using System.Security.Permissions;
+
+public class Program {
+
+ [SecurityPermission (SecurityAction.Assert, UnmanagedCode=true)]
+ [SecurityPermission (SecurityAction.Demand, UnmanagedCode=true)]
+ static int Test ()
+ {
+ return 1;
+ }
+
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode=true)]
+ static int Main ()
+ {
+ int result = 2;
+ try {
+ result = Test ();
+ Console.WriteLine ("*1* Unexpected call to Test");
+ }
+ catch (SecurityException se) {
+ result = 0;
+ Console.WriteLine ("*0* Expected SecurityException\n{0}", se);
+ }
+ return result;
+ }
+}
--- /dev/null
+using System;
+using System.Security.Permissions;
+
+public class Program {
+
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode=true)]
+ [SecurityPermission (SecurityAction.Demand, UnmanagedCode=true)]
+ static int Test ()
+ {
+ Console.WriteLine ("*0* Expected call to Test()");
+ return 0;
+ }
+
+ static int Main ()
+ {
+ return Test ();
+ }
+}
--- /dev/null
+using System;
+using System.Security;
+using System.Security.Permissions;
+
+public class Program {
+
+ [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode=true)]
+ [SecurityPermission (SecurityAction.Demand, ControlAppDomain=true)]
+ static int Test ()
+ {
+ Console.WriteLine ("*0* Expected call to Test()");
+ return 0;
+ }
+
+ static int Main ()
+ {
+ return Test ();
+ }
+}