From 7b214dd7de60c9dbc5ceba8edbe50477ddfc5da2 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 28 Nov 2011 21:10:26 -0200 Subject: add extra checks for local permissions --- src/luarocks/dir.lua | 2 +- src/luarocks/fs/lua.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/luarocks/dir.lua b/src/luarocks/dir.lua index 5a8058dc..00a9317f 100644 --- a/src/luarocks/dir.lua +++ b/src/luarocks/dir.lua @@ -10,7 +10,7 @@ separator = "/" function base_name(pathname) assert(type(pathname) == "string") - local base = pathname:match(".*[/\\]([^/\\]*)") + local base = pathname:gsub("[/\\]*$", ""):match(".*[/\\]([^/\\]*)") return base or pathname end diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index ce0877db..2a176259 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -633,7 +633,7 @@ end -- plus an error message. function check_command_permissions(flags) local root_dir = path.root_dir(cfg.rocks_dir) - if not flags["local"] and not fs.is_writable(root_dir) then + if not flags["local"] and not (fs.is_writable(root_dir) or fs.is_writable(dir.dir_name(root_dir))) then return nil, "Your user does not have write permissions in " .. root_dir .. " \n-- you may want to run as a privileged user or use your local tree with --local." end -- cgit v1.2.3-55-g6feb