Date: Thu, 16 Oct 2008 13:47:00 +0100 From: "Daniel Bye" <danielby@slightlystrange.org> To: freebsd-questions@freebsd.org Subject: Re: FreeBSD and Nagios - permissions Message-ID: <20081016124700.GC80147@torus.slightlystrange.org> In-Reply-To: <20081016110501.GB80147@torus.slightlystrange.org> References: <48F6EDF2.4070109@intersonic.se> <20081016080452.GA4150@icarus.home.lan> <20081016110501.GB80147@torus.slightlystrange.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--2JFBq9zoW8cOFH7v
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Thu, Oct 16, 2008 at 12:05:01PM +0100, Daniel Bye wrote:
> It is possible to configure sudo to run only exactly the required command
> (including arguments) precisely to guard against this type of abuse -
> I use it extensively in my own nagios setup.
>=20
> This Cmnd_Alias in sudoers will do the trick:
>=20
> Cmnd_Alias NAGIOS_CMNDS =3D /sbin/camcontrol inquiry da0
>=20
> man sudoers for more information about what you can do with sudo.
I just realised this example is woefully incomplete - apologies for that.
There are a few ways you can set up /usr/local/etc/sudoers (make sure
you use visudo to edit it, as it will catch any syntax errors for you,
thus helping somewhat to prevent breaking your setup).
The simplest case will just be to allow nagios to run the command, as root,
without a password:
nagios ALL=3D(root) NOPASSWD: /sbin/camcontrol inquiry da0
If, as is quite possible, nagios should be able to run more than just
that one command, you can define a Cmnd_Alias, as above. To include more
than one command in the alias, simply separate them with a comma. You
can use `\' to escape newlines and make your file a little easier to read:
Cmnd_Alias NAGIOS_CMNDS =3D /sbin/camcontrol inquiry da0 \
/sbin/camcontrol inquiry da1
and so on. Now, to use that alias, set the user's permissions to
nagios ALL=3D(root) NOPASSWD: NAGIOS_CMNDS
The sudoers man page has more information, and there is also a good
tutorial by M Lucas on O'Reilly's Big Scary Daemons (it's from 2002, but
still a good introduction):
http://www.onlamp.com/pub/a/bsd/2002/08/29/Big_Scary_Daemons.html?page=3D1
Dan
--=20
Daniel Bye
_
ASCII ribbon campaign ( )
- against HTML, vCards and X
- proprietary attachments in e-mail / \
--2JFBq9zoW8cOFH7v
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)
iEYEARECAAYFAkj3N8QACgkQixf5fBYiFmq19QCeLohFdQJqyBy+tnHBIgiPy9xC
U8cAoM5MXYbuwhgpcGHiqZuiAxm8ha/6
=ZXSX
-----END PGP SIGNATURE-----
--2JFBq9zoW8cOFH7v--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081016124700.GC80147>
