diff options
author | Matthew Wild <mwild1@gmail.com> | 2018-03-22 22:35:27 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2018-03-22 22:35:27 +0000 |
commit | d93d78a56b9eee3132f23970a700f97f0c172666 (patch) | |
tree | 70a6c86fe4a5aff9ba1d180a4ea5be4d1b544170 /util/startup.lua | |
parent | bcfd829b6d76f47241dfba1afeead81438e996b1 (diff) | |
download | prosody-d93d78a56b9eee3132f23970a700f97f0c172666.tar.gz prosody-d93d78a56b9eee3132f23970a700f97f0c172666.zip |
util.startup: Expose user switching information via prosody global object
Diffstat (limited to 'util/startup.lua')
-rw-r--r-- | util/startup.lua | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/util/startup.lua b/util/startup.lua index d8d9866f..d8f67d4e 100644 --- a/util/startup.lua +++ b/util/startup.lua @@ -364,7 +364,6 @@ function startup.switch_user() -- 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 @@ function startup.switch_user() 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 @@ function startup.switch_user() 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 |