diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2020-06-09 15:58:32 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-06-09 15:58:32 +0200 |
commit | 002be6e821eedfa190c5b060e7b61acb306c2a92 (patch) | |
tree | 3eb0d206c179a42807947060b666f816cee7cca6 | |
parent | b2ab920716f640cbaaf486512ba177f4e0b597c5 (diff) | |
download | busybox-w32-002be6e821eedfa190c5b060e7b61acb306c2a92.tar.gz busybox-w32-002be6e821eedfa190c5b060e7b61acb306c2a92.tar.bz2 busybox-w32-002be6e821eedfa190c5b060e7b61acb306c2a92.zip |
sysctl: do report EACCES errors on write
function old new delta
sysctl_act_recursive 165 179 +14
sysctl_act_on_setting 467 471 +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 18/0) Total: 18 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | procps/sysctl.c | 9 | ||||
-rwxr-xr-x | testsuite/unexpand.tests | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/procps/sysctl.c b/procps/sysctl.c index 6d77185ca..e16b119e9 100644 --- a/procps/sysctl.c +++ b/procps/sysctl.c | |||
@@ -169,13 +169,15 @@ static int sysctl_act_on_setting(char *setting) | |||
169 | 169 | ||
170 | if (fd < 0) { | 170 | if (fd < 0) { |
171 | switch (errno) { | 171 | switch (errno) { |
172 | case EACCES: | ||
173 | /* Happens for write-only settings, e.g. net.ipv6.route.flush */ | ||
174 | goto end; | ||
175 | case ENOENT: | 172 | case ENOENT: |
176 | if (option_mask32 & FLAG_SHOW_KEY_ERRORS) | 173 | if (option_mask32 & FLAG_SHOW_KEY_ERRORS) |
177 | bb_error_msg("error: '%s' is an unknown key", outname); | 174 | bb_error_msg("error: '%s' is an unknown key", outname); |
178 | break; | 175 | break; |
176 | case EACCES: | ||
177 | /* Happens for write-only settings, e.g. net.ipv6.route.flush */ | ||
178 | if (!writing) | ||
179 | goto end; | ||
180 | /* fall through */ | ||
179 | default: | 181 | default: |
180 | bb_perror_msg("error %sing key '%s'", | 182 | bb_perror_msg("error %sing key '%s'", |
181 | writing ? | 183 | writing ? |
@@ -236,6 +238,7 @@ static int sysctl_act_recursive(const char *path) | |||
236 | int retval = 0; | 238 | int retval = 0; |
237 | 239 | ||
238 | if (!(option_mask32 & FLAG_WRITE) | 240 | if (!(option_mask32 & FLAG_WRITE) |
241 | && !strchr(path, '=') /* do not try to resurse on "var=val" */ | ||
239 | && stat(path, &buf) == 0 | 242 | && stat(path, &buf) == 0 |
240 | && S_ISDIR(buf.st_mode) | 243 | && S_ISDIR(buf.st_mode) |
241 | ) { | 244 | ) { |
diff --git a/testsuite/unexpand.tests b/testsuite/unexpand.tests index 4ab693ec8..aeaae13f0 100755 --- a/testsuite/unexpand.tests +++ b/testsuite/unexpand.tests | |||
@@ -33,8 +33,8 @@ testing "unexpand case 8" "unexpand" \ | |||
33 | 33 | ||
34 | testcase() | 34 | testcase() |
35 | { | 35 | { |
36 | testing "unexpand flags $*" "unexpand $*" \ | 36 | testing "unexpand flags $*" "unexpand $*" \ |
37 | "$want" "" ' a b c' | 37 | "$want" "" ' a b c' |
38 | } | 38 | } |
39 | 39 | ||
40 | # tabs=8, Convert only leading sequences of blanks | 40 | # tabs=8, Convert only leading sequences of blanks |