Tarantool development patches archive
 help / color / mirror / Atom feed
From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Georgy Kirichenko <georgy@tarantool.org>
Cc: Alexander Turenko <alexander.turenko@tarantool.org>,
	tarantool-patches@freelists.org,
	"Alexander V . Tikhonov" <avtikhon@tarantool.org>,
	Mergen Imeev <imeevma@tarantool.org>
Subject: [tarantool-patches] [PATCH 1/2] lua: workaround pwd.getpwall() issue on Fedora 29
Date: Fri, 16 Aug 2019 05:32:35 +0300	[thread overview]
Message-ID: <543c1b3b3d93460a3ff7184f96e8482dbc435849.1565920130.git.alexander.turenko@tarantool.org> (raw)
In-Reply-To: <cover.1565920130.git.alexander.turenko@tarantool.org>

This is a workaround for systemd-nss issue:
https://github.com/systemd/systemd/issues/9585

The following error is observed on app-tap/pwd.test.lua on Fedora 29
(glibc-2.28-26.fc29, systemd-239-12.git8bca462.fc29) when tarantool is
linked with libcurl w/o GSS-API support:

 | builtin/pwd.lua:169: getpwall failed [errno 2]: No such file or directory

Such tarantool build lacks of libselinux.so.1 transitive dependency
(tarantool -> libcurl.so.4 -> libgssapi_krb5.so.2 -> libkrb5support.so.0
-> libselinux.so.1) and strace shows the following calls when
pwd.getpwall() is invoked first time:

 | openat(AT_FDCWD, "/lib64/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 7A
 | <...>
 | access("/etc/selinux/config", F_OK)     = -1 ENOENT (No such file or directory)

It looks like a part of libselinux initialization code and is invoked
during execution of a last ffi.C.getpwent() call that returns `nil` as a
result and left errno set to ENOENT. Our pwd module set errno to zero
before getpwent() call and expects that it will be preserved if no
unrecoverable errors occur. It seems that this expectation is not meet
due to the systemd-nss issue linked above.

Second and next getpwall() calls will succeed, so the commit adds an
extra getpwall() during pwd module load. This workaround is disabled on
FreeBSD due to another issue: #4428 ('getpwall() hangs on FreeBSD 12').

See also the previous related commit:
efccac691a4609c11f555a11704e91af4cda0836 ('lua: fix error handling in
getpwall and getgrall').

Follows up #3766.
Part of #4318.
---
 src/lua/pwd.lua | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/lua/pwd.lua b/src/lua/pwd.lua
index 58c2e94f3..b6de1562f 100644
--- a/src/lua/pwd.lua
+++ b/src/lua/pwd.lua
@@ -194,6 +194,19 @@ local function getgrall()
     return grs
 end
 
+-- Workaround pwd.getpwall() issue on Fedora 29: successful
+-- getgrent() call that should normally return NULL and preserve
+-- errno, set it to ENOENT due to systemd-nss issue [1] when a
+-- password database is traversed first time.
+--
+-- [1]: https://github.com/systemd/systemd/issues/9585
+--
+-- It is disabled on FreeBSD due to gh-4428: getpwall() hangs on
+-- FreeBSD 12.
+if jit.os ~= 'BSD' then
+    pcall(getpwall)
+end
+
 return {
     getpw = getpw,
     getgr = getgr,
-- 
2.22.0

  reply	other threads:[~2019-08-16  2:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-16  2:32 [tarantool-patches] [PATCH 0/2] Build libcurl statically Alexander Turenko
2019-08-16  2:32 ` Alexander Turenko [this message]
2019-08-16  2:32 ` [tarantool-patches] [PATCH 2/2] build: link libcurl statically from a submodule Alexander Turenko
2019-08-19 22:54 ` [tarantool-patches] Re: [PATCH 0/2] Build libcurl statically Alexander Turenko
2019-08-20  7:51   ` Георгий Кириченко
2019-08-22  8:42 ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=543c1b3b3d93460a3ff7184f96e8482dbc435849.1565920130.git.alexander.turenko@tarantool.org \
    --to=alexander.turenko@tarantool.org \
    --cc=avtikhon@tarantool.org \
    --cc=georgy@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 1/2] lua: workaround pwd.getpwall() issue on Fedora 29' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox