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 158235 Details for
Bug 245815
DS Admin Migration framework
[?]
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]
diffs for adding adminserver migration
cvsdiffs (text/plain), 18.29 KB, created by
Rich Megginson
on 2007-06-29 18:22:01 UTC
(
hide
)
Description:
diffs for adding adminserver migration
Filename:
MIME Type:
Creator:
Rich Megginson
Created:
2007-06-29 18:22:01 UTC
Size:
18.29 KB
patch
obsolete
>Index: adminserver/admserv/newinst/src/AdminServer.pm.in >=================================================================== >RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/AdminServer.pm.in,v >retrieving revision 1.3 >diff -u -8 -r1.3 AdminServer.pm.in >--- adminserver/admserv/newinst/src/AdminServer.pm.in 22 Jun 2007 01:34:19 -0000 1.3 >+++ adminserver/admserv/newinst/src/AdminServer.pm.in 29 Jun 2007 18:20:41 -0000 >@@ -34,18 +34,22 @@ > # Copyright (C) 2007 Red Hat, Inc. > # All rights reserved. > # END COPYRIGHT BLOCK > # > > package AdminServer; > require Exporter; > @ISA = qw(Exporter); >-@EXPORT = qw(createAdminServer reconfigAdminServer registerDSWithConfigDS); >-@EXPORT_OK = qw(createAdminServer reconfigAdminServer registerDSWithConfigDS); >+@EXPORT = qw(createAdminServer reconfigAdminServer registerDSWithConfigDS >+ createASFilesAndDirs setFileOwnerPerms updateHttpConfFiles >+ startAdminServer registerManyDSWithConfigDS); >+@EXPORT_OK = qw(createAdminServer reconfigAdminServer registerDSWithConfigDS >+ createASFilesAndDirs setFileOwnerPerms updateHttpConfFiles >+ startAdminServer registerManyDSWithConfigDS); > > use File::Path; > # tempfiles > use File::Temp qw(tempfile tempdir); > > # load perldap > use Mozilla::LDAP::Conn; > use Mozilla::LDAP::Utils qw(normalizeDN); >@@ -71,16 +75,49 @@ > $setup->msg($FATAL, "missing_general_param", $general); > return 0; > } > } > > return 1; > } > >+sub setFileOwnerPerms { >+ my $setup = shift; >+ my $configdir = shift; >+ my $admConf = getAdmConf($configdir); >+ my $uid = getpwnam $admConf->{sysuser}; >+ >+ # chown and chmod other files appropriately >+ for (glob("$configdir/*")) { >+ # these are owned by root >+ next if (/httpd.conf$/); >+ next if (/nss.conf$/); >+ next if (/admserv.conf$/); >+ next if (! -f $_); # should never happen >+ # all other files should be owned by SysUser >+ $! = 0; # clear errno >+ chown $uid, -1, $_; >+ if ($!) { >+ $setup->msg($FATAL, 'error_chowning_file', $_, >+ $admConf->{sysuser}, $!); >+ return 0; >+ } >+ # the files should be writable >+ $! = 0; # clear errno >+ chmod 0600, $_; >+ if ($!) { >+ $setup->msg($FATAL, 'error_chmoding_file', $_, $!); >+ return 0; >+ } >+ } >+ >+ return 1; >+} >+ > sub createASFilesAndDirs { > my $setup = shift; > my $configdir = shift; > my $securitydir = shift; > my $logdir = shift; > my $rundir = shift; > > my $uid = getpwnam $setup->{inf}->{admin}->{SysUser}; >@@ -123,16 +160,23 @@ > $! = 0; # clear errno > chown -1, $gid, $rundir; > if ($!) { > $setup->msg($FATAL, 'error_chgrping_directory', $rundir, > $setup->{inf}->{General}->{SuiteSpotGroup}, $!); > return 0; > } > >+ return 1; >+} >+ >+sub makeConfFiles { >+ my $setup = shift; >+ my $configdir = shift; >+ > my @start_slapd; > if ($setup->{inf}->{slapd}->{SlapdConfigForMC} =~ /yes/i) { > my $slapdid = $setup->{inf}->{slapd}->{ServerIdentifier}; > @start_slapd = ('ldapStart', "slapd-$slapdid/start-slapd"); > } > $setup->msg('updating_admconf'); > my $rc = updateAdmConf({ldapurl => $setup->{inf}->{General}->{ConfigDirectoryLdapURL}, > SuiteSpotUserID => $setup->{inf}->{General}->{SuiteSpotUserID}, >@@ -151,46 +195,16 @@ > $rc = updateAdmpw($setup->{inf}->{admin}->{ServerAdminID}, > $setup->{inf}->{admin}->{ServerAdminPwd}, > $configdir); > if (!$rc) { > $setup->msg($FATAL, 'error_updating_admpw'); > return 0; > } > >- # chown and chmod other files appropriately >- for (glob("$configdir/*")) { >- # these are owned by root >- next if (/httpd.conf$/); >- next if (/nss.conf$/); >- next if (/admserv.conf$/); >- # these should have been handled above >- next if (/adm.conf$/); >- next if (/admpw$/); >- next if (/local.conf$/); >- next if (! -f $_); # should never happen >- # all other files should be owned by SysUser >- $! = 0; # clear errno >- chown $uid, -1, $_; >- if ($!) { >- $setup->msg($FATAL, 'error_chowning_file', $_, >- $setup->{inf}->{admin}->{SysUser}, $!); >- return 0; >- } >- # the files should be writable >- $! = 0; # clear errno >- my ($ignore, $ignore, $mode, @rest) = stat $_; >- $mode &= 0700; # disallow access to non-owner >- chmod $mode, $_; >- if ($!) { >- $setup->msg($FATAL, 'error_chmoding_file', $_, $!); >- return 0; >- } >- } >- > return 1; > } > > # This is how we extract the sie and isie as the as entries are > # being added > sub registercb { > my ($context, $entry) = @_; > >@@ -285,31 +299,31 @@ > > $conn->close(); > return 1; > } > > # update other config files - these are the fields which users typically want to > # change during an install or an upgrade, that also must be synced to the Apache > # style config files - we use the config CGI in command line mode because it >-# already has all of the logic to update the files correctly */ >+# already has all of the logic to update the files correctly > sub updateHttpConfFiles { > my $serverAddress = shift; > my $port = shift; > my $configdir = shift; > my $origport = shift; > my $admConf = getAdmConf($configdir); > my $user = $admConf->{sysuser}; > > # this is required on some platforms in order to execute the config command > my $savepath = $ENV{SHLIB_PATH} || $ENV{LD_LIBRARY_PATH}; > $ENV{LD_LIBRARY_PATH} = "@LIBPATH@:$savepath"; > $ENV{SHLIB_PATH} = $ENV{LD_LIBRARY_PATH}; > my $cmd = "@cgibindir@/config op=set configuration.nsSuiteSpotUser=\"$user\""; >- if ($port != $origport) { # need to change the port number >+ if (!defined($origport) or ($port != $origport)) { # need to change the port number > $cmd .= " configuration.nsServerPort=\"$port\""; > } > if ($serverAddress) { > $cmd .= " configuration.nsServerAddress=\"$serverAddress\""; > } > > if (system($cmd)) { > $ENV{LD_LIBRARY_PATH} = $savepath; >@@ -396,28 +410,36 @@ > my $rundir = $setup->{inf}->{admin}->{run_dir} || > $ENV{ADMSERV_PID_DIR} || > "@piddir@"; > > if (!createASFilesAndDirs($setup, $configdir, $securitydir, $logdir, $rundir)) { > return 0; > } > >+ if (!makeConfFiles($setup, $configdir)) { >+ return 0; >+ } >+ > if (!registerASWithConfigDS($setup, $configdir)) { > return 0; > } > > $setup->msg('updating_httpconf'); > if (!updateHttpConfFiles($setup->{inf}->{admin}->{ServerIpAddress}, > $setup->{inf}->{admin}->{Port}, > $configdir, $setup->{asorigport})) { > $setup->msg($FATAL, 'error_updating_httpconf'); > return 0; > } > >+ if (!setFileOwnerPerms($setup, $configdir)) { >+ return 0; >+ } >+ > if (!startAdminServer($setup, $configdir, $logdir, $rundir)) { > return 0; > } > > if ($reconfig) { > $setup->msg('end_reconfig_adminserver'); > } else { > $setup->msg('end_create_adminserver'); >@@ -427,46 +449,100 @@ > > sub reconfigAdminServer { > my $setup = shift; > return createAdminServer($setup, 1); > } > > sub registerDSWithConfigDS { > my $setup = shift; >- my $inf = $setup->{inf}; >- my $configdir = shift; >+ my $inf = shift || $setup->{inf}; >+ my $configdir = shift || "$setup->{configdir}/admin-serv"; > my @errs; > > $setup->msg('registering_dirserver'); > # open a connection to the configuration directory server >- my $conn = getConfigDSConn($inf->{General}->{ConfigDirectoryLdapURL}, >- $inf->{General}->{ConfigDirectoryAdminID}, >- $inf->{General}->{ConfigDirectoryAdminPwd}, >- $configdir, \@errs); >+ my $conn; >+ if (ref($configdir)) { >+ $conn = $configdir; >+ } else { >+ $conn = getConfigDSConn($inf->{General}->{ConfigDirectoryLdapURL}, >+ $inf->{General}->{ConfigDirectoryAdminID}, >+ $inf->{General}->{ConfigDirectoryAdminPwd}, >+ $configdir, \@errs); >+ } > > if (@errs) { > $setup->msg($FATAL, @errs); > return 0; > } > > # add the Admin Server configuration entries > my @ldiffiles = ("@ldifdir@/10dsdata.ldif.tmpl", > "@ldifdir@/11dstasks.ldif.tmpl" > ); > my $setupinf = new Inf("@infdir@/setup.inf"); > my $slapdinf = new Inf("@infdir@/slapd.inf"); > > my $mapper = new Inf("@infdir@/dirserver.map"); > >+ if (!$inf->{General}->{ConfigDirectoryLdapURL}) { >+ $inf->{General}->{ConfigDirectoryLdapURL} = >+ $setup->{inf}->{General}->{ConfigDirectoryLdapURL}; >+ } >+ > $mapper = process_maptbl($mapper, ($inf, $slapdinf, $setupinf)); > if (!$mapper) { > $conn->close(); > $setup->msg($FATAL, 'error_creating_dirserver_maptbl'); > return 0; > } > > my $context = [$conn]; > getMappedEntries($mapper, \@ldiffiles, \&check_and_add_entry, $context); > >- $conn->close(); >+ if (!ref($configdir)) { >+ $conn->close(); >+ } >+ > return 1; > } >+ >+# this takes a list of DS instances and registers all of them >+# with the config DS >+sub registerManyDSWithConfigDS { >+ my $setup = shift; >+ my $configdir = shift; >+ my @instances = @_; >+ my @errs; >+ my $inf = $setup->{inf}; >+ >+ if (!@instances) { >+ return 1; >+ } >+ >+ $setup->msg('registering_dirserver_instances'); >+ # open a connection to the configuration directory server >+ my $conn = getConfigDSConn($inf->{General}->{ConfigDirectoryLdapURL}, >+ $inf->{General}->{ConfigDirectoryAdminID}, >+ $inf->{General}->{ConfigDirectoryAdminPwd}, >+ $configdir, \@errs); >+ >+ if (@errs) { >+ $setup->msg($FATAL, @errs); >+ return 0; >+ } >+ >+ my $admConf = getAdmConf($configdir); >+ >+ for (@instances) { >+ my $instinf = createInfFromConfig("$setup->{configdir}/$_", $_); >+ $instinf->{General}->{AdminDomain} = $admConf->{AdminDomain}; >+ unlink($instinf->{filename}); >+ if (!registerDSWithConfigDS($setup, $instinf, $conn)) { >+ return 0; >+ } >+ } >+ >+ $conn->close(); >+ >+ return 0; >+} >Index: adminserver/admserv/newinst/src/AdminUtil.pm.in >=================================================================== >RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/AdminUtil.pm.in,v >retrieving revision 1.6 >diff -u -8 -r1.6 AdminUtil.pm.in >--- adminserver/admserv/newinst/src/AdminUtil.pm.in 28 Jun 2007 16:24:41 -0000 1.6 >+++ adminserver/admserv/newinst/src/AdminUtil.pm.in 29 Jun 2007 18:20:41 -0000 >@@ -35,19 +35,21 @@ > # All rights reserved. > # END COPYRIGHT BLOCK > # > > package AdminUtil; > require Exporter; > @ISA = qw(Exporter); > @EXPORT = qw(getAdmConf getConfigDSConn createConfigDS createSubDS >- updateAdmConf updateAdmpw updateLocalConf importCACert); >+ updateAdmConf updateAdmpw updateLocalConf importCACert >+ getLocalConfigDS getPset); > @EXPORT_OK = qw(getAdmConf getConfigDSConn createConfigDS createSubDS >- updateAdmConf updateAdmpw updateLocalConf importCACert); >+ updateAdmConf updateAdmpw updateLocalConf importCACert >+ getLocalConfigDS getPset); > > # load perldap > use Mozilla::LDAP::Conn; > use Mozilla::LDAP::Utils qw(normalizeDN); > use Mozilla::LDAP::API qw(:constant ldap_url_parse ldap_explode_dn); > use Mozilla::LDAP::LDIF qw(enlist_values); > > use Util; >@@ -329,16 +331,17 @@ > $admConf->{$key} = $val; > } > > # write it out > my $filename = "$configdir/adm.conf"; > delete $admConf->{configdir}; # don't write this > open(ADMCONF, "> $filename") || die "Can't write $filename: $!"; > while (my ($key,$val) = each %{$admConf}) { >+ next if (!defined($key) or !defined($val)); > if (ref($val)) { > for my $vv (@{$val}) { > print ADMCONF "$key: $vv\n"; > } > } else { > print ADMCONF "$key: $val\n"; > } > } >@@ -426,16 +429,17 @@ > next if $nopsetattrs{lc($attr)}; > my $attrName; > if ($prefix) { > $attrName = $prefix . "." . $attr; > } else { > $attrName = $attr; > } > foreach my $val ($entry->getValues($attr)) { >+ debug(3, "updateLocalConf: writing $attrName: $val\n"); > print $localfh "$attrName: $val\n"; > } > } > > return 1; > } > > sub importCACert { >@@ -483,8 +487,27 @@ > if ($?) { > @errs = ('error_return2_certutil', $?, $!, $output); > return @errs; > } > } > > return @errs; > } >+ >+# if the config ds is local to this machine, return >+# the instance name (e.g. "localhost" for slapd-localhost) >+# if not, return null >+sub getLocalConfigDS { >+ my $configdir = shift; >+ my $admConf = getAdmConf($configdir); >+ my $ldapStart = $admConf->{ldapStart}; >+ my $inst; >+ if (!$ldapStart) { >+ return $inst; # empty >+ } >+ >+ if ($ldapStart =~ /slapd-(.+?)\//) { >+ $inst = $1; >+ } >+ >+ return $inst; >+} >Index: adminserver/admserv/newinst/src/setup-ds-admin.pl.in >=================================================================== >RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/setup-ds-admin.pl.in,v >retrieving revision 1.5 >diff -u -8 -r1.5 setup-ds-admin.pl.in >--- adminserver/admserv/newinst/src/setup-ds-admin.pl.in 28 Jun 2007 16:24:41 -0000 1.5 >+++ adminserver/admserv/newinst/src/setup-ds-admin.pl.in 29 Jun 2007 18:20:41 -0000 >@@ -43,25 +43,23 @@ > > use Setup; > use SetupLog; > use Inf; > use Resource; > use DialogManager; > use AdminUtil; > use AdminServer; >+use Util; > > my $res = new Resource("@propertydir@/setup-ds.res", > "@propertydir@/setup-ds-admin.res"); > > my $setup = new Setup($res); > >-# see what directory server instances we already have configured >-my @dirservers = $setup->getDirServers(); >- > # see if there is already a configds > my $admConf = AdminUtil::getAdmConf("$setup->{configdir}/admin-serv"); > > # set defaults > if ($admConf && %{$admConf}) { > $setup->{inf}->{General}->{ConfigDirectoryLdapURL} = $admConf->{ldapurl}; > $setup->{inf}->{General}->{ConfigDirectoryAdminID} = $admConf->{userdn}; > $setup->{inf}->{General}->{AdminDomain} = $admConf->{AdminDomain}; >@@ -142,19 +140,22 @@ > $createconfigds = 1; > } > > $setup->{inf}->write(); > > $setup->msg('create_dirserver'); > > # create a directory server instance >-if (system("@bindir@/ds_newinst.pl $setup->{inffile}")) { >- $setup->msg($FATAL, 'error_create_dirserver'); >+my ($rc, $output) = createDSInstance($setup->{inf}); >+if ($rc) { >+ $setup->msg($FATAL, 'error_creating_dsinstance', $rc, $output); > exit 1; >+} else { >+ $setup->msg('created_dsinstance', $output); > } > > # setup directory server instance to be the configuration DS > if ($createconfigds) { > my @errs = (); > $setup->msg('create_configds'); > if (!createConfigDS($setup->{inf}, \@errs)) { > $setup->msg($FATAL, @errs); >Index: adminserver/Makefile.am >=================================================================== >RCS file: /cvs/dirsec/adminserver/Makefile.am,v >retrieving revision 1.20 >diff -u -8 -r1.20 Makefile.am >--- adminserver/Makefile.am 28 Jun 2007 16:24:41 -0000 1.20 >+++ adminserver/Makefile.am 29 Jun 2007 18:20:42 -0000 >@@ -138,41 +138,45 @@ > admserv/schema/ldif/10dsdata.ldif.tmpl \ > admserv/schema/ldif/11dstasks.ldif.tmpl \ > admserv/schema/ldif/12dsconfig.mod.tmpl \ > admserv/schema/ldif/13dsschema.mod.tmpl \ > admserv/schema/ldif/14dsmonitor.mod.tmpl \ > admserv/schema/ldif/15dspta.ldif.tmpl \ > admserv/schema/ldif/20asdata.ldif.tmpl \ > admserv/schema/ldif/21astasks.ldif.tmpl \ >- admserv/schema/ldif/22ascommands.ldif.tmpl >+ admserv/schema/ldif/22ascommands.ldif.tmpl \ >+ admserv/schema/ldif/asmigrate.ldif.tmpl > > inf_DATA = admserv/newinst/src/admin.inf \ > admserv/newinst/src/setup.inf \ > admserv/newinst/src/register_param.map \ > admserv/newinst/src/configdsroot.map \ > admserv/newinst/src/adminserver.map \ >- admserv/newinst/src/dirserver.map >+ admserv/newinst/src/dirserver.map \ >+ admserv/newinst/src/asmigrate.map > > cgibin_PROGRAMS = admpw security ugdsconfig ReadLog start_config_ds \ > config statpingserv viewdata dsconfig monreplication restartsrv \ > statusping viewlog htmladmin sec-activate stopsrv download help \ > ds_start ds_restart ds_shutdown ds_ldif2db ds_db2ldif ds_bak2db \ > ds_db2bak ds_listdb ds_rmdb ds_remove ds_snmpctrl ds_vlvindex ds_addindex > > bin_SCRIPTS = admserv/newinst/src/register_server.pl > cgibin_SCRIPTS = admserv/cgi-src40/Cgi.pm > nodist_cmdbin_SCRIPTS = admserv/cfgstuff/start-ds-admin admserv/cfgstuff/stop-ds-admin admserv/cfgstuff/restart-ds-admin > >-cmdbin_SCRIPTS = admserv/newinst/src/setup-ds-admin.pl >+cmdbin_SCRIPTS = admserv/newinst/src/setup-ds-admin.pl \ >+ admserv/newinst/src/migrate-ds-admin.pl > > perl_SCRIPTS = admserv/newinst/src/ASDialogs.pm \ > admserv/newinst/src/AdminUtil.pm \ > admserv/newinst/src/AdminServer.pm \ >- admserv/newinst/src/ConfigDSDialogs.pm >+ admserv/newinst/src/ConfigDSDialogs.pm \ >+ admserv/newinst/src/AdminMigration.pm > > libds_admin_serv_la_SOURCES = $(libbase_a_SOURCES) $(libsi18n_a_SOURCES) $(libadmin_a_SOURCES) > libds_admin_serv_la_LINK = $(MYLINK) > > libdsa_a_SOURCES = lib/libdsa/dsalib_conf.c \ > lib/libdsa/dsalib_debug.c \ > lib/libdsa/dsalib_ldif.c \ > lib/libdsa/dsalib_tailf.c \ >@@ -363,17 +367,18 @@ > admserv/cgi-src40/restartsrv_root.res admserv/cgi-src40/viewdata_root.res \ > admserv/cgi-src40/sec-activate_root.res \ > admserv/cgi-src40/viewlog_root.res > > MOSTLYCLEANFILES += $(RESOURCE_BUNDLES_ROOT) > # ICU resource file installation is handled specially > nodist_property_DATA = $(RESOURCE_BUNDLES_ROOT) > # regular property files go here >-property_DATA = admserv/newinst/src/setup-ds-admin.res >+property_DATA = admserv/newinst/src/setup-ds-admin.res \ >+ admserv/newinst/src/migrate-ds-admin.res > > # French resource bundles (for the French localization in the future) > #RESOURCE_BUNDLES_FR = foo_fr.res > > # German resource bundles (for the German localization in the future) > #RESOURCE_BUNDLES_DE = foo_de.res > > %_root.res : %.properties
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 245815
:
158147
|
158227
|
158228
|
158229
|
158230
|
158231
| 158235 |
158236
|
158237
|
158238
|
158239
|
158241
|
158266
|
158269
|
158883
|
158885
|
159053
|
159352