Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure tools never create config.ldb #7551

Closed
wants to merge 4 commits into from

Conversation

alexey-tikhonov
Copy link
Member

This is an addition to a008acc

@alexey-tikhonov alexey-tikhonov added no-backport This should go to target branch only. non-privileged labels Aug 30, 2024
Take a note this also enforces check for existance of config.ldb in additional
code paths (this is intentional side effect, see a008acc)
@alexey-tikhonov alexey-tikhonov force-pushed the confdb-init branch 2 times, most recently from 8289db3 to b94f8cf Compare August 31, 2024 08:29
Take a note this also enforces check for existance of config.ldb in additional
code paths (this is intentional side effect, see a008acc)
@@ -108,18 +112,14 @@ static errno_t sss_tool_confdb_init(TALLOC_CTX *mem_ctx,
return ret;
}

ret = confdb_init(mem_ctx, &confdb, path);
ret = confdb_init(mem_ctx, _confdb, path);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not directly related to you commit.

confdb_init() is assuming its cdb_ctx parameter is not NULL. It clearly is not here, but could be in other calls. Shouldn't we also check inside this function that it is not NULL? Or maybe just move the check to that function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Shouldn't we also check inside this function that it is not NULL?

this == sss_tool_confdb_init()?

But here is the check in place at the beginning (line 97)
Or do I misunderstand?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, sorry. this == confdb_init().

In other words, sss_tool_confdb_init() is checking _confdb != NULL, but other functions are also calling confdb_init(), and those functions may or may not check that condition. It might be better to move the check inside confdb_init().

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, added one more patch.

closer to a place where argument is really used
Copy link
Contributor

@aplopez aplopez left a comment

Choose a reason for hiding this comment

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

ACK. Thanks.

@alexey-tikhonov
Copy link
Member Author

Pushed PR: #7551

  • master
    • 604be8d - CONFDB: move sanity check
    • 50b4579 - TOOLS: use sss_tool_confdb_init() everywhere
    • 14d4e01 - TOOLS: get rid of code duplication
    • 432f280 - TOOLS: skip confdb_init if no context ptr provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport This should go to target branch only. non-privileged Pushed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants