]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
options: Allow interface block to be pattern matching
authorRoy Marples <roy@marples.name>
Mon, 24 Feb 2025 16:31:23 +0000 (16:31 +0000)
committerRoy Marples <roy@marples.name>
Mon, 24 Feb 2025 16:31:23 +0000 (16:31 +0000)
Fixes #473

src/dhcpcd.conf.5.in
src/if-options.c
src/if.c

index c8a0f62acb53b0af3ba2ff7b8008b357145137ba..8d7898e37cfd6b89d1287a7708012388e51891cf 100644 (file)
@@ -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
index 0958b684cffb56501dc5d38ed21f1a276dd5bd18..06ef1cb8a6d53c187939f9d6361d772faf8ab3b3 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <ctype.h>
 #include <errno.h>
+#include <fnmatch.h>
 #include <getopt.h>
 #include <grp.h>
 #include <inttypes.h>
@@ -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;
index 8db013085e4f9661eddac1ecc8969b7940542a38..4db1f8187d555650272eff8d6286d81a9b2f9a39 100644 (file)
--- 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;