From d3d71d91bb20d92843483063086a5f685b84710d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 24 Oct 2018 17:04:17 +0200 Subject: prosodyctl: Allow cert dir to not be owned by root (fixes #1075) --- prosodyctl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'prosodyctl') diff --git a/prosodyctl b/prosodyctl index e280367d..380f8e04 100755 --- a/prosodyctl +++ b/prosodyctl @@ -944,7 +944,8 @@ function commands.cert(arg) show_warning("The directory "..cert_basedir.." does not exist"); return 1; -- TODO Should we create it? end - if pposix.getuid() ~= cert_dir_attrs.uid then + local uid = pposix.getuid(); + if uid ~= 0 and uid ~= cert_dir_attrs.uid then show_warning("The directory "..cert_basedir.." is not owned by the current user, won't be able to write files to it"); return 1; elseif not cert_dir_attrs.permissions then -- COMPAT with LuaFilesystem < 1.6.2 (hey CentOS!) -- cgit v1.2.3 From 2dd5ee93572d91455ad7bcf84e9555b756c5ffc5 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 24 Oct 2018 17:13:49 +0200 Subject: prosodyctl: Change ownership of certs to same as the cert base dir when running from a source checkout --- prosodyctl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'prosodyctl') diff --git a/prosodyctl b/prosodyctl index 380f8e04..76bf4e12 100755 --- a/prosodyctl +++ b/prosodyctl @@ -867,7 +867,10 @@ local function copy(from, to, umask, owner, group) end assert(input:close()); assert(output:close()); - if owner and group then + if not prosody.installed then + -- FIXME this is possibly specific to GNU chown + os.execute(("chown -c --reference=%s %s"):format(sh_esc(cert_basedir), sh_esc(to))); + elseif owner and group then local ok = os.execute(("chown %s:%s %s"):format(sh_esc(owner), sh_esc(group), sh_esc(to))); assert(ok == true or ok == 0, "Failed to change ownership of "..to); end -- cgit v1.2.3