From bf3935ad71d7dce67c63b33fc01004bf101d7a7f Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 25 Oct 2007 14:29:51 +0000 Subject: [PATCH] Added check to all system entries which checks for a valid host name. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7665 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_componentGeneric.inc | 5 +++++ plugins/admin/systems/class_phoneGeneric.inc | 5 +++++ plugins/admin/systems/class_printGeneric.inc | 2 +- plugins/admin/systems/class_servGeneric.inc | 5 +++++ plugins/admin/systems/class_terminalGeneric.inc | 5 +++++ plugins/admin/systems/class_workstationGeneric.inc | 5 +++++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/plugins/admin/systems/class_componentGeneric.inc b/plugins/admin/systems/class_componentGeneric.inc index 2e65dccb0..09ca79507 100644 --- a/plugins/admin/systems/class_componentGeneric.inc +++ b/plugins/admin/systems/class_componentGeneric.inc @@ -148,6 +148,11 @@ class componentGeneric extends plugin $message[]= _("The required field 'Component name' is not set."); } + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn) && chkacl ($this->acl, "cn") == ""){ + $message[] = _("Please specify a valid name for this object."); + } + /* To check for valid ip*/ if($this->netConfigDNS->ipHostNumber == ""){ $message[]= _("The required field IP address is empty."); diff --git a/plugins/admin/systems/class_phoneGeneric.inc b/plugins/admin/systems/class_phoneGeneric.inc index 33388787b..0374211ae 100644 --- a/plugins/admin/systems/class_phoneGeneric.inc +++ b/plugins/admin/systems/class_phoneGeneric.inc @@ -303,6 +303,11 @@ class phoneGeneric extends plugin $message[]= _("The 'Phone name' '0' is reserved and cannot be used."); } + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn) && chkacl ($this->acl, "cn") == ""){ + $message[] = _("Please specify a valid name for this object."); + } + $ui= get_userinfo(); $acl= get_permissions ($this->dn, $ui->subtreeACL); $acl= get_module_permission($acl, "phone", $this->dn); diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc index 86d13fa9f..1345146e6 100644 --- a/plugins/admin/systems/class_printGeneric.inc +++ b/plugins/admin/systems/class_printGeneric.inc @@ -644,7 +644,7 @@ class printgeneric extends plugin } /* must: cn */ - if(($this->BelongsTo == "Printer") && !preg_match("/^[a-z0-9\.\-_]*$/i",$this->cn)){ + if(($this->BelongsTo == "Printer") && !is_dns_name($this->cn)){ $message[]= _("Invalid character in printer name."); } diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc index d730adafe..ca9ed1740 100644 --- a/plugins/admin/systems/class_servGeneric.inc +++ b/plugins/admin/systems/class_servGeneric.inc @@ -245,6 +245,11 @@ class servgeneric extends plugin $message[]= _("The required field 'Server name' is not set."); } + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn) && chkacl ($this->acl, "cn") == ""){ + $message[] = _("Please specify a valid name for this object."); + } + $ui= get_userinfo(); $acl= get_permissions ($this->dn, $ui->subtreeACL); $acl= get_module_permission($acl, "servgeneric", $this->dn); diff --git a/plugins/admin/systems/class_terminalGeneric.inc b/plugins/admin/systems/class_terminalGeneric.inc index dcfce668c..aa593d854 100644 --- a/plugins/admin/systems/class_terminalGeneric.inc +++ b/plugins/admin/systems/class_terminalGeneric.inc @@ -422,6 +422,11 @@ class termgeneric extends plugin $message[]= _("The required field 'Terminal name' is not set."); } + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn) && chkacl ($this->acl, "cn") == ""){ + $message[] = _("Please specify a valid name for this object."); + } + if ($this->orig_dn == 'new'){ $ldap= $this->config->get_ldap_link(); $ldap->cd ($this->config->current['BASE']); diff --git a/plugins/admin/systems/class_workstationGeneric.inc b/plugins/admin/systems/class_workstationGeneric.inc index 341dc15a8..ca1333fbd 100644 --- a/plugins/admin/systems/class_workstationGeneric.inc +++ b/plugins/admin/systems/class_workstationGeneric.inc @@ -386,6 +386,11 @@ class workgeneric extends plugin $message[]= _("The required field 'Workstation name' is not set."); } + /* Check if given name is a valid host/dns name */ + if(!is_dns_name($this->cn) && chkacl ($this->acl, "cn") == ""){ + $message[] = _("Please specify a valid name for this object."); + } + if ($this->orig_dn != $this->dn){ $ldap= $this->config->get_ldap_link(); $ldap->cd ($this->base); -- 2.30.2