0 Star 0 Fork 35

付安安/bash

forked from src-openEuler/bash 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bugfix-Forbidden-non-root-user-to-clear-history.patch 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
From 68c1a3a7b8277cb225ab221c3a6a4f239b81c9e1 Mon Sep 17 00:00:00 2001
From: shenyangyang <shenyangyang4@huawei.com>
Date: Mon, 2 Sep 2019 22:30:32 -0400
Subject: [PATCH] bugfix-Forbidden-non-root-user-to-clear-history
---
bashhist.c | 5 +++--
lib/readline/history.c | 8 +++++++-
lib/readline/history.h | 2 +-
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/bashhist.c b/bashhist.c
index d2155dc..e61bde6 100644
--- a/bashhist.c
+++ b/bashhist.c
@@ -345,8 +345,9 @@ load_history ()
void
bash_clear_history ()
{
- clear_history ();
- history_lines_this_session = 0;
+ int ret = clear_history ();
+ if (ret == 0)
+ history_lines_this_session = 0;
/* XXX - reset history_lines_read_from_file? */
}
diff --git a/lib/readline/history.c b/lib/readline/history.c
index 67158b1..3c1652b 100644
--- a/lib/readline/history.c
+++ b/lib/readline/history.c
@@ -590,9 +590,14 @@ history_is_stifled (void)
return (history_stifled);
}
-void
+int
clear_history (void)
{
+ uid_t uid = getuid();
+
+ if (uid)
+ return 1;
+
register int i;
/* This loses because we cannot free the data. */
@@ -604,4 +609,5 @@ clear_history (void)
history_offset = history_length = 0;
history_base = 1; /* reset history base to default */
+ return 0;
}
diff --git a/lib/readline/history.h b/lib/readline/history.h
index cc3de29..78f8f52 100644
--- a/lib/readline/history.h
+++ b/lib/readline/history.h
@@ -110,7 +110,7 @@ extern histdata_t free_history_entry PARAMS((HIST_ENTRY *));
extern HIST_ENTRY *replace_history_entry PARAMS((int, const char *, histdata_t));
/* Clear the history list and start over. */
-extern void clear_history PARAMS((void));
+extern int clear_history PARAMS((void));
/* Stifle the history list, remembering only MAX number of entries. */
extern void stifle_history PARAMS((int));
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fly_fzc/bash.git
git@gitee.com:fly_fzc/bash.git
fly_fzc
bash
bash
master

搜索帮助

Cb406eda 1850385 E526c682 1850385