4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-18 04:19:21 +08:00

* mkpasswd.c (current_user): Actually *use* $HOME if it's available.

Add comment to explain what we're doing here.
This commit is contained in:
Corinna Vinschen 2012-05-05 08:55:17 +00:00
parent fb9d631817
commit 6428476bdd
2 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2012-05-05 Corinna Vinschen <corinna@vinschen.de>
* mkpasswd.c (current_user): Actually *use* $HOME if it's available.
Add comment to explain what we're doing here.
2012-04-05 Corinna Vinschen <corinna@vinschen.de>
* mkgroup.c (print_special_by_sid): Rename from print_special. Change

View File

@ -172,9 +172,13 @@ current_user (const char *sep, const char *passed_home_path, DWORD id_offset,
*GetSidSubAuthorityCount(curr_pgrp.psid) - 1);
if (passed_home_path[0] == '\0')
{
char *envhome = getenv ("HOME"); /* POSIX! */
char *envhome = getenv ("HOME");
if (!envhome || envhome[0] == '\0')
/* If $HOME exists and is non-empty, just copy it over to homedir_psx.
Otherwise, generate a new path of the form "/home/$USER". */
if (envhome && envhome[0] != '\0')
strncat (homedir_psx, envhome, sizeof (homedir_psx) - 1);
else
{
wcstombs (stpncpy (homedir_psx, "/home/", sizeof (homedir_psx)),
user, sizeof (homedir_psx) - 6);