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_get_passwd: Fix potential omission of gid/uid values in non-Windows environments #591

Merged
merged 1 commit into from
Mar 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,15 @@ static int luv_os_get_passwd(lua_State* L) {
lua_pushstring(L, pwd.username);
lua_setfield(L, -2, "username");
}
if (pwd.uid != -1) {
lua_pushinteger(L, pwd.uid);
lua_setfield(L, -2, "uid");
}
if (pwd.gid != -1) {
lua_pushinteger(L, pwd.gid);
lua_setfield(L, -2, "gid");
}
// From the uv_os_get_passwd docs:
// "On Windows, uid and gid are set to -1 and have no meaning"
// so we omit these fields on Windows.
#ifndef _WIN32
lua_pushinteger(L, pwd.uid);
lua_setfield(L, -2, "uid");
lua_pushinteger(L, pwd.gid);
lua_setfield(L, -2, "gid");
#endif
if (pwd.shell) {
lua_pushstring(L, pwd.shell);
lua_setfield(L, -2, "shell");
Expand Down