Conversation
|
Is this the only thing we need/want from |
There was a problem hiding this comment.
We can now document functions with automagic links to man pages:
":man:getaddrinfo(3)"
Yes, it would be nice, but we are limited by the Windows side. Separate calls are needed for all of these things - |
I don't know, just wondering :-) Maybe some uv_passwd_t, with the common subset of things would be a good thing. On Unix we could fill in more things than on Windows. As a side note, Python does this: https://docs.python.org/2/library/getpass.html#getpass.getuser that is, it reads the environment variables to get the username. Doesn't sound very reliable though. |
fe57056 to
c98af6d
Compare
|
@saghul I updated the PR based on your comments, minus moving to the |
|
@piscisaureus ping |
There was a problem hiding this comment.
- use
len - 1because otherwise adding the null terminator (couple lines below) could cause a buffer overrun. - I'd prefer to use
WideCharToMultiByteinstead ofwcstombslike we do everywhere in libuv.
|
@piscisaureus sorry I should have added this to my ping. Please see my message when I originally opened the PR. I'm having problems with Windows and including |
There was a problem hiding this comment.
What's implied here is that the returned length doesn't include the null terminator.
I have no particular opinion on whether that's good or bad, but please ensure that this API behaves the same as the unix version, and be consistent with other path-returning functions (e.g. uv_cwd())
Just make sure |
|
Some other comments:
|
8280d15 to
9d26496
Compare
|
@piscisaureus thank you for the help. I've updated the PR based on your comments. The unix and windows branches both ignore the null terminator when returning the length. Also, in my testing I didn't encounter any trailing slashes on the home directories. The |
|
@cjihrig Great. The windows bits lgtm. I guess @bnoordhuis or @saghul could review the unix implementation. I'm a bit surprised that looking up the home dir requires retrieving the username first - looks like |
|
I'm traveling ATM, I'll have a look on Monday, if Ben doesn't beat me to it
|
There was a problem hiding this comment.
This looks incorrect to me. Most platforms leave _POSIX_LOGIN_NAME_MAX at the POSIX default of 9 (8 characters + zero byte) even though their real maximum is much larger.
|
I don't have much say in how libuv behaves, but to me it seems that truncating is not helpful, and instead it would be better to return |
There was a problem hiding this comment.
Probably unlikely, but we should check GetLastError here, in case it's ERROR_ENVVAR_NOT_FOUND it's not an error, we should just continue. I see you handle it later, but I guess we need to check both times, because threads!
@bnoordhuis but they do! https://github.com/libuv/libuv/blob/v1.x/src/uv-common.c#L373 |
bf12f74 to
c22b2f4
Compare
|
Another round of updates pushed :-) |
|
Great! let's establish some common patterns |
|
Build has tons of red, but that has nothing to do with this patch, great work @cjihrig! |
There was a problem hiding this comment.
One last thing (if you're not around I'll add it during merge) can you add a ".. versionadded 1.6.0" here please? :-)
|
Fantastic! Can we get another LGTM? /cc @bnoordhuis, @piscisaureus |
There was a problem hiding this comment.
I'd rather you stick to getpwuid_r() here. getenv() at least is MT-safe on most platforms if no other threads concurrently modify the environment, but getpwuid() is basically always unsafe.
There was a problem hiding this comment.
Oh I missed that during my review. Agreed!
There was a problem hiding this comment.
@bnoordhuis @saghul restored getpwuid_r().
|
LGTM |
|
Kewl, I'll merge then. |
PR-URL: #350 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
|
Great work Colin! Landed in ✨ a62c2d5 ✨ |
|
Thanks Saul/Ben/Bert for working with me through this. |
PR-URL: libuv#350 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
PR-URL: libuv#350 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
PR-URL: libuv#350 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This is a first pass at implementing a
homedir()function, per the discussion in nodejs/node#1670.@piscisaureus I'm running into a problem on the Windows side, where including
shlobj.h(needed forSHGetKnownFolderPath()) is causing a ton of compiler errors. Any assistance would be much appreciated.Also related to #11.