Software /
code /
prosody
Comparison
util/startup.lua @ 10597:25a3c8134b0a 0.11
prosody/util.startup: Switch to parse_args() for --root and --config
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 19 Jan 2020 15:27:16 +0000 |
parent | 10596:cb107ea49b35 |
child | 10599:4f655918fef1 |
child | 10600:08f2fe5ac30f |
comparison
equal
deleted
inserted
replaced
10596:cb107ea49b35 | 10597:25a3c8134b0a |
---|---|
68 | 68 |
69 function startup.read_config() | 69 function startup.read_config() |
70 local filenames = {}; | 70 local filenames = {}; |
71 | 71 |
72 local filename; | 72 local filename; |
73 if arg[1] == "--config" and arg[2] then | 73 if prosody.opts.config then |
74 table.insert(filenames, arg[2]); | 74 table.insert(filenames, prosody.opts.config); |
75 if CFG_CONFIGDIR then | 75 if CFG_CONFIGDIR then |
76 table.insert(filenames, CFG_CONFIGDIR.."/"..arg[2]); | 76 table.insert(filenames, CFG_CONFIGDIR.."/"..prosody.opts.config); |
77 end | 77 end |
78 table.remove(arg, 1); table.remove(arg, 1); | |
79 elseif os.getenv("PROSODY_CONFIG") then -- Passed by prosodyctl | 78 elseif os.getenv("PROSODY_CONFIG") then -- Passed by prosodyctl |
80 table.insert(filenames, os.getenv("PROSODY_CONFIG")); | 79 table.insert(filenames, os.getenv("PROSODY_CONFIG")); |
81 else | 80 else |
82 table.insert(filenames, (CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); | 81 table.insert(filenames, (CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); |
83 end | 82 end |
457 print(string.format("Unknown version (%s) of binary pposix module, expected %s", | 456 print(string.format("Unknown version (%s) of binary pposix module, expected %s", |
458 tostring(pposix._VERSION), want_pposix_version)); | 457 tostring(pposix._VERSION), want_pposix_version)); |
459 os.exit(1); | 458 os.exit(1); |
460 end | 459 end |
461 prosody.current_uid = pposix.getuid(); | 460 prosody.current_uid = pposix.getuid(); |
462 local arg_root = arg[1] == "--root"; | 461 local arg_root = prosody.opts.root; |
463 if arg_root then table.remove(arg, 1); end | |
464 if prosody.current_uid == 0 and config.get("*", "run_as_root") ~= true and not arg_root then | 462 if prosody.current_uid == 0 and config.get("*", "run_as_root") ~= true and not arg_root then |
465 -- We haz root! | 463 -- We haz root! |
466 local desired_user = config.get("*", "prosody_user") or "prosody"; | 464 local desired_user = config.get("*", "prosody_user") or "prosody"; |
467 local desired_group = config.get("*", "prosody_group") or desired_user; | 465 local desired_group = config.get("*", "prosody_group") or desired_user; |
468 local ok, err = pposix.setgid(desired_group); | 466 local ok, err = pposix.setgid(desired_group); |
567 end | 565 end |
568 end | 566 end |
569 | 567 |
570 -- prosodyctl only | 568 -- prosodyctl only |
571 function startup.prosodyctl() | 569 function startup.prosodyctl() |
570 startup.parse_args(); | |
572 startup.init_global_state(); | 571 startup.init_global_state(); |
573 startup.read_config(); | 572 startup.read_config(); |
574 startup.force_console_logging(); | 573 startup.force_console_logging(); |
575 startup.init_logging(); | 574 startup.init_logging(); |
576 startup.setup_plugindir(); | 575 startup.setup_plugindir(); |
587 end | 586 end |
588 | 587 |
589 function startup.prosody() | 588 function startup.prosody() |
590 -- These actions are in a strict order, as many depend on | 589 -- These actions are in a strict order, as many depend on |
591 -- previous steps to have already been performed | 590 -- previous steps to have already been performed |
591 startup.parse_args(); | |
592 startup.init_global_state(); | 592 startup.init_global_state(); |
593 startup.read_config(); | 593 startup.read_config(); |
594 startup.init_logging(); | 594 startup.init_logging(); |
595 startup.sanity_check(); | 595 startup.sanity_check(); |
596 startup.sandbox_require(); | 596 startup.sandbox_require(); |