List:General Discussion« Previous MessageNext Message »
From:Joerg Bruehe Date:July 29 2005 7:01pm
Subject:Re: mysql command line execution
View as plain text  
Hi!

Nuno Pereira wrote:
> Michael Stassen wrote:
> 
>> [[...]]
>>
>> echo "unlock table " | mysql -udbuser -pdbpassword -Ddbname 
>> -hlocalhost -P3306
>>
>> The password is on the command line of the commands issued by the 
>> script, so it can be seen with ps.
> 
> 
> That isn't true. If you make a ps, you will see something like "mysql -p 
> x xxxxxxxx ................".

This does not work / happen everywhere, AFAIK. In inexact terms:

When a Unix-style system (including Linux) starts a process, the command 
line arguments are provided by the parent process (typically: the shell) 
which then calls fork() and exec(). Across the exec(), they are stored 
in some system area linked to the process table.
 From there, they are copied to the new program's address space to be 
accessed as the "char **argv" parameter of main().
The program can modify argv, but it cannot modify the system area.

Now AFAIK there are systems where "ps" will look at the program's 
address space and see the changed arguments, but also ones where ps will 
look at the system's address space and see the original arguments (and 
report them!).

> 
> As I said before, you can use something like:
> "mysql -uUser --password=`cat password_file` db"

This does not change anything, as backticks are evaluated by the shell. 
When mysql is started in this way, the password is still a plaintext 
argument.


Jörg

-- 
Joerg Bruehe, Senior Production Engineer
MySQL AB, www.mysql.com
Thread
mysql command line executionJeff Richards29 Jul
  • Re: mysql command line executionBruce Dembecki29 Jul
  • Re: mysql command line executionMichael Stassen29 Jul
  • Re: mysql command line executionEhrwin Mina29 Jul
    • Re: mysql command line executionMichael Stassen29 Jul
      • Re: mysql command line executionNuno Pereira29 Jul
        • Re: mysql command line executionMichael Stassen29 Jul
          • Re: mysql command line executionNuno Pereira29 Jul
            • Re: mysql command line executionJason Pyeron29 Jul
              • Re: mysql command line executionNuno Pereira1 Aug
        • Re: mysql command line executionJoerg Bruehe29 Jul
        • Re: mysql command line executionEhrwin Mina1 Aug
          • Re: mysql command line executionEugene Kosov1 Aug
            • RE: mysql command line executionEdwin Cruz1 Aug
              • Re: mysql command line executionNuno Pereira1 Aug
Re: mysql command line executionNuno Pereira2 Aug
Re: mysql command line executionNuno Pereira3 Aug