From: Zbigniew Jędrzejewski-Szmek Date: Mon, 29 Jan 2018 13:23:31 +0000 (+0100) Subject: sysusers: emit a bit more info at debug level when locking fails X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=fa454203ef5f60bca221ab6372d4e4f2318c7150;p=elogind.git sysusers: emit a bit more info at debug level when locking fails This is the first error message when running unprivileged, and the message is unspecific, so let's at least add some logging at debug level to make this less confusing. --- diff --git a/src/basic/user-util.c b/src/basic/user-util.c index 78effacf8..ecb1e5fc8 100644 --- a/src/basic/user-util.c +++ b/src/basic/user-util.c @@ -560,18 +560,18 @@ int take_etc_passwd_lock(const char *root) { * awfully racy, and thus we just won't do them. */ if (root) - path = prefix_roota(root, "/etc/.pwd.lock"); + path = prefix_roota(root, ETC_PASSWD_LOCK_PATH); else - path = "/etc/.pwd.lock"; + path = ETC_PASSWD_LOCK_PATH; fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0600); if (fd < 0) - return -errno; + return log_debug_errno(errno, "Cannot open %s: %m", path); r = fcntl(fd, F_SETLKW, &flock); if (r < 0) { safe_close(fd); - return -errno; + return log_debug_errno(errno, "Locking %s failed: %m", path); } return fd; diff --git a/src/basic/user-util.h b/src/basic/user-util.h index 348160897..6b2f1af52 100644 --- a/src/basic/user-util.h +++ b/src/basic/user-util.h @@ -71,6 +71,8 @@ int take_etc_passwd_lock(const char *root); #define UID_NOBODY ((uid_t) 65534U) #define GID_NOBODY ((gid_t) 65534U) +#define ETC_PASSWD_LOCK_PATH "/etc/.pwd.lock" + #if 0 /// UNNEEDED by elogind static inline bool uid_is_dynamic(uid_t uid) { return DYNAMIC_UID_MIN <= uid && uid <= DYNAMIC_UID_MAX;