From ecf2e1202a86c92f232efbaa15216f406fa3514f Mon Sep 17 00:00:00 2001 From: Martin Pärtel Date: Mon, 13 Apr 2020 13:16:07 +0300 Subject: On UID/GID DB read failure, print non-debug message and tolerate ENOENT. --- src/userinfo.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/userinfo.c') diff --git a/src/userinfo.c b/src/userinfo.c index b9a47e6..3adadea 100644 --- a/src/userinfo.c +++ b/src/userinfo.c @@ -114,7 +114,11 @@ static int rebuild_uid_cache() if (pw == NULL) { if (errno == 0) { break; + } else if (errno == ENOENT) { // We might have gotten some entries. This happens at least on the CentOS 8 Vagrant image (tested 2020-04-13). + fprintf(stderr, "Got ENOENT while rebuilding uid cache. The cache may be incomplete.\n"); + break; } else { + perror("Failed to rebuild uid cache"); goto error; } } @@ -136,7 +140,6 @@ static int rebuild_uid_cache() error: endpwent(); clear_uid_cache(); - DPRINTF("Failed to rebuild uid cache"); return 0; } @@ -160,7 +163,11 @@ static int rebuild_gid_cache() if (gr == NULL) { if (errno == 0) { break; + } else if (errno == ENOENT) { // We might have gotten some entries. This happens at least on the CentOS 8 Vagrant image (tested 2020-04-13). + fprintf(stderr, "Got ENOENT while rebuilding gid cache. The cache may be incomplete.\n"); + break; } else { + perror("Failed to rebuild gid cache"); goto error; } } @@ -194,7 +201,6 @@ static int rebuild_gid_cache() error: endgrent(); clear_gid_cache(); - DPRINTF("Failed to rebuild uid cache"); return 0; } -- cgit v1.2.3