diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2015-03-19 17:08:59 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-03-19 17:08:59 -0300 |
commit | 4c969726b78b61523f3422cbe64e8f0adb1cfac1 (patch) | |
tree | 912a51ed65ee76b5615df9ec79d4ffc361023561 /src | |
parent | 603b0ea346d050bef2ced801ec8818773aae0fa0 (diff) | |
download | luarocks-4c969726b78b61523f3422cbe64e8f0adb1cfac1.tar.gz luarocks-4c969726b78b61523f3422cbe64e8f0adb1cfac1.tar.bz2 luarocks-4c969726b78b61523f3422cbe64e8f0adb1cfac1.zip |
Don't use user tree when running as root. Fixes #303.
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/cfg.lua | 2 | ||||
-rw-r--r-- | src/luarocks/command_line.lua | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index ea80e5b5..b4781840 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -139,7 +139,7 @@ else | |||
139 | cfg.home = os.getenv("HOME") or "" | 139 | cfg.home = os.getenv("HOME") or "" |
140 | sys_config_dir = sys_config_dir or "/etc/luarocks" | 140 | sys_config_dir = sys_config_dir or "/etc/luarocks" |
141 | home_config_dir = cfg.home.."/.luarocks" | 141 | home_config_dir = cfg.home.."/.luarocks" |
142 | cfg.home_tree = cfg.home.."/.luarocks/" | 142 | cfg.home_tree = (os.getenv("USER") ~= "root") and cfg.home.."/.luarocks/" |
143 | end | 143 | end |
144 | 144 | ||
145 | cfg.variables = {} | 145 | cfg.variables = {} |
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index c885575e..a92a3f9d 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
@@ -153,6 +153,11 @@ function command_line.run_command(...) | |||
153 | replace_tree(flags, args, root_dir) | 153 | replace_tree(flags, args, root_dir) |
154 | end | 154 | end |
155 | elseif flags["local"] then | 155 | elseif flags["local"] then |
156 | if not cfg.home_tree then | ||
157 | die("The --local flag is meant for operating in a user's home directory.\n".. | ||
158 | "You are running as a superuser, which is intended for system-wide operation.\n".. | ||
159 | "To force using the superuser's home, use --tree explicitly.") | ||
160 | end | ||
156 | replace_tree(flags, args, cfg.home_tree) | 161 | replace_tree(flags, args, cfg.home_tree) |
157 | else | 162 | else |
158 | local trees = cfg.rocks_trees | 163 | local trees = cfg.rocks_trees |