Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Pouliot <sebastien@ximian.com>2004-12-21 19:25:28 +0300
committerSebastien Pouliot <sebastien@ximian.com>2004-12-21 19:25:28 +0300
commit7e2562313364d8e7fc84152e7752417ed394099b (patch)
treead4a6e5b13f480337af8615b970fa0c443f5c2b0 /mcs/tools/security
parent35cfe26d5950a6dad85e9a904a5cba2e61ba1c7e (diff)
2004-12-21 Sebastien Pouliot <sebastien@ximian.com>
* Makefile: Added permview to the build. * permview.cs: Fixed option /OUTPUT to close the TextWriter so that the output is available (in the file) after execution. The default execution (without /DECL) works with a *very* recent Mono runtime. svn path=/trunk/mcs/; revision=38032
Diffstat (limited to 'mcs/tools/security')
-rw-r--r--mcs/tools/security/ChangeLog7
-rw-r--r--mcs/tools/security/Makefile2
-rw-r--r--mcs/tools/security/permview.cs38
3 files changed, 28 insertions, 19 deletions
diff --git a/mcs/tools/security/ChangeLog b/mcs/tools/security/ChangeLog
index 68394b1672c..f09bf2d5d19 100644
--- a/mcs/tools/security/ChangeLog
+++ b/mcs/tools/security/ChangeLog
@@ -1,3 +1,10 @@
+2004-12-21 Sebastien Pouliot <sebastien@ximian.com>
+
+ * Makefile: Added permview to the build.
+ * permview.cs: Fixed option /OUTPUT to close the TextWriter so that
+ the output is available (in the file) after execution. The default
+ execution (without /DECL) works with a *very* recent Mono runtime.
+
2004-12-17 Sebastien Pouliot <sebastien@ximian.com>
* permview.cs: New. Managed declarative security permission viewer for
diff --git a/mcs/tools/security/Makefile b/mcs/tools/security/Makefile
index 1d4cacaa98c..4e8e422b75d 100644
--- a/mcs/tools/security/Makefile
+++ b/mcs/tools/security/Makefile
@@ -5,7 +5,7 @@ include ../../build/rules.make
LOCAL_MCS_FLAGS = /lib:$(topdir)/class/lib/$(PROFILE) /r:Mono.Security.dll
-SECURITY_PROGRAMS = secutil.exe cert2spc.exe sn.exe MakeCert.exe chktrust.exe signcode.exe setreg.exe certmgr.exe caspol.exe
+SECURITY_PROGRAMS = secutil.exe cert2spc.exe sn.exe MakeCert.exe chktrust.exe signcode.exe setreg.exe certmgr.exe caspol.exe permview.exe
SECURITY_SOURCES = AssemblyInfo.cs StrongNameManager.cs $(SECURITY_PROGRAMS:.exe=.cs)
PROGRAM_INSTALL_DIR = $(prefix)/lib/mono/$(FRAMEWORK_VERSION)
diff --git a/mcs/tools/security/permview.cs b/mcs/tools/security/permview.cs
index 2d3341f9646..bd727128abf 100644
--- a/mcs/tools/security/permview.cs
+++ b/mcs/tools/security/permview.cs
@@ -52,27 +52,30 @@ namespace Mono.Tools {
tw.WriteLine ();
}
+ static PermissionSet GetPermissionSet (Assembly a, string name)
+ {
+ FieldInfo fi = typeof (Assembly).GetField (name, BindingFlags.Instance | BindingFlags.NonPublic);
+ if (fi == null)
+ throw new NotSupportedException ("Wrong runtime ?");
+ return (PermissionSet) fi.GetValue (a);
+ }
+
static bool ProcessAssemblyOnly (TextWriter tw, Assembly a)
{
Type t = typeof (Assembly);
- FieldInfo fi = t.GetField ("_minimum", BindingFlags.Instance | BindingFlags.NonPublic);
- if (fi == null)
- return false;
- PermissionSet ps = (PermissionSet) fi.GetValue (a);
- ShowPermissionSet (tw, "Minimal Permission Set:", ps);
-
- fi = t.GetField ("_optional", BindingFlags.Instance | BindingFlags.NonPublic);
- if (fi == null)
+ // Minimum, Optional and Refuse permission set are only evaluated
+ // on demand (delayed as much as possible). A call Resolve will
+ // trigger their retrieval from the assembly metadata
+ MethodInfo resolve = t.GetMethod ("Resolve", BindingFlags.Instance | BindingFlags.NonPublic);
+ if (resolve == null)
return false;
- ps = (PermissionSet) fi.GetValue (a);
- ShowPermissionSet (tw, "Optional Permission Set:", ps);
+ resolve.Invoke (a, null);
+
+ ShowPermissionSet (tw, "Minimal Permission Set:", GetPermissionSet (a, "_minimum"));
+ ShowPermissionSet (tw, "Optional Permission Set:", GetPermissionSet (a, "_optional"));
+ ShowPermissionSet (tw, "Refused Permission Set:", GetPermissionSet (a, "_refuse"));
- fi = t.GetField ("_refuse", BindingFlags.Instance | BindingFlags.NonPublic);
- if (fi == null)
- return false;
- ps = (PermissionSet) fi.GetValue (a);
- ShowPermissionSet (tw, "Refused Permission Set:", ps);
return true;
}
@@ -200,8 +203,6 @@ namespace Mono.Tools {
[STAThread]
static int Main (string[] args)
{
- int result = 1;
-
try {
Console.WriteLine (new AssemblyInfo ().ToString ());
if (args.Length == 0) {
@@ -227,12 +228,13 @@ namespace Mono.Tools {
Console.Error.WriteLine ("Couldn't load assembly '{0}'.", assemblyName);
return 2;
}
+ tw.Close ();
}
catch (Exception e) {
Console.Error.WriteLine ("Error: " + e.ToString ());
Help ();
}
- return result;
+ return 0;
}
}
}