Rebase feature/RDKEMW-8178 branch inline with develop#434
Rebase feature/RDKEMW-8178 branch inline with develop#434KTirumalaSrihari wants to merge 197 commits intofeature/RDKEMW-8178from
Conversation
Sysint Release for Develop
…ution Update rebootNow.sh
Update CODEOWNERS
…elop Deploy cla action
RDKTV-38567: PAT_EntOS_A4K-Soft Reboot failed from settings; Stuck on Black screen
Reason for change: Defauting MTLS and remove fallback Test Procedure: Make sure all communication is MTLS & secure Risks: Medium Priority: P1
Deploy fossid_integration_stateless_diffscan_target_repo action
Rebase with develop
Release tag for sysint repo
Rebase with develop
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 57 out of 57 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (3)
lib/rdk/NM_Bootstrap.sh:36
- This script is declared as /bin/sh, but uses bash-only regex matching and BASH_REMATCH (e.g.
[[ ... =~ ... ]]and${BASH_REMATCH[1]}). On platforms where /bin/sh is BusyBox ash/dash, this will fail and prevent NM bootstrap from extracting the PSK. Please replace this with POSIX-compatible parsing (e.g. sed/awk) or change the interpreter to bash if that’s guaranteed on target devices.
if [ -f $RDKV_SUPP_CONF ]; then
SSID=$(cat $RDKV_SUPP_CONF | grep -w ssid= | cut -d '"' -f 2)
PSK_LINE=$(grep psk= "$RDKV_SUPP_CONF")
# Case 1: Quoted passphrase
if [[ "$PSK_LINE" =~ psk=\"(.+)\" ]]; then
PSK="${BASH_REMATCH[1]}"
# Case 2: Unquoted 64-char raw PSK
elif [[ "$PSK_LINE" =~ psk=([a-fA-F0-9]{64}) ]]; then
PSK="${BASH_REMATCH[1]}"
lib/rdk/getDeviceDetails.sh:292
- getBluetoothMac() initializes bluetooth_mac to a default, but then unconditionally overwrites it with the output of readBTAddress-*.sh. If those scripts output an empty string (e.g. Bluetooth disabled), this will return an empty value instead of the intended default. Consider only overwriting when the script returns a non-empty MAC (or have the helper scripts always emit a default).
getBluetoothMac()
{
bluetooth_mac="00:00:00:00:00:00"
if [ -f /lib/rdk/readBTAddress-vendor.sh ]; then
bluetooth_mac=`sh /lib/rdk/readBTAddress-vendor.sh`
else
bluetooth_mac=`sh /lib/rdk/readBTAddress-generic.sh`
fi
echo "$bluetooth_mac"
}
lib/rdk/readBTAddress-generic.sh:31
- If BLUETOOTH_ENABLED is not "true", bluetooth_mac is never initialized and the script echoes an empty string. Callers like getDeviceDetails.sh expect a valid MAC (or a default like 00:00:00:00:00:00). Initialize bluetooth_mac to a safe default and quote it when echoing to avoid word-splitting.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Get the next available file descriptor and export if it's valid | ||
| FD_NUMBER=$(get_next_fd) | ||
| if [ $? -eq 0 ]; then | ||
| export FD_NUMBER | ||
|
|
||
| # Create a named pipe | ||
| PIPE=$(mktemp -u) | ||
| if ! mkfifo "$PIPE" 2>/dev/null; then | ||
| echo_t "STUNNEL: ERROR - Failed to create named pipe" | ||
| fi | ||
|
|
||
| # Open the pipe using the available FD, with error handling | ||
| if ! eval "exec $FD_NUMBER<>$PIPE" 2>/dev/null; then | ||
| echo_t "STUNNEL: ERROR - Failed to open pipe with file descriptor" | ||
| fi | ||
|
|
||
| # Removing the pipe after opening | ||
| rm "$PIPE" | ||
|
|
||
| # Writing passcode to open file descriptor | ||
| echo "$(eval "$PASSCODE")" >&$FD_NUMBER & | ||
| else |
There was a problem hiding this comment.
The new FD/pipe block references PASSCODE but that variable is not defined anywhere in this script. As written, it will write an empty value (or whatever is inherited from the environment) to the FD, and eval "$PASSCODE" is also a command-injection risk. Define/validate where the passcode comes from (e.g. an explicit argument), and avoid eval by writing the literal value safely.
| # Create a named pipe | ||
| PIPE=$(mktemp -u) | ||
| if ! mkfifo "$PIPE" 2>/dev/null; then | ||
| echo_t "STUNNEL: ERROR - Failed to create named pipe" | ||
| fi | ||
|
|
||
| # Open the pipe using the available FD, with error handling | ||
| if ! eval "exec $FD_NUMBER<>$PIPE" 2>/dev/null; then | ||
| echo_t "STUNNEL: ERROR - Failed to open pipe with file descriptor" | ||
| fi | ||
|
|
||
| # Removing the pipe after opening | ||
| rm "$PIPE" | ||
|
|
||
| # Writing passcode to open file descriptor | ||
| echo "$(eval "$PASSCODE")" >&$FD_NUMBER & |
There was a problem hiding this comment.
PIPE=$(mktemp -u) is unsafe (TOCTOU race) and can be exploited if an attacker can create the same path before mkfifo runs. Prefer creating a secure temp path with mktemp (without -u) and then creating the FIFO under that directory or using a securely generated filename that you create atomically.
| # Create a named pipe | |
| PIPE=$(mktemp -u) | |
| if ! mkfifo "$PIPE" 2>/dev/null; then | |
| echo_t "STUNNEL: ERROR - Failed to create named pipe" | |
| fi | |
| # Open the pipe using the available FD, with error handling | |
| if ! eval "exec $FD_NUMBER<>$PIPE" 2>/dev/null; then | |
| echo_t "STUNNEL: ERROR - Failed to open pipe with file descriptor" | |
| fi | |
| # Removing the pipe after opening | |
| rm "$PIPE" | |
| # Writing passcode to open file descriptor | |
| echo "$(eval "$PASSCODE")" >&$FD_NUMBER & | |
| # Create a named pipe in a securely created temporary directory | |
| PIPE_DIR=$(mktemp -d 2>/dev/null) | |
| if [ -z "$PIPE_DIR" ] || [ ! -d "$PIPE_DIR" ]; then | |
| echo_t "STUNNEL: ERROR - Failed to create temporary directory for named pipe" | |
| else | |
| PIPE="$PIPE_DIR/pipe" | |
| if ! mkfifo "$PIPE" 2>/dev/null; then | |
| echo_t "STUNNEL: ERROR - Failed to create named pipe" | |
| rmdir "$PIPE_DIR" 2>/dev/null | |
| else | |
| # Open the pipe using the available FD, with error handling | |
| if ! eval "exec $FD_NUMBER<>$PIPE" 2>/dev/null; then | |
| echo_t "STUNNEL: ERROR - Failed to open pipe with file descriptor" | |
| fi | |
| # Removing the pipe after opening | |
| rm -f "$PIPE" | |
| rmdir "$PIPE_DIR" 2>/dev/null | |
| # Writing passcode to open file descriptor | |
| echo "$(eval "$PASSCODE")" >&$FD_NUMBER & | |
| fi | |
| fi |
| if [ -f "/tmp/checkpacketloss" ] ; then | ||
| if [ "$version" = "V4" ] ; then | ||
| gwIp=$(cat /tmp/checkpacketloss) | ||
| pingCmd="ping" | ||
| fi |
There was a problem hiding this comment.
When /tmp/checkpacketloss exists, the code only sets gwIp/pingCmd for the V4 call. On the subsequent V6 call, gwIp remains empty, so the function will incorrectly treat it as "no route" and can skew packet-loss state/telemetry. Consider either supporting a V6 override file as well, or only using /tmp/checkpacketloss for V4 while still computing V6 gwIp normally.
| key="$1" | ||
| # Extract RHS after '=' and trim whitespace | ||
| grep -m1 -E "^[[:space:]]*$key=" "$BOOTSTRAP" 2>/dev/null | \ | ||
| cut -d'=' -f2- | sed 's/^[[:space:]]*//; s/[[:space:]]*$//' | ||
| } |
There was a problem hiding this comment.
In get_bs_val(), grep is using an extended-regex pattern built from the full TR-181 key (e.g. Device.Time.NTPServer1). Because the key contains '.' characters, -E will treat them as wildcards and may match unintended lines in bootstrap.ini. Use a fixed-string match (grep -F) or escape the key before building the regex.
| if [ "x$PROCESS_NAME" == "xdeepSleepMgrMain" ]; then | ||
| # Message data is actual metadata header in case of trigger from deepSleep manager process | ||
| # This change is needed since there are data clouds in different deployment which are not flexible to accomodate any deviations in data format | ||
| strjson="{\"searchResult\":[{\"Time\":\"$currentTime\"},{\"process_name\":\"$PROCESS_NAME\"},{\"mac\":\"$estb_mac\"},{\"Version\":\"$software_version\"},{\"PartnerId\":\"$partnerId\"},{\"$MSG_DATA\":\"1\"}]}" | ||
| else | ||
| strjson="{\"searchResult\":[{\"process_name\":\"$PROCESS_NAME\"},{\"mac\":\"$estb_mac\"},{\"Version\":\"$software_version\"},{\"msgTime\":\"$currentTime\"},{\"PartnerId\":\"$partnerId\"},{\"logEntry\":\"$MSG_DATA\"}]}" | ||
| fi |
There was a problem hiding this comment.
MSG_DATA is embedded directly into JSON (both as a key in the deepSleepMgrMain branch and as a string value in the else branch) without any escaping. If MSG_DATA contains quotes, backslashes, or newlines, the JSON becomes invalid; if exec_curl_mtls ultimately evals/executes the curl string, this can also become a command-injection vector. Escape MSG_DATA for JSON (or build the payload with a JSON tool) and avoid passing a shell-constructed curl command through eval-style execution.
Sysint Release 5.0.1
…is missing (#511) * RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_file_name is missing Reason for change: gstreamer-cleanup is happening on every reboot when /opt/cdl_flashed_file_name is missing Test Procedure: Boot the TV and check for gstreamer-cleanup metrics in rdk_milestones.log Risks: low Signed-off-by: Renuka Varry <rvarry049@cable.comcast.com> * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_file_name is missing Reason for change: gstreamer-cleanup is happening on every reboot when /opt/cdl_flashed_file_name is missing Test Procedure: Boot the TV and check for gstreamer-cleanup metrics in rdk_milestones.log Risks: low Signed-off-by: Renuka Varry <rvarry049@cable.comcast.com> * License banner addition Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * RDKEMW-10725:gstreamer-cleanup conditions when cdl_flashed_file_name is missing Reason for change: gstreamer-cleanup is happening on every reboot when /opt/cdl_flashed_file_name is missing Test Procedure: Boot the TV and check for gstreamer-cleanup metrics in rdk_milestones.log Risks: low Signed-off-by: Renuka Varry <rvarry049@cable.comcast.com> --------- Signed-off-by: Renuka Varry <rvarry049@cable.comcast.com> Co-authored-by: Renuka Varry <rvarry049@cable.comcast.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 58 out of 58 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
lib/rdk/readBTAddress-generic.sh:31
- When BLUETOOTH_ENABLED is not "true", bluetooth_mac is never set, so this script echoes an empty value. Callers (e.g., getDeviceDetails.sh) expect a deterministic output; consider setting bluetooth_mac to a default like "00:00:00:00:00:00" (or explicitly echoing that default) when Bluetooth is disabled/unavailable.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| FD_NUMBER=$(get_next_fd) | ||
| if [ $? -eq 0 ]; then | ||
| export FD_NUMBER | ||
|
|
||
| # Create a named pipe | ||
| PIPE=$(mktemp -u) | ||
| if ! mkfifo "$PIPE" 2>/dev/null; then | ||
| echo_t "STUNNEL: ERROR - Failed to create named pipe" | ||
| fi | ||
|
|
||
| # Open the pipe using the available FD, with error handling | ||
| if ! eval "exec $FD_NUMBER<>$PIPE" 2>/dev/null; then | ||
| echo_t "STUNNEL: ERROR - Failed to open pipe with file descriptor" | ||
| fi | ||
|
|
||
| # Removing the pipe after opening | ||
| rm "$PIPE" | ||
|
|
||
| # Writing passcode to open file descriptor | ||
| echo "$(eval "$PASSCODE")" >&$FD_NUMBER & | ||
| else | ||
| echo "Error: No available file descriptor to use." >&2 | ||
| fi |
There was a problem hiding this comment.
This new pipe/FD block appears broken: PASSCODE is never defined anywhere in this script, so the eval will write an empty string (or error) to the FD. Additionally, eval here is a command-injection risk, and mktemp -u is vulnerable to TOCTOU races. If a passcode needs to be passed to a downstream process, define a clear source for it, avoid eval, and use a securely-created FIFO (mktemp + mkfifo) or a different IPC mechanism; otherwise remove this dead/unreliable block.
| #Send telemetry notification for 20%,30%....90% packet loss | ||
| if [ "$packetsLostipv4" -gt "$lossThreshold" ] || [ "$packetsLostipv6" -gt "$lossThreshold" ] ; then | ||
| echo "$(/bin/timestamp) Packet loss more than $lossThreshold% observed." >> "$logsFile" | ||
| [ "$lossThreshold" -eq 10 ] && t2CountNotify "WIFIV_WARN_PL_10PERC" | ||
| if [ "$packetsLostipv4" -ne 100 ] && [ "$packetsLostipv6" -ne 100 ]; then | ||
| for i in {1..9}; do | ||
| if ([ "$packetsLostipv4" -ge $((i*10)) ] && [ "$packetsLostipv4" -lt $((i*10+10)) ]) || ([ "$packetsLostipv6" -ge $((i*10)) ] && [ "$packetsLostipv6" -lt $((i*10+10)) ]); then | ||
| echo "$(/bin/timestamp) Current Packet loss is WIFIV_WARN_PL_"$((i*10))"PERC" >> "$logsFile" | ||
| t2CountNotify "WIFIV_WARN_PL_"$((i*10))"PERC" | ||
| break | ||
| fi | ||
| done |
There was a problem hiding this comment.
This script is /bin/sh, but the loop for i in {1..9} relies on bash brace expansion, which is not supported by many /bin/sh implementations (dash/busybox ash). That will cause the telemetry threshold loop to run once with the literal string "{1..9}", breaking the packet-loss notification logic. Use a POSIX-compatible loop (e.g., a numeric while loop or seq) instead.
| [Unit] | ||
| Description=Log Internet connectivity and Trigger network target | ||
| After=dbus.service | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| ExecStartPre=/bin/touch /tmp/connectivity_check_done | ||
| ExecStart=/lib/rdk/logMilestone.sh "INTERNET_FULLY_CONNECTED" |
There was a problem hiding this comment.
This unit file has no [Install] section and is not referenced by any other unit in this repo, so it won’t be enabled or started by default. If it’s meant to run during boot/network bring-up, add an [Install] stanza (e.g., WantedBy=...) or wire it in via Wants=/After= from an existing target/unit; otherwise it’s likely to be dead configuration.
| if [ -f /lib/rdk/utils-vendor.sh ]; then | ||
| . $RDK_PATH/utils-vendor.sh | ||
| fi |
There was a problem hiding this comment.
The file existence check uses a hard-coded path (/lib/rdk/utils-vendor.sh) but the script sources "$RDK_PATH/utils-vendor.sh". If RDK_PATH is not "/lib/rdk" (or if only one of these locations is populated), this will silently skip vendor utilities or fail to source them. Use the same path for both the -f check and the subsequent source (or check both locations explicitly).
| getBluetoothMac() | ||
| { | ||
| bluetooth_mac="00:00:00:00:00:00" | ||
| if [ "$BLUETOOTH_ENABLED" = "true" ]; then | ||
| bluetooth_mac=$(getDeviceBluetoothMac) | ||
| if [ -f /lib/rdk/readBTAddress-vendor.sh ]; then | ||
| bluetooth_mac=`sh /lib/rdk/readBTAddress-vendor.sh` | ||
| else | ||
| bluetooth_mac=`sh /lib/rdk/readBTAddress-generic.sh` | ||
| fi |
There was a problem hiding this comment.
getBluetoothMac() initializes bluetooth_mac to a default, but then unconditionally overwrites it with the output of readBTAddress-*.sh. If BLUETOOTH_ENABLED is false, readBTAddress-generic.sh currently echoes an empty string, so this function will return an empty value instead of the intended default MAC. Preserve the default when the helper script returns empty (or update the helper script to always emit the default when Bluetooth is disabled/unavailable).
| if [ -z $PSK ]; then | ||
| #connect to wifi | ||
| nmcli conn add type wifi con-name "$SSID" autoconnect yes ifname wlan0 ssid "$SSID" | ||
| nmcli conn reload |
There was a problem hiding this comment.
Similarly, [ -z $PSK ] is unquoted and can produce test syntax errors when PSK is empty or contains whitespace. Quote PSK in the -z test to keep the branching reliable.
… sysint (#522) Co-authored-by: mtirum011 <madhubabu_tirumala@comcast.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 58 out of 58 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
lib/rdk/readBTAddress-generic.sh:31
bluetooth_macis only set whenBLUETOOTH_ENABLED=true, but the script always echoes the variable. When Bluetooth is disabled this prints an empty string, and callers (e.g.,getDeviceDetails.shassigns the script output) will treat it as the device BT MAC. Consider defaulting to00:00:00:00:00:00(or similar) when Bluetooth is disabled / lookup fails, and quote the echo to avoid surprises.
lib/rdk/NM_Bootstrap.sh:37- This script is
#!/bin/shbut uses bash-specific features ([[ ... =~ ... ]]regex matching andBASH_REMATCH). On platforms where/bin/shis not bash (e.g., dash/busybox ash), this will fail and break Wi-Fi bootstrap. Either change the shebang to bash (if guaranteed available) or rewrite the parsing using POSIX tools (grep/sed/awk).
if [[ "$PSK_LINE" =~ psk=\"(.+)\" ]]; then
PSK="${BASH_REMATCH[1]}"
# Case 2: Unquoted 64-char raw PSK
elif [[ "$PSK_LINE" =~ psk=([a-fA-F0-9]{64}) ]]; then
PSK="${BASH_REMATCH[1]}"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if [ -z $SSID ]; then | ||
| echo "`/bin/timestamp` :$0: No SSID found in supplicant conf" >> /opt/logs/NMMonitor.log |
There was a problem hiding this comment.
[ -z $SSID ] (and similarly [ -z $PSK ]) should quote the variable ([ -z "$SSID" ]) to avoid test syntax errors when the variable is empty or contains whitespace. As written, an empty SSID can result in [ -z ] and the script may exit with a shell error.
| PIPE=$(mktemp -u) | ||
| if ! mkfifo "$PIPE" 2>/dev/null; then | ||
| echo_t "STUNNEL: ERROR - Failed to create named pipe" | ||
| fi | ||
|
|
||
| # Open the pipe using the available FD, with error handling | ||
| if ! eval "exec $FD_NUMBER<>$PIPE" 2>/dev/null; then | ||
| echo_t "STUNNEL: ERROR - Failed to open pipe with file descriptor" |
There was a problem hiding this comment.
mktemp -u is inherently race-prone (TOCTOU) and can be exploited to pre-create the chosen path. Since this pipe is used to pass sensitive data (passcode), generate a secure unique path with mktemp (without -u) and then create the FIFO safely (e.g., create temp file, remove it, then mkfifo), or use a fixed, permission-restricted directory.
… present (#528) * RDKEMW-17800:gst-cleanup conditions when cdl_flashed_file_name is not present Reason for change: gstreamer-cleanup is happening on every reboot when /opt/cdl_flashed_file_name is missing. Test Procedure: Boot the TV and check for gstreamer-cleanup metrics in rdk_milestones.log Risks: low Signed-off-by: Renuka Varry <rvarry049@cable.comcast.com> * RDKEMW-17800:gst-cleanup conditions when cdl_flashed_file_name is not present Reason for change: gstreamer-cleanup is happening on every reboot when /opt/cdl_flashed_file_name is missing. Test Procedure: Boot the TV and check for gstreamer-cleanup metrics in rdk_milestones.log Risks: low Signed-off-by: Renuka Varry <rvarry049@cable.comcast.com> --------- Signed-off-by: Renuka Varry <rvarry049@cable.comcast.com> Co-authored-by: Renuka Varry <rvarry049@cable.comcast.com>
* RDKEMW-16774: [Security] Device partition structure seen in logs * Updating system_info_collector script to log top output --------- Co-authored-by: Saranya <saranya_elango@comcast.com>
… crashes (#539) Co-authored-by: mtirum011 <madhubabu_tirumala@comcast.com> Co-authored-by: nhanasi <navihansi@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 59 out of 59 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
lib/rdk/readBTAddress-generic.sh:31
bluetooth_macis only set whenBLUETOOTH_ENABLEDis true; otherwise the script echoes an empty string. Since callers (e.g.getDeviceDetails.sh) expect this helper to always return a value (often defaulting to00:00:00:00:00:00), please initializebluetooth_macto a safe default before the conditional and always echo a quoted value.
lib/rdk/NM_Bootstrap.sh:37- This script is declared with
#!/bin/shbut uses bash-only regex matching ([[ ... =~ ... ]]) andBASH_REMATCH. On systems where/bin/shis not bash, this will fail and prevent WiFi bootstrap from configuring NetworkManager. Either switch the shebang to/bin/bash(and ensure bash is available) or rewrite the PSK extraction to be POSIX-sh compatible (e.g., usingsed/awk).
if [ -f $RDKV_SUPP_CONF ]; then
SSID=$(cat $RDKV_SUPP_CONF | grep -w ssid= | cut -d '"' -f 2)
PSK_LINE=$(grep psk= "$RDKV_SUPP_CONF")
# Case 1: Quoted passphrase
if [[ "$PSK_LINE" =~ psk=\"(.+)\" ]]; then
PSK="${BASH_REMATCH[1]}"
# Case 2: Unquoted 64-char raw PSK
elif [[ "$PSK_LINE" =~ psk=([a-fA-F0-9]{64}) ]]; then
PSK="${BASH_REMATCH[1]}"
* Update NM_Bootstrap.sh * Update NM_Bootstrap.sh * Update NM_Bootstrap.sh * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Update NM_Bootstrap.sh * Update NM_Bootstrap.sh * Update NM_Bootstrap.sh * Update NM_Bootstrap.sh * Update NM_Bootstrap.sh * Update NM_Bootstrap.sh --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
… present (#538) Reason for change: gstreamer-cleanup is happening on every reboot when /opt/cdl_flashed_file_name is missing. Fixing the issues as well as re-locating gstreamer-cleanup.service file to meta-rdk-video instead of sysint folder Test Procedure: Boot the TV and check for gstreamer-cleanup metrics in rdk_milestones.log Risks: low Signed-off-by: Renuka Varry <rvarry049@cable.comcast.com> Co-authored-by: Renuka Varry <rvarry049@cable.comcast.com> Co-authored-by: nhanasi <navihansi@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 59 out of 59 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
lib/rdk/readBTAddress-generic.sh:31
- If
BLUETOOTH_ENABLEDis nottrue,bluetooth_macis never set and the script prints an empty line. Since callers (e.g.,getDeviceDetails.sh) fall back to this script to obtain the BT MAC, consider printing a deterministic default (like00:00:00:00:00:00) when Bluetooth is disabled or whengetDeviceBluetoothMacreturns empty.
| #Function to find available fd at this point in time | ||
| get_next_fd() { | ||
| local fd=3 # Start checking from FD 3 (since 0, 1, 2 are standard in/out/err) | ||
| local max_fd=20 # Maximum FD to check | ||
|
|
||
| # Try to redirect to /dev/null and check if the FD is free | ||
| while [ $fd -le $max_fd ]; do | ||
| if ! { true >&$fd; } 2>/dev/null; then | ||
| echo "$fd" # Output the available FD (goes to standard output) | ||
| return 0 # Set exit status to success | ||
| fi | ||
| fd=$((fd + 1)) | ||
| done | ||
|
|
||
| # Log failure if no free FD is found | ||
| echo "Error: No available file descriptor found up to FD $max_fd" >&2 | ||
| return 1 # Set exit status to failure | ||
| } |
| # Purpose: This script is used to backup the Logs | ||
| # Scope: RDK devices | ||
| # Usage: This script is triggered by systemd service |
No description provided.