From ea5788380b408894e8a7b0d165bf535d1a3fbe51 Mon Sep 17 00:00:00 2001 From: Stephen Baynham Date: Thu, 10 Oct 2019 06:27:43 -0700 Subject: Add quotes around usernames to handle usernames with space on Windows --- spec/fs_spec.lua | 6 +++--- src/luarocks/fs/win32/tools.lua | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/fs_spec.lua b/spec/fs_spec.lua index 0acca613..e3643f78 100644 --- a/spec/fs_spec.lua +++ b/spec/fs_spec.lua @@ -39,7 +39,7 @@ describe("Luarocks fs test #unit", function() local make_unreadable = function(path) if is_win then - fs.execute("icacls " .. fs.Q(path) .. " /inheritance:d /deny %USERNAME%:(R)") + fs.execute("icacls " .. fs.Q(path) .. " /inheritance:d /deny \"%USERNAME%\":(R)") else fs.execute("chmod -r " .. fs.Q(path)) end @@ -47,7 +47,7 @@ describe("Luarocks fs test #unit", function() local make_unwritable = function(path) if is_win then - fs.execute("icacls " .. fs.Q(path) .. " /inheritance:d /deny %USERNAME%:(W,M)") + fs.execute("icacls " .. fs.Q(path) .. " /inheritance:d /deny \"%USERNAME%\":(W,M)") else fs.execute("chmod -w " .. fs.Q(path)) end @@ -55,7 +55,7 @@ describe("Luarocks fs test #unit", function() local make_unexecutable = function(path) if is_win then - fs.execute("icacls " .. fs.Q(path) .. " /inheritance:d /deny %USERNAME%:(X)") + fs.execute("icacls " .. fs.Q(path) .. " /inheritance:d /deny \"%USERNAME%\":(X)") else fs.execute("chmod -x " .. fs.Q(path)) end diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index f9468517..57e8c80e 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua @@ -239,7 +239,7 @@ function tools.set_permissions(filename, mode, scope) return false, "Could not take ownership of the given file" end -- Grant the current user the proper rights - ok = fs.execute_quiet(vars.ICACLS .. " " .. fs.Q(filename) .. " /inheritance:d /grant:r %USERNAME%:" .. perms) + ok = fs.execute_quiet(vars.ICACLS .. " " .. fs.Q(filename) .. " /inheritance:d /grant:r \"%USERNAME%\":" .. perms) if not ok then return false, "Failed setting permission " .. mode .. " for " .. scope end @@ -267,7 +267,7 @@ function tools.set_permissions(filename, mode, scope) 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) if not ok then return false, "Failed setting permission " .. mode .. " for " .. scope end -- cgit v1.2.3-55-g6feb