git: 3cb808226c1f - main - setkey(8): add -e option to take script from the command line
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 03 Apr 2023 19:50:21 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3cb808226c1f62ed5c726480073eb9035a24d2cc commit 3cb808226c1f62ed5c726480073eb9035a24d2cc Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-04-03 01:03:50 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-04-03 19:48:48 +0000 setkey(8): add -e option to take script from the command line Reviewed by: ae Sponsored by: Nvidia networking MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39393 --- sbin/setkey/setkey.8 | 14 ++++++++++---- sbin/setkey/setkey.c | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/sbin/setkey/setkey.8 b/sbin/setkey/setkey.8 index 6df1839ca6e4..38c10546cccb 100644 --- a/sbin/setkey/setkey.8 +++ b/sbin/setkey/setkey.8 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 19, 2022 +.Dd April 3, 2023 .Dt SETKEY 8 .Os .\" @@ -45,6 +45,9 @@ .Op Fl v .Fl f Ar filename .Nm +.Op Fl v +.Fl e Ar script +.Nm .Op Fl Pgltv .Fl D .Nm @@ -65,11 +68,14 @@ The .Nm utility takes a series of operations from the standard input (if invoked with -.Fl c ) -or the file named +.Fl c ) , +from the file named .Ar filename (if invoked with -.Fl f Ar filename ) . +.Fl f Ar filename ) , +or from the command line argument following the option +(if invoked with +.Fl e Ar script ) . .Bl -tag -width indent .It Fl D Dump the SAD entries. diff --git a/sbin/setkey/setkey.c b/sbin/setkey/setkey.c index faf6373b312e..50f1c7056381 100644 --- a/sbin/setkey/setkey.c +++ b/sbin/setkey/setkey.c @@ -99,6 +99,7 @@ usage(void) printf("usage: setkey [-v] -c\n"); printf(" setkey [-v] -f filename\n"); + printf(" setkey [-v] -e \"<script>\"\n"); printf(" setkey [-Pagltv] -D\n"); printf(" setkey [-Pv] -F\n"); printf(" setkey [-h] -x\n"); @@ -129,13 +130,27 @@ main(int ac, char **av) thiszone = gmt2local(0); - while ((c = getopt(ac, av, "acdf:ghltvxDFP")) != -1) { + while ((c = getopt(ac, av, "acde:f:ghltvxDFP")) != -1) { switch (c) { case 'c': f_mode = MODE_SCRIPT; fp = stdin; break; + case 'e': + if (fp != stdin) { + err(-1, "only one -f/-e option is accepted"); + } + f_mode = MODE_SCRIPT; + fp = fmemopen(optarg, strlen(optarg), "r"); + if (fp == NULL) { + err(-1, "fmemopen"); + /*NOTREACHED*/ + } + break; case 'f': + if (fp != stdin) { + err(-1, "only one -f/-e option is accepted"); + } f_mode = MODE_SCRIPT; if ((fp = fopen(optarg, "r")) == NULL) { err(-1, "fopen");