From 88a1919eee48fc3e60f9680863bc49f84c886d74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be>
Date: Mon, 23 Jan 2017 12:51:37 +0100
Subject: [PATCH] Fixes bugs introduced by latest sonar fixes

---
 contrib/bin/fusiondirectory-insert-schema | 40 +++++++++++------------
 contrib/openldap/core-fd.schema           |  1 -
 2 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/contrib/bin/fusiondirectory-insert-schema b/contrib/bin/fusiondirectory-insert-schema
index 7635e9425..7b5586df7 100644
--- a/contrib/bin/fusiondirectory-insert-schema
+++ b/contrib/bin/fusiondirectory-insert-schema
@@ -206,18 +206,18 @@ sub insert_schema
       my $dn_part = $1;
       # if the schema already exists in the LDAP server, modify it
       if ($modify == 1) {
-        open(my $schema, q{<}, $path.$schema.".ldif") or die_with_error('Could not open '."<".$path.$schema.".ldif: $!");
-        open(my $update, q{>}, $path.$schema."_update.ldif") or die_with_error('Could not open '.">".$path.$schema."_update.ldif: $!");
+        open(my $schemafile, q{<}, $path.$schema.".ldif") or die_with_error('Could not open '."<".$path.$schema.".ldif: $!");
+        open(my $updatefile, q{>}, $path.$schema."_update.ldif") or die_with_error('Could not open '.">".$path.$schema."_update.ldif: $!");
         push @gen_files, $path.$schema."_update";
         my $attrs   = 0;
         my $classes = 0;
-        while (<$schema>) {
+        while (<$schemafile>) {
           next if m/^#/; # remove comments
           chomp;
           next if m/^$/; # remove empty lines
           if (m/^dn: cn=([^,]+),cn=schema,cn=config$/) {
-            print $update "dn: $dn_part,cn=schema,cn=config\n";
-            print $update "changetype: modify\n";
+            $updatefile->print("dn: $dn_part,cn=schema,cn=config\n");
+            $updatefile->print("changetype: modify\n");
             next;
           }
           if (!m/^olcAttributeTypes:/ && !m/^olcObjectClasses:/ && !m/^ /) {
@@ -231,29 +231,29 @@ sub insert_schema
 
           if (!$attrs && m/^olcAttributeTypes:/) {
             $attrs = 1;
-            print $update "replace: olcAttributeTypes\n";
+            $updatefile->print("replace: olcAttributeTypes\n");
           }
           if (!$classes && m/^olcObjectClasses:/) {
             $classes = 1;
-            print $update "-\n";
-            print $update "replace: olcObjectClasses\n";
+            $updatefile->print("-\n");
+            $updatefile->print("replace: olcObjectClasses\n");
           }
 
-          print $update;
-          print $update "\n";
+          $updatefile->print($_);
+          $updatefile->print("\n");
         }
-        close $schema;
-        close $update;
+        $schemafile->close();
+        $updatefile->close();
       } else { # Emptying schema
-        open(my $update, q{>}, $path.$schema."_update.ldif") or die_with_error('Could not open '.">".$path.$schema."_update.ldif: $!");
+        open(my $updatefile, q{>}, $path.$schema."_update.ldif") or die_with_error('Could not open '.">".$path.$schema."_update.ldif: $!");
         push @gen_files, $path.$schema."_update";
-        print $update "dn: $dn_part,cn=schema,cn=config\n";
-        print $update "changetype: modify\n";
-        print $update "delete: olcAttributeTypes\n";
-        print $update "-\n";
-        print $update "delete: olcObjectClasses\n";
-        print $update "-\n";
-        close $update;
+        $updatefile->print("dn: $dn_part,cn=schema,cn=config\n");
+        $updatefile->print("changetype: modify\n");
+        $updatefile->print("delete: olcAttributeTypes\n");
+        $updatefile->print("-\n");
+        $updatefile->print("delete: olcObjectClasses\n");
+        $updatefile->print("-\n");
+        $updatefile->close();
       }
       $full_cmd = $mod_cmd.$path.$schema."_update.ldif";
       print "executing '$full_cmd'\n";
diff --git a/contrib/openldap/core-fd.schema b/contrib/openldap/core-fd.schema
index 1f2b83ed2..4f293d4da 100644
--- a/contrib/openldap/core-fd.schema
+++ b/contrib/openldap/core-fd.schema
@@ -108,4 +108,3 @@ objectclass ( 1.3.6.1.4.1.10098.1.2.1.19.19 NAME 'gosaSnapshotObject'
 objectclass ( 1.3.6.1.4.1.38414.62.2.1 NAME 'fdLockEntry' SUP top STRUCTURAL
   DESC 'GOsa - Class for FD locking'
   MUST ( fdUserDn $ fdObjectDn $ cn $ fdLockTimestamp ))
-
-- 
GitLab