From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-network] dhcp: dnsmasq: Use dir_glob_foreach for deleting configuration files
Date: Tue, 28 Nov 2023 09:58:57 +0100 [thread overview]
Message-ID: <20231128085857.61974-1-s.hanreich@proxmox.com> (raw)
The current invocation is quite unsafe and triggers the taint mode of
Perl. Replacing it with dir_glob_foreach solves those issues.
Reported-By: Friedrich Weber <f.weber@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
I wasn't sure whether directly unlinking the files in the callback
would influence the iteration, hence why I store them in an
intermediate array. Also, unlinking them all at once probably is
better than unlinking them one-by-one (although it shouldn't matter
with the low amount of files here..)
src/PVE/Network/SDN/Dhcp/Dnsmasq.pm | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
index e65e973..2844943 100644
--- a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
+++ b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
@@ -234,7 +234,13 @@ CFG
$default_dnsmasq_config
);
- unlink glob "$config_directory/10-*.conf";
+ my @config_files = ();
+ PVE::Tools::dir_glob_foreach($config_directory, '10-.*\.conf', sub {
+ my ($file) = @_;
+ push @config_files, "$config_directory/$file";
+ });
+
+ unlink @config_files;
}
sub after_configure {
--
2.39.2
next reply other threads:[~2023-11-28 8:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 8:58 Stefan Hanreich [this message]
2023-11-29 10:09 ` [pve-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231128085857.61974-1-s.hanreich@proxmox.com \
--to=s.hanreich@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.