Skip to content

Commit f582cf5

Browse files
committed
breaking change: Remove ad-hoc setuid/setgid bindings
These functions aren't coming from libuv, they aren't portable (to the point of the function bindings being wrapped a #ifndef _WIN32), and there's proper support for setgid/setuid in the libuv process spawning API. These functions are also seemingly unused except by a single personal project for which the bindings were added in the first place. The ad-hoc getuid/getgid functions do see some use in neovim plugins, so they remain but it's now recommended to use the proper `os_get_passwd` function from libuv instead. There's also some potential security issues around setuid/setgid that we aren't dealing with correctly and there's no good reason to take on that responsibility (closes #341).
1 parent f65fe9d commit f582cf5

File tree

5 files changed

+22
-78
lines changed

5 files changed

+22
-78
lines changed

docs/docs.lua

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4442,35 +4442,25 @@ local doc = {
44424442
desc = 'Returns the user ID of the process.',
44434443
returns = 'integer',
44444444
notes = {
4445-
'This is not a libuv function and is not supported on Windows.',
4445+
'This is not a libuv function and does not exist when targeting Windows.',
4446+
},
4447+
warnings = {
4448+
[[
4449+
This is a legacy function that may be removed in the future. It's recommended to use `uv.os_get_passwd()` instead.
4450+
]],
44464451
},
44474452
},
44484453
{
44494454
name = 'getgid',
44504455
desc = 'Returns the group ID of the process.',
44514456
returns = 'integer',
44524457
notes = {
4453-
'This is not a libuv function and is not supported on Windows.',
4454-
},
4455-
},
4456-
{
4457-
name = 'setuid',
4458-
desc = 'Sets the user ID of the process with the integer `id`.',
4459-
params = {
4460-
{ name = 'id', type = 'integer' },
4461-
},
4462-
notes = {
4463-
'This is not a libuv function and is not supported on Windows.',
4464-
},
4465-
},
4466-
{
4467-
name = 'setgid',
4468-
desc = 'Sets the group ID of the process with the integer `id`.',
4469-
params = {
4470-
{ name = 'id', type = 'integer' },
4458+
'This is not a libuv function and does not exist when targeting Windows.',
44714459
},
4472-
notes = {
4473-
'This is not a libuv function and is not supported on Windows.',
4460+
warnings = {
4461+
[[
4462+
This is a legacy function that may be removed in the future. It's recommended to use `uv.os_get_passwd()` instead.
4463+
]],
44744464
},
44754465
},
44764466
{

docs/docs.md

Lines changed: 5 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/meta.lua

Lines changed: 6 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/luv.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,7 @@ static const luaL_Reg luv_functions[] = {
329329
{"getpid", luv_getpid},
330330
#ifndef _WIN32
331331
{"getuid", luv_getuid},
332-
{"setuid", luv_setuid},
333332
{"getgid", luv_getgid},
334-
{"setgid", luv_setgid},
335333
#endif
336334
{"getrusage", luv_getrusage},
337335
#if LUV_UV_VERSION_GEQ(1, 50, 0)

src/misc.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -473,24 +473,6 @@ static int luv_getgid(lua_State* L){
473473
return 1;
474474
}
475475

476-
static int luv_setuid(lua_State* L){
477-
int uid = luaL_checkinteger(L, 1);
478-
int r = setuid(uid);
479-
if (-1 == r) {
480-
luaL_error(L, "Error setting UID");
481-
}
482-
return 0;
483-
}
484-
485-
static int luv_setgid(lua_State* L){
486-
int gid = luaL_checkinteger(L, 1);
487-
int r = setgid(gid);
488-
if (-1 == r) {
489-
luaL_error(L, "Error setting GID");
490-
}
491-
return 0;
492-
}
493-
494476
#if LUV_UV_VERSION_GEQ(1, 8, 0)
495477
static int luv_print_all_handles(lua_State* L){
496478
luv_ctx_t* ctx = luv_context(L);

0 commit comments

Comments
 (0)