Mitch Capper wrote:
> For requests to get the actual username I don't know if it is better to:
> 1) Try the official API GetUserName but it requires an additional windows
> library if it is not already included (which most of the time it is not)
> https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getusernamea
> 2) Rely on the environmental variable USERNAME which should contain the
> current user but clearly is just an ENV var
> 3) Return some constant value
> 
> I would be inclined to do #2, it will be correct most of the time but not
> have additional deps.

Gnulib's getlogin() and getlogin_r() functions use 1). We have stuffed the
link dependency into a variable GETLOGIN_LIB.

And the unit test for these functions use 2) and verify that the two results
agree.

> For the uid/gid if there is a specific constant we want to stick to for
> windows I can try to make sure to standardize on that.

The uid, gid is the hard part, that has no correspondence in the Windows API.

Bruno




Reply via email to