diff --git a/gosa-plugins/systems/admin/systems/class_servGeneric.inc b/gosa-plugins/systems/admin/systems/class_servGeneric.inc
index e2742a93742e54dd5b4ed8d3d2ee96baa2752465..3257f7025f09345bd1f0d405add1af79d1d0604d 100644 (file)
var $l= "";
var $description= "";
var $orig_dn= "";
- var $didAction= FALSE;
+ var $orig_cn= "";
+ var $orig_base= "";
/* attribute list for save action */
var $attributes= array("cn", "description","gotoMode");
var $netConfigDNS;
var $modes = array();
var $ui ;
+ var $validActions = array("reboot" => "", "update" => "", "localboot" => "", "reinstall" => "", "rescan" => "",
+ "wakeup" => "", "memcheck" => "", "sysinfo" => "");
+
+ var $fai_activated =FALSE;
+ var $view_logged = FALSE;
+
+ var $currently_installing = FALSE;
+ var $currently_installing_warned = FALSE;
+
+ var $kerberos_key_service = NULL;
+
var $mapActions = array("reboot" => "",
- "update" => "softupdate",
+ "instant_update" => "softupdate",
"localboot" => "localboot",
+ "update" => "sceduledupdate",
"reinstall" => "install",
"rescan" => "",
- "wake" => "",
+ "wakeup" => "",
"memcheck" => "memcheck",
"sysinfo" => "sysinfo");
- var $fai_activated =FALSE;
- var $view_logged = FALSE;
function servgeneric (&$config, $dn= NULL, $parent= NULL)
{
plugin::plugin ($config, $dn, $parent);
+ /* Initialize kerberos host key plugin */
+ if(class_available("krbHostKeys")){
+ $this->kerberos_key_service = new krbHostKeys($this->config,$this);
+ }
+
$this->ui = get_userinfo();
$this->modes["active"]= _("Activated");
$this->modes["locked"]= _("Locked");
$this->base= dn2base($ui->dn);
$this->cn= "";
} else {
- $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
+ $this->base= preg_replace ("/^[^,]+,".normalizePreg(get_ou("serverRDN"))."/", "", $this->dn);
}
$this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses);
$this->netConfigDNS->set_acl_category("server");
$this->netConfigDNS->set_acl_base($this->base);
+
+ /* Check if this host is currently in installation process*/
+ if($this->dn != "new" && class_available("gosaSupportDaemon") && class_available("DaemonEvent")){
+ $o = new gosaSupportDaemon();
+ $e_types = DaemonEvent::get_event_types(USER_EVENT | SYSTEM_EVENT | HIDDEN_EVENT);
+ $evts = $o->get_entries_by_mac(array($this->netConfigDNS->macAddress));
+ foreach($evts as $evt){
+ if(isset($e_types['QUEUED'][$evt['HEADERTAG']]) && $evt['STATUS'] == "processing" &&
+ $e_types['QUEUED'][$evt['HEADERTAG']] == "DaemonEvent_reinstall"){
+ $this->currently_installing =TRUE;
+ }
+ }
+ }
/* Save dn for later references */
- $this->orig_dn= $this->dn;
+ $this->orig_dn = $this->dn;
+ $this->orig_cn = $this->cn;
+ $this->orig_base = $this->base;
}
/* Do we represent a valid server? */
if (!$this->is_account && $this->parent === NULL){
- $display= "<img alt=\"\" src=\"images/stop.png\" align=middle> <b>".
- _("This 'dn' has no server features.")."</b>";
+ $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle> <b>".
+ msgPool::noValidExtension(_("server"))."</b>";
return($display);
}
-
-
if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->mapActions[$_POST['saction']]) ){
-
- /* Check given action */
- $mapEvent = array("wake" => "wakeup",
- "instant_update" => "update");
$action = $_POST['saction'];
- if(isset($mapEvent[$action])){
- $action = $mapEvent[$action];
- }
-
/* Check if we have an DaemonEvent for this action */
if(class_available("DaemonEvent")){
$tmp->set_type(TRIGGERED_EVENT);
$o_queue = new gosaSupportDaemon();
if(!$o_queue->append($tmp)){
- msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
- $o_queue->get_error()),ERROR_DIALOG);
+ msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
}
}
}else{
-
- msg_dialog::display(_("Missing Daemon Event"),
- sprintf(_("The requested action does not exists '%s' Sending event manually."),"DaemonEvent_".$action),ERROR_DIALOG);
-
- /* No event found, send action manually.
- */
- $method= "gosa";
- $action= $_POST['saction'];
- if ($action == "reinstall" || $action == "update" || $action == "instant_update"){
- $method= "job";
- }
-
- gosaSupportDaemon::send("${method}_trigger_action_".$action,
- $this->netConfigDNS->macAddress,
- array("macAddress" => $this->netConfigDNS->macAddress));
- }
-
- $this->didAction= TRUE;
-
- if ($_POST['saction'] != "wake") {
-
- /* Set FAIstate */
- if($this->fai_activated && $this->dn != "new"){
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->cat($this->dn,array("objectClass"));
- $res = $ldap->fetch();
-
- $attrs = array();
- $attrs['FAIstate'] = "";
- if(isset($this->mapActions[$_POST['saction']])){
- $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']];
- }
-
- for($i = 0; $i < $res['objectClass']['count'] ; $i ++){
- $attrs['objectClass'][] = $res['objectClass'][$i];
- }
-
- if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
- $attrs['objectClass'][] = "FAIobject";
- }
-
- if($attrs['FAIstate'] == ""){
- #FIXME we should check if FAIobject is used anymore
- $attrs['FAIstate'] = array();
- }
-
- $ldap->cd($this->dn);
- $ldap->modify($attrs);
- }
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/generic (FAIstate) with dn '%s' failed."),$this->dn));
+ msg_dialog::display(_("Event error"),
+ sprintf(_("Event '%s' is not available!"),$action),ERROR_DIALOG);
}
}
/* Assign status */
if (gosaSupportDaemon::ping($this->netConfigDNS->macAddress)){
$smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
- "instant_update" => _("Instant update"),
- "update" => _("Scheduled update"),
+ "update" => _("System update"),
"reinstall" => _("Reinstall"),
"rescan" => _("Rescan hardware"),
"memcheck" => _("Memory test"),
"localboot" => _("Force localboot"),
"sysinfo" => _("System analysis")));
} else {
- $smarty->assign("actions", array("wake" => _("Wake up"),
+ $smarty->assign("actions", array("wakeup" => _("Wake up"),
"reinstall" => _("Reinstall"),
- "update" => _("Scheduled update"),
+ "update" => _("System update"),
"memcheck" => _("Memory test"),
"localboot" => _("Force localboot"),
"sysinfo" => _("System analysis")));
}
$smarty->assign("netconfig", $str);
$smarty->assign("modes", $this->modes);
+ $smarty->assign("currently_installing", $this->currently_installing);
+
+ $smarty->assign("host_key","");
+ if(is_object($this->kerberos_key_service)){
+ $smarty->assign("host_key",$this->kerberos_key_service->execute_by_prefix("host/"));
+ }
return($smarty->fetch (get_template_path('server.tpl', TRUE)));
}
return;
}
+ /* Remove kerberos key dependencies too */
+ if(is_object($this->kerberos_key_service)){
+ $this->kerberos_key_service->remove_from_parent_by_prefix("host/");
+ }
+
$this->netConfigDNS->remove_from_parent();
$ldap= $this->config->get_ldap_link();
$ldap->rmdir($this->dn);
+ update_accessTo($this->orig_cn,"");
+
new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/generic with dn '%s' failed."),$this->dn));
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
+ }
/* Delete references to object groups */
$ldap->cd ($this->config->current['BASE']);
unset($og->member[$this->dn]);
$og->save ();
}
+
+ /* Clean queue form entries with this mac
+ */
+ if(class_available("gosaSupportDaemon") && tests::is_mac($this->netConfigDNS->orig_macAddress)){
+ $q = new gosaSupportDaemon();
+ $q->clean_queue_from_mac($this->netConfigDNS->orig_macAddress);
+ }
$this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
}
$this->base = $base_tmp;
}
}
+
+ /* Hanle kerberos host key plugin */
+ if(is_object($this->kerberos_key_service)){
+ $this->kerberos_key_service->save_object_by_prefix("host/");
+ }
}
/* Call common method to give check the hook */
$message= plugin::check();
$message= array_merge($message, $this->netConfigDNS->check());
- $this->dn= "cn=".$this->cn.",".get_ou('serverou').$this->base;
+ $this->dn= "cn=".$this->cn.",".get_ou('serverRDN').$this->base;
/* must: cn */
if ($this->cn == ""){
if ($ldap->count() != 0){
while ($attrs= $ldap->fetch()){
if ($attrs['dn'] != $this->orig_dn){
- if(!preg_match("/cn=dhcp,/",$attrs['dn']) && !preg_match("/,".get_ou('incomingou')."/",$attrs['dn']) && preg_match("/,".get_ou('serverou')."/",$attrs['dn'])){
+ if(!preg_match("/cn=dhcp,/",$attrs['dn']) && !preg_match("/,".get_ou('systemIncomingRDN')."/",$attrs['dn']) && preg_match("/,".get_ou('serverRDN')."/",$attrs['dn'])){
$message[]= msgPool::duplicated(_("Server name"));
break;
}
}
}
+ /* Warn the user, that this host is currently installing */
+ if($this->currently_installing && !$this->currently_installing_warned && !preg_match("/".normalizePreg(get_ou("systemIncomingRDN"))."/",$this->orig_dn)){
+
+ /* Force aborting without message dialog */
+ $message[] = "";
+ $this->currently_installing_warned = TRUE;
+ msg_dialog::display(_("Software deployment"),
+ _("This host is currently installing, if you really want to save it, press 'OK'."),
+ CONFIRM_DIALOG);
+ }
+
+ /* Check if we are allowed to create or move this object
+ */
+ if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
+ $message[] = msgPool::permCreate();
+ }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
+ $message[] = msgPool::permMove();
+ }
+
return ($message);
}
new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
$mode= "add";
} else {
-
- /* cn is not case sensitive for ldap, but for php it is!! */
- if($this->config->current['DNMODE'] == "cn"){
- if (strtolower($this->orig_dn) != (strtolower($this->dn))){
- $this->recursive_move($this->orig_dn, $this->dn);
- plugin::save();
- }
- }else{
- if ($this->orig_dn != $this->dn){
- $this->recursive_move($this->orig_dn, $this->dn);
- plugin::save();
- }
- }
$ldap->cd($this->dn);
$this->cleanup();
$ldap->modify ($this->attrs);
new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ /* Update all accessTo/trust dependencies */
+ if($this->orig_cn != $this->cn){
+ update_accessTo($this->orig_cn,$this->cn);
+ }
+
$mode= "modify";
}
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/generic with dn '%s' failed."),$this->dn));
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
+ }
$this->netConfigDNS->cn = $this->cn;
$this->netConfigDNS->save();
/* Optionally execute a command after we're done */
- if(!$this->didAction){
- $this->handle_post_events($mode,array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
- }
+ $this->handle_post_events($mode,array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
if ($activate){
$tmp->set_type(TRIGGERED_EVENT);
$tmp->add_targets(array($this->netConfigDNS->macAddress));
if(!$o_queue->append($tmp)){
- msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
- $o_queue->get_error()),ERROR_DIALOG);
+ msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
}
}
}