~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Andrew Hutchings
  • Date: 2011-04-19 17:41:43 UTC
  • mto: This revision was merged to the branch mainline in revision 2330.
  • Revision ID: andrew@linuxjedi.co.uk-20110419174143-j5ir17bdq87sbob9
Add better shell user detect functionality and add it to console

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
#include <boost/scoped_ptr.hpp>
155
155
#include <drizzled/program_options/config_file.h>
156
156
 
 
157
#include "user_detect.h"
 
158
 
157
159
using namespace std;
158
160
namespace po=boost::program_options;
159
161
namespace dpo=drizzled::program_options;
1474
1476
  _("Automatic limit for rows in a join when using --safe-updates"))
1475
1477
  ;
1476
1478
#ifndef DRIZZLE_ADMIN_TOOL
1477
 
  const char* unix_user= getlogin();
 
1479
  UserDetect *detected_user= new UserDetect();
 
1480
  const char* shell_user= detected_user->getUser();
1478
1481
#endif
1479
1482
  po::options_description client_options(_("Options specific to the client"));
1480
1483
  client_options.add_options()
1487
1490
#ifdef DRIZZLE_ADMIN_TOOL
1488
1491
  ("user,u", po::value<string>(&current_user)->default_value("root"),
1489
1492
#else
1490
 
  ("user,u", po::value<string>(&current_user)->default_value((unix_user ? unix_user : "")),
 
1493
  ("user,u", po::value<string>(&current_user)->default_value(shell_user ? shell_user : ""),
1491
1494
#endif
1492
1495
  _("User for login if not current user."))
1493
1496
  ("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),