~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/user_detect.h

  • Committer: Olaf van der Spek
  • Date: 2011-06-14 19:24:40 UTC
  • mto: (2318.6.3 refactor7)
  • mto: This revision was merged to the branch mainline in revision 2337.
  • Revision ID: olafvdspek@gmail.com-20110614192440-85tlnug3gr6azl3m
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() ? 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
    }