Skip to content

Commit 2669fb7

Browse files
committed
options: Allow interface block to be pattern matching
Fixes #473
1 parent 4d22418 commit 2669fb7

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/dhcpcd.conf.5.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2525
.\" SUCH DAMAGE.
2626
.\"
27-
.Dd February 23, 2025
27+
.Dd February 24, 2025
2828
.Dt DHCPCD.CONF 5
2929
.Os
3030
.Sh NAME
@@ -446,6 +446,8 @@ encodes the FQDN hostname as specified in
446446
.It Ic interface Ar interface
447447
Subsequent options are only parsed for this
448448
.Ar interface .
449+
Pattern matching is allowed by
450+
.Xr fnmatch 3 .
449451
.It Ic ipv4ll_time Ar seconds
450452
Wait for
451453
.Ar seconds

src/if-options.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include <ctype.h>
3535
#include <errno.h>
36+
#include <fnmatch.h>
3637
#include <getopt.h>
3738
#include <grp.h>
3839
#include <inttypes.h>
@@ -2875,7 +2876,7 @@ read_config(struct dhcpcd_ctx *ctx,
28752876
skip = 1;
28762877
continue;
28772878
}
2878-
if (ifname && strcmp(line, ifname) == 0)
2879+
if (ifname && fnmatch(line, ifname, 0) == 0)
28792880
skip = 0;
28802881
else
28812882
skip = 1;

src/if.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ if_hasconf(struct dhcpcd_ctx *ctx, const char *ifname)
250250
int i;
251251

252252
for (i = 0; i < ctx->ifcc; i++) {
253-
if (strcmp(ctx->ifcv[i], ifname) == 0)
253+
if (fnmatch(ctx->ifcv[i], ifname, 0) == 0)
254254
return 1;
255255
}
256256
return 0;

0 commit comments

Comments
 (0)