From 2669fb715fadfd3cac931aec787c16c0d87be9a2 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Mon, 24 Feb 2025 16:31:23 +0000 Subject: [PATCH] options: Allow interface block to be pattern matching Fixes #473 --- src/dhcpcd.conf.5.in | 4 +++- src/if-options.c | 3 ++- src/if.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dhcpcd.conf.5.in b/src/dhcpcd.conf.5.in index c8a0f62a..8d7898e3 100644 --- a/src/dhcpcd.conf.5.in +++ b/src/dhcpcd.conf.5.in @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 23, 2025 +.Dd February 24, 2025 .Dt DHCPCD.CONF 5 .Os .Sh NAME @@ -446,6 +446,8 @@ encodes the FQDN hostname as specified in .It Ic interface Ar interface Subsequent options are only parsed for this .Ar interface . +Pattern matching is allowed by +.Xr fnmatch 3 . .It Ic ipv4ll_time Ar seconds Wait for .Ar seconds diff --git a/src/if-options.c b/src/if-options.c index 0958b684..06ef1cb8 100644 --- a/src/if-options.c +++ b/src/if-options.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -2875,7 +2876,7 @@ read_config(struct dhcpcd_ctx *ctx, skip = 1; continue; } - if (ifname && strcmp(line, ifname) == 0) + if (ifname && fnmatch(line, ifname, 0) == 0) skip = 0; else skip = 1; diff --git a/src/if.c b/src/if.c index 8db01308..4db1f818 100644 --- a/src/if.c +++ b/src/if.c @@ -250,7 +250,7 @@ if_hasconf(struct dhcpcd_ctx *ctx, const char *ifname) int i; for (i = 0; i < ctx->ifcc; i++) { - if (strcmp(ctx->ifcv[i], ifname) == 0) + if (fnmatch(ctx->ifcv[i], ifname, 0) == 0) return 1; } return 0; -- 2.47.3