Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 158485 Details for
Bug 246683
Reimplement ds_create without setuputil code
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
ds diffs
cvsdiffs (text/plain), 19.31 KB, created by
Rich Megginson
on 2007-07-03 22:31:36 UTC
(
hide
)
Description:
ds diffs
Filename:
MIME Type:
Creator:
Rich Megginson
Created:
2007-07-03 22:31:36 UTC
Size:
19.31 KB
patch
obsolete
>Index: ldapserver/Makefile.am >=================================================================== >RCS file: /cvs/dirsec/ldapserver/Makefile.am,v >retrieving revision 1.47 >diff -u -8 -r1.47 Makefile.am >--- ldapserver/Makefile.am 29 Jun 2007 21:12:21 -0000 1.47 >+++ ldapserver/Makefile.am 3 Jul 2007 22:29:10 -0000 >@@ -195,17 +195,18 @@ > ldap/admin/src/scripts/Setup.pm \ > ldap/admin/src/scripts/SetupDialogs.pm \ > ldap/admin/src/scripts/Inf.pm \ > ldap/admin/src/scripts/DialogManager.pm \ > ldap/admin/src/scripts/Dialog.pm \ > ldap/admin/src/scripts/DSDialogs.pm \ > ldap/admin/src/scripts/Setup.pm \ > ldap/admin/src/scripts/Migration.pm \ >- ldap/admin/src/scripts/DSMigration.pm >+ ldap/admin/src/scripts/DSMigration.pm \ >+ ldap/admin/src/scripts/FileConn.pm > > property_DATA = ldap/admin/src/scripts/setup-ds.res \ > ldap/admin/src/scripts/migrate-ds.res > > task_SCRIPTS = ldap/admin/src/scripts/template-bak2db \ > ldap/admin/src/scripts/template-db2bak \ > ldap/admin/src/scripts/template-db2index \ > ldap/admin/src/scripts/template-db2ldif \ >Index: ldapserver/ldap/admin/src/scripts/DSMigration.pm.in >=================================================================== >RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/DSMigration.pm.in,v >retrieving revision 1.1 >diff -u -8 -r1.1 DSMigration.pm.in >--- ldapserver/ldap/admin/src/scripts/DSMigration.pm.in 29 Jun 2007 21:12:21 -0000 1.1 >+++ ldapserver/ldap/admin/src/scripts/DSMigration.pm.in 3 Jul 2007 22:29:10 -0000 >@@ -369,37 +369,43 @@ > > return $tmpdse; > } > > sub migrateDS { > my $mig = shift; > $pkgname = $mig->{pkgname}; # set globals > $oldsroot = $mig->{oldsroot}; # set globals >+ my @errs; > > # for each instance > foreach my $inst (@{$mig->{instances}}) { > if (-f "@instconfigdir@/$inst/dse.ldif") { > $mig->msg($WARN, 'instance_already_exists', "@instconfigdir@/$inst/dse.ldif"); > next; > } > # set instance specific defaults > my $newdbdir = "@localstatedir@/lib/$pkgname/$inst/db"; > my $newcertdir = "@instconfigdir@/$inst"; > my $newcldbdir = "@localstatedir@/lib/$pkgname/$inst/cldb"; > > # extract the information needed for ds_newinst.pl > my $configdir = "$oldsroot/$inst/config"; >- my $inf = createInfFromConfig($configdir, $inst); >+ my $inf = createInfFromConfig($configdir, $inst, \@errs); > debug(2, "Using inffile $inf->{filename} created from $configdir\n"); >+ if (@errs) { >+ $mig->msg(@errs); >+ return 0; >+ } > > # create the new instance >- my ($rc, $output) = createDSInstance($inf); >+ my ($rc, $output) = createDSInstance($inf, \@errs); > unlink($inf->{filename}); > if ($rc) { >+ $mig->msg(@errs); > $mig->msg($FATAL, 'error_creating_dsinstance', $rc, $output); > return 0; > } else { > $mig->msg('created_dsinstance', $output); > } > > # copy over the files/directories > # copy the databases >Index: ldapserver/ldap/admin/src/scripts/Resource.pm >=================================================================== >RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Resource.pm,v >retrieving revision 1.3 >diff -u -8 -r1.3 Resource.pm >--- ldapserver/ldap/admin/src/scripts/Resource.pm 15 Jun 2007 22:11:15 -0000 1.3 >+++ ldapserver/ldap/admin/src/scripts/Resource.pm 3 Jul 2007 22:29:10 -0000 >@@ -107,17 +107,19 @@ > } > if ($iscontinuation) { # if line ends with a backslash, continue the data on the next line > $incontinuation = 1; > } else { > $incontinuation = 0; > } > } > # replace \n with real newline >- $self->{res}->{$curkey} =~ s/\\n/\n/g; >+ if (defined($curkey)) { >+ $self->{res}->{$curkey} =~ s/\\n/\n/g; >+ } > close RES; > } > } > > # given a resource key and optional args, return the value > # $text = $res->getText('key'); > # or > # $text = $res->getText('key', @args); >Index: ldapserver/ldap/admin/src/scripts/Util.pm.in >=================================================================== >RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Util.pm.in,v >retrieving revision 1.4 >diff -u -8 -r1.4 Util.pm.in >--- ldapserver/ldap/admin/src/scripts/Util.pm.in 29 Jun 2007 21:12:21 -0000 1.4 >+++ ldapserver/ldap/admin/src/scripts/Util.pm.in 3 Jul 2007 22:29:10 -0000 >@@ -114,18 +114,17 @@ > $sentry = $conn->nextEntry(); > } > # reverse order > my $dn = pop @mystack; > while ($dn) { > $conn->delete($dn); > my $rc = $conn->getErrorCode(); > if ( $rc != 0 ) { >- $conn->printError(); >- print "ERROR: unable to delete entry $dn, error code: $rc\n"; >+ debug(1, "ERROR: unable to delete entry $dn, error code: $rc:" . $conn->getErrorString() . "\n"); > return 1; > } > $dn = pop @mystack; > } > return 0; > } > > my %ignorelist = ( >@@ -215,17 +214,17 @@ > # use like this: > # getMappedEntries($mapper, \@ldiffiles, \&check_and_add_entry, > # [$conn, $fresh, $verbose]); > # where $conn is a perldap Conn > # $fresh if true will update the entry if it exists > # $verbose prints out more info > sub check_and_add_entry > { >- my ($context, $aentry) = @_; >+ my ($context, $aentry, $errs) = @_; > my $conn = $context->[0]; > my $fresh = $context->[1]; > my $verbose = $context->[2]; > my @ctypes = $aentry->getValues("changetype"); > my $sentry = $conn->search($aentry->{dn}, "base", "(objectclass=*)", 0, ("*", "aci")); > if ($sentry) { > debug(3, "check_and_add_entry: Found entry " . $sentry->getDN() . "\n"); > } else { >@@ -272,16 +271,17 @@ > { > # $fresh || $rc == -1 > # an entry having the same DN exists, but the attributes do not > # match. remove the entry and the subtree underneath. > debug(1, "Deleting an entry dn: $sentry->{dn} ...\n"); > $rc = delete_all($conn, $sentry); > if ( 0 != $rc ) > { >+ push @{$errs}, 'error_deleteall_entries', $sentry->{dn}, $conn->getErrorString(); > debug(1, "Error deleting $sentry->{dn}\n"); > return 0; > } > } > } > else # aentry: modify format > { > $needtoadd = 0; >@@ -300,18 +300,18 @@ > > if ( 1 == $needtoadd ) > { > $conn->add($aentry); > my $rc = $conn->getErrorCode(); > if ( $rc != 0 ) > { > my $string = $conn->getErrorString(); >- print "ERROR: adding an entry $aentry->{dn} failed, error: $string\n"; >- print "[entry]\n"; >+ push @{$errs}, 'error_adding_entry', $aentry->{dn}, $string; >+ debug(1, "ERROR: adding an entry $aentry->{dn} failed, error: $string\n"); > $aentry->printLDIF(); > $conn->close(); > return 0; > } > debug(1, "Entry $aentry->{dn} is added\n"); > } > elsif ( 0 < $needtomod ) # $sentry exists > { >@@ -354,18 +354,18 @@ > } > } > } > $conn->update($sentry); > my $rc = $conn->getErrorCode(); > if ( $rc != 0 ) > { > my $string = $conn->getErrorString(); >- print "ERROR: updating an entry $sentry->{dn} failed, error: $string\n"; >- print "[entry]\n"; >+ push @{$errs}, 'error_updating_entry', $sentry->{dn}, $string; >+ debug(1, "ERROR: updating an entry $sentry->{dn} failed, error: $string\n"); > $aentry->printLDIF(); > $conn->close(); > return 0; > } > } > if ( $sentry ) > { > $sentry = $conn->nextEntry(); # supposed to have no more entries >@@ -391,115 +391,121 @@ > # given to this callback. The callback should return a list > # of localizable errors. If no callback is supplied, the > # entries will be returned in a list. > # Arguments: > # mapper - a hash ref - the keys are the tokens to replace > # and the values are the replacements > # ldiffiles - an array ref - the list of LDIF files to > # operate on >+# errs - an array ref - this is filled in with the >+# errors encountered in processing - this is >+# suitable for passing to setup->msg or >+# Resource->getText > # callback (optional) - a code ref - a ref to a subroutine > # that will be called with each entry - see below > # context (optional) - this will be passed as the first > # argument to your given callback - see below >-# errs (optional) - an array ref - This is how errors >-# are returned to the caller - see below > # Callback: > # The callback sub will be called for each entry after > # the entry has been converted. The callback will be > # called with the given context as the first argument > # and the Mozilla::LDAP::Entry as the second argument, > # and an errs array ref as the third argument. The > # callback should return true to continue processing, > # or false if a fatal error was encountered that should > # abort processing of any further. > # Errors: > # This function should return an array of errors in the >-# format described below, for use with Resource::getText(). >-# If the callback returns any errors >+# format described below, for use with Resource::getText() >+# or Setup::msg() > # Return: > # The return value is a list of entries. > # Example usage: > # sub handle_entries { > # my $context = shift; > # my $entry = shift; >+# my $errs = shift; > # .... do something with entry .... > # .... if $context is Mozilla::LDAP::Conn, $conn->add($entry); ... > # .... report errors .... > # if ($fatalerror) { >+# push @{$errs}, 'error_token', arg1, arg2, ...; > # return 0; > # } else { > # return 1; > # } > # } > # $mapper = {foo => 'bar', baz => 'biff'}; > # @ldiffiles = ('foo.ldif', 'bar.ldif', ..., 'biff.ldif'); > # $conn = new Mozilla::LDAP::Conn(...); >-# @entries = getMappedEntries($mapper, \@ldiffiles, \&handle_entries, $conn); >+# my @errs; >+# @entries = getMappedEntries($mapper, \@ldiffiles, \@errs, \&handle_entries, $conn); > # Note that this will return 0 entries since a callback was used. > # The simpler example is this: >-# @entries = getMappedEntries($mapper, \@ldiffiles); >+# @entries = getMappedEntries($mapper, \@ldiffiles, \@errs); > # > sub getMappedEntries { > my $mapper = shift; > my $ldiffiles = shift; >+ my $errs = shift; > my $callback = shift || \&cbaddent; # default - just add entry to @entries > my @entries = (); > my $context = shift || \@entries; > my $error; > > if (!ref($ldiffiles)) { > $ldiffiles = [ $ldiffiles ]; > } > > foreach my $ldiffile (@{$ldiffiles}) { >- open(MYLDIF, "< $ldiffile") or die "Can't open $ldiffile : $!"; >+ if (!open(MYLDIF, "< $ldiffile")) { >+ push @{$errs}, "error_opening_ldiftmpl", $ldiffile, $!; >+ return 0; >+ } > my $in = new Mozilla::LDAP::LDIF(*MYLDIF); > debug(1, "Processing $ldiffile ...\n"); > ENTRY: while (my $entry = Mozilla::LDAP::LDIF::readOneEntry($in)) { > # first, fix the DN > my $dn = $entry->getDN(); > my $origdn = $dn; > while ( $dn =~ /%([\w_-]+)%/ ) { > if (exists($mapper->{$1})) { > $dn =~ s{%([\w_-]+)%}{$mapper->{$1}}ge; > } else { >- print "ERROR: \"$origdn\" mapped to \"$dn\".\n"; >- print "The LDIF file $ldiffile contains a token $1 for which there is no mapper.\n"; >- print "Please check $ldiffile and your mapper to make sure all tokens are handled correctly.\n"; >+ push @{$errs}, 'error_mapping_token_ldiftmpl', $dn, $ldiffile, $1; > $error = 1; > last ENTRY; > } > } > $entry->setDN($dn); > # next, fix all of the values in all of the attributes > foreach my $attr (keys %{$entry}) { > my @newvalues = (); > foreach my $value ($entry->getValues($attr)) { > # Need to repeat to handle nested subst > my $origvalue = $value; > while ( $value =~ /%([\w_-]+)%/ ) { > if (exists($mapper->{$1})) { > $value =~ s{%([\w_-]+)%}{$mapper->{$1}}ge; > } else { >- print "ERROR: \"$origvalue\" mapped to \"$value\".\n"; >- print "The LDIF file $ldiffile contains a token $1 for which there is no mapper.\n"; >- print "Please check $ldiffile and your mapper to make sure all tokens are handled correctly.\n"; >+ push @{$errs}, 'error_mapping_token_ldiftmpl', $dn, $ldiffile, $1; >+ debug(1, "ERROR: \"$origvalue\" mapped to \"$value\".\n"); > $error = 1; > last ENTRY; > } > } > push @newvalues, $value; > } > $entry->setValues( $attr, @newvalues ); > } > >- if (!&{$callback}($context, $entry)) { >- print "There was an error processing entry ", $entry->getDN(), "\n"; >- print "Cannot continue processing entries.\n"; >+ if (!&{$callback}($context, $entry, $errs)) { >+ debug(1, "ERROR: There was an error processing entry ". $entry->getDN(). "\n"); >+ debug(1, "Cannot continue processing entries.\n"); > $error = 1; > last ENTRY; > } > > } > close(MYLDIF); > last if ($error); # do not process any more ldiffiles if an error occurred > } >@@ -635,17 +641,17 @@ > # in either of the setup inf file (static) or the install inf file (dynamic). > # * Variables surrounded by @ (e.g., @admin_confdir@) are replaced with the > # system path at the compile time. > # * The right-hand value can contain variables surrounded by % (e.g., %asid%) > # which refers the right-hand value (key) of this map file. > # The %token% tokens are replaced in getMappedEntries > sub process_maptbl > { >- my ($mapper, @infdata) = @_; >+ my ($mapper, $errs, @infdata) = @_; > > if (defined($mapper->{""})) { > $mapper = $mapper->{""}; # side effect of Inf with no sections > } > > KEY: foreach my $key (keys %{$mapper}) > { > my $value = $mapper->{$key}; >@@ -675,17 +681,17 @@ > { > $mapper->{$key} = $infsection->{$value}; > next KEY; > } > } > } > if (!defined($infsection->{$value})) > { >- print "ERROR: $value not found in the .inf files\n"; >+ push @{$errs}, 'no_mapvalue_for_key', $value, $key; > return {}; > } > } > } > return $mapper; > } > > sub getHashedPassword { >@@ -704,38 +710,44 @@ > my $hashedpwd = `$cmd`; > chomp($hashedpwd); > > return $hashedpwd; > } > > sub createDSInstance { > my $inf = shift; >+ my $errs = shift; # unused for now > # find ds_newinst.pl - in same directory as this script or in PATH > my $ds_newinst; > ($ds_newinst = $0) =~ s|/[^/]+$|/ds_newinst.pl|; > if (! -x $ds_newinst) { > $ds_newinst = "@bindir@/ds_newinst.pl"; > } > if (! -x $ds_newinst) { > $ds_newinst = "ds_newinst.pl"; # just get from path > } > $? = 0; # clear error condition > my $output = `$ds_newinst $inf->{filename}`; > return ($?, $output); > } > > # this creates an Inf suitable for passing to createDSInstance >+# except that it has a bogus suffix > sub createInfFromConfig { > my $configdir = shift; > my $inst = shift; >+ my $errs = shift; > my $fname = "$configdir/dse.ldif"; > my $id; > ($id = $inst) =~ s/^slapd-//; >- open( DSELDIF, "$fname" ) || die "Can't open $fname: $!"; >+ if (!open( DSELDIF, "$fname" )) { >+ push @{$errs}, "error_opening_dseldif", $fname, $!; >+ return 0; >+ } > my ($outfh, $inffile) = tempfile(SUFFIX => '.inf'); > my $in = new Mozilla::LDAP::LDIF(*DSELDIF) ; > while (my $ent = readOneEntry $in) { > my $dn = $ent->getDN(); > if ($dn =~ /cn=config/) { > print $outfh "[General]\n"; > print $outfh "FullMachineName = ", $ent->getValues('nsslapd-localhost'), "\n"; > print $outfh "SuiteSpotUserID = ", $ent->getValues('nsslapd-localuser'), "\n"; >Index: ldapserver/ldap/admin/src/scripts/setup-ds.pl.in >=================================================================== >RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/setup-ds.pl.in,v >retrieving revision 1.3 >diff -u -8 -r1.3 setup-ds.pl.in >--- ldapserver/ldap/admin/src/scripts/setup-ds.pl.in 29 Jun 2007 21:12:21 -0000 1.3 >+++ ldapserver/ldap/admin/src/scripts/setup-ds.pl.in 3 Jul 2007 22:29:10 -0000 >@@ -64,16 +64,18 @@ > > my $rc = $dialogmgr->run(); > if ($rc) { > $setup->doExit(); > } > $setup->{inf}->write(); > } > >-my ($rc, $output) = createDSInstance($setup->{inf}); >+my @errs; >+my ($rc, $output) = createDSInstance($setup->{inf}, \@errs); > if ($rc) { >+ $setup->msg(@errs); > $setup->msg($FATAL, 'error_creating_dsinstance', $rc, $output); > } else { > $setup->msg('created_dsinstance', $output); > } > > $setup->doExit(); >Index: ldapserver/ldap/admin/src/scripts/setup-ds.res.in >=================================================================== >RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/setup-ds.res.in,v >retrieving revision 1.5 >diff -u -8 -r1.5 setup-ds.res.in >--- ldapserver/ldap/admin/src/scripts/setup-ds.res.in 29 Jun 2007 21:12:21 -0000 1.5 >+++ ldapserver/ldap/admin/src/scripts/setup-ds.res.in 3 Jul 2007 22:29:10 -0000 >@@ -84,8 +84,14 @@ > backend_already_exists = A database backend with the name '%s' already exists. Config entry DN '%s'. Please choose another backend name. addSuffix can generate a unique backend name if you do not specify a backend name.\n\n > suffix_already_exists = The suffix '%s' already exists. Config entry DN '%s'.\n\n > error_creating_suffix_backend = Could not create the suffix '%s'. There was an error creating the backend database named '%s' for the suffix. Error: %s\n\n > error_creating_suffix = Could not create the suffix '%s'. Error: %s\n\n > > setup_exiting = Exiting . . .\nLog file is '%s'\n\n > error_creating_dsinstance = Error: Could not create directory server instance. Error code %s. Output:\n%s\n > created_dsinstance = Your new DS instance was successfully created. Output:\n%s\n >+no_mapvalue_for_key = The map value '%s' for key '%s' did not map to a value in any of the given information files.\n >+error_opening_ldiftmpl = Could not open the LDIF template file '%s'. Error: %s\n >+error_mapping_token_ldiftmpl = The entry '%s' in LDIF file '%s' contains a token '%s' for which there is no mapper.\nPlease check the file and your mapper to make sure all tokens are handled correctly.\n >+error_deleteall_entries = Error deleting entry '%s' and all children. Error: %s\n >+error_adding_entry = Error adding entry '%s'. Error: %s\n >+error_updating_entry = Error updating entry '%s'. Error: %s\n
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 246683
:
158484
| 158485 |
158486
|
158487
|
158491
|
158494
|
158914
|
158989
|
159007