aboutsummaryrefslogtreecommitdiffstats
path: root/prosodyctl
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-05-05 14:20:26 +0100
committerMatthew Wild <mwild1@gmail.com>2009-05-05 14:20:26 +0100
commit794ba972aff856e82e95f20d593b8d318d23654b (patch)
tree8e18b577e3bfdd1834e4dfc747b96003fbc079b4 /prosodyctl
parent2fff09895975e5b2fb3d0aee38c2f652c6029e15 (diff)
parenta4afb372653da9df1bc407230838a7bb958242ac (diff)
downloadprosody-794ba972aff856e82e95f20d593b8d318d23654b.tar.gz
prosody-794ba972aff856e82e95f20d593b8d318d23654b.zip
Merge with 0.4
Diffstat (limited to 'prosodyctl')
-rwxr-xr-xprosodyctl28
1 files changed, 28 insertions, 0 deletions
diff --git a/prosodyctl b/prosodyctl
index 7998d033..f451b7ee 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -61,6 +61,29 @@ do
end
end
+-- Switch away from root and into the prosody user --
+local switched_user, current_uid;
+local ok, pposix = pcall(require, "util.pposix");
+if ok and pposix then
+ current_uid = pposix.getuid();
+ if current_uid == 0 then
+ -- We haz root!
+ local desired_user = config.get("*", "core", "prosody_user") or "prosody";
+ local ok, err = pposix.setuid(desired_user);
+ if ok then
+ -- Yay!
+ switched_user = true;
+ else
+ -- Boo!
+ print("Warning: Couldn't switch to Prosody user '"..tostring(desired_user).."': "..tostring(err));
+ end
+ end
+else
+ print("Error: Unable to load pposix module. Check that Prosody is installed correctly.")
+ print("For more help send the below error to us through http://prosody.im/discuss");
+ print(tostring(pposix))
+end
+
local error_messages = setmetatable({
["invalid-username"] = "The given username is invalid in a Jabber ID";
["invalid-hostname"] = "The given hostname is invalid";
@@ -291,6 +314,11 @@ function commands.status(arg)
return 0;
else
show_message("Prosody is not running");
+ if not switched_user and current_uid ~= 0 then
+ print("\nNote: You will also see this if prosodyctl is not running under the same");
+ print(" user account as Prosody. Try running as root (e.g. with 'sudo' in front) to");
+ print(" gain access to Prosody's real status.");
+ end
return 2
end
return 1;