aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-08-31 15:14:39 +0100
committerMatthew Wild <mwild1@gmail.com>2010-08-31 15:14:39 +0100
commit50b20f4af49bda557b78da9f7d3cb6b1f620e7e8 (patch)
tree729448ab0d6cae1fb77a55dcdc0391dc0f57c603
parentc14f4168f2ae10f931f46ec9d43029bce889369f (diff)
downloadprosody-50b20f4af49bda557b78da9f7d3cb6b1f620e7e8.tar.gz
prosody-50b20f4af49bda557b78da9f7d3cb6b1f620e7e8.zip
util.pposix: Add pposix.uname(), bump version
-rw-r--r--plugins/mod_posix.lua2
-rwxr-xr-xprosodyctl2
-rw-r--r--util-src/pposix.c27
3 files changed, 28 insertions, 3 deletions
diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua
index 38195b13..a3c01cfb 100644
--- a/plugins/mod_posix.lua
+++ b/plugins/mod_posix.lua
@@ -7,7 +7,7 @@
--
-local want_pposix_version = "0.3.4";
+local want_pposix_version = "0.3.5";
local pposix = assert(require "util.pposix");
if pposix._VERSION ~= want_pposix_version then module:log("warn", "Unknown version (%s) of binary pposix module, expected %s", tostring(pposix._VERSION), want_pposix_version); end
diff --git a/prosodyctl b/prosodyctl
index 9af36ad9..74dade5f 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -79,7 +79,7 @@ require "util.datamanager".set_data_path(data_path);
-- Switch away from root and into the prosody user --
local switched_user, current_uid;
-local want_pposix_version = "0.3.4";
+local want_pposix_version = "0.3.5";
local ok, pposix = pcall(require, "util.pposix");
if ok and pposix then
diff --git a/util-src/pposix.c b/util-src/pposix.c
index 1b1f85fd..c5ebc4b4 100644
--- a/util-src/pposix.c
+++ b/util-src/pposix.c
@@ -13,7 +13,7 @@
* POSIX support functions for Lua
*/
-#define MODULE_VERSION "0.3.4"
+#define MODULE_VERSION "0.3.5"
#include <stdlib.h>
#include <math.h>
@@ -22,6 +22,7 @@
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/utsname.h>
#include <fcntl.h>
#include <syslog.h>
@@ -553,6 +554,28 @@ int lc_abort(lua_State* L)
return 0;
}
+int lc_uname(lua_State* L)
+{
+ struct utsname uname_info;
+ if(uname(&uname_info) != 0)
+ {
+ lua_pushstring(L, strerror(errno));
+ return 2;
+ }
+ lua_newtable(L);
+ lua_pushstring(L, uname_info.sysname);
+ lua_setfield(L, -2, "sysname");
+ lua_pushstring(L, uname_info.nodename);
+ lua_setfield(L, -2, "nodename");
+ lua_pushstring(L, uname_info.release);
+ lua_setfield(L, -2, "release");
+ lua_pushstring(L, uname_info.version);
+ lua_setfield(L, -2, "version");
+ lua_pushstring(L, uname_info.machine);
+ lua_setfield(L, -2, "machine");
+ return 1;
+}
+
/* Register functions */
int luaopen_util_pposix(lua_State *L)
@@ -582,6 +605,8 @@ int luaopen_util_pposix(lua_State *L)
{ "setrlimit", lc_setrlimit },
{ "getrlimit", lc_getrlimit },
+ { "uname", lc_uname },
+
{ NULL, NULL }
};