On Fri, Apr 12, 2024 at 07:13:41AM -0700, Bart Van Assche wrote:
> On 4/12/24 06:44, Mark Johnston wrote:
> > I would like to introduce the patch below, which gets compiled when
> > --without-kmem-usage is specified.  In this case, snmpd will still use
> > libkvm, but won't open /dev/(k)mem.  In my testing so far, this works
> > perfectly.  Does anyone have any thoughts on this patch/approach?  Would
> > the net-snmp project be willing to accept the patch?  Thank you in
> > advance for any feedback or guidance.
> 
> What privileges are required to call kvm_open() on FreeBSD? Are
> the same privileges required as for opening /dev/kmem or not?

The only privileges required are those needed to open the file.  So,
kvm_openfiles(NULL, NULL, NULL, O_RDONLY, err) requires root privileges,
because it tries to open /dev/mem.  If I change the second parameter to
"/dev/null", then any user can call it successfully, and most of the
kvm_* functions will still work as expected.

> If not,
> has it been considered to make init_kmem() call kvm_open() on FreeBSD
> independent of whether or not --without-kmem-usage has been specified?

Assuming I don't misunderstand, that's effectively what my patch does -
it just does so in a separate implementation of init_kmem().

Do you mean that on FreeBSD we should always perform an unprivileged
kvm_openfile() call, no matter whether --without-kmem-usage is
specified?


_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to