Code

Added vim configuration line (.. // vim:tabstop=2:ex...) and applied code aligment...
[gosa.git] / gosa-core / bin / gosa-encrypt-passwords
index 05568bdb81b41babee787ad7f8e7cc294eb62292..7d5c69d1ba7712a11752fce1e3dc078745bbf47c 100755 (executable)
@@ -64,14 +64,24 @@ $conf = new DOMDocument();
 $conf->load("/etc/gosa/gosa.conf") or die ("Cannot read /etc/gosa/gosa.conf - aborted\n");
 $conf->encoding = 'UTF-8';
 $referrals= $conf->getElementsByTagName("referral");
-echo "* encrypting existent passwords with master key\n";
 foreach($referrals as $referral){
   $user = $referral->attributes->getNamedItem("adminDn");
-  echo "* encrypting password for: ".$user->nodeValue."\n";
+  echo "* encrypting GOsa password for: ".$user->nodeValue."\n";
   $pw= $referral->attributes->getNamedItem("adminPassword");
   $pw->nodeValue= cred_encrypt($pw->nodeValue, $master_key);
 }
 
+# Encrypt the snapshot passwords 
+$locations= $conf->getElementsByTagName("location");
+foreach($locations as $location){
+  $name = $location->attributes->getNamedItem("name"); 
+  $node = $location->attributes->getNamedItem("snapshotAdminPassword"); 
+  if($node->nodeValue){
+    echo "* encrypting snapshot pasword for location: ".$name->nodeValue."\n";
+    $node->nodeValue = cred_encrypt($node->nodeValue, $master_key);;
+  }
+}
+
 # Move original gosa.conf out of the way and make it unreadable for the web user
 echo "* creating backup in /etc/gosa/gosa.conf.orig\n";
 rename("/etc/gosa/gosa.conf", "/etc/gosa/gosa.conf.orig");