[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [PATCH] sysctl: fix the problem that no error is reported when access fails
From: "zhuyan (M)" <zhuyan34 () huawei ! com>
Date: 2020-05-16 2:39:18
Message-ID: 087124ffe9174d14a0df8f23fcae3f00 () huawei ! com
[Download RAW message or body]
When an general user without authority sets the system configuration,
0 is returned, but the modification is not successful. It is unreasonable.
Such as, general user didn't have /proc/sys/fs/protected_hardlinks permissions, but \
run the command 'busybox sysctl fs.protected_symlinks', 0 is returned.
Signed-off-by: Yan Zhu <zhuyan34@huawei.com>
---
procps/sysctl.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/procps/sysctl.c b/procps/sysctl.c index 6d77185..dd981f8 100644
--- a/procps/sysctl.c
+++ b/procps/sysctl.c
@@ -129,6 +129,7 @@ static int sysctl_act_on_setting(char *setting)
char *cptr, *outname;
char *value = value; /* for compiler */
bool writing = (option_mask32 & FLAG_WRITE);
+ bool read_all = (option_mask32 & FLAG_SHOW_ALL);
outname = xstrdup(setting);
@@ -170,6 +171,13 @@ static int sysctl_act_on_setting(char *setting)
if (fd < 0) {
switch (errno) {
case EACCES:
+ if (!read_all) {
+ bb_perror_msg("error %sing key '%s'",
+ writing ?
+ "sett" : "read",
+ outname);
+ break;
+ }
/* Happens for write-only settings, e.g. net.ipv6.route.flush */
goto end;
case ENOENT:
--
2.12.3
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic