git: 7e093e5780bb - main - ifconfig: Fix handling of unsupported -j option with MK_JAIL=no
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 23 Jun 2026 21:04:22 UTC
The branch main has been updated by hrs:
URL: https://cgit.FreeBSD.org/src/commit/?id=7e093e5780bbf5af416526c1ab6339fe6e94b37b
commit 7e093e5780bbf5af416526c1ab6339fe6e94b37b
Author: Hiroki Sato <hrs@FreeBSD.org>
AuthorDate: 2026-06-23 21:02:47 +0000
Commit: Hiroki Sato <hrs@FreeBSD.org>
CommitDate: 2026-06-23 21:02:47 +0000
ifconfig: Fix handling of unsupported -j option with MK_JAIL=no
The ifconfig(8) utility built with MK_JAIL=no does not support the
-j option. When the option is specified, Perror() is called without
setting errno, which can result in errno being reported as zero and
a misleading error message being displayed.
Also remove "[-j jail]" from the usage message when built with
MK_JAIL=no.
Event: Halifax Hackathon 202606
---
sbin/ifconfig/ifconfig.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 9aeb4a09ef49..0e839eeafc5b 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -168,15 +168,21 @@ usage(void)
strlcat(options, " ", sizeof(options));
}
+#ifdef JAIL
+#define JFLAG " [-j jail] "
+#else
+#define JFLAG " "
+#endif
fprintf(stderr,
- "usage: ifconfig [-j jail] [-f type:format] %sinterface address_family\n"
+ "usage: ifconfig" JFLAG "[-f type:format] %sinterface address_family\n"
" [address [dest_address]] [parameters]\n"
- " ifconfig [-j jail] interface create\n"
- " ifconfig [-j jail] -a %s[-d] [-m] [-u] [-v] [address_family]\n"
- " ifconfig [-j jail] -l [-d] [-u] [address_family]\n"
- " ifconfig [-j jail] %s[-d] [-m] [-u] [-v]\n",
+ " ifconfig" JFLAG "interface create\n"
+ " ifconfig" JFLAG "-a %s[-d] [-m] [-u] [-v] [address_family]\n"
+ " ifconfig" JFLAG "-l [-d] [-u] [address_family]\n"
+ " ifconfig" JFLAG "%s[-d] [-m] [-u] [-v]\n",
options, options, options);
exit(1);
+#undef JFLAG
}
static void
@@ -503,7 +509,7 @@ args_parse(struct ifconfig_args *args, int argc, char *argv[])
if (jail_attach(jid) != 0)
Perror("cannot attach to jail");
#else
- Perror("not built with jail support");
+ Perrorc("not built with jail support", EINVAL);
#endif
break;
case 'k':