Skip to content
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: add Windows support #1789

Closed
gopherbot opened this issue May 8, 2011 · 6 comments
Closed

os/user: add Windows support #1789

gopherbot opened this issue May 8, 2011 · 6 comments

Comments

@gopherbot
Copy link

by paulo.jpinto:

What steps will reproduce the problem?
1. Create an application that makes use of os.user on Windows
2. Compile it
3. Execute it

What is the expected output?
Real information about existing Windows users

What do you see instead?
Dummy results.

Which compiler are you using (5g, 6g, 8g, gccgo)?
Problem applies to all compilers.

Which operating system are you using?
Windows

Which revision are you using?  (hg identify)
2f0fa51fa2da+ weekly/weekly.2011-04-27

Please provide any additional information below.
I am creating an issue to better track down the discussion we are having on the mailing
list:

http://groups.google.com/group/golang-nuts/browse_thread/thread/c464373522f92d7c

The attached file contains the modified source files that provide initial support for
os.user on Windows, plus some hacks I needed to do to mkerrors_windows.sh to make it
properly run under my go_mingw installation.


The original issue is of course, that the actual os.user package does not provide any
real functionality under Windows, just a set of dummy functions.

I have added enough entry points to syscall, that now it is possible to get the user
name from a SID and vice-versa. But there are other issues that are not that easy to
solve and maintain a kind of portable implementation.

The way Windows security works, it is only possible to obtain the user home directory,
in two possible ways:
 - Asking the information for the owner of the current process
 - Login in the user into the system and make use of the logon token

For the second option, the user's password is required.

There is a possible way how to fetch the user's profile, but it only works if the user
has already logged at least once, and is an undocumented feature.

Regarding getting the user's fullname, it only works properly for the users defined on
the local security database (SAM) or if the system can fetch the user data from the
domain server, which might not work all the time.

Currently there are two issues that affect the design of a portable os.user:
 1 - Not possible to fetch the homedir for any user with the lookup functions;
 2 - It is not guaranteed that a fullname can be provided in all queries. Plus it suffers a restriction similar to the homedir

Attachments:

  1. pkg.zip (13287 bytes)
@alexbrainman
Copy link
Member

Comment 1:

Thank you for taking it on.
It's very hard to comment on your code. If you would like to contribute, please, use
codereview http://golang.org/doc/contribute.html. 
Alex

Labels changed: added packagebug, os-windows.

Owner changed to @alexbrainman.

Status changed to Accepted.

@gopherbot
Copy link
Author

Comment 2 by paulo.jpinto:

I did not follow the contribute process, because my code is still a bit rough.
As I mentioned I had to hack the mkerrors_windows.sh to generate missing error
identifiers in the mingw based build.
Plus we were still discussing how os.user might look like.
But if that is the route I should take, I will use the codereview process.

@gopherbot
Copy link
Author

Comment 3 by paulo.jpinto:

Hi,
the code is now available for review,
http://golang.org/cl/4521053

@rsc
Copy link
Contributor

rsc commented Dec 9, 2011

Comment 4:

Labels changed: added priority-later, removed priority-medium.

@rsc
Copy link
Contributor

rsc commented Jan 29, 2012

Comment 5:

I believe Alex is working on this.

@alexbrainman
Copy link
Member

Comment 6:

This issue was closed by revision dcbc77d.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants