X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fsecurity-core-clr.c;h=43e06db574b9ab524bfb06748b7db29413d6f448;hb=6b2e92f179c0aced16ac5ef737052bffaa5b4a79;hp=1be63ffc2240dbfcce52661320765620449a384d;hpb=566e77925daef452479a197e17b5330bf8daa8a8;p=mono.git diff --git a/mono/metadata/security-core-clr.c b/mono/metadata/security-core-clr.c index 1be63ffc224..43e06db574b 100644 --- a/mono/metadata/security-core-clr.c +++ b/mono/metadata/security-core-clr.c @@ -960,6 +960,40 @@ mono_security_core_clr_class_level (MonoClass *class) return mono_security_core_clr_class_level_no_platform_check (class); } +/* + * mono_security_core_clr_field_level: + * + * Return the MonoSecurityCoreCLRLevel for the specified field. + * If with_class_level is TRUE then the type (class) will also be + * checked, otherwise this will only report the information about + * the field itself. + */ +MonoSecurityCoreCLRLevel +mono_security_core_clr_field_level (MonoClassField *field, gboolean with_class_level) +{ + MonoCustomAttrInfo *cinfo; + MonoSecurityCoreCLRLevel level = MONO_SECURITY_CORE_CLR_TRANSPARENT; + + /* if get_reflection_caller returns NULL then we assume the caller has NO privilege */ + if (!field) + return level; + + /* non-platform code is always Transparent - whatever the attributes says */ + if (!mono_security_core_clr_test && !mono_security_core_clr_is_platform_image (field->parent->image)) + return level; + + cinfo = mono_custom_attrs_from_field (field->parent, field); + if (cinfo) { + level = mono_security_core_clr_level_from_cinfo (cinfo, field->parent->image); + mono_custom_attrs_free (cinfo); + } + + if (with_class_level && level == MONO_SECURITY_CORE_CLR_TRANSPARENT) + level = mono_security_core_clr_class_level (field->parent); + + return level; +} + /* * mono_security_core_clr_method_level: * @@ -1070,6 +1104,12 @@ mono_security_core_clr_class_level (MonoClass *class) return MONO_SECURITY_CORE_CLR_TRANSPARENT; } +MonoSecurityCoreCLRLevel +mono_security_core_clr_field_level (MonoClassField *field, gboolean with_class_level) +{ + return MONO_SECURITY_CORE_CLR_TRANSPARENT; +} + MonoSecurityCoreCLRLevel mono_security_core_clr_method_level (MonoMethod *method, gboolean with_class_level) {