From 11ddae641f9f23a01291443bf2569104edb855e1 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 8 Nov 2021 07:52:23 -0300 Subject: win32: icacls fix for usernames with spaces --- src/luarocks/fs/win32/tools.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index 5d98e526..80f07866 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua @@ -275,8 +275,18 @@ function tools.set_permissions(filename, mode, scope) if not ok then return false, "Failed setting permission " .. mode .. " for " .. scope end + -- Grant permissions available only to the current user - ok = fs.execute_quiet(vars.ICACLS .. " " .. fs.Q(filename) .. " /inheritance:d /grant %USERNAME%:" .. my_perms) + ok = fs.execute_quiet(vars.ICACLS .. " " .. fs.Q(filename) .. " /inheritance:d /grant \"%USERNAME%\":" .. my_perms) + + -- This may not be necessary if the above syntax is correct, + -- but I couldn't really test the extra quotes above, so if that + -- fails we try again with the syntax used in previous releases + -- just to be on the safe side + if not ok then + ok = fs.execute_quiet(vars.ICACLS .. " " .. fs.Q(filename) .. " /inheritance:d /grant %USERNAME%:" .. my_perms) + end + if not ok then return false, "Failed setting permission " .. mode .. " for " .. scope end -- cgit v1.2.3-55-g6feb