Software /
code /
prosody
Changeset
8672:86b12ae8d427
util.startup: Expose user switching information via prosody global object
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 22 Mar 2018 22:35:27 +0000 |
parents | 8671:a4899174a894 |
children | 8673:6aeed79d9283 |
files | util/startup.lua |
diffstat | 1 files changed, 4 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/util/startup.lua Thu Mar 22 22:33:42 2018 +0000 +++ b/util/startup.lua Thu Mar 22 22:35:27 2018 +0000 @@ -364,7 +364,6 @@ -- NOTE: This function is only used by prosodyctl. -- The prosody process is built with the assumption that -- it is already started as the appropriate user. - local switched_user, current_uid; local want_pposix_version = "0.4.0"; local have_pposix, pposix = pcall(require, "util.pposix"); @@ -375,10 +374,10 @@ tostring(pposix._VERSION), want_pposix_version)); os.exit(1); end - current_uid = pposix.getuid(); + prosody.current_uid = pposix.getuid(); local arg_root = arg[1] == "--root"; if arg_root then table.remove(arg, 1); end - if current_uid == 0 and config.get("*", "run_as_root") ~= true and not arg_root then + if prosody.current_uid == 0 and config.get("*", "run_as_root") ~= true and not arg_root then -- We haz root! local desired_user = config.get("*", "prosody_user") or "prosody"; local desired_group = config.get("*", "prosody_group") or desired_user; @@ -390,10 +389,10 @@ ok, err = pposix.setuid(desired_user); if ok then -- Yay! - switched_user = true; + prosody.switched_user = true; end end - if not switched_user then + if not prosody.switched_user then -- Boo! print("Warning: Couldn't switch to Prosody user/group '"..tostring(desired_user).."'/'"..tostring(desired_group).."': "..tostring(err)); else