From d72ba1533e852f33dd085e5054c79c554545fd06 Mon Sep 17 00:00:00 2001 From: Someguynamedpie Date: Wed, 27 Mar 2019 18:40:50 -0500 Subject: [PATCH] Update unixstream.c SO_PEERCRED, cont'd. --- src/unixstream.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/unixstream.c b/src/unixstream.c index 85cf4a8..5044ea3 100644 --- a/src/unixstream.c +++ b/src/unixstream.c @@ -58,6 +58,9 @@ static luaL_Reg unixstream_methods[] = { {"getsockname", meth_getsockname}, {"settimeout", meth_settimeout}, {"shutdown", meth_shutdown}, +#ifndef _WIN32 + {"getoption", meth_getoption}, +#endif {NULL, NULL} }; @@ -66,6 +69,9 @@ static t_opt optset[] = { {"keepalive", opt_set_keepalive}, {"reuseaddr", opt_set_reuseaddr}, {"linger", opt_set_linger}, +#ifndef _WIN32 + {"passcred", opt_set_passcred}, +#endif {NULL, NULL} }; @@ -75,6 +81,14 @@ static luaL_Reg func[] = { {NULL, NULL} }; +#ifndef _WIN32 + +static t_opt optget[] = { + {"passcred", opt_get_passcred}, + {"peercred", opt_get_peercred}, + {NULL, NULL} +}; +#endif /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ @@ -128,6 +142,11 @@ static int meth_setoption(lua_State *L) { return opt_meth_setoption(L, optset, &un->sock); } +static int meth_getoption(lua_State *L) { + p_unix un = (p_unix) auxiliar_checkgroup(L, "unixstream{any}", 1); + return opt_meth_getoption(L, optget, &un->sock); +} + /*-------------------------------------------------------------------------*\ * Select support methods \*-------------------------------------------------------------------------*/