RDKB-65607: Check devicetype RFC for prod images alone - #392
RDKB-65607: Check devicetype RFC for prod images alone #392NareshM1702 wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the dropbear (sshd) startup logic to apply the DeviceType RFC check only for prod images, while defaulting to development authorization keys for non-prod builds.
Changes:
- Moves DeviceType-based
authorized_keys_devselection intodo_start(). - Gates DeviceType RFC evaluation behind
BUILD_TYPE=prodand defaults non-prod builds to dev keys.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
241c1aa to
5a8b3ff
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
source/scripts/init/service.d/service_sshd.sh:156
- The
BUILD_TYPE,DEVICETYPE, andUSE_DYNAMICKEYINGvariables are unquoted in[tests. If any are empty/unset, the test can error (e.g., "unary operator expected") and prevent sshd/dropbear from starting. Also,dmcliis executed even for non-prod builds whereDEVICETYPEis ignored; moving thedmclicall inside the prod branch matches the intent (check DeviceType RFC for prod images only) and avoids the extra runtime dependency.
DEVICETYPE=$(dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType | grep value | cut -d ":" -f 3 | tr -d ' ' | tr -s ' ' | tr '[:lower:]' '[:upper:]')
if [ $BUILD_TYPE = "prod" ]; then
if [ $DEVICETYPE = "TEST" ] && [ $USE_DYNAMICKEYING = "TRUE" ]; then
USE_DEVKEYS="-f authorized_keys_dev"
echo_t "[utopia]: dropbear using dev authorization keys"
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
source/scripts/init/service.d/service_sshd.sh:156
dmcliis invoked on everydo_start, even though the DeviceType RFC value is only used to decide key selection for prod images. This contradicts the PR intent (“prod images only”) and adds an unnecessary runtime dependency/cost (and potential hang/failure) on non-prod builds. Gate the RFC query under theBUILD_TYPE=prodbranch.
USE_DEVKEYS="-f authorized_keys_dev"
DEVICETYPE=$(dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType | grep value | cut -d ":" -f 3 | tr -d ' ' | tr -s ' ' | tr '[:lower:]' '[:upper:]')
if [ "$BUILD_TYPE" = "prod" -a "$DEVICETYPE" = "PROD" ]; then
USE_DEVKEYS=""
fi
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
source/scripts/init/service.d/service_sshd.sh:156
- DeviceType RFC is queried unconditionally and the result is only used to clear
USE_DEVKEYSfor prod builds; this contradicts the PR intent (“prod images alone”) and adds an unnecessarydmclidependency/latency on non-prod images. Also, on prod builds the current logic defaults to dev keys unless DeviceType resolves exactly toPROD(fail-open if the RFC read fails/returns unexpected), which is security-sensitive.
Consider only querying RFC on prod builds and defaulting to prod keys on prod builds, enabling dev keys only for an explicit TEST value (and avoid test -a by using nested if/&&).
USE_DEVKEYS="-f authorized_keys_dev"
DEVICETYPE=$(dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType | grep value | cut -d ":" -f 3 | tr -d ' ' | tr -s ' ' | tr '[:lower:]' '[:upper:]')
if [ "$BUILD_TYPE" = "prod" -a "$DEVICETYPE" = "PROD" ]; then
USE_DEVKEYS=""
fi
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
source/scripts/init/service.d/service_sshd.sh:157
USE_DEVKEYScurrently defaults to the dev authorized_keys file and is only cleared when bothBUILD_TYPE=prodand the RFC returnsPROD. On a prod image, if thedmcliread fails or returns an unexpected/empty value, this becomes a security-sensitive fail-open to dev keys. Also, per the PR description (“prod images alone”), the RFC read should be done only for prod builds.
USE_DEVKEYS="-f authorized_keys_dev"
DEVICETYPE=$(dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType | grep value | cut -d ":" -f 3 | tr -d ' ' | tr -s ' ' | tr '[:lower:]' '[:upper:]')
if [ "$BUILD_TYPE" = "prod" -a "$DEVICETYPE" = "PROD" ]; then
USE_DEVKEYS=""
fi
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
source/scripts/init/service.d/service_sshd.sh:157
dmcli ... DeviceTypeis executed unconditionally andUSE_DEVKEYSdefaults to dev keys. On a prod build, if the RFC read fails/returns empty, this falls back to dev keys (fail-open) and also contradicts the PR intent of checking DeviceType only for prod images. Consider reading the RFC only whenBUILD_TYPE=prodand defaulting to prod keys when the RFC value is missing.
USE_DEVKEYS="-f authorized_keys_dev"
DEVICETYPE=$(dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DeviceType | grep value | cut -d ":" -f 3 | tr -d ' ' | tr -s ' ' | tr '[:lower:]' '[:upper:]')
if [ "$BUILD_TYPE" = "prod" -a "$DEVICETYPE" = "PROD" ]; then
USE_DEVKEYS=""
fi
Reason for change: Bind dropbear according to DeviceType RFC for prod images only
Test Procedure: build and test ssh
Risks: Low
Priority: P1
Signed-off by : nareshkumar_m@comcast.com