1 Star 0 Fork 25

SuperSix173/procps-ng

forked from src-openEuler/procps-ng 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
openeuler-uptime-Fix-uptime-return-0-user-when-systemd-pam-is-.patch 988 Bytes
一键复制 编辑 原始数据 按行查看 历史
From 600cc2dff859aac525d62000316d957846da4a66 Mon Sep 17 00:00:00 2001
From: Chao Liu <liuchao173@huawei.com>
Date: Tue, 7 May 2024 03:42:34 +0000
Subject: [PATCH 1/2] uptime: Fix uptime return 0 user when systemd-pam is not
installed
When systemd-pam is not installed, systemd won't create files in /run/systemd/sessions/ and sd_get_sessions will return 0. However, the actual number of users is not 0. When sd_get_sessions return 0, uptime should use getutxent for statistics.
---
library/uptime.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/library/uptime.c b/library/uptime.c
index 52720cbc..0db38ee5 100644
--- a/library/uptime.c
+++ b/library/uptime.c
@@ -71,7 +71,9 @@ PROCPS_EXPORT int procps_users(void)
#if defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)
if (sd_booted() > 0)
- return sd_get_sessions(NULL);
+ numuser = sd_get_sessions(NULL);
+ if (numuser > 0)
+ return numuser;
#endif
setutent();
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/SuperSix173/procps-ng.git
git@gitee.com:SuperSix173/procps-ng.git
SuperSix173
procps-ng
procps-ng
master

搜索帮助