-
Notifications
You must be signed in to change notification settings - Fork 17.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os/user: On windows, current() -> t.GetUserProfileDirectory() errors when for RemoteInteractive Logon session on system without user profile #37348
Comments
Could you please update issue detail to describe version or conditions your Windows OS? And #30102 seems not depend on this issue. |
Mistake on adding the issue number, @christophert can you send OS Version & Release information. |
@mattn We're running Windows Server 2016 Version 1607 Build 14393.3326. The error we get back from |
Could you please confirm that following key exists on the remote server?
You can get UID with using simple code. package main
import (
"fmt"
"os/user"
)
func main() {
u, _ := user.Current()
fmt.Println(u.Uid)
} |
@mattn The key does not exist when you PSRemote into a machine you haven't interactively logged into before. The code snippet you posted will fail because the call to |
/cc @bradfitz |
@gopherbot add OS-Windows |
I am not security expert. I wouldn't trust myself making any decisions here. Sorry. Maybe Jason have some opinion about this. Alex |
Looks like the issue is that sometimes current() is unable to get the user profile directory but is able to get the other information. @khyberspache's proposal appears to be to just make getting the user profile directory non-fatal, and having that be a nil field inside the returned struct. That seems probably fine. |
Something like this would allow for a dir, e := t.GetUserProfileDirectory()
if e != nil && e != syscall.ERROR_FILE_NOT_FOUND {
return nil, e
} |
What happens, if home disrectlry exists and t.GetUserProfileDirectory returns syscall.ERROR_FILE_NOT_FOUND for a reason? Alex |
I'd have to dig into the implementation of dir, e := t.GetUserProfileDirectory()
if e !=nil {
dir = nil
} |
I am not sure that is better than your original proposal. And I don't have good suggestions. Leaving for others to decide. Alex |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Attempted to use WMIC/PSRemote to interact with a system to launch a GO executable that logs the current user (aka PSSession user/WMI exec) using
user.Current()
. User returns asnil
with errThe system cannot find the file specified.
because the user does not have a home directory on the remote system.Platform:
Windows Server 2016 Version 1607 Build 14393.3326
What did you expect to see?
Valid User structure with Dir as nil/empty string.
os/user/lookup_windows.go:184
What did you see instead?
No user returned, error stated above.
Extra information
The specific issue resides in how
t.GetUserProfileDirectory()
is handled incurrent()
:In windows environments it is possible to have a login type where the user doesn't have a Home Directory on that system (all remote windows domain administrator tasks). I will submit a PR with a proposed solution to this.
@christophert and I discovered this while trying to start remote tasks on Windows system that we had never logged into.
The text was updated successfully, but these errors were encountered: