Argh! - besides everything what jmc@ said, it should have been the following diff *for sure*:
diff --git a/sbin/dhclient/dhclient.8 b/sbin/dhclient/dhclient.8 index 9d77c7e..b6094c1 100644 --- a/sbin/dhclient/dhclient.8 +++ b/sbin/dhclient/dhclient.8 @@ -57,6 +57,16 @@ The name of the network interface that .Nm should attempt to configure must be specified on the command line. +If the given name starts with the character +.Cm = , +then +.Nm +will treat the remaining characters as the name of a group defined by +.Xr ifconfig 8 , +and try to use the interface which is marked in that group. +See +.Xr ifconfig 8 +for more on groups. .Pp The options are as follows: .Bl -tag -width "-p port" @@ -169,7 +179,8 @@ database of acquired leases .Xr dhclient-script 8 , .Xr dhcp 8 , .Xr dhcpd 8 , -.Xr dhcrelay 8 +.Xr dhcrelay 8 , +.Xr ifconfig 8 .Sh AUTHORS .An -nosplit .Nm diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 8d35021..3fb1bf7 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -2073,41 +2073,57 @@ fork_privchld(int fd, int fd2) void get_ifname(char *ifname, char *arg) { +#ifdef SMALL + if (strlcpy(ifi->name, arg, IFNAMSIZ) >= IFNAMSIZ) + error("Interface name too long"); +#else struct ifgroupreq ifgr; struct ifg_req *ifg; + char *group; int s, len; - if (!strcmp(arg, "egress")) { - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s == -1) - error("socket error"); - bzero(&ifgr, sizeof(ifgr)); - strlcpy(ifgr.ifgr_name, "egress", sizeof(ifgr.ifgr_name)); - if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) { - if (errno == ENOENT) - error("no interface in group egress found"); - error("ioctl SIOCGIFGMEMB: %m"); - } - len = ifgr.ifgr_len; - if ((ifgr.ifgr_groups = calloc(1, len)) == NULL) - error("get_ifname"); - if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) - error("ioctl SIOCGIFGMEMB: %m"); - - arg = NULL; - for (ifg = ifgr.ifgr_groups; - ifg && len >= sizeof(struct ifg_req); ifg++) { - len -= sizeof(struct ifg_req); - if (arg) - error("too many interfaces in group egress"); - arg = ifg->ifgrq_member; - } - + if (*arg == '=') + ++arg; + /* 'egress' for compatibility */ + else if (strcmp(arg, "egress")) { if (strlcpy(ifi->name, arg, IFNAMSIZ) >= IFNAMSIZ) - error("Interface name too long: %m"); + error("Interface name too long"); + return; + } - free(ifgr.ifgr_groups); - close(s); - } else if (strlcpy(ifi->name, arg, IFNAMSIZ) >= IFNAMSIZ) + /* Try deduce interface from if */ + group = arg; + + s = socket(AF_INET, SOCK_DGRAM, 0); + if (s == -1) + error("socket error"); + bzero(&ifgr, sizeof(ifgr)); + + if (strlcpy(ifgr.ifgr_name, group, IFNAMSIZ) >= IFNAMSIZ) error("Interface name too long"); + + if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) { + if (errno == ENOENT) + error("no interface in group %s found", group); + error("ioctl SIOCGIFGMEMB: %m"); + } + len = ifgr.ifgr_len; + if ((ifgr.ifgr_groups = calloc(1, len)) == NULL) + error("get_ifname"); + if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) + error("ioctl SIOCGIFGMEMB: %m"); + + arg = NULL; + for (ifg = ifgr.ifgr_groups; + ifg && len >= sizeof(struct ifg_req); ifg++) { + len -= sizeof(struct ifg_req); + if (arg) + error("too many interfaces in group %s", group); + arg = ifg->ifgrq_member; + } + (void)strlcpy(ifi->name, arg, IFNAMSIZ); + + free(ifgr.ifgr_groups); + close(s); +#endif /* SMALL */ }