From e02f569dd3add89a6b1152d1f01631e48b3dfcbc Mon Sep 17 00:00:00 2001 From: Federico Di Gregorio Date: Tue, 16 Jan 2007 11:29:07 +0000 Subject: [PATCH] Password obfuscation to close: #147. --- ChangeLog | 2 ++ psycopg/connection_type.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 823f911d..e73e74f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2007-01-16 Federico Di Gregorio + * psycopg/connection_type.c: obfuscate password after using it. + * lib/extras.py: moved SQL_IN to extensions.py; we're now officially adapting tuples. diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index 990cc6ab..b55b325a 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -272,6 +272,9 @@ static struct PyMemberDef connectionObject_members[] = { static int connection_setup(connectionObject *self, char *dsn) { + int i; + char *pos; + Dprintf("connection_setup: init connection object at %p, refcnt = %d", self, ((PyObject *)self)->ob_refcnt); @@ -284,7 +287,13 @@ connection_setup(connectionObject *self, char *dsn) self->async_cursor = NULL; self->pgconn = NULL; self->mark = 0; - + + pos = strstr(self->dsn, "password"); + if (pos != NULL) { + for (pos = pos+9 ; *pos != '\0' && *pos != ' '; pos++) + *pos = 'x'; + } + pthread_mutex_init(&(self->lock), NULL); if (conn_connect(self) != 0) {