You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Regis Xu (JIRA)" <ji...@apache.org> on 2009/03/02 08:12:12 UTC

[jira] Created: (HARMONY-6106) [classlib][security] PolicyUtils.expandURL may return invalid URL on linux

[classlib][security] PolicyUtils.expandURL may return invalid URL on linux
--------------------------------------------------------------------------

                 Key: HARMONY-6106
                 URL: https://issues.apache.org/jira/browse/HARMONY-6106
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 5.0M8
            Reporter: Regis Xu
             Fix For: 5.0M9


the test:
        Properties props = new Properties();
        props.put("my.home", "/home/bahamut");
        String location = PolicyUtils.expandURL("file:/${my.home}/test", props);
        URL url = new URL(location);
        System.out.println(url.getHost());
        System.out.println(url.getPath());
        System.out.println(url.toString());

output is:
home
/bahamut/test
file://home/bahamut/test

the expanded URL is "file://home/bahamut/test", but what we want is "file:/home/bahamut/test", 
the one extra "/" make host of URL to be "home" which should be "", and then url.openConnection(), 
the wrong URL will use ftp protocol to open the file.



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


[jira] Updated: (HARMONY-6106) [classlib][security] PolicyUtils.expandURL may return invalid URL on linux

Posted by "Regis Xu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-6106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Regis Xu updated HARMONY-6106:
------------------------------

    Attachment: HARMONY-6106.diff

Would anyone want to try this?

> [classlib][security] PolicyUtils.expandURL may return invalid URL on linux
> --------------------------------------------------------------------------
>
>                 Key: HARMONY-6106
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6106
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M8
>            Reporter: Regis Xu
>             Fix For: 5.0M9
>
>         Attachments: HARMONY-6106.diff
>
>
> the test:
>         Properties props = new Properties();
>         props.put("my.home", "/home/bahamut");
>         String location = PolicyUtils.expandURL("file:/${my.home}/test", props);
>         URL url = new URL(location);
>         System.out.println(url.getHost());
>         System.out.println(url.getPath());
>         System.out.println(url.toString());
> output is:
> home
> /bahamut/test
> file://home/bahamut/test
> the expanded URL is "file://home/bahamut/test", but what we want is "file:/home/bahamut/test", 
> the one extra "/" make host of URL to be "home" which should be "", and then url.openConnection(), 
> the wrong URL will use ftp protocol to open the file.

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


[jira] Assigned: (HARMONY-6106) [classlib][security] PolicyUtils.expandURL may return invalid URL on linux

Posted by "Sean Qiu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-6106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sean Qiu reassigned HARMONY-6106:
---------------------------------

    Assignee: Sean Qiu

> [classlib][security] PolicyUtils.expandURL may return invalid URL on linux
> --------------------------------------------------------------------------
>
>                 Key: HARMONY-6106
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6106
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M8
>            Reporter: Regis Xu
>            Assignee: Sean Qiu
>         Attachments: HARMONY-6106.diff
>
>
> the test:
>         Properties props = new Properties();
>         props.put("my.home", "/home/bahamut");
>         String location = PolicyUtils.expandURL("file:/${my.home}/test", props);
>         URL url = new URL(location);
>         System.out.println(url.getHost());
>         System.out.println(url.getPath());
>         System.out.println(url.toString());
> output is:
> home
> /bahamut/test
> file://home/bahamut/test
> the expanded URL is "file://home/bahamut/test", but what we want is "file:/home/bahamut/test", 
> the one extra "/" make host of URL to be "home" which should be "", and then url.openConnection(), 
> the wrong URL will use ftp protocol to open the file.

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


[jira] Commented: (HARMONY-6106) [classlib][security] PolicyUtils.expandURL may return invalid URL on linux

Posted by "Regis Xu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-6106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678591#action_12678591 ] 

Regis Xu commented on HARMONY-6106:
-----------------------------------

You are right, PolicyUtils.expandURL only replace the string, it shouldn't be blamed :)
But I found Harmony's security policy file is wrong, java.security:57:

policy.url.1=file:/${java.home}/lib/security/java.policy
policy.url.2=file:/${user.home}/.java.policy

after expansion, there would be a extra "/" in URL, which is incorrect.



> [classlib][security] PolicyUtils.expandURL may return invalid URL on linux
> --------------------------------------------------------------------------
>
>                 Key: HARMONY-6106
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6106
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M8
>            Reporter: Regis Xu
>         Attachments: HARMONY-6106.diff
>
>
> the test:
>         Properties props = new Properties();
>         props.put("my.home", "/home/bahamut");
>         String location = PolicyUtils.expandURL("file:/${my.home}/test", props);
>         URL url = new URL(location);
>         System.out.println(url.getHost());
>         System.out.println(url.getPath());
>         System.out.println(url.toString());
> output is:
> home
> /bahamut/test
> file://home/bahamut/test
> the expanded URL is "file://home/bahamut/test", but what we want is "file:/home/bahamut/test", 
> the one extra "/" make host of URL to be "home" which should be "", and then url.openConnection(), 
> the wrong URL will use ftp protocol to open the file.

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


[jira] Commented: (HARMONY-6106) [classlib][security] PolicyUtils.expandURL may return invalid URL on linux

Posted by "Regis Xu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-6106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678354#action_12678354 ] 

Regis Xu commented on HARMONY-6106:
-----------------------------------

PolicyUtils is in o.a.h.security package, so it's depends on our implementation.

The key point is PolicyUtils.expandURL expected to return a string of URL, which could be used to constructed
a URL, like above test, and reference that file use "file" protocol not "ftp".
"file:/home/bahamut/test " and "file://home/bahamut/test " are totally different, I believe PolicyUtils.expandURL expected the former.

BTW, Harmony's behavior of processing URL "file://home/bahamut/test" is same with RI, so I think URL do the right thing.
      URL url = new URL("file://c:/test/.java.policy");
      System.out.println(url.getHost());
      System.out.println(url.getAuthority());
      URLConnection conn = url.openConnection();
      System.out.println(conn.getClass());

output of RI:
c
c:
class sun.net.www.protocol.ftp.FtpURLConnection

output of Harmony:
c
c:
class org.apache.harmony.luni.internal.net.www.protocol.ftp.FtpURLConnection

> [classlib][security] PolicyUtils.expandURL may return invalid URL on linux
> --------------------------------------------------------------------------
>
>                 Key: HARMONY-6106
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6106
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M8
>            Reporter: Regis Xu
>             Fix For: 5.0M9
>
>         Attachments: HARMONY-6106.diff
>
>
> the test:
>         Properties props = new Properties();
>         props.put("my.home", "/home/bahamut");
>         String location = PolicyUtils.expandURL("file:/${my.home}/test", props);
>         URL url = new URL(location);
>         System.out.println(url.getHost());
>         System.out.println(url.getPath());
>         System.out.println(url.toString());
> output is:
> home
> /bahamut/test
> file://home/bahamut/test
> the expanded URL is "file://home/bahamut/test", but what we want is "file:/home/bahamut/test", 
> the one extra "/" make host of URL to be "home" which should be "", and then url.openConnection(), 
> the wrong URL will use ftp protocol to open the file.

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


[jira] Closed: (HARMONY-6106) [classlib][security] PolicyUtils.expandURL may return invalid URL on linux

Posted by "Regis Xu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-6106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Regis Xu closed HARMONY-6106.
-----------------------------


I have created a another issue HARMONY-6113 for incorrect value of policy.url

> [classlib][security] PolicyUtils.expandURL may return invalid URL on linux
> --------------------------------------------------------------------------
>
>                 Key: HARMONY-6106
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6106
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M8
>            Reporter: Regis Xu
>            Assignee: Sean Qiu
>         Attachments: HARMONY-6106.diff
>
>
> the test:
>         Properties props = new Properties();
>         props.put("my.home", "/home/bahamut");
>         String location = PolicyUtils.expandURL("file:/${my.home}/test", props);
>         URL url = new URL(location);
>         System.out.println(url.getHost());
>         System.out.println(url.getPath());
>         System.out.println(url.toString());
> output is:
> home
> /bahamut/test
> file://home/bahamut/test
> the expanded URL is "file://home/bahamut/test", but what we want is "file:/home/bahamut/test", 
> the one extra "/" make host of URL to be "home" which should be "", and then url.openConnection(), 
> the wrong URL will use ftp protocol to open the file.

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


[jira] Commented: (HARMONY-6106) [classlib][security] PolicyUtils.expandURL may return invalid URL on linux

Posted by "Alexey Varlamov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-6106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678311#action_12678311 ] 

Alexey Varlamov commented on HARMONY-6106:
------------------------------------------

Hmm, unsure how this complies with syntactic guidelines for a policy file. Just curious, how RI behaves here?

> [classlib][security] PolicyUtils.expandURL may return invalid URL on linux
> --------------------------------------------------------------------------
>
>                 Key: HARMONY-6106
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6106
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M8
>            Reporter: Regis Xu
>             Fix For: 5.0M9
>
>         Attachments: HARMONY-6106.diff
>
>
> the test:
>         Properties props = new Properties();
>         props.put("my.home", "/home/bahamut");
>         String location = PolicyUtils.expandURL("file:/${my.home}/test", props);
>         URL url = new URL(location);
>         System.out.println(url.getHost());
>         System.out.println(url.getPath());
>         System.out.println(url.toString());
> output is:
> home
> /bahamut/test
> file://home/bahamut/test
> the expanded URL is "file://home/bahamut/test", but what we want is "file:/home/bahamut/test", 
> the one extra "/" make host of URL to be "home" which should be "", and then url.openConnection(), 
> the wrong URL will use ftp protocol to open the file.

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


[jira] Resolved: (HARMONY-6106) [classlib][security] PolicyUtils.expandURL may return invalid URL on linux

Posted by "Alexey Varlamov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-6106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Varlamov resolved HARMONY-6106.
--------------------------------------

       Resolution: Invalid
    Fix Version/s:     (was: 5.0M9)

Yes, PolicyUtils is (a part of) our default policy implementation, but I see no reason to deviate from RI in policy file syntax and other aspects of user interface (policy locations etc).
Looking at the RI policy documentation [1], I'd say you simply misused property expansion. Quoting:
1) "For example, the default system and user policy files are defined in the security properties file as 
policy.url.1=file:${java.home}/lib/security/java.policy
policy.url.2=file:${user.home}/.java.policy"
2) "Also, as a special case, if you expand a property in a codebase, such as 
    grant codeBase "file:${java.home}/lib/ext/"
then any file.separator characters will be automatically converted to /'s. Thus on a Win32 system, the above would get converted to 
    grant codeBase "file:C:/jdk1.4/jre/lib/ext/"
even if "java.home" is set to C:\jdk1.4\jre. Thus you don't need to use ${/} in codebase strings (and you shouldn't). "

Therefore, I resolve this issue as "Invalid".

[1] http://java.sun.com/j2se/1.5.0/docs/guide/security/PolicyFiles.html

> [classlib][security] PolicyUtils.expandURL may return invalid URL on linux
> --------------------------------------------------------------------------
>
>                 Key: HARMONY-6106
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6106
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M8
>            Reporter: Regis Xu
>         Attachments: HARMONY-6106.diff
>
>
> the test:
>         Properties props = new Properties();
>         props.put("my.home", "/home/bahamut");
>         String location = PolicyUtils.expandURL("file:/${my.home}/test", props);
>         URL url = new URL(location);
>         System.out.println(url.getHost());
>         System.out.println(url.getPath());
>         System.out.println(url.toString());
> output is:
> home
> /bahamut/test
> file://home/bahamut/test
> the expanded URL is "file://home/bahamut/test", but what we want is "file:/home/bahamut/test", 
> the one extra "/" make host of URL to be "home" which should be "", and then url.openConnection(), 
> the wrong URL will use ftp protocol to open the file.

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