shadow-utils/shadow-4.9-nss-get-shadow-l...

49 lines
1.5 KiB
Diff

From e101219ad71de11da3fdd1b3ec2620fd1a97b92c Mon Sep 17 00:00:00 2001
From: Iker Pedrosa <ipedrosa@redhat.com>
Date: Mon, 10 Jan 2022 15:30:28 +0100
Subject: [PATCH] nss: get shadow_logfd with log_get_logfd()
If /etc/nsswitch.conf doesn't exist podman crashes because shadow_logfd
is NULL. In order to avoid that load the log file descriptor with the
log_get_logfd() helper function.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2038811
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
---
lib/nss.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/nss.c b/lib/nss.c
index 02742902..06fa48e5 100644
--- a/lib/nss.c
+++ b/lib/nss.c
@@ -9,6 +9,7 @@
#include "prototypes.h"
#include "../libsubid/subid.h"
#include "shadowlog_internal.h"
+#include "shadowlog.h"
#define NSSWITCH "/etc/nsswitch.conf"
@@ -42,6 +43,7 @@ void nss_init(const char *nsswitch_path) {
FILE *nssfp = NULL;
char *line = NULL, *p, *token, *saveptr;
size_t len = 0;
+ FILE *shadow_logfd = log_get_logfd();
if (atomic_flag_test_and_set(&nss_init_started)) {
// Another thread has started nss_init, wait for it to complete
@@ -57,7 +59,7 @@ void nss_init(const char *nsswitch_path) {
// subid: files
nssfp = fopen(nsswitch_path, "r");
if (!nssfp) {
- fprintf(shadow_logfd, "Failed opening %s: %m", nsswitch_path);
+ fprintf(shadow_logfd, "Failed opening %s: %m\n", nsswitch_path);
atomic_store(&nss_init_completed, true);
return;
}
--
2.34.1