Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

dbconsole support password passing through /dev/fd/

#2707

A comment to the article at

http://dev.mysql.com/doc/refman/5.0/en/password-security-user.html

describes how one can pipe the password to mysql, instead of exposing it to other users when placing the password in the argument list when exec'ing to the mysql executable. Currently script/dbconsole offers the -p / --include-password option, so that the user will not inadvertently disclose their password.

On systems that allow pipes (most UNIX), and have the necessary /dev/fd filesystem support, this -p option is not needed, while still being able to provide the password to mysql. This is the motivation for the submitted patch. The implementation checks for compatibility and uses the feature if it is supported (ignoring the -p option)

In making this change, I found it quite involved, and so I split up all of the existing adapter code into separate ...Console classes.

I also added some new command line options. With this patch the options are


$ script/dbconsole -h
Usage: script/dbconsole [options] [environment] [database.yml]

Default environment is development
Default database.yml file is config/database.yml

Specific options:
    -x, --executable EXECUTABLE      executable to use. Defaults are sqlite, sqlite3, psql, mysql
    -p, --include-password           mysql/postgresql only: Automatically provide the password from database.yml
        --mycnf                      mysql only: Just output my.cnf file
        --mode [MODE]                sqlite3 only: put the database in the specified mode (html, list, line, column)
        --[no-]header                sqlite3 only: Turn headers on or off
    -v, --[no-]verbose               Run verbosely
    -h, --help                       Show this help message

In particular -h is now "help", and not "header". See comment to CommandLineInterfaceTest#test_help_option.

I added unit tests, and a new Rake task test:dbconsole to run these.

Reported by Stephan Wehner · May 24th, 2009 @ 05:32 AM

State: wontfix
Milestone: 3.x
Assigned to: Rizwan Reza Rizwan Reza
Importance: none

Activity

  1. Stephan Wehner
    Stephan Wehner
    • Tag changed from dbconsole, mysql, patch to dbconsole, mysql, patch, security

    May 25th, 2009 @ 02:41 PM

  2. Stephan Wehner
    Stephan Wehner

    Ticket

    asks about dbconsole using the database_configuration_file in config/environment.rb. This may be half-way accomplished through the option of this patch to specify the database.yml on the command line.

    May 26th, 2009 @ 05:12 PM

  3. Stephan Wehner
    Stephan Wehner

    Attaching patch after rebasing / smaller changes.

    May 28th, 2009 @ 03:58 PM

  4. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from dbconsole, mysql, patch, security to bugmash, dbconsole, mysql, patch, security

    August 6th, 2009 @ 02:55 PM

  5. Rizwan Reza
    Rizwan Reza

    not reproducible

    -1 Both patches fail.

    August 9th, 2009 @ 05:53 PM

  6. Elad Meidar
    Elad Meidar

    i didn't quiet understand how to reproduce this ticket, pointers?

    August 9th, 2009 @ 06:49 PM

  7. Stephan Wehner
    Stephan Wehner

    The point of this ticket is that the implementation of dbconsole's -p option, in the mysql case, is not as safe as it could be.

    The idea of the -p option is that the database password is available when reading the config/database.yml file, and so the
    user should not have to provide it.

    The implementation before this patch uses mysql'd command line switch -p ... in other words, the password is passed to the mysql process through its argument list.

    In general, the argument list of a process is not protected on Unix systems, and can be obtained by any other process.

    In other words, the password is left to float around in plaintext in the system. Not a good idea!

    So this patch provides a different, hopefully safer solution. It is based on the comment to the article at

    http://dev.mysql.com/doc/refman/5.0/en/password-security-user.html

    (as the description of this ticket begins with.)

    September 20th, 2009 @ 05:18 AM

  8. John Pignata
    John Pignata

    -1 This is a very involved change for a small security gain. It would probably be best to inform users via the --help msg that using -p could have security implications.

    September 24th, 2009 @ 02:13 PM

  9. Stephan Wehner
    Stephan Wehner

    I believe it's good to make use of operating system features. I don't think I would judge the security gain as small.

    The change is involved mostly because it includes unit tests, and the corresponding, new, "units".
    Should be good also for future changes to have these tests.

    September 30th, 2009 @ 09:29 PM

  10. Rizwan Reza
    Rizwan Reza
    • Tag changed from bugmash, dbconsole, mysql, patch, security to dbconsole, mysql, patch, security

    February 12th, 2010 @ 12:46 PM

  11. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  12. Rohit Arondekar
    Rohit Arondekar
    • Assigned user set to Rizwan Reza

    Looks like this ticket can be closed?

    June 15th, 2010 @ 10:45 AM

  13. Rizwan Reza
    Rizwan Reza
    • State changed from new to wontfix
    • Importance changed from to

    September 6th, 2010 @ 10:39 PM