You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2009/04/04 03:57:30 UTC

DO NOT REPLY [Bug 46967] New: ManagerBase.setRandomFile error handling fix

https://issues.apache.org/bugzilla/show_bug.cgi?id=46967

           Summary: ManagerBase.setRandomFile error handling fix
           Product: Tomcat 6
           Version: 6.0.18
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: kirk@wolf-associates.com


On some platforms (z/OS for sure), the device file /dev/urandom can pass the
"f.exists()" test, but throws an IOException of some kind when trying to open
it.  The current code in ManagerBase.setRandomFile() doesn't handle this, which
results in EVERY call to getRandom() to try again and log the error  "Failed to
close randomIS".

The following changes to the method will add proper error handling to correct
this (my changes marked "// kjw")

    public void setRandomFile( String s ) {
        // as a hack, you can use a static file - and genarate the same
        // session ids ( good for strange debugging )
        if (Globals.IS_SECURITY_ENABLED){
            randomIS = (DataInputStream)AccessController.doPrivileged(new
PrivilegedSetRandomFile());          
        } else {
            try{
                devRandomSource=s;
                File f=new File( devRandomSource );
                if( ! f.exists() ) return;
                randomIS= new DataInputStream( new FileInputStream(f));
                randomIS.readLong();
                if( log.isDebugEnabled() )
                    log.debug( "Opening " + devRandomSource );
            } catch( IOException ex ) {
                log.debug("Error reading " + devRandomSource, ex); //kjw
                if (randomIS != null) {  // kjw: if opened
                    try {
                        randomIS.close();
                    } catch (Exception e) {
                        log.warn("Failed to close randomIS.");
                    }
                }                       // kjw 
                devRandomSource = null; // kjw: don't try again automatically
                randomIS=null;
            }
        }
    }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 46967] ManagerBase.setRandomFile error handling fix

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46967


Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Tim.Whittington@orionhealth
                   |                            |.com




--- Comment #3 from Konstantin Kolinko <kn...@gmail.com>  2009-07-17 10:41:58 PST ---
*** Bug 47276 has been marked as a duplicate of this bug. ***

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 46967] ManagerBase.setRandomFile error handling fix

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46967


Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #5 from Konstantin Kolinko <kn...@gmail.com> 2009-08-12 18:23:28 PDT ---
This has been fixed in 5.5 and will be in 5.5.29 onwards.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 46967] ManagerBase.setRandomFile error handling fix

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46967


Tim <tf...@sdsusa.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tfull@sdsusa.com




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 46967] ManagerBase.setRandomFile error handling fix

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46967


Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
          Component|Catalina                    |Catalina
            Version|6.0.18                      |5.5.27
         Resolution|FIXED                       |
            Product|Tomcat 6                    |Tomcat 5
   Target Milestone|default                     |---




--- Comment #4 from Konstantin Kolinko <kn...@gmail.com>  2009-07-17 10:45:26 PST ---
Reopening, to track fixing it in 5.5 branch.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 46967] ManagerBase.setRandomFile error handling fix

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46967





--- Comment #1 from Mark Thomas <ma...@apache.org>  2009-04-08 06:02:07 PST ---
Thanks for the patch. I have applied it to trunk and proposed it for 6.0.x.

I extended your patch to make the behaviour consistent when running under a
security manager.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 46967] ManagerBase.setRandomFile error handling fix

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46967


Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #2 from Mark Thomas <ma...@apache.org>  2009-05-22 08:15:11 PST ---
This has been fixed in 6.0.x and will be in 6.0.21 onwards.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org