cloud-mu 3.6.10 → 3.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Berksfile +2 -3
- data/Berksfile.lock +11 -14
- data/bin/mu-aws-setup +16 -4
- data/bin/mu-configure +2 -1
- data/cloud-mu.gemspec +2 -2
- data/cookbooks/mu-firewall/Berksfile +1 -1
- data/cookbooks/mu-firewall/attributes/default.rb +2 -2
- data/cookbooks/mu-firewall/metadata.rb +3 -3
- data/cookbooks/mu-firewall/recipes/default.rb +11 -2
- data/cookbooks/mu-master/Berksfile +1 -1
- data/cookbooks/mu-master/attributes/default.rb +14 -1
- data/cookbooks/mu-master/files/default/389ds-perl/ASDialogs.pm +173 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminMigration.pm +569 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminServer.pm +952 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminUtil.pm +983 -0
- data/cookbooks/mu-master/files/default/389ds-perl/ConfigDSDialogs.pm +449 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSCreate.pm +1551 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSDialogs.pm +233 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSMigration.pm +1175 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUpdate.pm +534 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUpdateDialogs.pm +152 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUtil.pm +1710 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Dialog.pm +249 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DialogManager.pm +212 -0
- data/cookbooks/mu-master/files/default/389ds-perl/FileConn.pm +461 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Inf.pm +268 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Migration.pm +327 -0
- data/cookbooks/mu-master/files/default/389ds-perl/RegDSDialogs.pm +94 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Resource.pm +137 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Setup.pm +240 -0
- data/cookbooks/mu-master/files/default/389ds-perl/SetupDialogs.pm +243 -0
- data/cookbooks/mu-master/files/default/389ds-perl/SetupLog.pm +82 -0
- data/cookbooks/mu-master/files/default/setCertName.ldif +4 -0
- data/cookbooks/mu-master/libraries/mu.rb +2 -2
- data/cookbooks/mu-master/metadata.rb +1 -1
- data/cookbooks/mu-master/recipes/389ds.rb +71 -32
- data/cookbooks/mu-master/recipes/basepackages.rb +5 -0
- data/cookbooks/mu-master/recipes/default.rb +16 -5
- data/cookbooks/mu-master/recipes/init.rb +36 -3
- data/cookbooks/mu-master/recipes/ssl-certs.rb +6 -0
- data/cookbooks/mu-master/recipes/sssd.rb +85 -62
- data/cookbooks/mu-master/recipes/update_nagios_only.rb +7 -1
- data/cookbooks/mu-master/templates/default/389-directory-setup.inf.erb +11 -26
- data/cookbooks/mu-master/templates/default/sssd.conf.erb +18 -8
- data/cookbooks/mu-tools/files/default/Mu_CA.pem +33 -0
- data/cookbooks/mu-tools/metadata.rb +0 -1
- data/cookbooks/mu-tools/recipes/set_local_fw.rb +7 -1
- data/cookbooks/mu-tools/templates/amazon/sshd_config.erb +5 -1
- data/cookbooks/nagios/CHANGELOG.md +679 -0
- data/cookbooks/nagios/LICENSE +201 -0
- data/cookbooks/nagios/README.md +340 -0
- data/cookbooks/nagios/attributes/config.rb +163 -0
- data/cookbooks/nagios/attributes/default.rb +204 -0
- data/cookbooks/nagios/libraries/base.rb +311 -0
- data/cookbooks/nagios/libraries/command.rb +68 -0
- data/cookbooks/nagios/libraries/contact.rb +229 -0
- data/cookbooks/nagios/libraries/contactgroup.rb +111 -0
- data/cookbooks/{firewall/recipes/disable_firewall.rb → nagios/libraries/custom_option.rb} +20 -7
- data/cookbooks/nagios/libraries/data_bag_helper.rb +23 -0
- data/cookbooks/nagios/libraries/default.rb +90 -0
- data/cookbooks/nagios/libraries/helpers.rb +229 -0
- data/cookbooks/nagios/libraries/host.rb +410 -0
- data/cookbooks/nagios/libraries/hostdependency.rb +178 -0
- data/cookbooks/nagios/libraries/hostescalation.rb +170 -0
- data/cookbooks/nagios/libraries/hostgroup.rb +117 -0
- data/cookbooks/nagios/libraries/nagios.rb +277 -0
- data/cookbooks/nagios/libraries/resource.rb +59 -0
- data/cookbooks/nagios/libraries/service.rb +449 -0
- data/cookbooks/nagios/libraries/servicedependency.rb +213 -0
- data/cookbooks/nagios/libraries/serviceescalation.rb +193 -0
- data/cookbooks/nagios/libraries/servicegroup.rb +142 -0
- data/cookbooks/nagios/libraries/timeperiod.rb +159 -0
- data/cookbooks/nagios/libraries/users_helper.rb +54 -0
- data/cookbooks/nagios/metadata.json +44 -0
- data/cookbooks/nagios/metadata.rb +22 -0
- data/cookbooks/nagios/recipes/_load_databag_config.rb +153 -0
- data/cookbooks/nagios/recipes/_load_default_config.rb +241 -0
- data/cookbooks/nagios/recipes/apache.rb +114 -0
- data/cookbooks/nagios/recipes/default.rb +41 -0
- data/cookbooks/nagios/recipes/nginx.rb +114 -0
- data/cookbooks/nagios/recipes/pagerduty.rb +95 -0
- data/cookbooks/nagios/recipes/server.rb +182 -0
- data/cookbooks/nagios/recipes/server_package.rb +85 -0
- data/cookbooks/nagios/recipes/server_source.rb +137 -0
- data/cookbooks/nagios/resources/command.rb +34 -0
- data/cookbooks/nagios/resources/conf.rb +52 -0
- data/cookbooks/nagios/resources/contact.rb +34 -0
- data/cookbooks/nagios/resources/contactgroup.rb +35 -0
- data/cookbooks/nagios/resources/host.rb +35 -0
- data/cookbooks/nagios/resources/hostdependency.rb +35 -0
- data/cookbooks/nagios/resources/hostescalation.rb +36 -0
- data/cookbooks/nagios/resources/hostgroup.rb +35 -0
- data/cookbooks/nagios/resources/resource.rb +34 -0
- data/cookbooks/nagios/resources/service.rb +35 -0
- data/cookbooks/nagios/resources/servicedependency.rb +35 -0
- data/cookbooks/nagios/resources/serviceescalation.rb +35 -0
- data/cookbooks/nagios/resources/servicegroup.rb +35 -0
- data/cookbooks/nagios/resources/timeperiod.rb +35 -0
- data/cookbooks/nagios/templates/apache2.conf.erb +102 -0
- data/cookbooks/nagios/templates/cgi.cfg.erb +266 -0
- data/cookbooks/nagios/templates/commands.cfg.erb +13 -0
- data/cookbooks/nagios/templates/contacts.cfg.erb +37 -0
- data/cookbooks/nagios/templates/hostgroups.cfg.erb +25 -0
- data/cookbooks/nagios/templates/hosts.cfg.erb +15 -0
- data/cookbooks/nagios/templates/htpasswd.users.erb +6 -0
- data/cookbooks/nagios/templates/nagios.cfg.erb +22 -0
- data/cookbooks/nagios/templates/nginx.conf.erb +80 -0
- data/cookbooks/nagios/templates/pagerduty.cgi.erb +185 -0
- data/cookbooks/nagios/templates/resource.cfg.erb +27 -0
- data/cookbooks/nagios/templates/servicedependencies.cfg.erb +15 -0
- data/cookbooks/nagios/templates/servicegroups.cfg.erb +14 -0
- data/cookbooks/nagios/templates/services.cfg.erb +14 -0
- data/cookbooks/nagios/templates/spawn-fcgi.erb +10 -0
- data/cookbooks/nagios/templates/templates.cfg.erb +31 -0
- data/cookbooks/nagios/templates/timeperiods.cfg.erb +13 -0
- data/extras/platform_berksfile_base +3 -3
- data/extras/python_rpm/build.sh +4 -4
- data/extras/python_rpm/muthon.spec +2 -4
- data/extras/vault_tools/export_vaults.sh +11 -1
- data/install/installer +1 -1
- data/modules/mu/kittens.rb +27523 -0
- data/modules/mu/master/ldap.rb +48 -31
- data/modules/mu/master.rb +69 -0
- data/modules/mu/mu.yaml.rb +351 -0
- data/modules/mu/providers/aws/firewall_rule.rb +3 -1
- data/modules/mu/providers/aws.rb +11 -5
- data/modules/mu.rb +5 -4
- metadata +99 -48
- data/cookbooks/firewall/CHANGELOG.md +0 -488
- data/cookbooks/firewall/LICENSE +0 -202
- data/cookbooks/firewall/README.md +0 -366
- data/cookbooks/firewall/TODO.md +0 -6
- data/cookbooks/firewall/attributes/default.rb +0 -5
- data/cookbooks/firewall/attributes/firewalld.rb +0 -8
- data/cookbooks/firewall/attributes/iptables.rb +0 -17
- data/cookbooks/firewall/attributes/ufw.rb +0 -12
- data/cookbooks/firewall/attributes/windows.rb +0 -8
- data/cookbooks/firewall/libraries/helpers.rb +0 -105
- data/cookbooks/firewall/libraries/helpers_firewalld.rb +0 -116
- data/cookbooks/firewall/libraries/helpers_firewalld_dbus.rb +0 -72
- data/cookbooks/firewall/libraries/helpers_iptables.rb +0 -112
- data/cookbooks/firewall/libraries/helpers_nftables.rb +0 -170
- data/cookbooks/firewall/libraries/helpers_ufw.rb +0 -142
- data/cookbooks/firewall/libraries/helpers_windows.rb +0 -129
- data/cookbooks/firewall/libraries/provider_firewall_firewalld.rb +0 -179
- data/cookbooks/firewall/libraries/provider_firewall_iptables.rb +0 -171
- data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu.rb +0 -200
- data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu1404.rb +0 -200
- data/cookbooks/firewall/libraries/provider_firewall_rule.rb +0 -34
- data/cookbooks/firewall/libraries/provider_firewall_ufw.rb +0 -138
- data/cookbooks/firewall/libraries/provider_firewall_windows.rb +0 -126
- data/cookbooks/firewall/libraries/resource_firewall.rb +0 -26
- data/cookbooks/firewall/libraries/resource_firewall_rule.rb +0 -52
- data/cookbooks/firewall/metadata.json +0 -40
- data/cookbooks/firewall/metadata.rb +0 -15
- data/cookbooks/firewall/recipes/default.rb +0 -76
- data/cookbooks/firewall/recipes/firewalld.rb +0 -87
- data/cookbooks/firewall/resources/firewalld.rb +0 -28
- data/cookbooks/firewall/resources/firewalld_config.rb +0 -39
- data/cookbooks/firewall/resources/firewalld_helpers.rb +0 -106
- data/cookbooks/firewall/resources/firewalld_icmptype.rb +0 -88
- data/cookbooks/firewall/resources/firewalld_ipset.rb +0 -104
- data/cookbooks/firewall/resources/firewalld_policy.rb +0 -115
- data/cookbooks/firewall/resources/firewalld_service.rb +0 -98
- data/cookbooks/firewall/resources/firewalld_zone.rb +0 -118
- data/cookbooks/firewall/resources/nftables.rb +0 -71
- data/cookbooks/firewall/resources/nftables_rule.rb +0 -113
- data/cookbooks/firewall/templates/default/ufw/default.erb +0 -13
- /data/cookbooks/{firewall → nagios}/chefignore +0 -0
- /data/cookbooks/{firewall → nagios}/renovate.json +0 -0
@@ -0,0 +1,952 @@
|
|
1
|
+
# BEGIN COPYRIGHT BLOCK
|
2
|
+
# This Program is free software; you can redistribute it and/or modify it under
|
3
|
+
# the terms of the GNU General Public License as published by the Free Software
|
4
|
+
# Foundation; version 2 of the License.
|
5
|
+
#
|
6
|
+
# This Program is distributed in the hope that it will be useful, but WITHOUT
|
7
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
8
|
+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
9
|
+
#
|
10
|
+
# You should have received a copy of the GNU General Public License along with
|
11
|
+
# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
12
|
+
# Place, Suite 330, Boston, MA 02111-1307 USA.
|
13
|
+
#
|
14
|
+
# Copyright (C) 2007 Red Hat, Inc.
|
15
|
+
# All rights reserved.
|
16
|
+
# END COPYRIGHT BLOCK
|
17
|
+
#
|
18
|
+
|
19
|
+
package AdminServer;
|
20
|
+
require Exporter;
|
21
|
+
@ISA = qw(Exporter);
|
22
|
+
@EXPORT = qw(createAdminServer reconfigAdminServer
|
23
|
+
createASFilesAndDirs setFileOwnerPerms updateHttpConfFiles
|
24
|
+
startAdminServer stopAdminServer removeAdminServer setDefaults
|
25
|
+
updateSelinuxPolicy);
|
26
|
+
@EXPORT_OK = qw(createAdminServer reconfigAdminServer
|
27
|
+
createASFilesAndDirs setFileOwnerPerms updateHttpConfFiles
|
28
|
+
startAdminServer stopAdminServer removeAdminServer setDefaults
|
29
|
+
updateSelinuxPolicy);
|
30
|
+
|
31
|
+
use File::Path;
|
32
|
+
use File::Copy;
|
33
|
+
use File::Basename;
|
34
|
+
use File::Temp;
|
35
|
+
|
36
|
+
my $template_backup_dir = "tmpdirXXXX";
|
37
|
+
my $secfile_backup_dir = "";
|
38
|
+
|
39
|
+
# tempfiles
|
40
|
+
use File::Temp qw(tempfile tempdir);
|
41
|
+
|
42
|
+
# load perldap
|
43
|
+
use Mozilla::LDAP::Conn;
|
44
|
+
use Mozilla::LDAP::Utils qw(normalizeDN);
|
45
|
+
use Mozilla::LDAP::API qw(ldap_url_parse);
|
46
|
+
use Mozilla::LDAP::LDIF;
|
47
|
+
|
48
|
+
use DSUtil;
|
49
|
+
use Inf;
|
50
|
+
use Setup;
|
51
|
+
use AdminUtil;
|
52
|
+
|
53
|
+
sub setDefaults {
|
54
|
+
my $setup = shift;
|
55
|
+
|
56
|
+
if (!defined($setup->{inf}->{admin}->{ServerIpAddress})) {
|
57
|
+
$setup->{inf}->{admin}->{ServerIpAddress} = '0.0.0.0';
|
58
|
+
}
|
59
|
+
if (!defined($setup->{inf}->{admin}->{Port})) {
|
60
|
+
$setup->{inf}->{admin}->{Port} = 9830;
|
61
|
+
}
|
62
|
+
if (!defined($setup->{inf}->{admin}->{SysUser})) {
|
63
|
+
my $user = $setup->{inf}->{General}->{SuiteSpotUserID};
|
64
|
+
if (!defined($user)) {
|
65
|
+
if ($> == 0) { # if root, use the default user
|
66
|
+
$user = "nobody";
|
67
|
+
} else { # if not root, use the user's uid
|
68
|
+
$user = getLogin;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
$setup->{inf}->{admin}->{SysUser} = $user;
|
72
|
+
}
|
73
|
+
if (!defined($setup->{inf}->{admin}->{ServerAdminID})) {
|
74
|
+
my $id = $setup->{inf}->{General}->{ConfigDirectoryAdminID};
|
75
|
+
if (isValidDN($id)) {
|
76
|
+
$id =~ s/^(.*)=.*/$1/;
|
77
|
+
}
|
78
|
+
$setup->{inf}->{admin}->{ServerAdminID} = $id;
|
79
|
+
}
|
80
|
+
if (!defined($setup->{inf}->{admin}->{ServerAdminPwd})) {
|
81
|
+
my $pwd = $setup->{inf}->{General}->{ConfigDirectoryAdminPwd};
|
82
|
+
$setup->{inf}->{admin}->{ServerAdminPwd} = $pwd;
|
83
|
+
}
|
84
|
+
|
85
|
+
return 1;
|
86
|
+
}
|
87
|
+
|
88
|
+
sub checkRequiredParameters {
|
89
|
+
my $setup = shift;
|
90
|
+
for my $asparam (qw(ServerIpAddress Port SysUser ServerAdminID ServerAdminPwd)) {
|
91
|
+
if (!defined($setup->{inf}->{admin}->{$asparam})) {
|
92
|
+
$setup->msg($FATAL, "missing_adminserver_param", $asparam);
|
93
|
+
return 0;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
for my $general (qw(AdminDomain SuiteSpotUserID SuiteSpotGroup ConfigDirectoryLdapURL)) {
|
98
|
+
if (!defined($setup->{inf}->{General}->{$general})) {
|
99
|
+
$setup->msg($FATAL, "missing_general_param", $general);
|
100
|
+
return 0;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
return 1;
|
105
|
+
}
|
106
|
+
|
107
|
+
sub usingSELinux {
|
108
|
+
my $mydevnull = (-c "/dev/null" ? " /dev/null " : " NUL ");
|
109
|
+
|
110
|
+
if ((getLogin() eq 'root') and "yes" and -f "/usr/sbin/sestatus" and
|
111
|
+
!system ("/usr/sbin/sestatus | egrep -i \"selinux status:\\s*enabled\" > $mydevnull 2>&1")) {
|
112
|
+
# We are using SELinux
|
113
|
+
return 1;
|
114
|
+
}
|
115
|
+
return 0;
|
116
|
+
}
|
117
|
+
|
118
|
+
sub setFileOwnerPerms {
|
119
|
+
my $setup = shift;
|
120
|
+
my $configdir = shift;
|
121
|
+
my $admConf = getAdmConf($configdir);
|
122
|
+
my $uid = getpwnam $admConf->{sysuser};
|
123
|
+
|
124
|
+
# chown the config directory
|
125
|
+
$! = 0; # clear errno
|
126
|
+
chown $uid, -1, $configdir;
|
127
|
+
if ($!) {
|
128
|
+
$setup->msg($FATAL, 'error_chowning_file', $configdir,
|
129
|
+
$admConf->{sysuser}, $!);
|
130
|
+
return 0;
|
131
|
+
}
|
132
|
+
|
133
|
+
# chown and chmod other files appropriately
|
134
|
+
for (glob("$configdir/*")) {
|
135
|
+
# these are owned by root
|
136
|
+
next if (/httpd.conf$/);
|
137
|
+
next if (/nss.conf$/);
|
138
|
+
next if (/admserv.conf$/);
|
139
|
+
next if (! -f $_); # should never happen
|
140
|
+
# all other files should be owned by SysUser
|
141
|
+
$! = 0; # clear errno
|
142
|
+
chown $uid, -1, $_;
|
143
|
+
if ($!) {
|
144
|
+
$setup->msg($FATAL, 'error_chowning_file', $_,
|
145
|
+
$admConf->{sysuser}, $!);
|
146
|
+
return 0;
|
147
|
+
}
|
148
|
+
# the files should be writable
|
149
|
+
$! = 0; # clear errno
|
150
|
+
chmod 0600, $_;
|
151
|
+
if ($!) {
|
152
|
+
$setup->msg($FATAL, 'error_chmoding_file', $_, $!);
|
153
|
+
return 0;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
return 1;
|
158
|
+
}
|
159
|
+
|
160
|
+
sub createASFilesAndDirs {
|
161
|
+
my $setup = shift;
|
162
|
+
my $configdir = shift;
|
163
|
+
my $securitydir = shift;
|
164
|
+
my $logdir = shift;
|
165
|
+
my $rundir = shift;
|
166
|
+
|
167
|
+
my $uid = getpwnam $setup->{inf}->{admin}->{SysUser};
|
168
|
+
my $gid = getgrnam $setup->{inf}->{General}->{SuiteSpotGroup};
|
169
|
+
|
170
|
+
$setup->msg('create_adminserver_filesdirs');
|
171
|
+
|
172
|
+
# these paths are owned exclusively by admin sever
|
173
|
+
my @errs;
|
174
|
+
for ($configdir, $securitydir, $logdir) {
|
175
|
+
@errs = makePaths($_, 0700, $setup->{inf}->{admin}->{SysUser},
|
176
|
+
$setup->{inf}->{General}->{SuiteSpotGroup});
|
177
|
+
if (@errs) {
|
178
|
+
$setup->msg($FATAL, @errs);
|
179
|
+
return 0;
|
180
|
+
}
|
181
|
+
$! = 0; # clear errno
|
182
|
+
chmod 0700, $_;
|
183
|
+
if ($!) {
|
184
|
+
$setup->msg($FATAL, 'error_chmoding_directory', $_, $!);
|
185
|
+
return 0;
|
186
|
+
}
|
187
|
+
chown $uid, -1, $_;
|
188
|
+
if ($!) {
|
189
|
+
$setup->msg($FATAL, 'error_chowning_directory', $_,
|
190
|
+
$setup->{inf}->{admin}->{SysUser}, $!);
|
191
|
+
return 0;
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
# these paths are shared by SuiteSpotGroup members
|
196
|
+
@errs = makePaths($rundir, 0770, $setup->{inf}->{admin}->{SysUser},
|
197
|
+
$setup->{inf}->{General}->{SuiteSpotGroup});
|
198
|
+
if (@errs) {
|
199
|
+
$setup->msg($FATAL, @errs);
|
200
|
+
return 0;
|
201
|
+
}
|
202
|
+
$! = 0; # clear errno
|
203
|
+
chmod 0770, $rundir;
|
204
|
+
if ($!) {
|
205
|
+
$setup->msg($FATAL, 'error_chmoding_directory', $rundir, $!);
|
206
|
+
return 0;
|
207
|
+
}
|
208
|
+
chown -1, $gid, $rundir;
|
209
|
+
if ($!) {
|
210
|
+
$setup->msg($FATAL, 'error_chgrping_directory', $rundir,
|
211
|
+
$setup->{inf}->{General}->{SuiteSpotGroup}, $!);
|
212
|
+
return 0;
|
213
|
+
}
|
214
|
+
|
215
|
+
return 1;
|
216
|
+
}
|
217
|
+
|
218
|
+
sub makeConfFiles {
|
219
|
+
my $setup = shift;
|
220
|
+
my $configdir = shift;
|
221
|
+
|
222
|
+
my @start_slapd;
|
223
|
+
if ($setup->{inf}->{slapd}->{SlapdConfigForMC} =~ /yes/i) {
|
224
|
+
my $sbindir = $setup->{inf}->{slapd}->{sbindir};
|
225
|
+
my $inst_name = $setup->{inf}->{slapd}->{ServerIdentifier};
|
226
|
+
@start_slapd = ('ldapStart', "$sbindir/start-dirsrv $inst_name");
|
227
|
+
}
|
228
|
+
$setup->msg('updating_admconf');
|
229
|
+
my $rc = updateAdmConf({ldapurl => $setup->{inf}->{General}->{ConfigDirectoryLdapURL},
|
230
|
+
SuiteSpotUserID => $setup->{inf}->{General}->{SuiteSpotUserID},
|
231
|
+
SuiteSpotGroup => $setup->{inf}->{General}->{SuiteSpotGroup},
|
232
|
+
sysuser => $setup->{inf}->{admin}->{SysUser},
|
233
|
+
sysgroup => $setup->{inf}->{General}->{SuiteSpotGroup},
|
234
|
+
AdminDomain => $setup->{inf}->{General}->{AdminDomain},
|
235
|
+
@start_slapd},
|
236
|
+
$configdir);
|
237
|
+
if (!$rc) {
|
238
|
+
$setup->msg($FATAL, 'error_updating_admconf', $!);
|
239
|
+
return 0;
|
240
|
+
}
|
241
|
+
|
242
|
+
$setup->msg('updating_admpw');
|
243
|
+
$rc = updateAdmpw($setup->{inf}->{admin}->{ServerAdminID},
|
244
|
+
$setup->{inf}->{admin}->{ServerAdminPwd},
|
245
|
+
$configdir);
|
246
|
+
if (!$rc) {
|
247
|
+
$setup->msg($FATAL, 'error_updating_admpw');
|
248
|
+
return 0;
|
249
|
+
}
|
250
|
+
|
251
|
+
return 1;
|
252
|
+
}
|
253
|
+
|
254
|
+
# sub addDefaultSecurityInfo {
|
255
|
+
# my $setup = shift;
|
256
|
+
# my $inf = $setup->{inf};
|
257
|
+
# my $configdir = shift;
|
258
|
+
# my $reconfig = shift;
|
259
|
+
# my @errs;
|
260
|
+
|
261
|
+
# my $admConf = getAdmConf($configdir);
|
262
|
+
# my $localconf = "$configdir/local.conf";
|
263
|
+
# if (!open(LOCALCONF, ">$localconf")) {
|
264
|
+
# $setup->msg($FATAL, 'error_updating_localconf', $localconf, $!);
|
265
|
+
# return 0;
|
266
|
+
# }
|
267
|
+
|
268
|
+
# if (!open(CONSOLECONF, "$admConf->{configdir}/console.conf")) {
|
269
|
+
# debug(0, "Error opening $admConf->{configdir}/console.conf: $!");
|
270
|
+
# return 0;
|
271
|
+
# }
|
272
|
+
|
273
|
+
# print LOCALCONF "configuration.Encryption\n";
|
274
|
+
|
275
|
+
# close(LOCALCONF);
|
276
|
+
# return 1;
|
277
|
+
# }
|
278
|
+
|
279
|
+
# This is how we extract the sie and isie as the as entries are
|
280
|
+
# being added
|
281
|
+
sub registercb {
|
282
|
+
my ($context, $entry, $errs) = @_;
|
283
|
+
|
284
|
+
my $rc = check_and_add_entry([$context->{conn}], $entry, $errs);
|
285
|
+
my $setup = $context->{setup};
|
286
|
+
if ($rc) {
|
287
|
+
if ($entry->hasValue('objectclass', 'nsApplication', 1)) {
|
288
|
+
$context->{isie} = $entry->getDN();
|
289
|
+
} elsif ($entry->hasValue('objectclass', 'nsAdminServer', 1)) {
|
290
|
+
$context->{sie} = $entry->getDN();
|
291
|
+
}
|
292
|
+
|
293
|
+
if ($context->{sie}) {
|
294
|
+
$rc = updateLocalConf($entry, $context->{sie}, $context->{localfh});
|
295
|
+
if (!$rc) {
|
296
|
+
$setup->msg($FATAL, 'error_updating_localconf_entry', $entry->getDN());
|
297
|
+
}
|
298
|
+
}
|
299
|
+
} else {
|
300
|
+
$setup->msg(@{$errs});
|
301
|
+
$setup->msg($FATAL, 'error_adding_adminserver_config_entry', $entry->getDN());
|
302
|
+
}
|
303
|
+
|
304
|
+
return $rc;
|
305
|
+
}
|
306
|
+
|
307
|
+
sub registerASWithConfigDS {
|
308
|
+
my $setup = shift;
|
309
|
+
my $inf = $setup->{inf};
|
310
|
+
my $configdir = shift;
|
311
|
+
my @errs;
|
312
|
+
|
313
|
+
$setup->msg('registering_adminserver');
|
314
|
+
# open a connection to the configuration directory server
|
315
|
+
my $conn = getConfigDSConn($inf->{General}->{ConfigDirectoryLdapURL},
|
316
|
+
$inf->{General}->{ConfigDirectoryAdminID},
|
317
|
+
$inf->{General}->{ConfigDirectoryAdminPwd},
|
318
|
+
$configdir, \@errs);
|
319
|
+
|
320
|
+
if (@errs) {
|
321
|
+
$setup->msg($FATAL, @errs);
|
322
|
+
return 0;
|
323
|
+
}
|
324
|
+
|
325
|
+
# add the Admin Server configuration entries
|
326
|
+
my @ldiffiles = ("/usr/share/dirsrv/data/20asdata.ldif.tmpl",
|
327
|
+
"/usr/share/dirsrv/data/21astasks.ldif.tmpl",
|
328
|
+
"/usr/share/dirsrv/data/22ascommands.ldif.tmpl"
|
329
|
+
);
|
330
|
+
my @infs = getInfs("admin", "setup");
|
331
|
+
my $mapper = new Inf("/usr/share/dirsrv/inf/adminserver.map");
|
332
|
+
|
333
|
+
$mapper = process_maptbl($mapper, \@errs, $inf, @infs);
|
334
|
+
if (!$mapper or @errs) {
|
335
|
+
$conn->close();
|
336
|
+
$setup->msg(@errs);
|
337
|
+
$setup->msg($FATAL, 'error_creating_adminserver_maptbl');
|
338
|
+
return 0;
|
339
|
+
}
|
340
|
+
|
341
|
+
# context will get filled in with isie and sie in registercb
|
342
|
+
my $localconf = "$configdir/local.conf";
|
343
|
+
my $isnew;
|
344
|
+
if (! -f $localconf) {
|
345
|
+
$isnew = 1;
|
346
|
+
}
|
347
|
+
if (!open(LOCALCONF, ">$localconf")) {
|
348
|
+
$setup->msg($FATAL, 'error_updating_localconf', $localconf, $!);
|
349
|
+
return 0;
|
350
|
+
}
|
351
|
+
my $context = {conn => $conn, localfh => \*LOCALCONF, setup => $setup};
|
352
|
+
getMappedEntries($mapper, \@ldiffiles, \@errs, \®istercb, $context);
|
353
|
+
close(LOCALCONF);
|
354
|
+
|
355
|
+
if ($isnew) {
|
356
|
+
my $admConf = getAdmConf($configdir);
|
357
|
+
my $uid = getpwnam $admConf->{sysuser};
|
358
|
+
chmod 0600, "$localconf";
|
359
|
+
chown $uid, -1, "$localconf";
|
360
|
+
}
|
361
|
+
|
362
|
+
$setup->msg('updating_admconf_configds');
|
363
|
+
if ($context->{sie} or $context->{isie}) {
|
364
|
+
if (!updateAdmConf({sie => $context->{sie},
|
365
|
+
isie => $context->{isie},
|
366
|
+
userdn => $conn->{adminbinddn}},
|
367
|
+
$configdir)) {
|
368
|
+
$setup->msg($FATAL, 'error_updating_admconf', $!);
|
369
|
+
return 0;
|
370
|
+
}
|
371
|
+
}
|
372
|
+
|
373
|
+
$conn->close();
|
374
|
+
return @errs ? 0 : 1;
|
375
|
+
}
|
376
|
+
|
377
|
+
my @saveconffiles = qw(admserv.conf httpd.conf nss.conf console.conf);
|
378
|
+
my @savesecfiles = qw(cert8.db key3.db secmod.db password.conf);
|
379
|
+
my @reconfigsavefiles = qw (httpd.conf nss.conf cert8.db key3.db secmod.db password.conf);
|
380
|
+
|
381
|
+
# update other config files - these are the fields which users typically want to
|
382
|
+
# change during an install or an upgrade, that also must be synced to the Apache
|
383
|
+
# style config files - we use the config CGI in command line mode because it
|
384
|
+
# already has all of the logic to update the files correctly
|
385
|
+
sub updateHttpConfFiles {
|
386
|
+
my $serverAddress = shift;
|
387
|
+
my $port = shift;
|
388
|
+
my $configdir = shift;
|
389
|
+
my $origport = shift;
|
390
|
+
my $admConf = getAdmConf($configdir);
|
391
|
+
my $user = $admConf->{sysuser};
|
392
|
+
|
393
|
+
# this is required on some platforms in order to execute the config command
|
394
|
+
my $savepath = $ENV{SHLIB_PATH} || $ENV{LD_LIBRARY_PATH};
|
395
|
+
$ENV{LD_LIBRARY_PATH} = "";
|
396
|
+
libpath_add("/usr/lib64");
|
397
|
+
libpath_add("$savepath");
|
398
|
+
$ENV{SHLIB_PATH} = $ENV{LD_LIBRARY_PATH};
|
399
|
+
|
400
|
+
if (! -d "$admConf->{configdir}/bakup") {
|
401
|
+
if (system ("mkdir -p $admConf->{configdir}/bakup")) {
|
402
|
+
debug(0, "Error backing up $admConf->{configdir}/console.conf failed: $!");
|
403
|
+
}
|
404
|
+
}
|
405
|
+
# backup the savefiles for "remove-ds-admin.pl -a"
|
406
|
+
foreach my $savefile (@saveconffiles, @savesecfiles) {
|
407
|
+
if (! -f "$admConf->{configdir}/bakup/$savefile") {
|
408
|
+
if (-e "$admConf->{configdir}/$savefile"){
|
409
|
+
if(system ("cp -p $admConf->{configdir}/$savefile $admConf->{configdir}/bakup")) {
|
410
|
+
debug(0, "Error backing up $admConf->{configdir}/$savefile failed: $!\n");
|
411
|
+
}
|
412
|
+
}
|
413
|
+
}
|
414
|
+
}
|
415
|
+
|
416
|
+
my $cmd = "/usr/lib64/dirsrv/cgi-bin/config op=set configuration.nsSuiteSpotUser=\"$user\"";
|
417
|
+
if (!defined($origport) or ($port != $origport)) { # need to change the port number
|
418
|
+
$cmd .= " configuration.nsServerPort=\"$port\"";
|
419
|
+
}
|
420
|
+
if ($serverAddress) {
|
421
|
+
$cmd .= " configuration.nsServerAddress=\"$serverAddress\"";
|
422
|
+
}
|
423
|
+
debug(1, "Running $cmd ...");
|
424
|
+
$? = 0; # clear error
|
425
|
+
my $output = `$cmd 2>&1`;
|
426
|
+
# Check the output of the config CGI to see if something bad happened.
|
427
|
+
if ($? || $output =~ /NMC_Status: 1/) {
|
428
|
+
debug(0, "Error updating console.conf:\n");
|
429
|
+
debug(0, $output);
|
430
|
+
$ENV{LD_LIBRARY_PATH} = $savepath;
|
431
|
+
$ENV{SHLIB_PATH} = $savepath;
|
432
|
+
return 0;
|
433
|
+
}
|
434
|
+
|
435
|
+
debug(1, $output);
|
436
|
+
$ENV{LD_LIBRARY_PATH} = $savepath;
|
437
|
+
$ENV{SHLIB_PATH} = $savepath;
|
438
|
+
|
439
|
+
# update Group in console.conf
|
440
|
+
if ($admConf->{sysgroup}) {
|
441
|
+
if (!open(CONSOLECONF, "$admConf->{configdir}/console.conf")) {
|
442
|
+
debug(0, "Error opening $admConf->{configdir}/console.conf: $!");
|
443
|
+
return 0;
|
444
|
+
}
|
445
|
+
my @contents = <CONSOLECONF>;
|
446
|
+
close (CONSOLECONF);
|
447
|
+
grep { s/^Group.*$/Group $admConf->{sysgroup}/ } @contents;
|
448
|
+
if (!open(CONSOLECONF, ">$admConf->{configdir}/console.conf")) {
|
449
|
+
debug(0, "Error writing new group $admConf->{sysgroup} to $admConf->{configdir}/console.conf: $!");
|
450
|
+
return 0;
|
451
|
+
}
|
452
|
+
print CONSOLECONF @contents;
|
453
|
+
close (CONSOLECONF);
|
454
|
+
}
|
455
|
+
|
456
|
+
return 1;
|
457
|
+
}
|
458
|
+
|
459
|
+
sub startAdminServer {
|
460
|
+
my $setup = shift;
|
461
|
+
my $configdir = shift;
|
462
|
+
my $logdir = shift;
|
463
|
+
my $rundir = shift;
|
464
|
+
my $isrunning;
|
465
|
+
|
466
|
+
$pidfile = "$rundir/admin-serv.pid";
|
467
|
+
if (-f $pidfile) {
|
468
|
+
open(PIDFILE, $pidfile);
|
469
|
+
my $pid = <PIDFILE>;
|
470
|
+
close(PIDFILE);
|
471
|
+
if (kill 0, $pid) {
|
472
|
+
$isrunning = 1;
|
473
|
+
}
|
474
|
+
}
|
475
|
+
|
476
|
+
my ($fh, $filename) = tempfile("asstartupXXXXXX", UNLINK => 1,
|
477
|
+
SUFFIX => ".log", DIR => File::Spec->tmpdir);
|
478
|
+
close($fh);
|
479
|
+
my $rc;
|
480
|
+
my $selinux_cmd = "";
|
481
|
+
|
482
|
+
# If we're using selinux, start the server with the proper context
|
483
|
+
# to allow the process to transition to the proper domain.
|
484
|
+
if (usingSELinux()) {
|
485
|
+
$selinux_cmd = "runcon -u system_u -r system_r -t initrc_t";
|
486
|
+
}
|
487
|
+
|
488
|
+
if ($isrunning) {
|
489
|
+
$setup->msg('restarting_adminserver');
|
490
|
+
if ("") {
|
491
|
+
$rc = system("service dirsrv-admin restart > $filename 2>&1");
|
492
|
+
} elsif ("/usr/lib/systemd/system") {
|
493
|
+
$rc = system("/bin/systemctl restart dirsrv-admin.service > $filename 2>&1");
|
494
|
+
} else {
|
495
|
+
$rc = system("$selinux_cmd /usr/sbin/restart-ds-admin > $filename 2>&1");
|
496
|
+
}
|
497
|
+
} else {
|
498
|
+
$setup->msg('starting_adminserver');
|
499
|
+
if ("") {
|
500
|
+
$rc = system("service dirsrv-admin start > $filename 2>&1");
|
501
|
+
} elsif ("/usr/lib/systemd/system") {
|
502
|
+
$rc = system("/bin/systemctl start dirsrv-admin.service > $filename 2>&1");
|
503
|
+
} else {
|
504
|
+
$rc = system("$selinux_cmd /usr/sbin/start-ds-admin > $filename 2>&1");
|
505
|
+
}
|
506
|
+
}
|
507
|
+
|
508
|
+
open(STARTLOG, "$filename");
|
509
|
+
while (<STARTLOG>) {
|
510
|
+
$setup->msg('adminserver_startup_output', $_);
|
511
|
+
}
|
512
|
+
close(STARTLOG);
|
513
|
+
unlink($filename);
|
514
|
+
|
515
|
+
if ($rc) {
|
516
|
+
$setup->msg($FATAL, 'error_starting_adminserver', $rc);
|
517
|
+
return 0;
|
518
|
+
}
|
519
|
+
|
520
|
+
$setup->msg('success_starting_adminserver');
|
521
|
+
return 1;
|
522
|
+
}
|
523
|
+
|
524
|
+
sub reconfig_backup_secfiles
|
525
|
+
{
|
526
|
+
#
|
527
|
+
# Backup the security files, because when we reconfigure the admin
|
528
|
+
# server it overwrites these files and breaks SSL.
|
529
|
+
#
|
530
|
+
my $configdir = shift;
|
531
|
+
|
532
|
+
my $dirname = dirname $configdir;
|
533
|
+
my $my_template_backup_dir = $dirname . "/" . $template_backup_dir;
|
534
|
+
$secfile_backup_dir = mkdtemp($my_template_backup_dir);
|
535
|
+
if ( ! -d $secfile_backup_dir){
|
536
|
+
$setup->msg($FATAL, 'error_creating_secfile_backup', $secfile_backup_dir, $!);
|
537
|
+
return 0;
|
538
|
+
}
|
539
|
+
foreach my $savefile (@reconfigsavefiles) {
|
540
|
+
if ( -e "$configdir/$savefile"){
|
541
|
+
# To keep the ownership and modes, use move for backup.
|
542
|
+
move ("$configdir/$savefile", "$secfile_backup_dir/$savefile");
|
543
|
+
debug(1, "Backing up $configdir/$savefile to $secfile_backup_dir/$savefile\n");
|
544
|
+
if (! -e "$secfile_backup_dir/$savefile"){
|
545
|
+
debug(0, "Backup file $secfile_backup_dir/$savefile not found, error $!\n");
|
546
|
+
}
|
547
|
+
}
|
548
|
+
}
|
549
|
+
return 1;
|
550
|
+
}
|
551
|
+
|
552
|
+
sub reconfig_restore_secfiles
|
553
|
+
{
|
554
|
+
#
|
555
|
+
# Restore security files
|
556
|
+
#
|
557
|
+
my $configdir = shift;
|
558
|
+
|
559
|
+
if ( ! -d $secfile_backup_dir){
|
560
|
+
$setup->msg($FATAL, 'error_accessing_secfile_backup', $secfile_backup_dir);
|
561
|
+
return 0;
|
562
|
+
}
|
563
|
+
foreach my $savefile (@reconfigsavefiles) {
|
564
|
+
move ("$secfile_backup_dir/$savefile" ,"$configdir/$savefile");
|
565
|
+
debug(1, "Restoring $configdir/$savefile with $secfile_backup_dir/$savefile\n");
|
566
|
+
}
|
567
|
+
rmdir ($secfile_backup_dir);
|
568
|
+
return 1;
|
569
|
+
}
|
570
|
+
|
571
|
+
sub createAdminServer {
|
572
|
+
my $setup = shift;
|
573
|
+
my $reconfig = shift;
|
574
|
+
# setup has inf, res, and log
|
575
|
+
|
576
|
+
if (!setDefaults($setup)) {
|
577
|
+
return 0;
|
578
|
+
}
|
579
|
+
|
580
|
+
if (!checkRequiredParameters($setup)) {
|
581
|
+
return 0;
|
582
|
+
}
|
583
|
+
|
584
|
+
my $configdir = $setup->{inf}->{admin}->{config_dir} ||
|
585
|
+
$ENV{ADMSERV_CONF_DIR} ||
|
586
|
+
$setup->{configdir} . "/admin-serv";
|
587
|
+
|
588
|
+
my $securitydir = $setup->{inf}->{admin}->{security_dir} ||
|
589
|
+
$configdir;
|
590
|
+
|
591
|
+
my $logdir = $setup->{inf}->{admin}->{log_dir} ||
|
592
|
+
$ENV{ADMSERV_LOG_DIR} ||
|
593
|
+
"/var/log/dirsrv/admin-serv";
|
594
|
+
|
595
|
+
my $rundir = $setup->{inf}->{admin}->{run_dir} ||
|
596
|
+
$ENV{ADMSERV_PID_DIR} ||
|
597
|
+
"/var/run/dirsrv";
|
598
|
+
|
599
|
+
if ($reconfig) {
|
600
|
+
$setup->msg('begin_reconfig_adminserver');
|
601
|
+
if (!reconfig_backup_secfiles($configdir)) {
|
602
|
+
foreach my $savefile (@reconfigsavefiles) {
|
603
|
+
if (-e "$secfile_backup_dir/$savefile") {
|
604
|
+
move ("$secfile_backup_dir/$savefile" ,"$configdir/$savefile");
|
605
|
+
debug(1, "Restoring $configdir/$savefile with $secfile_backup_dir/$savefile\n");
|
606
|
+
}
|
607
|
+
}
|
608
|
+
return 0;
|
609
|
+
}
|
610
|
+
} else {
|
611
|
+
$setup->msg('begin_create_adminserver');
|
612
|
+
}
|
613
|
+
|
614
|
+
# if we're just doing the update, just register and return
|
615
|
+
if ($setup->{update}) {
|
616
|
+
if (!registerASWithConfigDS($setup, $configdir)) {
|
617
|
+
return 0;
|
618
|
+
}
|
619
|
+
|
620
|
+
# Update SELinux policy if needed
|
621
|
+
updateSelinuxPolicy($setup, $configdir, $securitydir, $logdir, $rundir);
|
622
|
+
|
623
|
+
# Restore the security files before we start the server
|
624
|
+
if ($reconfig) {
|
625
|
+
if (!reconfig_restore_secfiles($configdir)) {
|
626
|
+
return 0;
|
627
|
+
}
|
628
|
+
}
|
629
|
+
|
630
|
+
return 1;
|
631
|
+
}
|
632
|
+
|
633
|
+
if (!createASFilesAndDirs($setup, $configdir, $securitydir, $logdir, $rundir)) {
|
634
|
+
return 0;
|
635
|
+
}
|
636
|
+
|
637
|
+
if (!makeConfFiles($setup, $configdir)) {
|
638
|
+
return 0;
|
639
|
+
}
|
640
|
+
|
641
|
+
if (!registerASWithConfigDS($setup, $configdir)) {
|
642
|
+
return 0;
|
643
|
+
}
|
644
|
+
|
645
|
+
$setup->msg('updating_httpconf');
|
646
|
+
if (!updateHttpConfFiles($setup->{inf}->{admin}->{ServerIpAddress},
|
647
|
+
$setup->{inf}->{admin}->{Port},
|
648
|
+
$configdir, $setup->{asorigport})) {
|
649
|
+
$setup->msg($FATAL, 'error_updating_httpconf');
|
650
|
+
return 0;
|
651
|
+
}
|
652
|
+
|
653
|
+
if (!setFileOwnerPerms($setup, $configdir)) {
|
654
|
+
return 0;
|
655
|
+
}
|
656
|
+
|
657
|
+
# Update SELinux policy if needed
|
658
|
+
updateSelinuxPolicy($setup, $configdir, $securitydir, $logdir, $rundir);
|
659
|
+
|
660
|
+
# Restore the security files before we start the server
|
661
|
+
if ($reconfig) {
|
662
|
+
if (!reconfig_restore_secfiles($configdir)) {
|
663
|
+
return 0;
|
664
|
+
}
|
665
|
+
}
|
666
|
+
|
667
|
+
if (!startAdminServer($setup, $configdir, $logdir, $rundir)) {
|
668
|
+
return 0;
|
669
|
+
}
|
670
|
+
|
671
|
+
# Force to make log files owned by admin user and group
|
672
|
+
# to maintain consistency with the log files created via CGI/Console
|
673
|
+
my $uid = getpwnam $setup->{inf}->{admin}->{SysUser};
|
674
|
+
my $gid = getgrnam $setup->{inf}->{General}->{SuiteSpotGroup};
|
675
|
+
# chown log files appropriately
|
676
|
+
for (glob("$logdir/*")) {
|
677
|
+
$! = 0; # clear errno
|
678
|
+
debug(1, "Changing the owner of $_ to \($uid, $gid\)\n");
|
679
|
+
chown $uid, $gid, $_;
|
680
|
+
if ($!) {
|
681
|
+
$setup->msg($FATAL, 'error_chowning_file', $_,
|
682
|
+
$admConf->{sysuser}, $!);
|
683
|
+
return 0;
|
684
|
+
}
|
685
|
+
}
|
686
|
+
|
687
|
+
if ($reconfig) {
|
688
|
+
$setup->msg('end_reconfig_adminserver');
|
689
|
+
} else {
|
690
|
+
$setup->msg('end_create_adminserver');
|
691
|
+
}
|
692
|
+
return 1;
|
693
|
+
}
|
694
|
+
|
695
|
+
sub reconfigAdminServer {
|
696
|
+
my $setup = shift;
|
697
|
+
return createAdminServer($setup, 1);
|
698
|
+
}
|
699
|
+
|
700
|
+
sub stopAdminServer {
|
701
|
+
my $prog = "/usr/sbin/stop-ds-admin";
|
702
|
+
if ("") {
|
703
|
+
$prog = "service dirsrv-admin stop";
|
704
|
+
} elsif ("/usr/lib/systemd/system") {
|
705
|
+
$prog = "/bin/systemctl stop dirsrv-admin.service";
|
706
|
+
} elsif (! -x $prog) {
|
707
|
+
debug(1, "stopping admin server: no such program $prog: cannot stop server\n");
|
708
|
+
return 0;
|
709
|
+
}
|
710
|
+
$? = 0;
|
711
|
+
# run the stop command
|
712
|
+
my $output = `$prog 2>&1`;
|
713
|
+
my $status = $?;
|
714
|
+
debug(3, "stopping admin server returns status $status: output $output\n");
|
715
|
+
if ($status) {
|
716
|
+
# Ignore the stop failure
|
717
|
+
debug(1,"Warning: Could not stop admin server: status $status: output $output\n");
|
718
|
+
return 1;
|
719
|
+
}
|
720
|
+
|
721
|
+
debug(1, "Successfully stopped admin server\n");
|
722
|
+
return 1;
|
723
|
+
}
|
724
|
+
|
725
|
+
sub removeAdminServer {
|
726
|
+
my $baseconfigdir = shift;
|
727
|
+
my $force = shift;
|
728
|
+
my $all = shift;
|
729
|
+
if (!stopAdminServer()) {
|
730
|
+
if ($force) {
|
731
|
+
debug(1, "Warning: Could not stop admin server - forcing continue\n");
|
732
|
+
} else {
|
733
|
+
debug(1, "Error: Could not stop admin server - aborting - use -f flag to force removal\n");
|
734
|
+
return ( [ 'error_stopping_adminserver', $! ] );
|
735
|
+
}
|
736
|
+
}
|
737
|
+
|
738
|
+
my $configdir = $ENV{ADMSERV_CONF_DIR} || $baseconfigdir . "/admin-serv";
|
739
|
+
|
740
|
+
my $securitydir = $configdir;
|
741
|
+
|
742
|
+
my $logdir = $ENV{ADMSERV_LOG_DIR} || "/var/log/dirsrv/admin-serv";
|
743
|
+
|
744
|
+
my $rundir = $ENV{ADMSERV_PID_DIR} || "/var/run/dirsrv";
|
745
|
+
|
746
|
+
# Need to unlabel the port if we're using SELinux.
|
747
|
+
if (usingSELinux()) {
|
748
|
+
my $port;
|
749
|
+
|
750
|
+
# Read the console.conf file to find the port number.
|
751
|
+
if (!open(CONSOLECONF, "$configdir/console.conf")) {
|
752
|
+
if ($force) {
|
753
|
+
debug(1, "Warning: Could not open $configdir/console.conf: $!");
|
754
|
+
} else {
|
755
|
+
debug(1, "Error: Could not open $configdir/console.conf: $!");
|
756
|
+
return( [ 'error_reading_conffile', "$configdir/console.conf", $! ] );
|
757
|
+
}
|
758
|
+
} else {
|
759
|
+
# Find the Listen directive and read the port number.
|
760
|
+
while (<CONSOLECONF>) {
|
761
|
+
if (/^Listen /g) {
|
762
|
+
# The port is after the last ':'
|
763
|
+
my @listenline = split(/:/);
|
764
|
+
$port = $listenline[-1];
|
765
|
+
}
|
766
|
+
}
|
767
|
+
close(CONSOLECONF);
|
768
|
+
}
|
769
|
+
|
770
|
+
if (!$port) {
|
771
|
+
if ($force) {
|
772
|
+
debug(1, "Warning: Could not determine port number - forcing continue\n");
|
773
|
+
debug(1, "Warning: Port not removed from selinux policy correctly. Remove label manually using semanage.\n");
|
774
|
+
} else {
|
775
|
+
debug(1, "Error: Could not determine port number - aborting - use -f flag to force removal\n");
|
776
|
+
return ( [ 'error_reading_port' ] );
|
777
|
+
}
|
778
|
+
} else {
|
779
|
+
# Attempt to remove the http_port_t label from the port used by Admin Server.
|
780
|
+
my $semanage_err = `semanage port -d -t http_port_t -p tcp $port 2>&1`;
|
781
|
+
if ($? != 0) {
|
782
|
+
if ($semanage_err !~ /defined in policy, cannot be deleted/) {
|
783
|
+
debug(1, "Warning: Port $port not removed from selinux policy correctly. Error: $semanage_err\n");
|
784
|
+
if (!$force) {
|
785
|
+
return( [ 'error_removing_port_label', $port, $semanage_err ] );
|
786
|
+
}
|
787
|
+
}
|
788
|
+
}
|
789
|
+
}
|
790
|
+
|
791
|
+
# turn off the switch to allow admin server to connect to the ldap port
|
792
|
+
$? = 0; # clear error
|
793
|
+
|
794
|
+
my $cmd = "getsebool httpd_can_connect_ldap";
|
795
|
+
my $output = `$cmd 2>&1`;
|
796
|
+
chomp($output);
|
797
|
+
if ($output =~ /Error getting active value for httpd_can_connect_ldap/) {
|
798
|
+
# this version of selinux does not support the boolean value
|
799
|
+
debug(1, "This version of selinux does not support httpd_can_connect_ldap\n");
|
800
|
+
} elsif ($?) {
|
801
|
+
$setup->msg($SetupLog::WARN, 'error_running_command', $cmd, $output, $!);
|
802
|
+
} elsif ($output =~ /on$/) {
|
803
|
+
$cmd = "setsebool -P httpd_can_connect_ldap off";
|
804
|
+
$? = 0; # clear error
|
805
|
+
$output = `$cmd 2>&1`;
|
806
|
+
chomp($output);
|
807
|
+
if ($?) {
|
808
|
+
$setup->msg($SetupLog::WARN, 'error_running_command', $cmd, $output, $!);
|
809
|
+
} else {
|
810
|
+
debug(1, "$cmd was successful\n");
|
811
|
+
}
|
812
|
+
} else {
|
813
|
+
debug(1, "selinux boolean httpd_can_connect_ldap is already off - $output\n");
|
814
|
+
}
|
815
|
+
}
|
816
|
+
|
817
|
+
# remove admin server files in $rundir
|
818
|
+
my $file;
|
819
|
+
for $file (glob("$rundir/admin-serv.*")) {
|
820
|
+
unlink($file);
|
821
|
+
}
|
822
|
+
|
823
|
+
# remove admin server log dir
|
824
|
+
if ($logdir =~ /admin-serv/) { # make sure directory has admin-serv in it somewhere
|
825
|
+
if (!rmtree($logdir)) {
|
826
|
+
debug(1, "Warning: Could not remove directory $logdir: $!\n");
|
827
|
+
if (!$force) {
|
828
|
+
return ( [ 'error_removing_path', $logdir, $! ] );
|
829
|
+
}
|
830
|
+
}
|
831
|
+
}
|
832
|
+
|
833
|
+
# remove config files
|
834
|
+
my @savefiles = (@savesecfiles, @saveconffiles); # save security and conf files by default
|
835
|
+
if ($all) {
|
836
|
+
@savefiles = @saveconffiles; # $all means remove everything, except the files in rpm.
|
837
|
+
}
|
838
|
+
if (opendir(CONFDIR, $configdir)) {
|
839
|
+
while ($file = readdir(CONFDIR)) {
|
840
|
+
next if ($file eq '.' || $file eq '..');
|
841
|
+
if (-d "$configdir/$file") {
|
842
|
+
debug(1, "Skipping directory $configdir/$file - remove manually\n");
|
843
|
+
next;
|
844
|
+
}
|
845
|
+
if (grep /^$file$/, @savefiles) {
|
846
|
+
debug(1, "saving file $configdir/$file\n");
|
847
|
+
} else {
|
848
|
+
debug(1, "removing file $configdir/$file\n");
|
849
|
+
unlink("$configdir/$file");
|
850
|
+
}
|
851
|
+
}
|
852
|
+
closedir(CONFDIR);
|
853
|
+
# restore original conf files
|
854
|
+
foreach my $savefile (@saveconffiles) {
|
855
|
+
if (-f "$configdir/bakup/$savefile") {
|
856
|
+
if (system ("mv $configdir/bakup/$savefile $configdir")) {
|
857
|
+
debug(0, "Error Restoring $configdir/$savefile failed: $!");
|
858
|
+
}
|
859
|
+
}
|
860
|
+
}
|
861
|
+
# Clean up the bakup dir
|
862
|
+
system ("rm -rf $configdir/bakup");
|
863
|
+
} else {
|
864
|
+
debug(1, "Error: could not read config files in $configdir: $!");
|
865
|
+
if (!$force) {
|
866
|
+
return ( [ 'error_removing_path', $configdir, $! ] );
|
867
|
+
}
|
868
|
+
}
|
869
|
+
|
870
|
+
return;
|
871
|
+
}
|
872
|
+
|
873
|
+
sub updateSelinuxPolicy {
|
874
|
+
my $setup = shift;
|
875
|
+
my $configdir = shift;
|
876
|
+
my $securitydir = shift;
|
877
|
+
my $logdir = shift;
|
878
|
+
my $rundir = shift;
|
879
|
+
|
880
|
+
# if selinux is not available, do nothing
|
881
|
+
if (usingSELinux()) {
|
882
|
+
# run restorecon on all directories we created
|
883
|
+
system("restorecon -R $configdir $securitydir $logdir $rundir");
|
884
|
+
|
885
|
+
# Label the selected port as http_port_t.
|
886
|
+
if ($setup->{inf}->{admin}->{Port}) {
|
887
|
+
my $need_label = 1;
|
888
|
+
|
889
|
+
# check if the port is already labeled properly
|
890
|
+
my $portline = `semanage port -l | grep http_port_t | grep tcp`;
|
891
|
+
chomp($portline);
|
892
|
+
$portline =~ s/http_port_t\s+tcp\s+//g;
|
893
|
+
my @labeledports = split(/,\s+/, $portline);
|
894
|
+
foreach my $labeledport (@labeledports) {
|
895
|
+
if ($setup->{inf}->{admin}->{Port} == $labeledport) {
|
896
|
+
$need_label = 0;
|
897
|
+
last;
|
898
|
+
}
|
899
|
+
}
|
900
|
+
|
901
|
+
if ($need_label == 1) {
|
902
|
+
system("semanage port -a -t http_port_t -p tcp $setup->{inf}->{admin}->{Port}");
|
903
|
+
}
|
904
|
+
}
|
905
|
+
|
906
|
+
# turn on the switch to allow admin server to connect to the ldap port
|
907
|
+
$? = 0; # clear error
|
908
|
+
|
909
|
+
my $cmd = "getsebool httpd_can_connect_ldap";
|
910
|
+
my $output = `$cmd 2>&1`;
|
911
|
+
chomp($output);
|
912
|
+
if ($output =~ /Error getting active value for httpd_can_connect_ldap/) {
|
913
|
+
# this version of selinux does not support the boolean value
|
914
|
+
debug(1, "This version of selinux does not support httpd_can_connect_ldap\n");
|
915
|
+
} elsif ($?) {
|
916
|
+
$setup->msg($SetupLog::WARN, 'error_running_command', $cmd, $output, $!);
|
917
|
+
} elsif ($output =~ /off$/) {
|
918
|
+
$cmd = "setsebool -P httpd_can_connect_ldap on";
|
919
|
+
$? = 0; # clear error
|
920
|
+
$output = `$cmd 2>&1`;
|
921
|
+
chomp($output);
|
922
|
+
if ($?) {
|
923
|
+
$setup->msg($SetupLog::WARN, 'error_running_command', $cmd, $output, $!);
|
924
|
+
} else {
|
925
|
+
debug(1, "$cmd was successful\n");
|
926
|
+
}
|
927
|
+
} else {
|
928
|
+
debug(1, "selinux boolean httpd_can_connect_ldap is already on - $output\n");
|
929
|
+
}
|
930
|
+
}
|
931
|
+
}
|
932
|
+
|
933
|
+
sub libpath_add {
|
934
|
+
my $libpath = shift;
|
935
|
+
|
936
|
+
if ($libpath) {
|
937
|
+
if ($ENV{'LD_LIBRARY_PATH'}) {
|
938
|
+
$ENV{'LD_LIBRARY_PATH'} = "$ENV{'LD_LIBRARY_PATH'}:$libpath";
|
939
|
+
} else {
|
940
|
+
$ENV{'LD_LIBRARY_PATH'} = "$libpath";
|
941
|
+
}
|
942
|
+
}
|
943
|
+
}
|
944
|
+
|
945
|
+
1;
|
946
|
+
|
947
|
+
# emacs settings
|
948
|
+
# Local Variables:
|
949
|
+
# mode:perl
|
950
|
+
# indent-tabs-mode: nil
|
951
|
+
# tab-width: 4
|
952
|
+
# End:
|