An option to ignore sysctl CTLFLAG_ANYBODY

Teran McKinney sega01 at go-beyond.org
Sun Jun 21 22:02:10 UTC 2020


On 2020-06-21 04-58-03    , Alfonso Siciliano wrote:
> This new change to kern_sysctl.c should solve the problem:
> 
> https://github.com/freebsd/freebsd/blob/master/sys/kern/kern_sysctl.c#L2122
> from
> 	/* Is this sysctl writable by only privileged users? */
> 	if (req->newptr && !(oid->oid_kind & CTLFLAG_ANYBODY)) {
> to
> 	/*
> 	 * Is this sysctl writable? Does it belong to the undocumented interface
> 	 * or sysctlinfo?
> 	 */
> 	if (req->newptr && !(SYSCTL_CHILDREN(&sysctl___sysctl) == oid->oid_parent)) {
> 
> 
> Testing
> 
> 	% uname -K
> 	1300093
> 	% sysctl hw.ncpu
> 	hw.ncpu: 1
> 	% nsysctl -NatGv hw.snd.default_unit
> 	hw.snd.default_unit: integer:  RD WR RW ANYBODY TUN RDTUN RWTUN NOFETCH: 0
> 	% sysctl hw.snd.default_unit
> 	hw.snd.default_unit: 0
> 	% sysctl hw.snd.default_unit=1
> 	hw.snd.default_unit: 0
> 	sysctl: hw.snd.default_unit=1: Operation not permitted
> 
> 
> Alfonso
> 
> --- 
> Alfonso S. Siciliano 
>    http://alfix.gitlab.io
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"

Hi Alfonso,

Your patch works perfectly. Thank you so much! I appreciate it.

Sincerely,

Teran


More information about the freebsd-hackers mailing list