prosodyctl
changeset 1114 c463e30da312
parent 1102 c81df501fd38
child 1115 8a7bc1a5eae6
equal deleted inserted replaced
1113:89ac8e9e1426 1114:c463e30da312
    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";