MFC: 1.84. (and fixes)
If in silent mode, do not return an error responce if asked to delete a table entry that is not present, or add one that exists.
This commit is contained in:
parent
d9a624ae3b
commit
64961250b2
@ -232,7 +232,8 @@ commands in a script
|
||||
.Ql sh\ /etc/rc.firewall ) ,
|
||||
or by processing a file of many
|
||||
.Nm
|
||||
rules across a remote login session.
|
||||
rules across a remote login session. It also stops a table add or delete
|
||||
from failing if the entry already exists or is not present.
|
||||
If a
|
||||
.Cm flush
|
||||
is performed in normal (verbose) mode (with the default kernel
|
||||
|
@ -4826,9 +4826,20 @@ table_handler(int ac, char *av[])
|
||||
else
|
||||
ent.value = 0;
|
||||
if (do_cmd(do_add ? IP_FW_TABLE_ADD : IP_FW_TABLE_DEL,
|
||||
&ent, sizeof(ent)) < 0)
|
||||
err(EX_OSERR, "setsockopt(IP_FW_TABLE_%s)",
|
||||
do_add ? "ADD" : "DEL");
|
||||
&ent, sizeof(ent)) < 0) {
|
||||
/* If running silent, don't bomb out on these errors. */
|
||||
if (!(do_quiet && (errno == (do_add ? EEXIST : ESRCH))))
|
||||
err(EX_OSERR, "setsockopt(IP_FW_TABLE_%s)",
|
||||
do_add ? "ADD" : "DEL");
|
||||
/* In silent mode, react to a failed add by deleting */
|
||||
if (do_add) {
|
||||
do_cmd(IP_FW_TABLE_DEL, &ent, sizeof(ent));
|
||||
if (do_cmd(IP_FW_TABLE_ADD,
|
||||
&ent, sizeof(ent)) < 0)
|
||||
err(EX_OSERR,
|
||||
"setsockopt(IP_FW_TABLE_ADD)");
|
||||
}
|
||||
}
|
||||
} else if (_substrcmp(*av, "flush") == 0) {
|
||||
if (do_cmd(IP_FW_TABLE_FLUSH, &ent.tbl, sizeof(ent.tbl)) < 0)
|
||||
err(EX_OSERR, "setsockopt(IP_FW_TABLE_FLUSH)");
|
||||
|
Loading…
Reference in New Issue
Block a user