campaignd: Allow more than 3 arguments to setattr

This makes it possible to pass strings with whitespace in them.
Obviously this is still a bit awkward since only single whitespace is
accepted.
This commit is contained in:
Iris Morelle 2021-10-25 16:50:13 -03:00
parent e321d18687
commit 297ee3d1ce
No known key found for this signature in database
GPG key ID: E312033F4023A753

View file

@ -612,12 +612,18 @@ void server::handle_read_from_fifo(const boost::system::error_code& error, std::
}
}
} else if(ctl == "setattr") {
if(ctl.args_count() != 3) {
if(ctl.args_count() < 3) {
ERR_CS << "Incorrect number of arguments for 'setattr'\n";
} else {
const std::string& addon_id = ctl[1];
const std::string& key = ctl[2];
const std::string& value = ctl[3];
std::string value;
for (std::size_t i = 3; i <= ctl.args_count(); ++i) {
if(i > 3) {
value += ' ';
}
value += ctl[i];
}
config& addon = get_addon(addon_id);