From 7f99fb829a7e6b887e5718881328d38bf19e83c1 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Pandey <59823583+vivekpandey02@users.noreply.github.com> Date: Fri, 1 Mar 2024 04:44:28 +0530 Subject: [PATCH 1/2] fix User-Password authentication Update usrpwd.rs to handle whitespace and blank lines in credentials.txt --- .../src/unicast/establishment/ext/auth/usrpwd.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/io/zenoh-transport/src/unicast/establishment/ext/auth/usrpwd.rs b/io/zenoh-transport/src/unicast/establishment/ext/auth/usrpwd.rs index d66a4a02c7..73250d249c 100644 --- a/io/zenoh-transport/src/unicast/establishment/ext/auth/usrpwd.rs +++ b/io/zenoh-transport/src/unicast/establishment/ext/auth/usrpwd.rs @@ -79,14 +79,18 @@ impl AuthUsrPwd { // usr3:pwd3 // I.e.: one : entry per line for l in content.lines() { - let idx = l.find(':').ok_or_else(|| { + let line = l.trim(); + if line.is_empty() { + continue; + } + let idx = line.find(':').ok_or_else(|| { zerror!("{S} Invalid user-password dictionary file: invalid format.") })?; - let user = l[..idx].as_bytes().to_owned(); + let user = line[..idx].trim().as_bytes().to_owned(); if user.is_empty() { bail!("{S} Invalid user-password dictionary file: empty user.") } - let password = l[idx + 1..].as_bytes().to_owned(); + let password = line[idx + 1..].trim().as_bytes().to_owned(); if password.is_empty() { bail!("{S} Invalid user-password dictionary file: empty password.") } From 150b3a4994487eee0587c78734cfdbcdc5202162 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Pandey <59823583+vivekpandey02@users.noreply.github.com> Date: Fri, 1 Mar 2024 15:36:11 +0530 Subject: [PATCH 2/2] Format usrpwd.rs file --- io/zenoh-transport/src/unicast/establishment/ext/auth/usrpwd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io/zenoh-transport/src/unicast/establishment/ext/auth/usrpwd.rs b/io/zenoh-transport/src/unicast/establishment/ext/auth/usrpwd.rs index 73250d249c..5cbe122edd 100644 --- a/io/zenoh-transport/src/unicast/establishment/ext/auth/usrpwd.rs +++ b/io/zenoh-transport/src/unicast/establishment/ext/auth/usrpwd.rs @@ -80,7 +80,7 @@ impl AuthUsrPwd { // I.e.: one : entry per line for l in content.lines() { let line = l.trim(); - if line.is_empty() { + if line.is_empty() { continue; } let idx = line.find(':').ok_or_else(|| {