Skip to content

Commit

Permalink
cfg: check if /dev/log is available as SOCK_DGRAM
Browse files Browse the repository at this point in the history
On RHEL 7.9 and Centos 7.9 /dev/log is a UDP socket for some reason, and
simple socket.connect('unix/', '/dev/log') returns a "Protocol wrong type
for socket" error. Lets check if /dev/log is available as SOCK_DGRAM if
socket.connect failed.
  • Loading branch information
grafin committed Jul 20, 2023
1 parent 5d60dfa commit d66c390
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Changed

- Don't require systemd to default to syslog logging. Only check that syslog UNIX socket is available.

- Fix syslog UNIX socket check for older RHEL-based distros: check both SOCK_STREAM and SOCK_DGRAM.

-------------------------------------------------------------------------------
[2.8.0] - 2023-05-25
-------------------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions cartridge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,15 @@ local function cfg(opts, box_opts)
-- Using syslog driver, when available, by default
if box_opts.log == nil then
local syslog, _ = socket.connect('unix/', '/dev/log')

-- On RHEL 7.9 and Centos 7.9 /dev/log is a UDP socket, not TCP
if not syslog then
local s = socket('AF_UNIX', 'SOCK_DGRAM', 0)
if s:sysconnect('unix/', '/dev/log') then
syslog = s
end
end

if not syslog then
syslog, _ = socket.connect('unix/', '/var/run/syslog')
end
Expand Down

0 comments on commit d66c390

Please sign in to comment.