{"thread":{"id":"55016","subject":"Incorrect $HOME value when using runas on Windows","startedAt":"2021-01-20T11:33:20Z","lastAt":"2021-01-22T13:55:44Z","messageCount":3,"participants":["Mail","brian m. carlson","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"414783","messageId":"b2b0fd42-14a8-fbb6-8817-4e53efb9e730@dragonsoul.com","threadId":"55016","inReplyTo":null,"subject":"Incorrect $HOME value when using runas on Windows","fromName":"Mail","fromEmail":"mail@dragonsoul.com","sentAt":"2021-01-20T10:12:57Z","receivedAt":"2021-01-20T11:33:20Z","isPatch":false,"sender":{"key":"mail@dragonsoul.com","avatar":null},"body":"To reproduce the issue:\n1. Install git-windows x32 or x64 for all users.\n2. Install Total Commader or any other file manager that support system \ncontext menu\n3. Add user in Windows via msc or settings app and set password. Don't \nforget to disable \"User must change password on first login\" in case \nuser created via msc\n4. In current user session execute runas.exe /user:NewlyCreatedUser \n\"Path To File Manager\"\n5. Right click on empty space in file list and choose Git bash here\n6. Type `echo $HOME` in bash console and press enter\n7. The $HOME is `/c/Windows/System32`. Expected `/c/Users/NewlyCreatedUser`\nIt seems git for windows uses HOMEPATH that points to system32 in case \nof runas command. Might be using USERPROFILE variable is better.\n"},{"id":"414947","messageId":"YAoraIvKWWRj4cLJ@camp.crustytoothpaste.net","threadId":"55016","inReplyTo":"b2b0fd42-14a8-fbb6-8817-4e53efb9e730@dragonsoul.com","subject":"Re: Incorrect $HOME value when using runas on Windows","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-01-22T01:33:28Z","receivedAt":"2021-01-22T01:34:49Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-01-20 at 10:12:57, Mail wrote:\n> To reproduce the issue:\n> 1. Install git-windows x32 or x64 for all users.\n> 2. Install Total Commader or any other file manager that support system\n> context menu\n> 3. Add user in Windows via msc or settings app and set password. Don't\n> forget to disable \"User must change password on first login\" in case user\n> created via msc\n> 4. In current user session execute runas.exe /user:NewlyCreatedUser \"Path To\n> File Manager\"\n> 5. Right click on empty space in file list and choose Git bash here\n> 6. Type `echo $HOME` in bash console and press enter\n> 7. The $HOME is `/c/Windows/System32`. Expected `/c/Users/NewlyCreatedUser`\n> It seems git for windows uses HOMEPATH that points to system32 in case of\n> runas command. Might be using USERPROFILE variable is better.\n\nI'd recommend reporting this to the Git for Windows project[0].  The\nsetting of $HOME is normally a feature provided automatically by\nUnix-like operating systems, and its behavior in the MSYS environment is\ncontrolled by Git for Windows.\n\n[0] https://github.com/git-for-windows/git\n-- \nbrian m. carlson (he/him or they/them)\nHouston, Texas, US\n"},{"id":"414968","messageId":"nycvar.QRO.7.76.6.2101221432460.52@tvgsbejvaqbjf.bet","threadId":"55016","inReplyTo":"YAoraIvKWWRj4cLJ@camp.crustytoothpaste.net","subject":"Re: Incorrect $HOME value when using runas on Windows","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2021-01-22T13:54:02Z","receivedAt":"2021-01-22T13:55:44Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 22 Jan 2021, brian m. carlson wrote:\n\n> On 2021-01-20 at 10:12:57, Mail wrote:\n> > To reproduce the issue:\n> > 1. Install git-windows x32 or x64 for all users.\n> > 2. Install Total Commader or any other file manager that support system\n> > context menu\n> > 3. Add user in Windows via msc or settings app and set password. Don't\n> > forget to disable \"User must change password on first login\" in case user\n> > created via msc\n> > 4. In current user session execute runas.exe /user:NewlyCreatedUser \"Path To\n> > File Manager\"\n> > 5. Right click on empty space in file list and choose Git bash here\n> > 6. Type `echo $HOME` in bash console and press enter\n> > 7. The $HOME is `/c/Windows/System32`. Expected `/c/Users/NewlyCreatedUser`\n> > It seems git for windows uses HOMEPATH that points to system32 in case of\n> > runas command. Might be using USERPROFILE variable is better.\n>\n> I'd recommend reporting this to the Git for Windows project[0].  The\n> setting of $HOME is normally a feature provided automatically by\n> Unix-like operating systems, and its behavior in the MSYS environment is\n> controlled by Git for Windows.\n>\n> [0] https://github.com/git-for-windows/git\n\nThere is actually already a ticket about this:\nhttps://github.com/git-for-windows/git/issues/2709\n\nI integrated a patch that fixes this from `git.exe`'s side, but had\nforgotten the `git-bash.exe` side. Here is a PullRequest to address this:\n\n\thttps://github.com/git-for-windows/MINGW-packages/pull/45\n\nMail (if this is your real name, if not, please substitute your real name\nin your mind), feel free to test that PR's code and report back whether it\nsolves your problem or not.\n\nCiao,\nJohannes\n"}]}