Comparison

prosodyctl @ 8285:433b2a41351f

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Fri, 29 Sep 2017 13:45:03 +0200
parent 8268:e21d82551e05
parent 8277:57c5dd08ff0a
child 8440:4e6710b4f873
comparison
equal deleted inserted replaced
8271:c09deab9989e 8285:433b2a41351f
89 local ok, level, err = config.load(filename); 89 local ok, level, err = config.load(filename);
90 if not ok then 90 if not ok then
91 print("\n"); 91 print("\n");
92 print("**************************"); 92 print("**************************");
93 if level == "parser" then 93 if level == "parser" then
94 print("A problem occured while reading the config file "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); 94 print("A problem occured while reading the config file "..filename);
95 local err_line, err_message = tostring(err):match("%[string .-%]:(%d*): (.*)"); 95 local err_line, err_message = tostring(err):match("%[string .-%]:(%d*): (.*)");
96 print("Error"..(err_line and (" on line "..err_line) or "")..": "..(err_message or tostring(err))); 96 print("Error"..(err_line and (" on line "..err_line) or "")..": "..(err_message or tostring(err)));
97 print(""); 97 print("");
98 elseif level == "file" then 98 elseif level == "file" then
99 print("Prosody was unable to find the configuration file."); 99 print("Prosody was unable to find the configuration file.");
100 print("We looked for: "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); 100 print("We looked for: "..filename);
101 print("A sample config file is included in the Prosody download called prosody.cfg.lua.dist"); 101 print("A sample config file is included in the Prosody download called prosody.cfg.lua.dist");
102 print("Copy or rename it to prosody.cfg.lua and edit as necessary."); 102 print("Copy or rename it to prosody.cfg.lua and edit as necessary.");
103 end 103 end
104 print("More help on configuring Prosody can be found at https://prosody.im/doc/configure"); 104 print("More help on configuring Prosody can be found at https://prosody.im/doc/configure");
105 print("Good luck!"); 105 print("Good luck!");
160 end 160 end
161 end 161 end
162 if not switched_user then 162 if not switched_user then
163 -- Boo! 163 -- Boo!
164 print("Warning: Couldn't switch to Prosody user/group '"..tostring(desired_user).."'/'"..tostring(desired_group).."': "..tostring(err)); 164 print("Warning: Couldn't switch to Prosody user/group '"..tostring(desired_user).."'/'"..tostring(desired_group).."': "..tostring(err));
165 else
166 -- Make sure the Prosody user can read the config
167 local conf, err, errno = io.open(ENV_CONFIG);
168 if conf then
169 conf:close();
170 else
171 print("The config file is not readable by the '"..desired_user.."' user.");
172 print("Prosody will not be able to read it.");
173 print("Error was "..err);
174 os.exit(1);
175 end
165 end 176 end
166 end 177 end
167 178
168 -- Set our umask to protect data files 179 -- Set our umask to protect data files
169 pposix.umask(config.get("*", "umask") or "027"); 180 pposix.umask(config.get("*", "umask") or "027");
890 local owner, group; 901 local owner, group;
891 if pposix.getuid() == 0 then -- We need root to change ownership 902 if pposix.getuid() == 0 then -- We need root to change ownership
892 owner = config.get("*", "prosody_user") or "prosody"; 903 owner = config.get("*", "prosody_user") or "prosody";
893 group = config.get("*", "prosody_group") or owner; 904 group = config.get("*", "prosody_group") or owner;
894 end 905 end
906 local cm = require "core.certmanager";
895 local imported = {}; 907 local imported = {};
896 for _, host in ipairs(hostnames) do 908 for _, host in ipairs(hostnames) do
897 for _, dir in ipairs(arg) do 909 for _, dir in ipairs(arg) do
898 if lfs.attributes(dir .. "/" .. host .. "/fullchain.pem") 910 local paths = cm.find_cert(dir, host);
899 and lfs.attributes(dir .. "/" .. host .. "/privkey.pem") then 911 if paths then
900 copy(dir .. "/" .. host .. "/fullchain.pem", cert_basedir .. "/" .. host .. ".crt", nil, owner, group); 912 copy(paths.certificate, cert_basedir .. "/" .. host .. ".crt", nil, owner, group);
901 copy(dir .. "/" .. host .. "/privkey.pem", cert_basedir .. "/" .. host .. ".key", "0377", owner, group); 913 copy(paths.key, cert_basedir .. "/" .. host .. ".key", "0377", owner, group);
902 table.insert(imported, host);
903 elseif lfs.attributes(dir .. "/" .. host .. ".crt")
904 and lfs.attributes(dir .. "/" .. host .. ".key") then
905 copy(dir .. "/" .. host .. ".crt", cert_basedir .. "/" .. host .. ".crt", nil, owner, group);
906 copy(dir .. "/" .. host .. ".key", cert_basedir .. "/" .. host .. ".key", "0377", owner, group);
907 table.insert(imported, host); 914 table.insert(imported, host);
908 else 915 else
909 -- TODO Say where we looked 916 -- TODO Say where we looked
910 show_warning("No certificate for host "..host.." found :("); 917 show_warning("No certificate for host "..host.." found :(");
911 end 918 end