Overview
| Artifact ID: | fbb0e79a570d0f2b18de56bc5e4927bfc1f67582 |
|---|---|
| Ticket: | b42a8514758d43c03f5404feb5543f921c22cf09
file normalize ~user returns wrong directory on Windows |
| User & Date: | apnadkarni on 2015-10-06 10:14:56 |
Changes
- icomment:
Some more information looking at the code in TclpGetUserHome in tclWinFile.c - file normalize ~ looks at the HOME environment variable whereas ~ashok looks at the NetUserGetInfo call. The latter only returns non-null directory information if administrator has explicitly set the home dir path. Under the normal (default) case an empty string is returned. - When the home dir is "", the code then calls back to %SYSTEMDRIVE%:/users/default. This is broken for many reasons - the toplevel is "users" only on newer Windows versions and even that can be changed. Secondly the returned directory is not writable by the user without elevation. Third, it does not contain any files specific to the user. The correct solution would be to use GetUserProfileDirectory but that is unworkable because that call requires a security token with the appropriate access rights. A semi-workable solution would be to use GetProfilesDirectory and tack on the user name (essentially ~ashok -> GetProfilesDirectory/ashok) and return it if the corresponding directory exists. However, in this case ~ and ~ashok will not match. We cannot change semantics of ~ because current programs might be relying on it. Adding on a Documents part to the result of ~ashok is problematic because (I think) the folder is not called Documents on all Windows versions. My suggestion is to go with the semi-workable solution because it is better than what we do today.
- login: "apnadkarni"
- mimetype: "text/plain"