Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit19a251d

Browse files
committed
>>>>The JDBC driver requires
>>>>>>>> permission java.net.SocketPermission "host:port", "connect";>>>>>>>>in the policy file of the application using the JDBC driver>>>>in the postgresql.jar file. Since the Socket() call in the>>>>driver is not protected by AccessController.doPrivileged() this>>>>permission must also be granted to the entire application.>>>>>>>>The attached diff fixes it so that the connect permission can be>>>>restricted just the the postgresql.jar codeBase if desired.David Daney
1 parent1be615f commit19a251d

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

‎src/interfaces/jdbc/org/postgresql/PG_Stream.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
importjava.net.*;
66
importjava.util.*;
77
importjava.sql.*;
8+
importjava.security.*;
89
importorg.postgresql.*;
910
importorg.postgresql.core.*;
1011
importorg.postgresql.util.*;
1112

1213
/**
13-
* $Id: PG_Stream.java,v 1.11 2001/07/30 14:51:19 momjian Exp $
14+
* $Id: PG_Stream.java,v 1.12 2001/08/26 01:06:20 momjian Exp $
1415
*
1516
* This class is used by Connection & PGlobj for communicating with the
1617
* backend.
@@ -28,6 +29,25 @@ public class PG_Stream
2829
BytePoolDim1bytePoolDim1 =newBytePoolDim1();
2930
BytePoolDim2bytePoolDim2 =newBytePoolDim2();
3031

32+
privatestaticclassPrivilegedSocket
33+
implementsPrivilegedExceptionAction
34+
{
35+
privateStringhost;
36+
privateintport;
37+
38+
PrivilegedSocket(Stringhost,intport)
39+
{
40+
this.host =host;
41+
this.port =port;
42+
}
43+
44+
publicObjectrun()throwsException
45+
{
46+
returnnewSocket(host,port);
47+
}
48+
}
49+
50+
3151
/**
3252
* Constructor: Connect to the PostgreSQL back end and return
3353
* a stream connection.
@@ -38,7 +58,13 @@ public class PG_Stream
3858
*/
3959
publicPG_Stream(Stringhost,intport)throwsIOException
4060
{
41-
connection =newSocket(host,port);
61+
PrivilegedSocketps =newPrivilegedSocket(host,port);
62+
try {
63+
connection = (Socket)AccessController.doPrivileged(ps);
64+
}
65+
catch(PrivilegedActionExceptionpae){
66+
throw (IOException)pae.getException();
67+
}
4268

4369
// Submitted by Jason Venner <jason@idiom.com> adds a 10x speed
4470
// improvement on FreeBSD machines (caused by a bug in their TCP Stack)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp