diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2008-09-26 15:19:56 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2008-09-26 15:19:56 +0000 |
commit | f6aa7e9b26297e3aacacfc47da2dcd9b7a2e9ff6 (patch) | |
tree | 8ee0e3d73ae6b1b659de7460ece8408b6860062c /usr.sbin/snmpctl | |
parent | 78eb4b63025d2ad9bd0479786dd0ca6ea84cfdb0 (diff) |
allow to add an additional restricted control socket for trap sending
only (not even show commands). this allows to place a socket for
traps in another daemon's chroot.
(based on restricted socket support from bgpd)
Diffstat (limited to 'usr.sbin/snmpctl')
-rw-r--r-- | usr.sbin/snmpctl/snmpctl.8 | 16 | ||||
-rw-r--r-- | usr.sbin/snmpctl/snmpctl.c | 12 |
2 files changed, 20 insertions, 8 deletions
diff --git a/usr.sbin/snmpctl/snmpctl.8 b/usr.sbin/snmpctl/snmpctl.8 index ed46d31fde6..d04e0a7599a 100644 --- a/usr.sbin/snmpctl/snmpctl.8 +++ b/usr.sbin/snmpctl/snmpctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: snmpctl.8,v 1.8 2008/05/17 23:31:52 sobrado Exp $ +.\" $OpenBSD: snmpctl.8,v 1.9 2008/09/26 15:19:55 reyk Exp $ .\" .\" Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 17 2008 $ +.Dd $Mdocdate: September 26 2008 $ .Dt SNMPCTL 8 .Os .Sh NAME @@ -23,6 +23,7 @@ .Sh SYNOPSIS .Nm .Op Fl n +.Op Fl s Ar socket .Ar command .Op Ar arg ... .Sh DESCRIPTION @@ -36,6 +37,13 @@ The options are as follows: .Bl -tag -width Ds .It Fl n Show numeric OID values instead of their symbolic names. +.It Fl s Ar socket +Use +.Ar socket +instead of the default +.Pa /var/run/snmpd.sock +to communicate with +.Xr snmpd 8 . .El .Pp The following commands are available: @@ -97,8 +105,8 @@ An string describing an Object ID, for example .Sh FILES .Bl -tag -width "/var/run/snmpd.sockXX" -compact .It /var/run/snmpd.sock -Unix-domain socket used for communication with -.Xr snmpd 8 . +default UNIX-domain socket used for communication with +.Xr snmpd 8 .El .Sh SEE ALSO .Xr snmpd 8 diff --git a/usr.sbin/snmpctl/snmpctl.c b/usr.sbin/snmpctl/snmpctl.c index 41a8f3d9efb..89210679866 100644 --- a/usr.sbin/snmpctl/snmpctl.c +++ b/usr.sbin/snmpctl/snmpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpctl.c,v 1.8 2008/05/17 23:31:52 sobrado Exp $ */ +/* $OpenBSD: snmpctl.c,v 1.9 2008/09/26 15:19:55 reyk Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net> @@ -95,16 +95,20 @@ main(int argc, char *argv[]) int done = 0; int n; int ch; + const char *sock = SNMPD_SOCKET; if ((env = calloc(1, sizeof(struct snmpd *))) == NULL) err(1, "calloc"); gettimeofday(&env->sc_starttime, NULL); - while ((ch = getopt(argc, argv, "n")) != -1) { + while ((ch = getopt(argc, argv, "ns:")) != -1) { switch (ch) { case 'n': env->sc_flags |= SNMPD_F_NONAMES; break; + case 's': + sock = optarg; + break; default: usage(); /* NOTREACHED */ @@ -140,7 +144,7 @@ main(int argc, char *argv[]) bzero(&sun, sizeof(sun)); sun.sun_family = AF_UNIX; - strlcpy(sun.sun_path, SNMPD_SOCKET, sizeof(sun.sun_path)); + strlcpy(sun.sun_path, sock, sizeof(sun.sun_path)); reconnect: if (connect(ctl_sock, (struct sockaddr *)&sun, sizeof(sun)) == -1) { /* Keep retrying if running in monitor mode */ @@ -149,7 +153,7 @@ main(int argc, char *argv[]) usleep(100); goto reconnect; } - err(1, "connect: %s", SNMPD_SOCKET); + err(1, "connect: %s", sock); } if (res->ibuf != NULL) |