加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-sd-bus-print-debugging-information-if-bus_container_.patch 3.29 KB
一键复制 编辑 原始数据 按行查看 历史
From 4358cbc8076352e7946956f5d71bf7c80d7f2e43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Wed, 7 Jul 2021 18:01:03 +0200
Subject: [PATCH] sd-bus: print debugging information if
bus_container_connect_socket() fails
We would return the errno, but there are many steps, and without some
debugging info it's hard to figure out what exactly failed.
(cherry picked from commit 0c201ca945c64e97ba4961ded13ce38a63200468)
Conflict:NA
Reference:https://github.com/systemd/systemd/commit/4358cbc8076352e7946956f5d71bf7c80d7f2e43
---
src/libsystemd/sd-bus/bus-container.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/libsystemd/sd-bus/bus-container.c b/src/libsystemd/sd-bus/bus-container.c
index b11ebb3f65..1159af46cd 100644
--- a/src/libsystemd/sd-bus/bus-container.c
+++ b/src/libsystemd/sd-bus/bus-container.c
@@ -37,11 +37,11 @@ int bus_container_connect_socket(sd_bus *b) {
r = namespace_open(b->nspid, &pidnsfd, &mntnsfd, NULL, &usernsfd, &rootfd);
if (r < 0)
- return r;
+ return log_debug_errno(r, "Failed to open namespace of PID "PID_FMT": %m", b->nspid);
b->input_fd = socket(b->sockaddr.sa.sa_family, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (b->input_fd < 0)
- return -errno;
+ return log_debug_errno(errno, "Failed to create a socket: %m");
b->input_fd = fd_move_above_stdio(b->input_fd);
@@ -50,12 +50,12 @@ int bus_container_connect_socket(sd_bus *b) {
bus_socket_setup(b);
if (socketpair(AF_UNIX, SOCK_SEQPACKET|SOCK_CLOEXEC, 0, pair) < 0)
- return -errno;
+ return log_debug_errno(errno, "Failed to create a socket pair: %m");
r = namespace_fork("(sd-buscntrns)", "(sd-buscntr)", NULL, 0, FORK_RESET_SIGNALS|FORK_DEATHSIG,
pidnsfd, mntnsfd, -1, usernsfd, rootfd, &child);
if (r < 0)
- return r;
+ return log_debug_errno(r, "Failed to create namespace for (sd-buscntr): %m");
if (r == 0) {
pair[0] = safe_close(pair[0]);
@@ -80,20 +80,22 @@ int bus_container_connect_socket(sd_bus *b) {
n = read(pair[0], &error_buf, sizeof(error_buf));
if (n < 0)
- return -errno;
+ return log_debug_errno(errno, "Failed to read error status from (sd-buscntr): %m");
if (n > 0) {
if (n != sizeof(error_buf))
- return -EIO;
+ return log_debug_errno(SYNTHETIC_ERRNO(EIO),
+ "Read error status of unexpected length %zd from (sd-buscntr): %m", n);
if (error_buf < 0)
- return -EIO;
+ return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
+ "Got unexpected error status from (sd-buscntr): %m");
if (error_buf == EINPROGRESS)
return 1;
if (error_buf > 0)
- return -error_buf;
+ return log_debug_errno(error_buf, "Got error from (sd-buscntr): %m");
}
return bus_socket_start_auth(b);
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化