~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/user_detect.h

  • Committer: Mark Atwood
  • Date: 2011-06-16 06:04:05 UTC
  • mfrom: (2318.4.8 refactor7)
  • Revision ID: me@mark.atwood.name-20110616060405-jqxvti75k6bpq741
mergeĀ lp:~olafvdspek/drizzle/refactor9

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
class UserDetect
29
29
{
30
30
  public:
31
 
    const char* getUser() { return user.empty() ? NULL : &user[0]; }
 
31
    const char* getUser() { return user.empty() ? "" : &user[0]; }
32
32
 
33
33
    UserDetect()
34
34
    {
38
38
      char *pw_buffer= new char[pw_len];
39
39
 
40
40
      if (getpwuid_r(geteuid(), &pw_struct, pw_buffer, pw_len, &pw_tmp_struct) == 0)
41
 
      {
42
 
        user.resize(strlen(pw_struct.pw_name)+1);
43
 
        strcpy(&user[0], pw_struct.pw_name);
44
 
      }
 
41
        user.assign(pw_struct.pw_name, pw_struct.pw_name + strlen(pw_struct.pw_name) + 1);
45
42
 
46
43
      delete[] pw_buffer;
47
44
    }