diff options
Diffstat (limited to 'src/luarocks/command_line.lua')
-rw-r--r-- | src/luarocks/command_line.lua | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 528ca068..6a1cc519 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
@@ -40,6 +40,18 @@ local function replace_tree(flags, tree) | |||
40 | path.use_tree(tree) | 40 | path.use_tree(tree) |
41 | end | 41 | end |
42 | 42 | ||
43 | local function is_ownership_ok(directory) | ||
44 | local me = fs.current_user() | ||
45 | for _ = 1,3 do -- try up to grandparent | ||
46 | local owner = fs.attributes(directory, "owner") | ||
47 | if owner then | ||
48 | return owner == me | ||
49 | end | ||
50 | directory = dir.dir_name(directory) | ||
51 | end | ||
52 | return false | ||
53 | end | ||
54 | |||
43 | --- Main command-line processor. | 55 | --- Main command-line processor. |
44 | -- Parses input arguments and calls the appropriate driver function | 56 | -- Parses input arguments and calls the appropriate driver function |
45 | -- to execute the action requested on the command-line, forwarding | 57 | -- to execute the action requested on the command-line, forwarding |
@@ -182,8 +194,7 @@ function command_line.run_command(...) | |||
182 | die("Current directory does not exist. Please run LuaRocks from an existing directory.") | 194 | die("Current directory does not exist. Please run LuaRocks from an existing directory.") |
183 | end | 195 | end |
184 | 196 | ||
185 | if fs.attributes(cfg.local_cache, "owner") ~= fs.current_user() or | 197 | if not is_ownership_ok(cfg.local_cache) then |
186 | fs.attributes(dir.dir_name(cfg.local_cache), "owner") ~= fs.current_user() then | ||
187 | util.warning("The directory '" .. cfg.local_cache .. "' or its parent directory ".. | 198 | util.warning("The directory '" .. cfg.local_cache .. "' or its parent directory ".. |
188 | "is not owned by the current user and the cache has been disabled. ".. | 199 | "is not owned by the current user and the cache has been disabled. ".. |
189 | "Please check the permissions and owner of that directory. ".. | 200 | "Please check the permissions and owner of that directory. ".. |