Software / code / prosody
Comparison
prosodyctl @ 1119:61a011ebe243
Merge with 0.4
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 05 May 2009 14:20:26 +0100 |
| parent | 1115:8a7bc1a5eae6 |
| child | 1120:23fa69b911f7 |
comparison
equal
deleted
inserted
replaced
| 1112:e8a00a2ea910 | 1119:61a011ebe243 |
|---|---|
| 59 print(""); | 59 print(""); |
| 60 os.exit(1); | 60 os.exit(1); |
| 61 end | 61 end |
| 62 end | 62 end |
| 63 | 63 |
| 64 -- Switch away from root and into the prosody user -- | |
| 65 local switched_user, current_uid; | |
| 66 local ok, pposix = pcall(require, "util.pposix"); | |
| 67 if ok and pposix then | |
| 68 current_uid = pposix.getuid(); | |
| 69 if current_uid == 0 then | |
| 70 -- We haz root! | |
| 71 local desired_user = config.get("*", "core", "prosody_user") or "prosody"; | |
| 72 local ok, err = pposix.setuid(desired_user); | |
| 73 if ok then | |
| 74 -- Yay! | |
| 75 switched_user = true; | |
| 76 else | |
| 77 -- Boo! | |
| 78 print("Warning: Couldn't switch to Prosody user '"..tostring(desired_user).."': "..tostring(err)); | |
| 79 end | |
| 80 end | |
| 81 else | |
| 82 print("Error: Unable to load pposix module. Check that Prosody is installed correctly.") | |
| 83 print("For more help send the below error to us through http://prosody.im/discuss"); | |
| 84 print(tostring(pposix)) | |
| 85 end | |
| 86 | |
| 64 local error_messages = setmetatable({ | 87 local error_messages = setmetatable({ |
| 65 ["invalid-username"] = "The given username is invalid in a Jabber ID"; | 88 ["invalid-username"] = "The given username is invalid in a Jabber ID"; |
| 66 ["invalid-hostname"] = "The given hostname is invalid"; | 89 ["invalid-hostname"] = "The given hostname is invalid"; |
| 67 ["no-password"] = "No password was supplied"; | 90 ["no-password"] = "No password was supplied"; |
| 68 ["no-such-user"] = "The given user does not exist on the server"; | 91 ["no-such-user"] = "The given user does not exist on the server"; |
| 289 end | 312 end |
| 290 show_message("Prosody is running with PID %s", ret or "(unknown)"); | 313 show_message("Prosody is running with PID %s", ret or "(unknown)"); |
| 291 return 0; | 314 return 0; |
| 292 else | 315 else |
| 293 show_message("Prosody is not running"); | 316 show_message("Prosody is not running"); |
| 317 if not switched_user and current_uid ~= 0 then | |
| 318 print("\nNote: You will also see this if prosodyctl is not running under the same"); | |
| 319 print(" user account as Prosody. Try running as root (e.g. with 'sudo' in front) to"); | |
| 320 print(" gain access to Prosody's real status."); | |
| 321 end | |
| 294 return 2 | 322 return 2 |
| 295 end | 323 end |
| 296 return 1; | 324 return 1; |
| 297 end | 325 end |
| 298 | 326 |