dird: config: console: prohibit PAM usage with user ACL and Profiles in consoles#1318
Conversation
31fab3f to
d619457
Compare
arogge
left a comment
There was a problem hiding this comment.
We should really improve LockRes()/UnlockRes() as it is too easy to misuse.
I'm not sure if your check for the ACL is correct/complete, but overall it looks good.
| configfile.c_str()); | ||
| OK = false; | ||
| goto bail_out; | ||
| UnlockRes(my_config); |
There was a problem hiding this comment.
if we had GSL, you could set this up using finally() or if ConfigurationParser would satisfy BasicLockable one could just use a lock_guard lock{my_config}. This would remove the need for the explicit UnlockRes(my_config)
There was a problem hiding this comment.
another issue we have with this, is that in certain functions around the code base, there are instances where there are multiple locks and unlocks
void afunction() {
lockres(...)
do_something
unlockres(...)
do_something_else
lockres(..) //again
doxxxxx
unlockres(..)
}
unless we go around everywhere refactoring to make those functions use a single lock (there are 64 matches for lockres) and make sure the logic stays the same, I don't think there will be a quick fix for this.
I remember we did something similar before with the database locking by creating a DbLocker class that would do locking on construction and unlocking on destruction. But we were lucky in that instance because the locking and unlocking would occur only once for every function involved.
There was a problem hiding this comment.
We can probably keep the old behaviour, but allow newer and refactored code to utilize RAII here.
Besides that, you can always do it like this:
void afunction() {
{
std::lock_guard lock(my_config);
do_something
}
do_something_else
{
std::lock_guard lock(my_config);
doxxx
}
}
which isn't nice, but still a lot better than requiring manual unlock (which is btw. one of the main reasons a lot of our code is not exception-safe)
core/src/dird/reload.cc
Outdated
| consoles_with_auth_problems.push_back( | ||
| std::string(console->resource_name_)); |
There was a problem hiding this comment.
With emplace_back() you can just pass your arguments into the constructor of the contained type (and save a copy operation):
| consoles_with_auth_problems.push_back( | |
| std::string(console->resource_name_)); | |
| consoles_with_auth_problems.emplace_back(console->resource_name_); |
core/src/dird/reload.cc
Outdated
| "Console(s) `%s` using `Use Pam Authentication` while " | ||
| "having ACL or a Profile activated\n", |
There was a problem hiding this comment.
that describes a situation, but does not name the problem.
core/src/dird/reload.cc
Outdated
| BStringList consoles_with_auth_problems; | ||
| foreach_res (console, R_CONSOLE) { | ||
| if (console->use_pam_authentication_ | ||
| && (console->user_acl.ACL_lists[0] || console->user_acl.profiles)) { |
There was a problem hiding this comment.
if I understood it correctly, then ACL_lists[0] is only checking for Job_ACL, but not for the others like Catalog_ACL or Command_ACL.
arogge
left a comment
There was a problem hiding this comment.
Great work!
Besides the Changelog, I'm happy with it.
Thank you for contributing to the Bareos Project!
Description
This PR makes Bareos consider malformed, consoles whose configuration having simultaneously
use PAM authenticationand ACL commands, or a Profile having ACL.Please check
If you have any questions or problems, please give a comment in the PR.
Helpful documentation and best practices
Checklist for the reviewer of the PR (will be processed by the Bareos team)
General
Source code quality
bareos-check-sources --since-mergedoes not report any problemsTests