Ticket #7554: 7554.patch

File 7554.patch, 3.8 KB (added by FunkyBob, 13 years ago)

As requested, the patch now adds a "--insecure" switch to dbshell command so you must choose to permit it.

  • django/core/management/commands/dbshell.py

    diff --git a/django/core/management/commands/dbshell.py b/django/core/management/commands/dbshell.py
    index 7465920..610fcd4 100644
    a b class Command(BaseCommand):  
    1111        make_option('--database', action='store', dest='database',
    1212            default=DEFAULT_DB_ALIAS, help='Nominates a database onto which to '
    1313                'open a shell.  Defaults to the "default" database.'),
     14        make_option('--insecure', action='store_true', dest='insecure',
     15            default=False, help='Allow insecure passing of password via environment'
     16        ),
    1417    )
    1518
    1619    requires_model_validation = False
    class Command(BaseCommand):  
    1821    def handle(self, **options):
    1922        connection = connections[options.get('database')]
    2023        try:
    21             connection.client.runshell()
     24            connection.client.runshell(insecure=options.get('insecure'))
    2225        except OSError:
    2326            # Note that we're assuming OSError means that the client program
    2427            # isn't installed. There's a possibility OSError would be raised
  • django/db/backends/mysql/client.py

    diff --git a/django/db/backends/mysql/client.py b/django/db/backends/mysql/client.py
    index 1cf8cee..b9b5702 100644
    a b from django.db.backends import BaseDatabaseClient  
    66class DatabaseClient(BaseDatabaseClient):
    77    executable_name = 'mysql'
    88
    9     def runshell(self):
     9    def runshell(self, *args, **kwargs):
    1010        settings_dict = self.connection.settings_dict
    1111        args = [self.executable_name]
    1212        db = settings_dict['OPTIONS'].get('db', settings_dict['NAME'])
  • django/db/backends/oracle/client.py

    diff --git a/django/db/backends/oracle/client.py b/django/db/backends/oracle/client.py
    index ccc64eb..8f89964 100644
    a b from django.db.backends import BaseDatabaseClient  
    66class DatabaseClient(BaseDatabaseClient):
    77    executable_name = 'sqlplus'
    88
    9     def runshell(self):
     9    def runshell(self, *args, **kwargs):
    1010        conn_string = self.connection._connect_string()
    1111        args = [self.executable_name, "-L", conn_string]
    1212        if os.name == 'nt':
  • django/db/backends/postgresql_psycopg2/client.py

    diff --git a/django/db/backends/postgresql_psycopg2/client.py b/django/db/backends/postgresql_psycopg2/client.py
    index a5c0296..d0082cf 100644
    a b from django.db.backends import BaseDatabaseClient  
    66class DatabaseClient(BaseDatabaseClient):
    77    executable_name = 'psql'
    88
    9     def runshell(self):
     9    def runshell(self, insecure=False, **kwargs):
    1010        settings_dict = self.connection.settings_dict
    1111        args = [self.executable_name]
    1212        if settings_dict['USER']:
    class DatabaseClient(BaseDatabaseClient):  
    1515            args.extend(["-h", settings_dict['HOST']])
    1616        if settings_dict['PORT']:
    1717            args.extend(["-p", str(settings_dict['PORT'])])
     18        if insecure and settings_dict['PASSWORD']:
     19            os.environ['PGPASSWORD'] = settings_dict['PASSWORD']
    1820        args += [settings_dict['NAME']]
    1921        if os.name == 'nt':
    2022            sys.exit(os.system(" ".join(args)))
  • django/db/backends/sqlite3/client.py

    diff --git a/django/db/backends/sqlite3/client.py b/django/db/backends/sqlite3/client.py
    index 5b5b732..fa2d887 100644
    a b from django.db.backends import BaseDatabaseClient  
    66class DatabaseClient(BaseDatabaseClient):
    77    executable_name = 'sqlite3'
    88
    9     def runshell(self):
     9    def runshell(self, *args, **kwargs):
    1010        args = [self.executable_name,
    1111                self.connection.settings_dict['NAME']]
    1212        if os.name == 'nt':
Back to Top