Lines 93-116
get_pw_data (void)
Link Here
|
93 |
pthread_mutex_unlock (&pw_lock); |
93 |
pthread_mutex_unlock (&pw_lock); |
94 |
return; |
94 |
return; |
95 |
} |
95 |
} |
|
|
96 |
|
97 |
home_dir = g_getenv ("HOME"); |
98 |
user_name = g_getenv ("USER"); |
99 |
|
96 |
#ifdef HAVE_GETPWUID_R |
100 |
#ifdef HAVE_GETPWUID_R |
97 |
if (getpwuid_r (getuid (), &pw, buf, 4096, &result) == 0) { |
101 |
if (home_dir == NULL || user_name == NULL) { |
98 |
home_dir = g_strdup (pw.pw_dir); |
102 |
if (getpwuid_r (getuid (), &pw, buf, 4096, &result) == 0) { |
99 |
user_name = g_strdup (pw.pw_name); |
103 |
if (home_dir == NULL) |
|
|
104 |
home_dir = g_strdup (pw.pw_dir); |
105 |
if (user_name == NULL) |
106 |
user_name = g_strdup (pw.pw_name); |
107 |
} else { |
108 |
if (user_name == NULL) |
109 |
user_name = "somebody"; |
110 |
} |
100 |
} |
111 |
} |
101 |
#endif |
112 |
#endif |
102 |
if (home_dir == NULL) |
|
|
103 |
home_dir = g_getenv ("HOME"); |
104 |
|
113 |
|
105 |
if (user_name == NULL) { |
|
|
106 |
user_name = g_getenv ("USER"); |
107 |
if (user_name == NULL) |
108 |
user_name = "somebody"; |
109 |
} |
110 |
pthread_mutex_unlock (&pw_lock); |
114 |
pthread_mutex_unlock (&pw_lock); |
111 |
} |
115 |
} |
112 |
|
116 |
|
113 |
/* Give preference to /etc/passwd than HOME */ |
|
|
114 |
const gchar * |
117 |
const gchar * |
115 |
g_get_home_dir (void) |
118 |
g_get_home_dir (void) |
116 |
{ |
119 |
{ |