Skip to contentSkip to conversation

package/procps-ng/S02sysctl: pass SYSCTL_ARGS before -p argument for busybox

PATCH Applied Peter Korsgaard 2 participants 2 messages May 17, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/procps-ng/S02sysctl: pass SYSCTL_ARGS before -p argument for busybox

The busybox sysctl applet expects all arguments after -p to be filenames to read:

sysctl -p file -h
sysctl: -h: No such file or directory

VS:

sysctl -h -p file
sysctl: invalid option -- 'h'
BusyBox v1.36.1 (2024-05-17 15:27:21 CEST) multi-call binary.

Usage: sysctl [-enq] { -a | -p [FILE]... | [-w] [KEY[=VALUE]]... }

Show/set kernel parameters

        -e      Don't warn about unknown keys
        -n      Don't show key names
        -q      Quiet
        -a      Show all values
        -p      Set values from FILEs (default /etc/sysctl.conf)
        -w      Set values

This seems to be the intented behaviour:
https://git.busybox.net/busybox/tree/procps/sysctl.c#n317

Notice: The procps-ng variant is happy with both:

sysctl -p file -h

Usage:
sysctl [options] [variable[=value] ...]

VS:

sysctl -h -p file

Usage:
sysctl [options] [variable[=value] ...]

So pass SYSCTL_ARGS before the -p args so custom sysctl arguments can be passed.

---
 package/procps-ng/S02sysctl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
package/procps-ng/S02sysctl +2 -2
index 85d9ed50d0..c202833ab8 100644
@@ -43,7 +43,7 @@ run_logger() {
 				break
 			}
 			echo "* Applying $file ..."
-			/sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL"
+			/sbin/sysctl $SYSCTL_ARGS -p "$file" || prog_status="FAIL"
 		done 2>&1 >&3 | /usr/bin/logger -t sysctl -p kern.err
 	} 3>&1 | /usr/bin/logger -t sysctl -p kern.info
 }
@@ -60,7 +60,7 @@ run_std() {
 				break
 			}
 			echo "* Applying $file ..."
-			/sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL"
+			/sbin/sysctl $SYSCTL_ARGS -p "$file" || prog_status="FAIL"
 		done
 	}
 }
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Peter, All,

On 2024-05-17 16:14 +0200, Peter Korsgaard spake thusly:

Quoted 37 lines

The busybox sysctl applet expects all arguments after -p to be filenames to read:

sysctl -p file -h
sysctl: -h: No such file or directory

VS:

sysctl -h -p file
sysctl: invalid option -- 'h'
BusyBox v1.36.1 (2024-05-17 15:27:21 CEST) multi-call binary.

Usage: sysctl [-enq] { -a | -p [FILE]... | [-w] [KEY[=VALUE]]... }

Show/set kernel parameters

        -e      Don't warn about unknown keys
        -n      Don't show key names
        -q      Quiet
        -a      Show all values
        -p      Set values from FILEs (default /etc/sysctl.conf)
        -w      Set values

This seems to be the intented behaviour:
https://git.busybox.net/busybox/tree/procps/sysctl.c#n317

Notice: The procps-ng variant is happy with both:

sysctl -p file -h

Usage:
sysctl [options] [variable[=value] ...]

VS:

sysctl -h -p file

Quoted 7 lines

Usage:
sysctl [options] [variable[=value] ...]

So pass SYSCTL_ARGS before the -p args so custom sysctl arguments can be passed.

Applied to master, thanks.

Regards,
Yann E. MORIN.

Quoted 33 lines
---
 package/procps-ng/S02sysctl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
package/procps-ng/S02sysctl +2 -2
index 85d9ed50d0..c202833ab8 100644
@@ -43,7 +43,7 @@ run_logger() {
 				break
 			}
 			echo "* Applying $file ..."
-			/sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL"
+			/sbin/sysctl $SYSCTL_ARGS -p "$file" || prog_status="FAIL"
 		done 2>&1 >&3 | /usr/bin/logger -t sysctl -p kern.err
 	} 3>&1 | /usr/bin/logger -t sysctl -p kern.info
 }
@@ -60,7 +60,7 @@ run_std() {
 				break
 			}
 			echo "* Applying $file ..."
-			/sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL"
+			/sbin/sysctl $SYSCTL_ARGS -p "$file" || prog_status="FAIL"
 		done
 	}
 }
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot