diff --git a/README.md b/README.md index 5d17651..491e1ed 100755 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Take a look at the github releases for detailed information about the features. ## Bugs in 0.5.6: - [ ] Parse function could overwrite comments - - [ ] The same object can be added multiple times to a iqn + - [x] The same object can be added multiple times to a iqn ## Roadmap In version 0.6: diff --git a/app/models/target/Logic.php b/app/models/target/Logic.php index 752df94..a7130fa 100755 --- a/app/models/target/Logic.php +++ b/app/models/target/Logic.php @@ -109,8 +109,8 @@ protected function check_ietd_running() { * @return array|bool * */ - public function get_acls($type = 'initiator') { - if ($type === 'initiator') { + public function get_acls($type = 'initiators') { + if ($type === 'initiators') { $data = $this->parse_file($this->database->get_config('ietd_init_allow')['value'], [$this, 'parse_target_acl'], array(), true, false); } else { $data = $this->parse_file($this->database->get_config('ietd_target_allow')['value'], [$this, 'parse_target_acl'], array(), true, false); @@ -150,27 +150,22 @@ public function get_acls($type = 'initiator') { * */ protected function check_object_already_added($id, $type = 'initiators') { - $data = $this->get_acls(); - - if ($type == "targets") { - if (isset($data['targets'])) { - $value = $this->std->recursive_array_search($this->database->get_object_value($id), $data['targets']); - } else { - $value = false; - } - } else { - if (isset($data['initiators'])) { - $value = $this->std->recursive_array_search($this->database->get_object_value($id), $data['initiators']); - } else { - $value = false; - } - } - - if ($value === false) { - return false; - } else { - return true; - } + $data = $this->get_acls($type); + + if ($data !== false) { + // index 0 contains the iqn + unset($data[0]); + + $key = $this->std->recursive_array_search($this->database->get_object_value($id), $data); + + if ($key !== false) { + return true; + } else { + return false; + } + } else { + return false; + } } /**