Create sqlite zone entries for zones created outside of nsedit. Note that this will create users if they don't exist also.

This commit is contained in:
Richard Underwood 2017-11-13 11:59:53 +00:00
parent 41d6d16a86
commit dbdfea2ae1

View file

@ -97,7 +97,7 @@ function record_compare_content($a, $b) {
return 0; return 0;
} }
function add_db_zone($zonename, $accountname) { function add_db_zone($zonename, $accountname, $createuser = false) {
if (valid_user($accountname) === false) { if (valid_user($accountname) === false) {
jtable_respond(null, 'error', "$accountname is not a valid username"); jtable_respond(null, 'error', "$accountname is not a valid username");
} }
@ -105,7 +105,7 @@ function add_db_zone($zonename, $accountname) {
jtable_respond(null, 'error', "$zonename is not a valid zonename"); jtable_respond(null, 'error', "$zonename is not a valid zonename");
} }
if (is_apiuser() && !user_exists($accountname)) { if ((is_apiuser() || $createuser) && !user_exists($accountname)) {
add_user($accountname); add_user($accountname);
} }
@ -174,6 +174,10 @@ case "listslaves":
$zone->setAccount(get_zone_account($zone->name, 'admin')); $zone->setAccount(get_zone_account($zone->name, 'admin'));
} }
if(is_null(get_zone_id($zone->name))) {
add_db_zone($zone->name, $zone->account, true);
}
if (!check_permissions($zone->id,PERM_VIEW)) if (!check_permissions($zone->id,PERM_VIEW))
continue; continue;