ispman/scripts ldifupdate,1.17,1.18

Joerg Delker <[email protected]>
Newsgroups gmane.comp.isp.ispman.cvs
Message-ID <[email protected]>
Update of /cvsroot/ispman/ispman/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1338/scripts

Modified Files:
	ldifupdate 
Log Message:
fixed bug with posixGroup check when using "-m add" mode

Index: ldifupdate
===================================================================
RCS file: /cvsroot/ispman/ispman/scripts/ldifupdate,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- ldifupdate	26 Jun 2004 22:53:29 -0000	1.17
+++ ldifupdate	27 Jun 2004 20:35:44 -0000	1.18
@@ -148,6 +148,9 @@
 while ( not $ldif_in->eof() ) {
     my $entry = $ldif_in->read_entry();
 
+    # define slot for new entry
+    my $added_entry;
+
     # skip entry if we find an error
     if ( $ldif_in->error() ) {
         print STDERR "Error msg: ",    $ldif_in->error(),       "\n";
@@ -237,10 +240,10 @@
             if ( !$groups{$ispmanDomain} ) {
 
                 # add new group entry
-                my $group = Net::LDAP::Entry->new;
+                $added_entry = Net::LDAP::Entry->new;
 
-                $group->dn( "cn=" . $ispmanDomain . "," . $dn );
-                $group->add(
+                $added_entry->dn( "cn=" . $ispmanDomain . "," . $dn );
+                $added_entry->add(
                     objectclass => 'posixGroup',
                     cn          => $ispmanDomain,
                     gidnumber   => $entry->get_value("gidnumber")
@@ -248,7 +251,6 @@
                 $msg .=
                   "creating new posixGroup entry for domain "
                   . $ispmanDomain . "\n";
-                $ldif_out->write_entry($group);
             }
 
             # check ResellerId
@@ -520,6 +522,7 @@
     my ( $attrib, $attribval ) = $dn =~ m/^(\w+)?\=([^,]*)/;
     my @values = $entry->get_value($attrib);
     my $found  = 0;
+
     for (@values) {
         if ( $_ eq $attribval ) { $found = 1 }
     }
@@ -536,6 +539,9 @@
 
     # write ldif data
     $ldif_out->write_entry($entry);
+
+    # write added ldif data when present
+    $ldif_out->write_entry($added_entry) if ($added_entry);
 }
 
 $ldif_in->done();



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.