~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Monty Taylor
  • Date: 2010-06-19 21:25:32 UTC
  • mfrom: (1627.2.5 build)
  • Revision ID: mordred@inaugust.com-20100619212532-2e4bd11tm4plya7q
Rollup patch featuring: boost::program_options support for plugins, a
valgrind fix, a bugfix for password processing and a few build fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
166
166
 
167
167
/* Buffer to hold 'version' and 'version_comment' */
168
168
const int MAX_SERVER_VERSION_LENGTH= 128;
169
 
const string PASSWORD_SENTINEL("\0\0\0\0\0", 5);
170
169
 
171
170
#define PROMPT_CHAR '\\'
172
171
 
290
289
  opt_compress= false, opt_shutdown= false, opt_ping= false,
291
290
  vertical= false, line_numbers= true, column_names= true,
292
291
  opt_nopager= true, opt_outfile= false, named_cmds= false,
293
 
  tty_password= false, opt_nobeep= false, opt_reconnect= true,
 
292
  opt_nobeep= false, opt_reconnect= true,
294
293
  opt_secure_auth= false,
295
294
  default_pager_set= false, opt_sigint_ignore= false,
296
295
  auto_vertical_output= false,
1347
1346
  opt_max_input_line*=1024;
1348
1347
}
1349
1348
 
1350
 
static pair<string, string> parse_password_arg(std::string s)
1351
 
{
1352
 
  if (s.find("--password") == 0)
1353
 
  {
1354
 
    if (s == "--password")
1355
 
    {
1356
 
      tty_password= true;
1357
 
      //check if no argument is passed.
1358
 
      return make_pair("password", PASSWORD_SENTINEL);
1359
 
    }
1360
 
 
1361
 
    if (s.substr(10,3) == "=\"\"" || s.substr(10,3) == "=''")
1362
 
    {
1363
 
      // Check if --password="" or --password=''
1364
 
      return make_pair("password", PASSWORD_SENTINEL);
1365
 
    }
1366
 
    
1367
 
    if(s.substr(10) == "=" && s.length() == 11)
1368
 
    {
1369
 
      // check if --password= and return a default value
1370
 
      return make_pair("password", PASSWORD_SENTINEL);
1371
 
    }
1372
 
 
1373
 
    if(s.length()>12 && (s[10] == '"' || s[10] == '\''))
1374
 
    {
1375
 
      // check if --password has quotes, remove quotes and return the value
1376
 
      return make_pair("password", s.substr(11,s.length()-1));
1377
 
    }
1378
 
 
1379
 
    // if all above are false, it implies that --password=value, return value.
1380
 
    return make_pair("password", s.substr(11));
1381
 
  }
1382
 
 
1383
 
  else
1384
 
  {
1385
 
    return make_pair(string(""), string(""));
1386
 
  } 
1387
 
}
1388
 
 
1389
1349
int main(int argc,char *argv[])
1390
1350
{
1391
1351
try
1711
1671
      opt_password= current_password;
1712
1672
      tty_password= false;
1713
1673
    }
1714
 
    char *start= (char *)current_password.c_str();
1715
 
    char *temp_pass= (char *)current_password.c_str();
1716
 
    while (*temp_pass)
1717
 
    {
1718
 
        /* Overwriting password with 'x' */
1719
 
        *temp_pass++= 'x';
1720
 
    }
1721
 
    if (*start)
1722
 
    {
1723
 
      start[1]= 0;
1724
 
    }
1725
1674
  }
1726
1675
  else
1727
1676
  {