Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2012-05-05 12:55:17 +0400
committerCorinna Vinschen <corinna@vinschen.de>2012-05-05 12:55:17 +0400
commit6428476bdd21f998ba7ca0e969ebaeb7f1a49856 (patch)
treea63d486ec4e9d3823516c864cce646ac0a4246d6 /winsup/utils/mkpasswd.c
parentfb9d631817cc2b5d83c2a6ff928851d201c992bf (diff)
* mkpasswd.c (current_user): Actually *use* $HOME if it's available.
Add comment to explain what we're doing here.
Diffstat (limited to 'winsup/utils/mkpasswd.c')
-rw-r--r--winsup/utils/mkpasswd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/winsup/utils/mkpasswd.c b/winsup/utils/mkpasswd.c
index 6ca4e5db3..5373719c5 100644
--- a/winsup/utils/mkpasswd.c
+++ b/winsup/utils/mkpasswd.c
@@ -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);