mod_c2s: Use module:add_item() to add the net-provider for portmanager
[prosody.git] / util-src / pposix.c
index ffd2128835ddb9124cc8fb858a23be23e8e2734a..dae48390ab9e9a08eec7e81e0647075f4a07eb39 100644 (file)
@@ -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;
 }