Skip to content

Conversation

@abhishek-kumaracee2
Copy link
Contributor

Reason for change : Modify device.properties file based on partner ID
Test Procedure : Check that /etc/device.properties contains "IS_BCI=yes"
Risks : Low
Priority: Medium
Signed-off-by: abhishek_kumaracee2@comcast.com

Reason for change : Modify device.properties file based on partner ID
Test Procedure    : Check that /etc/device.properties contains "IS_BCI=yes"
Risks : Low
Priority: Medium
Signed-off-by: abhishek_kumaracee2@comcast.com
@abhishek-kumaracee2 abhishek-kumaracee2 requested review from a team as code owners January 20, 2026 16:14
Copilot AI review requested due to automatic review settings January 20, 2026 16:14
Copy link
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 modifies the device.properties file at runtime to add the "IS_BCI=yes" property for Comcast Business partner deployments. The change is triggered when the partner ID matches "comcast-business".

Changes:

  • Added a new function addPartnerDefaultsToDevPropFile() to append partner-specific properties to /etc/device.properties
  • Integrated the function call into the main workflow after sysevent processing completes

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

Comment on lines +3322 to +3355
static int addPartnerDefaultsToDevPropFile()
{
FILE *fp = NULL;
const char *is_bci = "IS_BCI=yes\n";
//open to check for existence
fp = fopen(DEV_PROP_FILE, "r");
if (fp == NULL)
{
APPLY_PRINT("[Utopia - %s]File %s does not exist or cannot be accessed",__FUNCTION__,DEV_PROP_FILE);
return 1;
}
fclose(fp); // we don't need it anymore

//open for writing
fp = fopen(DEV_PROP_FILE, "a");
if (fp == NULL)
{
APPLY_PRINT("[Utopia - %s]File %s couldnot open for writing",__FUNCTION__,DEV_PROP_FILE);
return 1;
}

if (fputs(is_bci, fp) == EOF)
{
APPLY_PRINT("[Utopia - %s]File %s write failed",__FUNCTION__,DEV_PROP_FILE);
fclose(fp);
return 1;
}

APPLY_PRINT("[Utopia - %s]File %s write successful",__FUNCTION__,DEV_PROP_FILE);

fclose(fp);

return 0;
}
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The function unconditionally appends "IS_BCI=yes" to the file every time it's called, without checking if the entry already exists. This will result in duplicate entries if the program runs multiple times or if the entry is already present. Before appending, check if "IS_BCI" already exists in the file to prevent duplicates.

Copilot uses AI. Check for mistakes.

if (0 == strcasecmp (PartnerID, "comcast-business"))
{
addPartnerDefaultsToDevPropFile();
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The return value of addPartnerDefaultsToDevPropFile() is not checked. If the function fails to write to the file (returns 1), the error is silently ignored. Consider checking the return value and logging an appropriate error message, similar to how other function calls in this section handle errors (see line 3563-3565).

Copilot uses AI. Check for mistakes.
Comment on lines +3327 to +3336
fp = fopen(DEV_PROP_FILE, "r");
if (fp == NULL)
{
APPLY_PRINT("[Utopia - %s]File %s does not exist or cannot be accessed",__FUNCTION__,DEV_PROP_FILE);
return 1;
}
fclose(fp); // we don't need it anymore

//open for writing
fp = fopen(DEV_PROP_FILE, "a");
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

Opening the file twice (first for read, then for append) creates a race condition window where the file could be deleted, modified, or have its permissions changed between the two operations. Consider combining the operations or using access() to check file existence if the only purpose of the first open is verification.

Copilot uses AI. Check for mistakes.
fp = fopen(DEV_PROP_FILE, "a");
if (fp == NULL)
{
APPLY_PRINT("[Utopia - %s]File %s couldnot open for writing",__FUNCTION__,DEV_PROP_FILE);
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

Spelling error in error message. "couldnot" should be two separate words: "could not".

Suggested change
APPLY_PRINT("[Utopia - %s]File %s couldnot open for writing",__FUNCTION__,DEV_PROP_FILE);
APPLY_PRINT("[Utopia - %s]File %s could not open for writing",__FUNCTION__,DEV_PROP_FILE);

Copilot uses AI. Check for mistakes.
#endif

#define DEV_PROP_FILE "/etc/device.properties"
static int addPartnerDefaultsToDevPropFile()
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The function lacks documentation. Add a comment block before the function explaining its purpose, parameters (if any were to be added), return values, and any side effects (modifying /etc/device.properties file). This is especially important since this function modifies a system configuration file.

Copilot uses AI. Check for mistakes.
}
#endif

#define DEV_PROP_FILE "/etc/device.properties"
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The macro DEV_PROP_FILE is defined locally within the function scope when it should be defined at file scope with other macros (near lines 64-66). This placement is inconsistent with the established pattern in the codebase where file path macros are defined at the top of the file.

Copilot uses AI. Check for mistakes.
FILE *fp = NULL;
const char *is_bci = "IS_BCI=yes\n";
//open to check for existence
fp = fopen(DEV_PROP_FILE, "r");
Copy link
Contributor

Choose a reason for hiding this comment

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

can we modify with access call?

}

sysevent_close(global_fd, global_id);

Copy link
Contributor

Choose a reason for hiding this comment

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

can you please bring this under ONESTACK_PRODUCT_REQ

static int addPartnerDefaultsToDevPropFile()
{
FILE *fp = NULL;
const char *is_bci = "IS_BCI=yes\n";
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep this in some kind of array and have a generic runner logic to add the paramaters in array.
This to support , if any additional parameters needed, we can add it in array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants