lucene-lucene-net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simone Chiaretta (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENENET-357) Lucene.Net in Medium Trust (Mostly won't work on shared hosts / Mosso cloud etc due to 'Trust' levels)
Date Fri, 07 May 2010 08:06:49 GMT

    [ https://issues.apache.org/jira/browse/LUCENENET-357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12865069#action_12865069
] 

Simone Chiaretta commented on LUCENENET-357:
--------------------------------------------

I saw the LOCK_DIR has already been removed in the trunk. but the problem with System.Environment.GetEnvironmentVariable
still exists.
Not really sure how a possible approach could be

		/// <summary>The value of <tt>System.getProperty("os.name")</tt>. *</summary>
		public static readonly System.String OS_NAME = System.Environment.GetEnvironmentVariable("OS")
?? "Linux";
		/// <summary>True iff running on Linux. </summary>
		public static readonly bool LINUX = OS_NAME.StartsWith("Linux");
		/// <summary>True iff running on Windows. </summary>
		public static readonly bool WINDOWS = OS_NAME.StartsWith("Windows");
		/// <summary>True iff running on SunOS. </summary>
		public static readonly bool SUN_OS = OS_NAME.StartsWith("SunOS");
		
		public static readonly System.String OS_ARCH = System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
		public static readonly System.String OS_VERSION = System.Environment.OSVersion.ToString();
		public static readonly System.String JAVA_VENDOR = SupportClass.AppSettings.Get("java.vendor",
"");

OS_ARCH and OS_VERSION  are used only for logging the config of the machine in the error message...
I think these can be removed

OS_NAME is only used indirectly with the WINDOWS flag in these two points in the code:

		public static FSDirectory Open(System.IO.DirectoryInfo path, LockFactory lockFactory)
		{
			/* For testing:
			MMapDirectory dir=new MMapDirectory(path, lockFactory);
			dir.setUseUnmap(true);
			return dir;
			*/
			
			if (Constants.WINDOWS)
			{
				return new SimpleFSDirectory(path, lockFactory);
			}
			else
			{
                //NIOFSDirectory is not implemented in Lucene.Net
				//return new NIOFSDirectory(path, lockFactory);
                return new SimpleFSDirectory(path, lockFactory);
			}
        }

Which in both branches does the exact same thing

and in 

		static IndexWriter()
		{
			DEFAULT_MERGE_FACTOR = LogMergePolicy.DEFAULT_MERGE_FACTOR;
			DEFAULT_MAX_MERGE_DOCS = LogDocMergePolicy.DEFAULT_MAX_MERGE_DOCS;
			MAX_TERM_LENGTH = DocumentsWriter.MAX_TERM_LENGTH;
			{
				if (Constants.WINDOWS)
					DEFAULT_MAX_SYNC_PAUSE_SECONDS = 10.0;
				else
					DEFAULT_MAX_SYNC_PAUSE_SECONDS = 0.0;
			}
		}

I've no idea of why windows and other OSes might have different defaults...

So, just putting
public static readonly System.String OS_NAME = "Windows";
public static readonly System.String OS_ARCH = "x86";
public static readonly System.String OS_VERSION = String.Empty;

in the Constants.cs file will fix the problem with the only side effect of always forcing
DEFAULT_MAX_SYNC_PAUSE_SECONDS = 10.0;

Simo

> Lucene.Net in Medium Trust (Mostly won't work on shared hosts / Mosso cloud etc due to
'Trust' levels)
> ------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENENET-357
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-357
>             Project: Lucene.Net
>          Issue Type: Bug
>         Environment: .NET 3.5 / Medium or Medium modified trust
>            Reporter: Frank West
>         Attachments: WeakKey.diff
>
>
> Initially I had to remove a few references to the Sys Environment to get it to work.
However now it fails use of the 'Weak Hashtable' - any reference to a 'weak[something]' will
fail with a security exception. The issue only happens when returning sorted results.
> As an example here's the web.config modified trust file I'm being forced to use on Mosso
(Rackspace cloud)
> <configuration>
>   <mscorlib>
>     <security>
>       <policy>
>         <PolicyLevel version="1">
>           <SecurityClasses>
>             <SecurityClass Name="AllMembershipCondition" Description="System.Security.Policy.AllMembershipCondition,
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="AspNetHostingPermission" Description="System.Web.AspNetHostingPermission,
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="ConfigurationPermission" Description="System.Configuration.ConfigurationPermission,
System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
>             <SecurityClass Name="DnsPermission" Description="System.Net.DnsPermission,
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="EnvironmentPermission" Description="System.Security.Permissions.EnvironmentPermission,
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="FileIOPermission" Description="System.Security.Permissions.FileIOPermission,
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="FirstMatchCodeGroup" Description="System.Security.Policy.FirstMatchCodeGroup,
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="IsolatedStorageFilePermission" Description="System.Security.Permissions.IsolatedStorageFilePermission,
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="NamedPermissionSet" Description="System.Security.NamedPermissionSet"/>
>             <SecurityClass Name="PrintingPermission" Description="System.Drawing.Printing.PrintingPermission,
System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
>             <SecurityClass Name="SecurityPermission" Description="System.Security.Permissions.SecurityPermission,
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="SmtpPermission" Description="System.Net.Mail.SmtpPermission,
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="SqlClientPermission" Description="System.Data.SqlClient.SqlClientPermission,
System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="StrongNameMembershipCondition" Description="System.Security.Policy.StrongNameMembershipCondition,
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="UIPermission" Description="System.Security.Permissions.UIPermission,
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="UnionCodeGroup" Description="System.Security.Policy.UnionCodeGroup,
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="UrlMembershipCondition" Description="System.Security.Policy.UrlMembershipCondition,
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="WebPermission" Description="System.Net.WebPermission,
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="ZoneMembershipCondition" Description="System.Security.Policy.ZoneMembershipCondition,
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="ReflectionPermission" Description="System.Security.Permissions.ReflectionPermission,
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="OleDbPermission" Description="System.Data.OleDb.OleDbPermission,
System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="OdbcPermission" Description="System.Data.Odbc.OdbcPermission,
System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>             <SecurityClass Name="SocketPermission" Description="System.Net.SocketPermission,
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
>           </SecurityClasses>
>           <NamedPermissionSets>
>             <PermissionSet class="NamedPermissionSet" version="1" Unrestricted="true"
Name="FullTrust" Description="Allows full access to all resources"/>
>             <PermissionSet class="NamedPermissionSet" version="1" Name="Nothing" Description="Denies
all resources, including the right to execute"/>
>             <PermissionSet class="NamedPermissionSet" version="1" Name="ASP.Net">
>               <IPermission class="AspNetHostingPermission" version="1" Level="Medium"/>
>               <IPermission class="ConfigurationPermission" version="1" Unrestricted="true"/>
>               <IPermission class="DnsPermission" version="1" Unrestricted="true"/>
>               <IPermission class="EnvironmentPermission" version="1" Read="TEMP;TMP;USERNAME;OS;COMPUTERNAME"/>
>               <IPermission class="FileIOPermission" version="1" Read="$AppDir$" Write="$AppDir$"
Append="$AppDir$" PathDiscovery="$AppDir$"/>
>               <IPermission class="IsolatedStorageFilePermission" version="1" Allowed="AssemblyIsolationByUser"
UserQuota="9223372036854775807"/>
>               <!-- <IPermission class="PrintingPermission" version="1" Level="DefaultPrinting"/>
-->
>               <IPermission class="SecurityPermission" version="1" Flags="Assertion,
Execution, ControlThread, ControlPrincipal, RemotingConfiguration"/>
>               <IPermission class="SmtpPermission" version="1" Access="ConnectToUnrestrictedPort"/>
>               <IPermission class="SqlClientPermission" version="1" Unrestricted="true"/>
>               <IPermission class="WebPermission" version="1" Unrestricted="true"/>
>               <IPermission class="OleDbPermission" version="1" Unrestricted="true"/>
>               <IPermission class="OdbcPermission" version="1" Unrestricted="true"/>
>               <IPermission class="SocketPermission" version="1" Unrestricted="true"
/>
>               <IPermission class="ReflectionPermission" version="1" Unrestricted="true"/>
>             </PermissionSet>
>           </NamedPermissionSets>
>           <CodeGroup class="FirstMatchCodeGroup" version="1" PermissionSetName="Nothing">
>             <IMembershipCondition class="AllMembershipCondition" version="1"/>
>             <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="ASP.Net">
>               <IMembershipCondition class="UrlMembershipCondition" version="1" Url="$AppDirUrl$/*"/>
>             </CodeGroup>
>             <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="ASP.Net">
>               <IMembershipCondition class="UrlMembershipCondition" version="1" Url="$CodeGen$/*"/>
>             </CodeGroup>
>             <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="Nothing">
>               <IMembershipCondition class="ZoneMembershipCondition" version="1" Zone="MyComputer"/>
>               <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust"
Name="Microsoft_Strong_Name" Description="This code group grants code signed with the Microsoft
strong name full trust. ">
>                 <IMembershipCondition class="StrongNameMembershipCondition" version="1"
PublicKeyBlob="002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293"/>
>               </CodeGroup>
>               <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust"
Name="Ecma_Strong_Name" Description="This code group grants code signed with the ECMA strong
name full trust. ">
>                 <IMembershipCondition class="StrongNameMembershipCondition" version="1"
PublicKeyBlob="00000000000000000400000000000000"/>
>               </CodeGroup>
>             </CodeGroup>
>           </CodeGroup>
>         </PolicyLevel>
>       </policy>
>     </security>
>   </mscorlib>
> </configuration>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message