Skip to content

RDKEMW-17726, RDKEMW-17727: Fix the Migration of RDKV-to-RDKE#529

Closed
jincysam87 wants to merge 36 commits intodevelopfrom
feature/RDKEMW-17727
Closed

RDKEMW-17726, RDKEMW-17727: Fix the Migration of RDKV-to-RDKE#529
jincysam87 wants to merge 36 commits intodevelopfrom
feature/RDKEMW-17727

Conversation

@jincysam87
Copy link
Copy Markdown
Contributor

Reason for change: Fix the SSID name in HEX format, support for SAE during migration
Test Procedure: Test with SSID name in HEX format, WPA3 personal mode as security mode
Risks: Medium
Signed-off-by: jincysaramma_sam@comcast.com

jincysam87 added 3 commits May 1, 2026 11:32
Revert "RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_fi…
Copilot AI review requested due to automatic review settings May 1, 2026 18:04
@jincysam87 jincysam87 requested a review from a team as a code owner May 1, 2026 18:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the NetworkManager bootstrap migration logic to better migrate Wi‑Fi profiles from RDKV to RDKE, specifically aiming to handle SSIDs stored in hex format and to support WPA3/SAE during migration.

Changes:

  • Add SSID extraction logic that attempts to decode hex-formatted SSIDs from wpa_supplicant.conf.
  • Add key_mgmt detection to choose sae vs wpa-psk when creating the nmcli connection.
  • Move NetworkManager state cleanup and adjust quoting for SSID/PSK checks and nmcli invocation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment on lines +60 to +63
elif [[ "$PSK_LINE" =~ psk=([a-fA-F0-9]+) ]]; then
HEX_PSK="${BASH_REMATCH[1]}"
PSK=$(printf "$(echo "$HEX_PSK" | sed 's/../\\x&/g')")
echo "Converted Hex PSK to string"
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unquoted psk= value in wpa_supplicant.conf is a 64-hex raw PSK (not a hex-encoded passphrase). Converting it to bytes via printf will produce binary (and can truncate at NUL), and it won’t be accepted by nmcli wifi-sec.psk. This should stay as the original 64-hex string (and the regex should enforce exactly 64 hex chars).

Suggested change
elif [[ "$PSK_LINE" =~ psk=([a-fA-F0-9]+) ]]; then
HEX_PSK="${BASH_REMATCH[1]}"
PSK=$(printf "$(echo "$HEX_PSK" | sed 's/../\\x&/g')")
echo "Converted Hex PSK to string"
elif [[ "$PSK_LINE" =~ psk=([a-fA-F0-9]{64})$ ]]; then
PSK="${BASH_REMATCH[1]}"
echo "PSK in raw 64-hex format"

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment on lines +53 to +55
PSK_LINE=$(grep psk= "$RDKV_SUPP_CONF")
# Case 1: Quoted passphrase
if [[ "$PSK_LINE" =~ psk=\"(.+)\" ]]; then
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grep psk= may return multiple matches (multiple network blocks), resulting in PSK_LINE containing multiple lines and the regex capturing an unexpected value. Consider selecting the intended network block (or at least using -m 1 and anchoring to the psk= key) so SSID/PSK don’t become mismatched.

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 1, 2026 18:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment on lines +30 to +36
# Extract the line containing ssid=
SSID_LINE=$(grep -m 1 "ssid=" "$RDKV_SUPP_CONF")

# Case 1: Quoted passphrase
if [[ "$PSK_LINE" =~ psk=\"(.+)\" ]]; then
PSK="${BASH_REMATCH[1]}"
# Case 1: SSID is a quoted readable string like ssid="Test's iPhone"
if [[ "$SSID_LINE" =~ ssid=\"(.*)\" ]]; then
SSID="${BASH_REMATCH[1]}"
echo "SSID in quoted format SSID: $SSID"
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SSID_LINE=$(grep -m 1 "ssid=" ...) will match any first occurrence of ssid= in the file (including outside a network={} block or not aligned with the psk/key_mgmt you later read). Since the migration depends on SSID/PSK/key_mgmt being from the same network block, consider parsing the first network={...} stanza (or the stanza you intend to migrate) as a unit (e.g., with awk/sed) and extracting all fields from that same block.

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment on lines +42 to +45
# Convert hex string to readable UTF-8 string
# Using printf with \x formatting for each byte pair
SSID=$(printf "$(echo "$HEX_SSID" | sed 's/../\\x&/g')")
echo "Converted Hex SSID to string: $SSID"
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hex SSID decoding doesn’t validate that the captured hex string has an even number of characters (byte pairs). With an odd-length value, the sed 's/../\\x&/g' + printf sequence will produce an invalid escape and can yield a corrupted SSID. Add an explicit even-length check (and fail/log) before attempting the conversion.

Suggested change
# Convert hex string to readable UTF-8 string
# Using printf with \x formatting for each byte pair
SSID=$(printf "$(echo "$HEX_SSID" | sed 's/../\\x&/g')")
echo "Converted Hex SSID to string: $SSID"
if (( ${#HEX_SSID} % 2 != 0 )); then
echo "Invalid hex SSID with odd length: $HEX_SSID"
else
# Convert hex string to readable UTF-8 string
# Using printf with \x formatting for each byte pair
SSID=$(printf "$(echo "$HEX_SSID" | sed 's/../\\x&/g')")
echo "Converted Hex SSID to string: $SSID"
fi

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment on lines +69 to +75
if grep -q "key_mgmt=SAE FT-SAE" "$RDKV_SUPP_CONF"; then
echo "key_mgmt is SAE"
KEY_MGMT=sae
else
echo "key_mgmt is wpa-psk"
KEY_MGMT=wpa-psk
fi
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SAE detection only matches the exact text key_mgmt=SAE FT-SAE. Common wpa_supplicant configs use key_mgmt=SAE (or may include SAE among other tokens with different spacing/order), which would currently fall back to wpa-psk and configure nmcli incorrectly for WPA3. Use a more flexible match (e.g., look for SAE as a token on the key_mgmt= line) and ideally extract it from the same network block as the selected SSID.

Copilot uses AI. Check for mistakes.
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment on lines +26 to +36
if [[ -f "$RDKV_SUPP_CONF" ]]; then
#########################
# SSID Extraction #
#########################
# Extract the line containing ssid=
SSID_LINE=$(grep -m 1 "ssid=" "$RDKV_SUPP_CONF")

# Case 1: Quoted passphrase
if [[ "$PSK_LINE" =~ psk=\"(.+)\" ]]; then
PSK="${BASH_REMATCH[1]}"
# Case 1: SSID is a quoted readable string like ssid="Test's iPhone"
if [[ "$SSID_LINE" =~ ssid=\"(.*)\" ]]; then
SSID="${BASH_REMATCH[1]}"
echo "SSID in quoted format SSID: $SSID"
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic relies on bash-specific features ([[ ... ]], regex matching with =~, and BASH_REMATCH). Since the script is invoked via #!/bin/sh, it will fail on systems where /bin/sh is not bash/ksh (e.g., dash). Either switch the shebang to bash or rewrite the matching/extraction using POSIX-compatible constructs.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 1, 2026 19:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment on lines +42 to +45
# Convert hex string to readable UTF-8 string
# Using printf with \x formatting for each byte pair
SSID=$(printf "$(echo "$HEX_SSID" | sed 's/../\\x&/g')")
echo "Converted Hex SSID to string: $SSID"
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hex SSID decoding uses printf "$(...)" where the decoded bytes become part of the format string. If the SSID contains % (common), printf will treat it as a format specifier and can error or corrupt output. Use a constant format string (e.g., printf '%b' ...) and also validate that the hex length is even before attempting byte-pair decoding.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings May 1, 2026 20:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rdk/NM_Bootstrap.sh Outdated
jincysam87 and others added 2 commits May 1, 2026 16:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 1, 2026 20:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 1, 2026 20:53
jincysam87 and others added 2 commits May 1, 2026 16:53
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 4, 2026 14:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
sed -i '/network={/,/}/d' "$RDKV_SUPP_CONF"

else
echo "Config file not found." >> /opt/logs/NMMonitor.log
jincysam87 and others added 2 commits May 4, 2026 10:15
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 4, 2026 14:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rdk/NM_Bootstrap.sh
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 4, 2026 15:04
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rdk/NM_Bootstrap.sh
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 4, 2026 16:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 4, 2026 17:29
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rdk/NM_Bootstrap.sh Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 4, 2026 17:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rdk/NM_Bootstrap.sh
Comment on lines +101 to +111
KEY_MGMT_LINE=$(grep -m 1 '^[[:space:]]*key_mgmt=' "$RDKV_SUPP_CONF")

case "$KEY_MGMT_LINE" in
*SAE*)
echo "`/bin/timestamp`:key_mgmt is SAE" >> /opt/logs/NMMonitor.log
KEY_MGMT=sae
;;
*)
echo "`/bin/timestamp`:key_mgmt is wpa-psk" >> /opt/logs/NMMonitor.log
KEY_MGMT=wpa-psk
;;
@jincysam87 jincysam87 closed this May 4, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants