~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/user_detect.h

Refactor

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() ? "" : &user[0]; }
 
31
    const char* getUser() { return user.empty() ? NULL : &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
 
        user.assign(pw_struct.pw_name, pw_struct.pw_name + strlen(pw_struct.pw_name) + 1);
 
41
      {
 
42
        user.resize(strlen(pw_struct.pw_name)+1);
 
43
        strcpy(&user[0], pw_struct.pw_name);
 
44
      }
42
45
 
43
46
      delete[] pw_buffer;
44
47
    }