diff options
author | Kim Alvefur <zash@zash.se> | 2011-11-18 06:13:24 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2011-11-18 06:13:24 +0100 |
commit | 06ae7417fb6d3fbfc3b2e3963a7dd74082f19cc4 (patch) | |
tree | a3533967fb5bd17d772eb83eb5ad1836a41ccab8 | |
parent | 011d76ac7652be0ca1b3e0c8b78975b2a8c66715 (diff) | |
download | prosody-06ae7417fb6d3fbfc3b2e3963a7dd74082f19cc4.tar.gz prosody-06ae7417fb6d3fbfc3b2e3963a7dd74082f19cc4.zip |
util.pposix: Don't trust errno for success. Thanks Quince
-rw-r--r-- | util-src/pposix.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/util-src/pposix.c b/util-src/pposix.c index ffd21288..dae48390 100644 --- a/util-src/pposix.c +++ b/util-src/pposix.c @@ -395,23 +395,27 @@ int lc_initgroups(lua_State* L) return 2; } ret = initgroups(lua_tostring(L, 1), gid); - switch(errno) + if(ret) + { + switch(errno) + { + case ENOMEM: + lua_pushnil(L); + lua_pushstring(L, "no-memory"); + break; + case EPERM: + lua_pushnil(L); + lua_pushstring(L, "permission-denied"); + break; + default: + lua_pushnil(L); + lua_pushstring(L, "unknown-error"); + } + } + else { - case 0: lua_pushboolean(L, 1); lua_pushnil(L); - break; - case ENOMEM: - lua_pushnil(L); - lua_pushstring(L, "no-memory"); - break; - case EPERM: - lua_pushnil(L); - lua_pushstring(L, "permission-denied"); - break; - default: - lua_pushnil(L); - lua_pushstring(L, "unknown-error"); } return 2; } |