# HG changeset patch # User Matthew Wild # Date 1283264079 -3600 # Node ID 72d3c8029178d4c577ec61ffe14bbbe7418a6a5b # Parent 97831dfe7f7284b801184c766a3c4829e316aa75 util.pposix: Add pposix.uname(), bump version diff -r 97831dfe7f72 -r 72d3c8029178 plugins/mod_posix.lua --- a/plugins/mod_posix.lua Tue Aug 31 00:38:44 2010 +0100 +++ b/plugins/mod_posix.lua Tue Aug 31 15:14:39 2010 +0100 @@ -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 -r 97831dfe7f72 -r 72d3c8029178 prosodyctl --- a/prosodyctl Tue Aug 31 00:38:44 2010 +0100 +++ b/prosodyctl Tue Aug 31 15:14:39 2010 +0100 @@ -79,7 +79,7 @@ -- 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 -r 97831dfe7f72 -r 72d3c8029178 util-src/pposix.c --- a/util-src/pposix.c Tue Aug 31 00:38:44 2010 +0100 +++ b/util-src/pposix.c Tue Aug 31 15:14:39 2010 +0100 @@ -13,7 +13,7 @@ * POSIX support functions for Lua */ -#define MODULE_VERSION "0.3.4" +#define MODULE_VERSION "0.3.5" #include #include @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -553,6 +554,28 @@ 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 @@ { "setrlimit", lc_setrlimit }, { "getrlimit", lc_getrlimit }, + { "uname", lc_uname }, + { NULL, NULL } };