Skip to content
Snippets Groups Projects
Commit 1dc3fb7e authored by Martin Stjernholm's avatar Martin Stjernholm
Browse files

Censor passwords in arguments so that they don't get printed by

describe_backtrace.

Rev: lib/modules/Sql.pmod/Sql.pike:1.90
Rev: lib/modules/Sql.pmod/mysql.pike:1.40
Rev: lib/modules/Sql.pmod/postgres.pike:1.27
Rev: lib/modules/Sql.pmod/rsql.pike:1.12
Rev: lib/modules/Sql.pmod/sybase.pike:1.11
parent ce5edefb
No related branches found
No related tags found
No related merge requests found
/* /*
* $Id: Sql.pike,v 1.89 2007/02/27 17:45:58 grubba Exp $ * $Id: Sql.pike,v 1.90 2008/01/09 14:26:07 mast Exp $
* *
* Implements the generic parts of the SQL-interface * Implements the generic parts of the SQL-interface
* *
...@@ -170,10 +170,15 @@ static program find_dbm(string program_name) { ...@@ -170,10 +170,15 @@ static program find_dbm(string program_name) {
//! @note //! @note
//! Support for @[options] was added in Pike 7.3. //! Support for @[options] was added in Pike 7.3.
//! //!
void create(string|object host, void|string|mapping(string:int|string) db, void create(string|object _host, void|string|mapping(string:int|string) db,
void|string user, void|string password, void|string user, void|string _password,
void|mapping(string:int|string) options) void|mapping(string:int|string) options)
{ {
// _host is censored only if we pick out a password from it below.
void|string|object host = _host;
string password = _password;
_password = "CENSORED";
if (objectp(host)) { if (objectp(host)) {
master_sql = host; master_sql = host;
if ((user && user != "") || (password && password != "") || if ((user && user != "") || (password && password != "") ||
...@@ -230,6 +235,8 @@ void create(string|object host, void|string|mapping(string:int|string) db, ...@@ -230,6 +235,8 @@ void create(string|object host, void|string|mapping(string:int|string) db,
if (password == "") { if (password == "") {
password = 0; password = 0;
} }
else
_host = "CENSORED";
} }
} }
arr = host/"/"; arr = host/"/";
......
/* /*
* $Id: mysql.pike,v 1.39 2007/05/26 13:53:26 mast Exp $ * $Id: mysql.pike,v 1.40 2008/01/09 14:26:07 mast Exp $
* *
* Glue for the Mysql-module * Glue for the Mysql-module
*/ */
...@@ -804,9 +804,12 @@ int(0..1) is_keyword( string name ) ...@@ -804,9 +804,12 @@ int(0..1) is_keyword( string name )
} }
static void create(string|void host, string|void database, static void create(string|void host, string|void database,
string|void user, string|void password, string|void user, string|void _password,
mapping(string:string|int)|void options) mapping(string:string|int)|void options)
{ {
string password = _password;
_password = "CENSORED";
if (options) { if (options) {
string charset = options->mysql_charset_name ? string charset = options->mysql_charset_name ?
lower_case (options->mysql_charset_name) : "latin1"; lower_case (options->mysql_charset_name) : "latin1";
......
/* /*
* This is part of the Postgres module for Pike. * This is part of the Postgres module for Pike.
* *
* $Id: postgres.pike,v 1.26 2006/06/06 03:26:00 adam Exp $ * $Id: postgres.pike,v 1.27 2008/01/09 14:26:07 mast Exp $
* *
*/ */
...@@ -153,7 +153,9 @@ static private int mkbool(string s) { ...@@ -153,7 +153,9 @@ static private int mkbool(string s) {
//! @seealso //! @seealso
//! @[Postgres.postgres], @[Sql.Sql], @[postgres->select_db] //! @[Postgres.postgres], @[Sql.Sql], @[postgres->select_db]
void create(void|string host, void|string database, void|string user, void create(void|string host, void|string database, void|string user,
void|string pass) { void|string _pass) {
string pass = _pass;
_pass = "CENSORED";
string real_host=host, real_db=database; string real_host=host, real_db=database;
int port=0; int port=0;
quote = this->_quote ? this->_quote : simple_quote; quote = this->_quote ? this->_quote : simple_quote;
......
...@@ -224,8 +224,11 @@ array(mapping(string:mixed)) query(mixed ... args) ...@@ -224,8 +224,11 @@ array(mapping(string:mixed)) query(mixed ... args)
return do_request('@', args); return do_request('@', args);
} }
void create(string|void host, string|void db, string|void user, string|void pw) void create(string|void host, string|void db, string|void user, string|void _pw)
{ {
string pw = _pw;
_pw = "CENSORED";
// Reconstruct the original URL (minus rsql://) // Reconstruct the original URL (minus rsql://)
if(!host) { if(!host) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Sybase driver for the Pike programming language. * Sybase driver for the Pike programming language.
* By Francesco Chemolli <kinkie@roxen.com> 10/12/1999 * By Francesco Chemolli <kinkie@roxen.com> 10/12/1999
* *
* $Id: sybase.pike,v 1.10 2004/04/16 12:12:46 grubba Exp $ * $Id: sybase.pike,v 1.11 2008/01/09 14:26:07 mast Exp $
* *
*/ */
...@@ -91,7 +91,9 @@ void seek(int skipthismany) { ...@@ -91,7 +91,9 @@ void seek(int skipthismany) {
} }
void create(void|string host, void|string db, void|string user, void create(void|string host, void|string db, void|string user,
void|string pass) { void|string _pass) {
string pass = _pass;
_pass = "CENSORED";
mo::create(host||"",db||"",user||"",pass||""); mo::create(host||"",db||"",user||"",pass||"");
if (db && stringp(db) && sizeof(db)) { if (db && stringp(db) && sizeof(db)) {
mo::big_query("use "+db); mo::big_query("use "+db);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment