git: 3cea7ca846e9 - stable/13 - setkey(8): add -e option to take script from the command line
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 10 Apr 2023 05:10:29 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3cea7ca846e94c90e3cb39200f72daac48bceac9 commit 3cea7ca846e94c90e3cb39200f72daac48bceac9 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-04-03 01:03:50 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-04-10 05:10:06 +0000 setkey(8): add -e option to take script from the command line (cherry picked from commit 3cb808226c1f62ed5c726480073eb9035a24d2cc) --- 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 2bb87cc21a97..20754c1b368f 100644 --- a/sbin/setkey/setkey.8 +++ b/sbin/setkey/setkey.8 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 13, 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 2bc8ec7e5816..ff2509555ff2 100644 --- a/sbin/setkey/setkey.c +++ b/sbin/setkey/setkey.c @@ -99,6 +99,7 @@ usage() 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"); @@ -131,13 +132,27 @@ main(ac, 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");