From: Christoph Heiss <c.heiss@proxmox.com>
To: Filip Schauer <f.schauer@proxmox.com>
Cc: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH installer] fetch-answer: encode unsafe characters in partition label
Date: Tue, 19 Nov 2024 16:40:52 +0100 [thread overview]
Message-ID: <e2kqtkmfb3b6mepkyvplg7ik2h2pqasmgiit3a7gswtv7jpldu@spqr5qbgvjii> (raw)
In-Reply-To: <20241119145934.102126-1-f.schauer@proxmox.com>
Good catch & thanks for tackeling this!
Also tested it with a simple whitespace character.
Tested-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Christoph Heiss <c.heiss@proxmox.com>
On Tue, Nov 19, 2024 at 03:59:34PM +0100, Filip Schauer wrote:
> Ensure potentially unsafe characters in the partition label are encoded,
> preventing the installer from failing to find the answer partition when
> the label contains whitespaces or !"$%&'()*,/;<>?[\]^`{|}~
> [..]
> ---
> .../src/fetch_plugins/partition.rs | 30 ++++++++++++++-----
> 1 file changed, 22 insertions(+), 8 deletions(-)
> [..]
> @@ -52,20 +65,21 @@ fn path_exists_logged(file_name: &str, search_path: &str) -> Option<PathBuf> {
> /// * `partlabel_source` - Partition Label, used for matching, in the exact, upper and lower case
> /// * `search_path` - Path where to search for the partition label
> fn scan_partlabels(partlabel: &str, search_path: &str) -> Result<PathBuf> {
> - if let Some(path) = path_exists_logged(partlabel, search_path) {
> - info!("Found partition with label '{partlabel}'");
> + let partlabel_enc = encode_partlabel(partlabel);
> + if let Some(path) = path_exists_logged(&partlabel_enc, search_path) {
> + info!("Found partition with label '{partlabel_enc}'");
I think the original, non-encoded partition label should be printed
here.
As it would be somewhat surprising to users/administrators to suddenly
see some partition label being searched that what the specified -- thus
considering this as an internal implementation detail, not public
interface.
> return Ok(path);
> }
>
> - let partlabel_upper_case = partlabel.to_uppercase();
> - if let Some(path) = path_exists_logged(&partlabel_upper_case, search_path) {
> - info!("Found partition with label '{partlabel_upper_case}'");
> + let partlabel_upper_case_enc = encode_partlabel(&partlabel.to_uppercase());
> + if let Some(path) = path_exists_logged(&partlabel_upper_case_enc, search_path) {
> + info!("Found partition with label '{partlabel_upper_case_enc}'");
.. same here ..
> return Ok(path);
> }
>
> - let partlabel_lower_case = partlabel.to_lowercase();
> - if let Some(path) = path_exists_logged(&partlabel_lower_case, search_path) {
> - info!("Found partition with label '{partlabel_lower_case}'");
> + let partlabel_lower_case_enc = encode_partlabel(&partlabel.to_lowercase());
> + if let Some(path) = path_exists_logged(&partlabel_lower_case_enc, search_path) {
> + info!("Found partition with label '{partlabel_lower_case_enc}'");
.. and here.
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2024-11-19 15:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 14:59 Filip Schauer
2024-11-19 15:40 ` Christoph Heiss [this message]
2024-11-19 15:58 ` Filip Schauer
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=e2kqtkmfb3b6mepkyvplg7ik2h2pqasmgiit3a7gswtv7jpldu@spqr5qbgvjii \
--to=c.heiss@proxmox.com \
--cc=f.schauer@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.