← Commit list

002be6e82

Denys Vlasenko
Denys Vlasenko
2020-06-09
SUCCESS Duration: 152s

Subject

sysctl: do report EACCES errors on write

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

procps/sysctl.c+6 -3
@@ -169,13 +169,15 @@ static int sysctl_act_on_setting(char *setting)
if (fd < 0) {
switch (errno) {
- case EACCES:
- /* Happens for write-only settings, e.g. net.ipv6.route.flush */
- goto end;
case ENOENT:
if (option_mask32 & FLAG_SHOW_KEY_ERRORS)
bb_error_msg("error: '%s' is an unknown key", outname);
break;
+ case EACCES:
+ /* Happens for write-only settings, e.g. net.ipv6.route.flush */
+ if (!writing)
+ goto end;
+ /* fall through */
default:
bb_perror_msg("error %sing key '%s'",
writing ?
@@ -236,6 +238,7 @@ static int sysctl_act_recursive(const char *path)
int retval = 0;
if (!(option_mask32 & FLAG_WRITE)
+ && !strchr(path, '=') /* do not try to resurse on "var=val" */
&& stat(path, &buf) == 0
&& S_ISDIR(buf.st_mode)
) {
testsuite/unexpand.tests+2 -2
@@ -33,8 +33,8 @@ testing "unexpand case 8" "unexpand" \
testcase()
{
- testing "unexpand flags $*" "unexpand $*" \
- "$want" "" ' a b c'
+ testing "unexpand flags $*" "unexpand $*" \
+ "$want" "" ' a b c'
}
# tabs=8, Convert only leading sequences of blanks