Mercurial > prosody-hg
comparison util/startup.lua @ 14205:a874c3f4570a 13.0
util.startup: Always apply umask (thanks Max Hearnden)
Commit c673ff1075bd removed mod_posix, and moved functionality into
util.startup, including applying a secure umask at runtime. However, the
new function was not called from the startup sequence, leading Prosody to run
with whatever umask it inherited from the environment.
Prosody Debian packages ship with a secure umask 027 in the systemd unit file
for the prosody service, so Debian systems using systemd are not affected.
prosodyctl calls the switch_user() function during startup, which would set
the umask, so prosodyctl commands which created files were unaffected.
This change makes both prosody and prosodyctl unconditionally set a secure
umask during the startup process.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 28 May 2026 17:25:46 +0100 |
| parents | a957cd3ea4eb |
| children | 2b13c24ba2d6 |
comparison
equal
deleted
inserted
replaced
| 14203:0ff587d7c742 | 14205:a874c3f4570a |
|---|---|
| 632 os.exit(1); | 632 os.exit(1); |
| 633 end | 633 end |
| 634 end | 634 end |
| 635 end | 635 end |
| 636 | 636 |
| 637 -- Set our umask to protect data files | |
| 638 pposix.umask(config.get("*", "umask") or "027"); | |
| 639 pposix.setenv("HOME", prosody.paths.data); | 637 pposix.setenv("HOME", prosody.paths.data); |
| 640 pposix.setenv("PROSODY_CONFIG", prosody.config_file); | 638 pposix.setenv("PROSODY_CONFIG", prosody.config_file); |
| 641 else | 639 else |
| 642 print("Error: Unable to load pposix module. Check that Prosody is installed correctly.") | 640 print("Error: Unable to load pposix module. Check that Prosody is installed correctly.") |
| 643 print("For more help send the below error to us through https://prosody.im/discuss"); | 641 print("For more help send the below error to us through https://prosody.im/discuss"); |
| 723 for hostname in pairs(config.getconfig()) do | 721 for hostname in pairs(config.getconfig()) do |
| 724 prosody.hosts[hostname] = startup.make_host(hostname); | 722 prosody.hosts[hostname] = startup.make_host(hostname); |
| 725 end | 723 end |
| 726 end | 724 end |
| 727 | 725 |
| 728 function startup.posix_umask() | 726 function startup.set_umask() |
| 729 if prosody.platform ~= "posix" then return end | 727 if prosody.platform ~= "posix" then return end |
| 730 local pposix = require "prosody.util.pposix"; | 728 local pposix = check_posix(); |
| 731 local umask = config.get("*", "umask") or "027"; | 729 local umask = config.get("*", "umask") or "027"; |
| 732 pposix.umask(umask); | 730 pposix.umask(umask); |
| 733 end | 731 end |
| 734 | 732 |
| 735 function startup.check_user() | 733 function startup.check_user() |
| 934 startup.setup_plugin_install_path(); | 932 startup.setup_plugin_install_path(); |
| 935 startup.setup_datadir(); | 933 startup.setup_datadir(); |
| 936 startup.chdir(); | 934 startup.chdir(); |
| 937 startup.read_version(); | 935 startup.read_version(); |
| 938 startup.switch_user(); | 936 startup.switch_user(); |
| 937 startup.set_umask(); | |
| 939 startup.check_dependencies(); | 938 startup.check_dependencies(); |
| 940 startup.log_startup_warnings(); | 939 startup.log_startup_warnings(); |
| 941 startup.check_unwriteable(); | 940 startup.check_unwriteable(); |
| 942 startup.load_libraries(); | 941 startup.load_libraries(); |
| 943 startup.init_http_client(); | 942 startup.init_http_client(); |
| 962 startup.load_libraries(); | 961 startup.load_libraries(); |
| 963 startup.setup_plugindir(); | 962 startup.setup_plugindir(); |
| 964 startup.setup_plugin_install_path(); | 963 startup.setup_plugin_install_path(); |
| 965 startup.setup_datadir(); | 964 startup.setup_datadir(); |
| 966 startup.chdir(); | 965 startup.chdir(); |
| 966 startup.set_umask(); | |
| 967 startup.add_global_prosody_functions(); | 967 startup.add_global_prosody_functions(); |
| 968 startup.read_version(); | 968 startup.read_version(); |
| 969 startup.log_greeting(); | 969 startup.log_greeting(); |
| 970 startup.log_startup_warnings(); | 970 startup.log_startup_warnings(); |
| 971 startup.load_secondary_libraries(); | 971 startup.load_secondary_libraries(); |
