diff options
-rw-r--r-- | src/luarocks/fs/unix/tools.lua | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index e6be9266..31d8f0ca 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
@@ -200,15 +200,24 @@ function tools.is_file(file) | |||
200 | end | 200 | end |
201 | 201 | ||
202 | do | 202 | do |
203 | local function rwx_to_octal(rwx) | ||
204 | return (rwx:match "r" and 4 or 0) | ||
205 | + (rwx:match "w" and 2 or 0) | ||
206 | + (rwx:match "x" and 1 or 0) | ||
207 | end | ||
203 | local umask_cache | 208 | local umask_cache |
204 | function tools._unix_umask() | 209 | function tools._unix_umask() |
205 | if umask_cache then | 210 | if umask_cache then |
206 | return umask_cache | 211 | return umask_cache |
207 | end | 212 | end |
208 | local fd = assert(io.popen("umask")) | 213 | local fd = assert(io.popen("umask -S")) |
209 | local umask = assert(fd:read("*a")) | 214 | local umask = assert(fd:read("*a")) |
210 | umask = umask:gsub("\n", "") | 215 | fd:close() |
211 | umask_cache = umask:sub(2, 4) | 216 | local u, g, o = umask:match("u=([rwx]*),g=([rwx]*),o=([rwx]*)") |
217 | umask_cache = string.format("%d%d%d", | ||
218 | 7 - rwx_to_octal(u), | ||
219 | 7 - rwx_to_octal(g), | ||
220 | 7 - rwx_to_octal(o)) | ||
212 | return umask_cache | 221 | return umask_cache |
213 | end | 222 | end |
214 | end | 223 | end |