diff options
| -rw-r--r-- | src/w32.c | 24 |
1 files changed, 23 insertions, 1 deletions
| @@ -2091,7 +2091,29 @@ getpwnam (char *name) | |||
| 2091 | return pw; | 2091 | return pw; |
| 2092 | 2092 | ||
| 2093 | if (xstrcasecmp (name, pw->pw_name)) | 2093 | if (xstrcasecmp (name, pw->pw_name)) |
| 2094 | return NULL; | 2094 | { |
| 2095 | /* Mimic what init_editfns does with these environment | ||
| 2096 | variables, so that the likes of ~USER is recognized by | ||
| 2097 | expand-file-name even if $LOGNAME gives a name different from | ||
| 2098 | the real username produced by the process token. */ | ||
| 2099 | char *logname = getenv ("LOGNAME"); | ||
| 2100 | char *username = getenv ("USERNAME"); | ||
| 2101 | if ((logname || username) | ||
| 2102 | && xstrcasecmp (name, logname ? logname : username) == 0) | ||
| 2103 | { | ||
| 2104 | static struct passwd alias_user; | ||
| 2105 | static char alias_name[PASSWD_FIELD_SIZE]; | ||
| 2106 | |||
| 2107 | memcpy (&alias_user, &dflt_passwd, sizeof dflt_passwd); | ||
| 2108 | alias_name[0] = '\0'; | ||
| 2109 | strncat (alias_name, logname ? logname : username, | ||
| 2110 | PASSWD_FIELD_SIZE - 1); | ||
| 2111 | alias_user.pw_name = alias_name; | ||
| 2112 | pw = &alias_user; | ||
| 2113 | } | ||
| 2114 | else | ||
| 2115 | return NULL; | ||
| 2116 | } | ||
| 2095 | 2117 | ||
| 2096 | return pw; | 2118 | return pw; |
| 2097 | } | 2119 | } |