Skip to content

Commit

Permalink
Fixing file permissions, closes Kong#461
Browse files Browse the repository at this point in the history
Former-commit-id: 47692e9b4f9c72e331df3a164eeb6b247b2fe83c
  • Loading branch information
subnetmarco committed Aug 11, 2015
1 parent bf1c96e commit de71b82
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions kong/plugins/filelog/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ int open(char * filename, int flags, int mode);
int write(int fd, void * ptr, int numbytes);
]]

local O_CREAT = 0x0200
local O_APPEND = 0x0008
local O_WRONLY = 0x0001
local octal = function(n) return tonumber(n, 8) end

local S_IWUSR = 0000200
local S_IRUSR = 0000400
local S_IROTH = 0000004
local O_CREAT = octal('0100')
local O_APPEND = octal('02000')
local O_WRONLY = octal('0001')

local S_IWUSR = octal('00200')
local S_IRUSR = octal('00400')
local S_IXUSR = octal('00100')

local function string_to_char(str)
return ffi.cast("uint8_t*", str)
Expand All @@ -32,7 +34,7 @@ local function log(premature, conf, message)

local fd = fd_util.get_fd(conf.path)
if not fd then
fd = ffi.C.open(string_to_char(conf.path), bit.bor(O_CREAT, O_APPEND, O_WRONLY), bit.bor(S_IWUSR, S_IRUSR, S_IROTH))
fd = ffi.C.open(string_to_char(conf.path), bit.bor(O_CREAT, O_APPEND, O_WRONLY), bit.bor(S_IWUSR, S_IRUSR, S_IXUSR))
fd_util.set_fd(conf.path, fd)
end

Expand Down

0 comments on commit de71b82

Please sign in to comment.