summaryrefslogtreecommitdiff
path: root/usr.sbin/relayctl
diff options
context:
space:
mode:
authorSebastian Benoit <benno@cvs.openbsd.org>2017-11-29 15:24:51 +0000
committerSebastian Benoit <benno@cvs.openbsd.org>2017-11-29 15:24:51 +0000
commit537d453366dab6dfebb76accd3c2801fd411bdfa (patch)
treeeb3eb39dad1d24b3a525451cc89d7eba4a107c4d /usr.sbin/relayctl
parentcfa3a3f13588075aac01acf20e063fd327704ff9 (diff)
add options to specify the control socket in relayd and relayctl.
From Kapetanakis Giannis, thanks. ok claudio@
Diffstat (limited to 'usr.sbin/relayctl')
-rw-r--r--usr.sbin/relayctl/relayctl.816
-rw-r--r--usr.sbin/relayctl/relayctl.c29
2 files changed, 38 insertions, 7 deletions
diff --git a/usr.sbin/relayctl/relayctl.8 b/usr.sbin/relayctl/relayctl.8
index 3ffe5834af6..c329136cdce 100644
--- a/usr.sbin/relayctl/relayctl.8
+++ b/usr.sbin/relayctl/relayctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: relayctl.8,v 1.32 2015/11/28 01:22:44 gsoares Exp $
+.\" $OpenBSD: relayctl.8,v 1.33 2017/11/29 15:24:50 benno Exp $
.\"
.\" Copyright (c) 2007 - 2013 Reyk Floeter <reyk@openbsd.org>
.\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -15,7 +15,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: November 28 2015 $
+.Dd $Mdocdate: November 29 2017 $
.Dt RELAYCTL 8
.Os
.Sh NAME
@@ -23,6 +23,7 @@
.Nd control the relay daemon
.Sh SYNOPSIS
.Nm
+.Op Fl s Ar socket
.Ar command
.Op Ar argument ...
.Sh DESCRIPTION
@@ -32,6 +33,17 @@ program controls the
.Xr relayd 8
daemon.
.Pp
+The following options are available:
+.Bl -tag -width Ds
+.It Fl s Ar socket
+Use
+.Ar socket
+instead of the default
+.Pa /var/run/relayd.sock
+to communicate with
+.Xr relayd 8 .
+.El
+.Pp
The following commands are available:
.Bl -tag -width Ds
.It Cm host disable Op Ar name | id
diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c
index 7b52c21e61e..83bacf05b94 100644
--- a/usr.sbin/relayctl/relayctl.c
+++ b/usr.sbin/relayctl/relayctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayctl.c,v 1.57 2016/09/03 14:44:21 reyk Exp $ */
+/* $OpenBSD: relayctl.c,v 1.58 2017/11/29 15:24:50 benno Exp $ */
/*
* Copyright (c) 2007 - 2013 Reyk Floeter <reyk@openbsd.org>
@@ -88,7 +88,8 @@ usage(void)
{
extern char *__progname;
- fprintf(stderr, "usage: %s command [argument ...]\n", __progname);
+ fprintf(stderr, "usage: %s [-s socket] command [argument ...]\n",
+ __progname);
exit(1);
}
@@ -101,9 +102,25 @@ main(int argc, char *argv[])
int ctl_sock;
int done = 0;
int n, verbose = 0;
+ int ch;
+ const char *sockname;
+
+ sockname = RELAYD_SOCKET;
+ while ((ch = getopt(argc, argv, "s:")) != -1) {
+ switch (ch) {
+ case 's':
+ sockname = optarg;
+ break;
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ }
+ argc -= optind;
+ argv += optind;
/* parse options */
- if ((res = parse(argc - 1, argv + 1)) == NULL)
+ if ((res = parse(argc, argv)) == NULL)
exit(1);
/* connect to relayd control socket */
@@ -112,7 +129,9 @@ main(int argc, char *argv[])
bzero(&sun, sizeof(sun));
sun.sun_family = AF_UNIX;
- (void)strlcpy(sun.sun_path, RELAYD_SOCKET, sizeof(sun.sun_path));
+ if (strlcpy(sun.sun_path, sockname, sizeof(sun.sun_path)) >=
+ sizeof(sun.sun_path))
+ errx(1, "socket `%s' too long", sockname);
reconnect:
if (connect(ctl_sock, (struct sockaddr *)&sun, sizeof(sun)) == -1) {
/* Keep retrying if running in monitor mode */
@@ -121,7 +140,7 @@ main(int argc, char *argv[])
usleep(100);
goto reconnect;
}
- err(1, "connect: %s", RELAYD_SOCKET);
+ err(1, "connect: %s", sockname);
}
if (pledge("stdio", NULL) == -1)