Skip to content

fix: prevent nomos CLI from connecting to DB when not required (#1299) - #2947

Merged
shaheemazmalmmd merged 1 commit into
fossology:masterfrom
SalmanDeveloperz:fix-nomos-cli-db-connection
May 29, 2025
Merged

shaheemazmalmmd merged 1 commit into
fossology:masterfrom
SalmanDeveloperz:fix-nomos-cli-db-connection

Conversation

@SalmanDeveloperz

Copy link
Copy Markdown
Contributor

Description

This pull request addresses issue #1299 by preventing the nomos CLI from attempting to read the Db.conf file when a database connection is not required. Specifically, the CLI no longer tries to open a DB connection when displaying the help message (-h flag), which previously caused a permission error.

Changes

  • Introduced a global flag should_connect_to_db in libfossscheduler.c to control whether a database connection should be initiated.
  • Modified the Usage() function in nomos.utils.c to set should_connect_to_db = 0 when the help command (-h) is used.
  • Updated the fo_scheduler_connect_conf() function to respect this flag, ensuring the database connection is only attempted when necessary.

How to test

  1. Display Help Message (-h):
    Run the following command to verify that the help message is displayed without any DB connection attempt or permission error:
    ./src/nomos/agent/nomos -h

Screenshot from 2025-02-01 12-09-39

@dvjsharma dvjsharma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @SalmanDeveloperz. Haven't tested the PR yet, PTAL at the comments.

Comment thread src/lib/c/libfossscheduler.c
Comment thread src/nomos/agent/nomos_utils.c
Kaushl2208
Kaushl2208 previously approved these changes Feb 4, 2025

@Kaushl2208 Kaushl2208 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes looks good, Needs test :)

@dvjsharma dvjsharma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes looks good.

@shaheemazmalmmd

Copy link
Copy Markdown
Member

@SalmanDeveloperz : please change the commit message according to our contributing guidelines

@SalmanDeveloperz

Copy link
Copy Markdown
Contributor Author

Hi @shaheemazmalmmd , Commit message updated as per the guidelines. Please let me know if any other changes are needed.
Thanks

@Kaushl2208

Copy link
Copy Markdown
Member

Hey @SalmanDeveloperz , Commit message is good but you still need to sign-off your commit. Take a look at Signing Commits
Also rebase your branch with current master.

Once those are done. It can be merged.

@SalmanDeveloperz

Copy link
Copy Markdown
Contributor Author

Hey @Kaushl2208 ,
I have added the Signed-off-by line to my commit and rebased the branch with the current master.
PR is updated and ready for review. Please let me know if further changes are required.
Thanks

…fossology#1299)

Signed-off-by: Muhammad Salman <chsalmanramzan422@gmail.com>
@Kaushl2208
Kaushl2208 force-pushed the fix-nomos-cli-db-connection branch from 3a7cd28 to fcf95aa Compare May 28, 2025 18:54
@shaheemazmalmmd
shaheemazmalmmd merged commit 3513991 into fossology:master May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants