* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-* The views and conclusions contained in the software and documentation are those
-* of the authors and should not be interpreted as representing official policies,
-* either expressed or implied, of the FreeBSD Project.
*/
#include <iostream>
pt::ini_parser::read_ini(CONFIG_FILE, config);
std::string nsupdate = config.get<std::string>("nsupdate");
unsigned server_port = config.get<unsigned>("port", 53);
+ std::string keyfile = config.get<std::string>("keyfile", "");
+ std::string key = config.get<std::string>("key", "");
+
+ /* check for some invalid configurations */
+ if (keyfile.size() > 0 && key.size() > 0) {
+ std::cerr << "You can only have either a keyfile or a key set. Please fix your configuration." << std::endl;
+ exit(1);
+ }
/* Given the domain, check whether the password matches */
optional<std::string> correct_password = config.get_optional<std::string>(pt::ptree::path_type(domain+"/password", '/'));
exit(1);
}
/* exec nsupdate */
- execl(nsupdate.c_str(), nsupdate.c_str(), "-p", std::to_string(server_port).c_str(), "-l", (char *)NULL);
+ if (keyfile.size() > 0) {
+ execl(nsupdate.c_str(), nsupdate.c_str(), "-k", keyfile.c_str(), "-p", std::to_string(server_port).c_str(), "-l", (char *)NULL);
+ }
+ else if (key.size() > 0) {
+ execl(nsupdate.c_str(), nsupdate.c_str(), "-y", key.c_str(), "-p", std::to_string(server_port).c_str(), "-l", (char *)NULL);
+ }
+ else {
+ execl(nsupdate.c_str(), nsupdate.c_str(), "-p", std::to_string(server_port).c_str(), "-l", (char *)NULL);
+ }
/* There was an error */
std::cerr << "There was an error executing nsupdate." << std::endl;
exit(1);