3 using System.Security.Permissions;
4 using System.Threading;
8 static void ShowStackTrace (object o)
11 Console.WriteLine ((int)o);
14 Console.WriteLine (Environment.UserName);
17 catch (SecurityException se) {
18 Console.WriteLine ("UNEXPECTED SecurityException {0}", se);
21 catch (Exception ex) {
22 Console.WriteLine ("UNEXPECTED {0}", ex);
28 static int result = 0;
30 // this Deny will *NOT* prevent the Environment.UserName property from working
31 // as the UnsafeQueueUserWorkItem method *DOESN'T* propagate the stack
32 [EnvironmentPermission (SecurityAction.Deny, Read = "USERNAME")]
33 static int Main (string[] args)
35 debug = (args.Length > 0);
37 SecurityManager.SecurityEnabled = (args [0] != "off");
40 if (SecurityManager.SecurityEnabled) {
41 Console.WriteLine ("SecurityManager.SecurityEnabled: true");
42 ShowStackTrace ((object)-1);
44 Console.WriteLine ("SecurityManager.SecurityEnabled: false");
48 for (int i=0; i < 5; i++)
49 ThreadPool.UnsafeQueueUserWorkItem (new WaitCallback (ShowStackTrace), i);
51 System.Threading.Thread.Sleep (5000);