mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-15 21:38:10 +00:00
Merge upstream/master into fix/opensuse-core-pod-man-buildrequires
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -15,7 +15,7 @@ jobs:
|
||||
- name: Install lifecycle test dependencies
|
||||
run: sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests ucf debconf-utils systemd libxml-simple-perl apache2 curl
|
||||
- name: Test Debian package lifecycle
|
||||
run: prove -v xCAT-test/native/xcatd_debian_lifecycle.t xCAT-test/native/xcatd_restart_callers.t xCAT-test/native/apache_package_lifecycle.t xCAT-test/native/package_upgrade_logging.t xCAT-test/native/profile_package_payload.t
|
||||
run: prove -v xCAT-test/native/xcatd_debian_lifecycle.t xCAT-test/native/xcatd_restart_callers.t xCAT-test/native/debian_chroot_services.t xCAT-test/native/debian_management_recovery.t xCAT-test/native/apache_package_lifecycle.t xCAT-test/native/package_upgrade_logging.t xCAT-test/native/profile_package_payload.t
|
||||
- name: Test optional statelite host keys
|
||||
if: ${{ !cancelled() }}
|
||||
run: prove -v xCAT-test/native/statelite_optional_hostkey.t
|
||||
@@ -62,6 +62,7 @@ jobs:
|
||||
xCAT-test/native/ubuntu_genimage_debootstrap_arch.t
|
||||
xCAT-test/native/ubuntu_genimage_apt_mirror.t
|
||||
xCAT-test/native/ubuntu_genimage_resolver_libs.t
|
||||
xCAT-test/native/debian_genimage_profile_assets.t
|
||||
- name: Exercise the liteimg ramdisk archive
|
||||
if: ${{ !cancelled() }}
|
||||
run: prove xCAT-test/native/liteimg_ramdisk_archive.t
|
||||
|
||||
+13
-16
@@ -697,7 +697,7 @@ sub index_repo {
|
||||
|
||||
# The stable bootstrap filename is a direct-download convenience, not a
|
||||
# second package. Keep it out of repository metadata.
|
||||
unlink $alias if -f $alias;
|
||||
unlink $alias if !$opts{source_only} && -f $alias;
|
||||
say "Creating repository $repodir";
|
||||
# Drop the top-level stray src.rpm and the mock logs (build.log/root.log/...)
|
||||
# that mock leaves in the resultdir, so the dir is directly deployable (upstream
|
||||
@@ -720,6 +720,7 @@ sub update_repo {
|
||||
|
||||
sub write_release_alias {
|
||||
my ($repodir) = @_;
|
||||
return if $opts{source_only};
|
||||
my $alias = "$repodir/xCAT-release-latest.noarch.rpm";
|
||||
|
||||
# glob() returns a wildcard-free pattern verbatim even when the file does not exist, so
|
||||
@@ -738,14 +739,12 @@ sub sign_rpms {
|
||||
sign_repo_dir("dist/$target/rpms", $opts{gpg_key_name});
|
||||
}
|
||||
|
||||
# Sign every rpm in a core repo dir -- the top-level binaries AND SRPMS/*.src.rpm --
|
||||
# then re-index (signing rewrites the rpms, invalidating checksums) and detach-sign
|
||||
# + export the key into BOTH the binary and the SRPMS repodata dirs.
|
||||
# Source-only runs sign and index only SRPMS; normal runs also update the binary repository.
|
||||
sub sign_repo_dir {
|
||||
my ($repodir, $key_name) = @_;
|
||||
|
||||
say "Signing RPMs in $repodir";
|
||||
my @bin = glob("$repodir/*.rpm");
|
||||
my @bin = $opts{source_only} ? () : glob("$repodir/*.rpm");
|
||||
if (@bin) {
|
||||
sh_or_die(qq(rpmsign --define "%_gpg_name $key_name" --addsign )
|
||||
. join(" ", map { qq("$_") } @bin),
|
||||
@@ -761,7 +760,7 @@ sub sign_repo_dir {
|
||||
# Signing can change RPM bytes without changing the size or timestamp used by the metadata cache.
|
||||
index_repo($repodir, 1);
|
||||
|
||||
for my $rd ("$repodir/repodata",
|
||||
for my $rd (($opts{source_only} ? () : ("$repodir/repodata")),
|
||||
(-d "$repodir/SRPMS/repodata" ? ("$repodir/SRPMS/repodata") : ())) {
|
||||
my $repomd = "$rd/repomd.xml";
|
||||
next unless -f $repomd;
|
||||
@@ -866,10 +865,7 @@ sub merge_core_repos {
|
||||
"Failed to rsync '$in' into '$out'\n");
|
||||
}
|
||||
|
||||
# Index, sign (when --gpg-sign), write the final repository metadata, then create the
|
||||
# xCAT-release-latest stable bootstrap alias. The alias MUST be created AFTER the final
|
||||
# metadata pass so write_release_alias can unlink it before createrepo and keep it out of
|
||||
# the repository index.
|
||||
# Create the bootstrap alias after the final index pass so it does not enter repository metadata.
|
||||
index_repo($out);
|
||||
if ($opts{gpg_sign}) {
|
||||
$ENV{GNUPGHOME} = $opts{gpg_home} if $opts{gpg_home};
|
||||
@@ -1199,11 +1195,10 @@ C<--rebuild> is skipped.
|
||||
./buildrpms.pl --target alma+epel-9-x86_64 --source-only
|
||||
|
||||
The srpms land in C<dist/E<lt>targetE<gt>/rpms/SRPMS/> and that index is regenerated.
|
||||
The binary metadata under C<dist/E<lt>targetE<gt>/rpms/> is deliberately left as the
|
||||
last binary build wrote it: re-indexing a directory with no binaries in it would
|
||||
replace working metadata with metadata for an empty repository. For the same reason
|
||||
no C<.repo> file or buildinfo is emitted, since both describe an installable binary
|
||||
repo that this mode does not produce. With C<--gpg-sign> the srpms are signed.
|
||||
Repository finalization leaves existing binary RPMs, metadata, signatures,
|
||||
public keys and the bootstrap alias unchanged. No C<.repo> file or buildinfo is
|
||||
emitted, since both describe an installable binary repo that this mode does not
|
||||
produce. With C<--gpg-sign>, the source RPMs and their repository metadata are signed.
|
||||
|
||||
Cannot be combined with C<--merge-core-repos>, which assembles already-built
|
||||
per-arch binary trees.
|
||||
@@ -1312,11 +1307,13 @@ Builds all selected package/target combinations.
|
||||
|
||||
=item 2.
|
||||
|
||||
Runs C<createrepo --update> for each selected target under C<dist/>.
|
||||
Indexes repositories for each selected target under C<dist/>. With C<--source-only>,
|
||||
only the SRPM repository is indexed.
|
||||
|
||||
=item 3.
|
||||
|
||||
If C<--gpg-sign> is set, signs RPMs and C<repomd.xml> for each target.
|
||||
With C<--source-only>, only source RPMs and their repository metadata are signed.
|
||||
|
||||
=item 4.
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@ If this does not work or the management node is not the same distro level, copy
|
||||
/opt/xcat/share/xcat/netboot/<os> to a system that is the proper architecture, and mount /install from
|
||||
the management node to that system. Then change directory to /opt/xcat/share/xcat/netboot/<os> and run ./genimage.
|
||||
|
||||
When copying Debian scripts from a source checkout, use \ **cp -RL**\ to include
|
||||
the shared profile helper. Installed packages include the helper in the Debian directory.
|
||||
|
||||
|
||||
**********
|
||||
Parameters
|
||||
|
||||
@@ -21,7 +21,8 @@ set -e
|
||||
|
||||
case "$1" in
|
||||
upgrade)
|
||||
if [ -x /opt/xcat/sbin/restartxcatd ] && [ -f "/proc/cmdline" ]; then
|
||||
if [ -x /opt/xcat/sbin/restartxcatd ] && [ -f /proc/cmdline ] &&
|
||||
[ "$(stat -c '%d:%i' /)" = "$(stat -c '%d:%i' /proc/1/root/. 2>/dev/null)" ]; then
|
||||
. /etc/profile.d/xcat.sh
|
||||
XCATROOT=/opt/xcat /opt/xcat/sbin/restartxcatd -r
|
||||
fi
|
||||
|
||||
@@ -16,6 +16,15 @@ BuildArch: noarch
|
||||
BuildRequires: perl perl-DBI perl-JSON
|
||||
# Do not need the SOAP rpm require, because rpm will generate it automatically if hpoa.pm is included
|
||||
#Requires: perl-SOAP-Lite
|
||||
# openSUSE has no perl-generators, so no perl(...) requirement is generated here and nothing
|
||||
# installs the modules this code loads. xcatd stays inactive without them: xCAT::Table dies
|
||||
# loading JSON. EL and openEuler generate these automatically and need no list.
|
||||
%if 0%{?suse_version}
|
||||
Requires: perl(Expect)
|
||||
Requires: perl(HTML::Form)
|
||||
Requires: perl(JSON)
|
||||
Requires: perl(SNMP)
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%description
|
||||
|
||||
@@ -6,6 +6,7 @@ use warnings;
|
||||
use Exporter qw(import);
|
||||
|
||||
use xCAT::Utils;
|
||||
use xCAT::Table;
|
||||
|
||||
our @EXPORT_OK = qw(find_genesis_boot_files);
|
||||
|
||||
@@ -42,4 +43,41 @@ sub volatile_addkcmdline {
|
||||
return $cmdhashref->{volatile} // '';
|
||||
}
|
||||
|
||||
sub expand_node_template {
|
||||
my ($node, $text, $on_error) = @_;
|
||||
return $text unless defined($text);
|
||||
|
||||
# Each initial token contributes to its pass's shared replacement budget.
|
||||
my $replacements_per_token = 16;
|
||||
my $remaining = $replacements_per_token * (() = $text =~ /#NODEATTRIB:[^:#]+:[^:#]+#/g);
|
||||
while ($text =~ /#NODEATTRIB:([^:#]+):([^:#]+)#/) {
|
||||
unless ($remaining--) {
|
||||
$on_error->("Node template expansion exceeded its replacement limit at #NODEATTRIB:$1:$2#");
|
||||
return;
|
||||
}
|
||||
my $table = xCAT::Table->new($1);
|
||||
my $entry = $table->getNodeAttribs($node, [$2]);
|
||||
my $value = $entry->{$2} // '';
|
||||
$text =~ s/#NODEATTRIB:([^:#]+):([^:#]+)#/$value/;
|
||||
}
|
||||
$remaining = $replacements_per_token * (() = $text =~ /#TABLE:[^:#]+:[^:#]+:[^:#]+#/g);
|
||||
while ($text =~ /#TABLE:([^:#]+):([^:#]+):([^:#]+)#/) {
|
||||
unless ($remaining--) {
|
||||
$on_error->("Node template expansion exceeded its replacement limit at #TABLE:$1:$2:$3#");
|
||||
return;
|
||||
}
|
||||
my ($table_name, $key, $column) = ($1, $2, $3);
|
||||
if ($key =~ /THISNODE/ or $key =~ /\$NODE/) {
|
||||
my $table = xCAT::Table->new($table_name);
|
||||
my $entry = $table->getNodeAttribs($node, [$column]);
|
||||
my $value = $entry->{$column} // '';
|
||||
$text =~ s/#TABLE:([^:#]+):([^:#]+):([^:#]+)#/$value/;
|
||||
} else {
|
||||
$on_error->("Table key of $key not yet supported by boottarget mini-template");
|
||||
return;
|
||||
}
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -120,4 +120,98 @@ sub update_discovery_data {
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 client_certificate_name
|
||||
|
||||
Descriptions: The name xcatd may record as the verified client certificate of a request.
|
||||
becomeuser and tokens replace the authenticated name with an account name.
|
||||
A name that differs from the certificate CN is therefore not a certificate name.
|
||||
|
||||
Arguments : $cert_cn - the CN of the client certificate, undef when there is none
|
||||
$authname - the authenticated name xcatd uses for the request
|
||||
Returns : $cert_cn when the request is still authenticated by that certificate, else undef
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
sub client_certificate_name {
|
||||
my ($cert_cn, $authname) = @_;
|
||||
return undef unless defined $cert_cn && $cert_cn ne '';
|
||||
return undef unless defined $authname && $authname eq $cert_cn;
|
||||
return $cert_cn;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 request_client_names
|
||||
|
||||
Descriptions: The names a node-initiated request offers for correlating it to a node, most
|
||||
trustworthy first.
|
||||
|
||||
xcatd fills _xcat_clienthost and _xcat_clientfqdn from a reverse lookup of the
|
||||
peer socket, so both are empty when that lookup fails.
|
||||
_xcat_certname is the CN of the validated client certificate.
|
||||
_xcat_authname is not a candidate: a password or a token can set it.
|
||||
The request's own node attribute is not a candidate: the client sends it.
|
||||
|
||||
Arguments : $request - the request hash xcatd built
|
||||
Returns : the candidate names, without duplicates; an empty list when there are none
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
sub request_client_names {
|
||||
my ($request) = @_;
|
||||
return () unless ref($request) eq 'HASH';
|
||||
my @names;
|
||||
foreach my $key (qw(_xcat_clienthost _xcat_clientfqdn _xcat_certname)) {
|
||||
my $name = _first_value($request, $key);
|
||||
next unless defined $name;
|
||||
push @names, $name unless grep { $_ eq $name } @names;
|
||||
}
|
||||
return @names;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 request_client_node
|
||||
|
||||
Descriptions: The node a node-initiated request comes from.
|
||||
A peer name is expanded as before, and the first node it gives is used.
|
||||
The certificate name must name exactly one node, with no group or range
|
||||
expansion, because xCAT signs user and node certificates with one CA.
|
||||
|
||||
Arguments : $request - the request hash xcatd built
|
||||
$expand - code ref that expands a noderange to a node list (noderange)
|
||||
Returns : the node name, or undef when no candidate names a node
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
sub request_client_node {
|
||||
my ($request, $expand) = @_;
|
||||
return undef unless ref($request) eq 'HASH' && ref($expand) eq 'CODE';
|
||||
foreach my $key (qw(_xcat_clienthost _xcat_clientfqdn)) {
|
||||
my $name = _first_value($request, $key);
|
||||
next unless defined $name;
|
||||
my ($node) = $expand->($name);
|
||||
return $node if $node;
|
||||
}
|
||||
my $cert = _first_value($request, '_xcat_certname');
|
||||
return undef unless defined $cert;
|
||||
my @nodes = $expand->($cert);
|
||||
return $cert if @nodes == 1 && defined $nodes[0] && $nodes[0] eq $cert;
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub _first_value {
|
||||
my ($request, $key) = @_;
|
||||
my $value = $request->{$key};
|
||||
return undef unless ref($value) eq 'ARRAY';
|
||||
my $name = $value->[0];
|
||||
return undef unless defined $name && $name ne '';
|
||||
return $name;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -38,6 +38,9 @@ If this does not work or the management node is not the same distro level, copy
|
||||
/opt/xcat/share/xcat/netboot/<os> to a system that is the proper architecture, and mount /install from
|
||||
the management node to that system. Then change directory to /opt/xcat/share/xcat/netboot/<os> and run ./genimage.
|
||||
|
||||
When copying Debian scripts from a source checkout, use B<cp -RL> to include
|
||||
the shared profile helper. Installed packages include the helper in the Debian directory.
|
||||
|
||||
|
||||
=head1 Parameters
|
||||
|
||||
|
||||
@@ -35,6 +35,12 @@ BuildArch: noarch
|
||||
|
||||
Requires: perl-xCAT = 4:%{version}-%{release}
|
||||
Requires: cpio
|
||||
# openSUSE has no perl-generators, so no perl(...) requirement is generated here and nothing
|
||||
# installs the modules this code loads. xcatd stays inactive without them: xCAT::Table dies
|
||||
# loading JSON. EL and openEuler generate these automatically and need no list.
|
||||
%if 0%{?suse_version}
|
||||
Requires: perl(Expect)
|
||||
%endif
|
||||
|
||||
# fping or nmap is needed by pping (in case xCAT-client is installed by itself on a remote client)
|
||||
%ifos linux
|
||||
|
||||
@@ -40,10 +40,25 @@ _dracut_install_opt() {
|
||||
fi
|
||||
}
|
||||
|
||||
# openssl req reads the config file at OPENSSLDIR/openssl.cnf and exits 1 without it, so the
|
||||
# node makes no certificate request. dracut_install copies the program and its libraries only.
|
||||
# OPENSSLDIR is /usr/lib/ssl on Ubuntu and /etc/pki/tls on EL, so ask openssl where it looks.
|
||||
_dracut_install_openssl_config() {
|
||||
local dir cnf
|
||||
dir=$(openssl version -d 2>/dev/null | sed -e 's/^OPENSSLDIR: *"*//' -e 's/"*$//')
|
||||
cnf="${dir:-/etc/ssl}/openssl.cnf"
|
||||
if [ ! -e "$cnf" ]; then
|
||||
dfatal "xcat: no openssl config at $cnf; Genesis cannot request a certificate"
|
||||
exit 1
|
||||
fi
|
||||
dracut_install "$cnf"
|
||||
}
|
||||
|
||||
install() {
|
||||
local genesis_openeuler=0 timezone timezone_files locale_file locale_files
|
||||
[[ -f /etc/openEuler-release ]] && genesis_openeuler=1
|
||||
dracut_install wget openssl tar mstflint ipmitool cpio gzip lsmod ethtool modprobe touch echo cut wc bash
|
||||
_dracut_install_openssl_config
|
||||
dracut_install netstat # broadcom update requires
|
||||
dracut_install uniq # mellanox update requires
|
||||
dracut_install grep ip hostname /usr/bin/awk egrep grep dirname expr
|
||||
|
||||
@@ -40,16 +40,37 @@ _dracut_install_opt() {
|
||||
fi
|
||||
}
|
||||
|
||||
# openssl req reads the config file at OPENSSLDIR/openssl.cnf and exits 1 without it, so the
|
||||
# node makes no certificate request. dracut_install copies the program and its libraries only.
|
||||
# OPENSSLDIR is /usr/lib/ssl on Ubuntu and /etc/pki/tls on EL, so ask openssl where it looks.
|
||||
_dracut_install_openssl_config() {
|
||||
local dir cnf
|
||||
dir=$(openssl version -d 2>/dev/null | sed -e 's/^OPENSSLDIR: *"*//' -e 's/"*$//')
|
||||
cnf="${dir:-/etc/ssl}/openssl.cnf"
|
||||
if [ ! -e "$cnf" ]; then
|
||||
dfatal "xcat: no openssl config at $cnf; Genesis cannot request a certificate"
|
||||
exit 1
|
||||
fi
|
||||
dracut_install "$cnf"
|
||||
}
|
||||
|
||||
install() {
|
||||
# Ubuntu multiarch triplet for architecture-specific library paths
|
||||
local TRIPLET
|
||||
TRIPLET=$(dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null || echo x86_64-linux-gnu)
|
||||
|
||||
dracut_install wget openssl tar ipmitool cpio gzip lsmod ethtool modprobe touch echo cut wc bash
|
||||
_dracut_install_openssl_config
|
||||
_dracut_install_opt mstflint
|
||||
dracut_install netstat # broadcom update requires
|
||||
dracut_install uniq # mellanox update requires
|
||||
dracut_install grep ip hostname /usr/bin/awk egrep grep dirname expr
|
||||
dracut_install grep ip hostname egrep grep dirname expr
|
||||
|
||||
# allowcred.awk, minixcatd.awk and udpcat.awk open a TCP stream with the gawk |&
|
||||
# coprocess and the /inet/ special file. mawk rejects both at parse time, and mawk is
|
||||
# the awk alternative on this build root, so name gawk and point awk at it.
|
||||
dracut_install gawk
|
||||
ln -sf gawk "$initdir/usr/bin/awk"
|
||||
dracut_install mount.nfs sshd vi reboot lspci parted screen mkfs mkfs.ext4 mkfs.btrfs
|
||||
#dracut_install libvirtd /usr/share/libvirt/cpu_map.xml /usr/bin/qemu-img /usr/libexec/qemu-kvm
|
||||
dracut_install mkswap df ifenslave ssh-keygen scp clear
|
||||
|
||||
@@ -14,7 +14,7 @@ my @BASE_PACKAGES = qw(
|
||||
openssh-server openssh-client rsyslog chrony
|
||||
nfs-common rpcbind pciutils usbutils parted
|
||||
dosfstools e2fsprogs lvm2 mdadm net-tools
|
||||
bc psmisc rsync wget cpio
|
||||
bc psmisc rsync wget cpio gawk
|
||||
isc-dhcp-client ifenslave
|
||||
systemd-sysv hwdata btrfs-progs netcat-openbsd iputils-ping fdisk ncurses-term
|
||||
dpkg-dev debhelper fakeroot devscripts vim-tiny
|
||||
|
||||
@@ -67,6 +67,7 @@ sub module_commands {
|
||||
path is looked for under the payload root.
|
||||
source: the module the commands came from, for the message
|
||||
sshd: the content of usr/sbin/sshd, or undef without one
|
||||
awk: the content of usr/bin/awk, or undef without one
|
||||
Returns:
|
||||
one "<path> (<reason>)" string per missing item, in the order checked.
|
||||
An empty list means the payload is complete.
|
||||
@@ -106,6 +107,15 @@ sub missing_paths {
|
||||
"usr/libexec/openssh/sshd-session (this sshd execs it for every connection)";
|
||||
}
|
||||
|
||||
# allowcred.awk, minixcatd.awk and udpcat.awk open a TCP stream with the gawk |&
|
||||
# coprocess and the /inet/ special file. mawk rejects both at parse time and the node
|
||||
# then asks for no credential, so read the binary back. gawk carries its own name. An
|
||||
# empty file carries no name and is not a program, so there is nothing to read.
|
||||
if (length($opt{awk} // '') && index($opt{awk}, 'GNU Awk') < 0) {
|
||||
push @missing,
|
||||
'usr/bin/awk is not gawk (allowcred.awk opens its TCP stream with the gawk /inet/ coprocess)';
|
||||
}
|
||||
|
||||
# tmux exits under the C locale. The hook then runs doxcat directly, but a Genesis
|
||||
# shell without tmux loses the console attach.
|
||||
if ($have->('usr/bin/tmux') && !$have->('usr/lib/locale/C.utf8/LC_CTYPE')) {
|
||||
@@ -157,17 +167,13 @@ sub check_payload {
|
||||
return (2, $@) if $@;
|
||||
}
|
||||
|
||||
my $sshd;
|
||||
if (open(my $fh, '<:raw', "$payload/usr/sbin/sshd")) {
|
||||
local $/;
|
||||
$sshd = <$fh> // '';
|
||||
close($fh);
|
||||
}
|
||||
my ($sshd, $awk) = (slurp("$payload/usr/sbin/sshd"), slurp("$payload/usr/bin/awk"));
|
||||
my @missing = missing_paths(sub { -e "$payload/$_[0]" },
|
||||
required => \@args,
|
||||
commands => \@commands,
|
||||
source => $commands_from,
|
||||
sshd => $sshd);
|
||||
sshd => $sshd,
|
||||
awk => $awk);
|
||||
return (1, "$ME: $payload is incomplete:" . join('', map { "\n $_" } @missing) . "\n")
|
||||
if @missing;
|
||||
return (0, "$ME: $payload is complete\n");
|
||||
@@ -175,6 +181,29 @@ sub check_payload {
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 slurp
|
||||
|
||||
Descriptions: read a file whole, in raw mode. usr/bin/awk and usr/sbin/sshd are
|
||||
binaries, and both are read to tell one program from another.
|
||||
Arguments:
|
||||
$path: the path to read
|
||||
Returns:
|
||||
the content, or undef when the file cannot be read
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
sub slurp {
|
||||
my ($path) = @_;
|
||||
open(my $fh, '<:raw', $path) or return undef;
|
||||
local $/;
|
||||
my $content = <$fh> // '';
|
||||
close($fh);
|
||||
return $content;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 main
|
||||
|
||||
Descriptions: run check_payload and print its message: on STDOUT when the
|
||||
|
||||
@@ -100,6 +100,18 @@ fi
|
||||
if [ ! -e /usr/share/empty.sshd ]; then
|
||||
mkdir -p /usr/share/empty.sshd
|
||||
fi
|
||||
# Debian and Ubuntu build sshd with --with-privsep-path=/run/sshd, and sshd exits with
|
||||
# "Missing privilege separation directory" when it is absent. The image carries /run and not
|
||||
# /run/sshd, so Genesis on Ubuntu answered no ssh and every case that reaches a booted node
|
||||
# over xdsh failed. Created here rather than baked into the image: /run is a tmpfs on a
|
||||
# running system, and a directory under it does not survive the mount.
|
||||
# The mode is set whether or not the directory had to be created: sshd refuses a privsep
|
||||
# directory that is group or world writable, with the same message, so a wrong mode looks
|
||||
# exactly like an absent one.
|
||||
for sshd_privsep in /run/sshd /var/run/sshd; do
|
||||
mkdir -p "$sshd_privsep"
|
||||
chmod 0755 "$sshd_privsep"
|
||||
done
|
||||
echo 'Protocol 2' >> /etc/ssh/sshd_config
|
||||
/usr/sbin/sshd
|
||||
mkdir -p /etc/xcat
|
||||
|
||||
@@ -21,9 +21,15 @@ fi
|
||||
# requests fail. An emulated node needs minutes for that key.
|
||||
CSR_TIMEOUT=${GETCERT_CSR_TIMEOUT:-600}
|
||||
CSR_DEADLINE=$((SECONDS + CSR_TIMEOUT))
|
||||
while ! openssl req -new -key /etc/xcat/certkey.pem -out /tmp/tls.csr -subj "/CN=$(hostname)" >& /dev/null; do
|
||||
CSR_ERROR=/tmp/getcert.csr.err
|
||||
while ! openssl req -new -key /etc/xcat/certkey.pem -out /tmp/tls.csr -subj "/CN=$(hostname)" > /dev/null 2> $CSR_ERROR; do
|
||||
if [ "$SECONDS" -ge "$CSR_DEADLINE" ]; then
|
||||
give_up "no certificate request after ${CSR_TIMEOUT}s; /etc/xcat/certkey.pem is not usable"
|
||||
# Name the key that was used AND what openssl printed: the key is usually intact and
|
||||
# the absent file is OPENSSLDIR/openssl.cnf.
|
||||
# Read and flatten with bash builtins. The Genesis payload is a minimal initramfs
|
||||
# and need not carry tr or cat.
|
||||
csr_error=$(< $CSR_ERROR)
|
||||
give_up "no certificate request after ${CSR_TIMEOUT}s using /etc/xcat/certkey.pem: ${csr_error//$'\n'/ }"
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
@@ -21,7 +21,8 @@ xcatd_init_compat=/opt/xcat/share/xcat/scripts/xcatd-init-compat
|
||||
|
||||
case "$1" in
|
||||
remove)
|
||||
if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image
|
||||
if [ -f /proc/cmdline ] &&
|
||||
[ "$(stat -c '%d:%i' /)" = "$(stat -c '%d:%i' /proc/1/root/. 2>/dev/null)" ]; then
|
||||
if "$xcatd_init_compat" can-use-systemctl; then
|
||||
systemctl stop xcatd.service
|
||||
systemctl disable --now xcat-uftp-listener.service >/dev/null 2>&1 || true
|
||||
@@ -32,6 +33,7 @@ case "$1" in
|
||||
if "$xcatd_init_compat" uses-systemd --explicit-target; then
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
systemctl disable xcatd.service
|
||||
systemctl disable xcat-uftp-listener.service >/dev/null 2>&1 || true
|
||||
fi
|
||||
else
|
||||
if command -v update-rc.d >/dev/null 2>&1; then
|
||||
|
||||
@@ -44,6 +44,9 @@ binary-arch:
|
||||
dh_installdocs
|
||||
# dh_installexamples
|
||||
dh_install -X".svn"
|
||||
# Debian scripts must remain self-contained when copied from an installed package.
|
||||
rm -f $(rootdir)/share/xcat/netboot/debian/xCAT/ProfileUtils.pm
|
||||
install -m 0644 share/xcat/netboot/imgutils/xCAT/ProfileUtils.pm $(rootdir)/share/xcat/netboot/debian/xCAT/ProfileUtils.pm
|
||||
chmod 755 $(rootdir)/bin/*
|
||||
chmod 755 $(rootdir)/sbin/*
|
||||
chmod 644 $(rootdir)/share/xcat/ca/*
|
||||
|
||||
@@ -12,6 +12,7 @@ use Thread qw(yield);
|
||||
use POSIX qw(WNOHANG nice);
|
||||
use xCAT::Table;
|
||||
use xCAT::Utils;
|
||||
use xCAT::BootUtils;
|
||||
use xCAT::TableUtils;
|
||||
use xCAT::MsgUtils;
|
||||
use xCAT::Template;
|
||||
@@ -158,29 +159,14 @@ sub mknetboot
|
||||
$kcmdline = $tent->{kcmdline};
|
||||
|
||||
#TODO: big todo, cheap and rapid, but should be more like esx.pm implementation, i.e. more scalable
|
||||
while ($kcmdline =~ /#NODEATTRIB:([^:#]+):([^:#]+)#/) {
|
||||
my $natab = xCAT::Table->new($1);
|
||||
my $naent = $natab->getNodeAttribs($node, [$2]);
|
||||
my $naval = $naent->{$2};
|
||||
$kcmdline =~ s/#NODEATTRIB:([^:#]+):([^:#]+)#/$naval/;
|
||||
}
|
||||
while ($kcmdline =~ /#TABLE:([^:#]+):([^:#]+):([^:#]+)#/) {
|
||||
my $tabname = $1;
|
||||
my $keyname = $2;
|
||||
my $colname = $3;
|
||||
if ($2 =~ /THISNODE/ or $2 =~ /\$NODE/) {
|
||||
my $natab = xCAT::Table->new($tabname);
|
||||
my $naent = $natab->getNodeAttribs($node, [$colname]);
|
||||
my $naval = $naent->{$colname};
|
||||
$kcmdline =~ s/#TABLE:([^:#]+):([^:#]+):([^:#]+)#/$naval/;
|
||||
} else {
|
||||
my $msg = "Table key of $2 not yet supported by boottarget mini-template";
|
||||
$callback->({
|
||||
error => ["$msg"],
|
||||
errorcode => [1]
|
||||
});
|
||||
|
||||
}
|
||||
my $template_error;
|
||||
$kcmdline = xCAT::BootUtils::expand_node_template(
|
||||
$node, $kcmdline,
|
||||
sub { $template_error = shift; }
|
||||
);
|
||||
if (defined($template_error)) {
|
||||
xCAT::MsgUtils->report_node_error($callback, $node, $template_error);
|
||||
next;
|
||||
}
|
||||
|
||||
if ($initrd eq '') {
|
||||
|
||||
@@ -11,6 +11,7 @@ package xCAT_plugin::getpostscript;
|
||||
use xCAT::Utils;
|
||||
use xCAT::MsgUtils;
|
||||
use xCAT::NodeRange;
|
||||
use xCAT::DiscoveryUtils;
|
||||
1;
|
||||
|
||||
#-------------------------------------------------------
|
||||
@@ -59,22 +60,22 @@ sub process_request
|
||||
my $client;
|
||||
if ($::XCATSITEVALS{nodeauthentication}) { #if requiring node authentication, this request will have a certificate associated with it, use it instead of name resolution
|
||||
unless (ref $request->{username}) { return; } #TODO: log an attempt without credentials?
|
||||
$client = $request->{username}->[0];
|
||||
} else {
|
||||
unless ($request->{'_xcat_clienthost'}->[0]) {
|
||||
|
||||
#ERROR? malformed request
|
||||
xCAT::MsgUtils->trace(0, 'E', "Received malformed getpostscript requesting, ignore it.");
|
||||
($client) = noderange($request->{username}->[0]);
|
||||
unless ($client) {
|
||||
xCAT::MsgUtils->trace(0, "E", "Received getpostscript from $request->{username}->[0], which couldn't be correlated to a node (domain mismatch?)");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
my @candidates = xCAT::DiscoveryUtils::request_client_names($request);
|
||||
unless (@candidates) {
|
||||
xCAT::MsgUtils->trace(0, 'E', "Received getpostscript from a client this request does not identify: it carries no peer name and no client certificate name. Ignoring it.");
|
||||
return;
|
||||
}
|
||||
$client = xCAT::DiscoveryUtils::request_client_node($request, \&noderange);
|
||||
unless ($client) { #Not able to do identify the host in question
|
||||
xCAT::MsgUtils->trace(0, "E", "Received getpostscript from " . join(', ', @candidates) . ", none of which could be correlated to a node (domain mismatch?)");
|
||||
return;
|
||||
}
|
||||
$client = $request->{'_xcat_clienthost'}->[0];
|
||||
}
|
||||
|
||||
my $origclient = $client;
|
||||
if ($client) { ($client) = noderange($client) }
|
||||
unless ($client) { #Not able to do identify the host in question
|
||||
xCAT::MsgUtils->trace(0, "E", "Received getpostscript from $origclient, which couldn't be correlated to a node (domain mismatch?)");
|
||||
return;
|
||||
}
|
||||
my $state;
|
||||
if ($request->{scripttype}) { $state = $request->{scripttype}->[0]; }
|
||||
|
||||
@@ -118,29 +118,12 @@ sub setstate {
|
||||
$kcmdlinehack = xCAT::BootUtils::volatile_addkcmdline($kcmdlinehack);
|
||||
|
||||
|
||||
while ($kcmdlinehack =~ /#NODEATTRIB:([^:#]+):([^:#]+)#/) {
|
||||
my $natab = xCAT::Table->new($1);
|
||||
my $naent = $natab->getNodeAttribs($node, [$2]);
|
||||
my $naval = $naent->{$2};
|
||||
$kcmdlinehack =~ s/#NODEATTRIB:([^:#]+):([^:#]+)#/$naval/;
|
||||
}
|
||||
while ($kcmdlinehack =~ /#TABLE:([^:#]+):([^:#]+):([^:#]+)#/) {
|
||||
my $tabname = $1;
|
||||
my $keyname = $2;
|
||||
my $colname = $3;
|
||||
if ($2 =~ /THISNODE/ or $2 =~ /\$NODE/) {
|
||||
my $natab = xCAT::Table->new($tabname);
|
||||
my $naent = $natab->getNodeAttribs($node, [$colname]);
|
||||
my $naval = $naent->{$colname};
|
||||
$kcmdlinehack =~ s/#TABLE:([^:#]+):([^:#]+):([^:#]+)#/$naval/;
|
||||
} else {
|
||||
my $msg = "Table key of $2 not yet supported by boottarget mini-template";
|
||||
$::PXE_callback->({
|
||||
error => ["$msg"],
|
||||
errorcode => [1]
|
||||
});
|
||||
}
|
||||
}
|
||||
my $template_error;
|
||||
$kcmdlinehack = xCAT::BootUtils::expand_node_template(
|
||||
$node, $kcmdlinehack,
|
||||
sub { $template_error = shift; }
|
||||
);
|
||||
return (1, $template_error) if defined($template_error);
|
||||
|
||||
#$kern->{kcmdline} .= " ".$kern->{addkcmdline};
|
||||
|
||||
@@ -533,7 +516,7 @@ sub process_request {
|
||||
($rc, $errstr) = setstate($_, \%bphash, \%chainhash, \%machash, \%nthash, $tftpdir, $linuximghash);
|
||||
if ($rc) {
|
||||
$response{node}->[0]->{errorcode}->[0] = $rc;
|
||||
$response{node}->[0]->{errorc}->[0] = $errstr;
|
||||
$response{node}->[0]->{error}->[0] = $errstr;
|
||||
$::PXE_callback->(\%response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,29 +203,12 @@ sub setstate {
|
||||
$kcmdlinehack = xCAT::BootUtils::volatile_addkcmdline($kcmdlinehack);
|
||||
|
||||
|
||||
while ($kcmdlinehack =~ /#NODEATTRIB:([^:#]+):([^:#]+)#/) {
|
||||
my $natab = xCAT::Table->new($1);
|
||||
my $naent = $natab->getNodeAttribs($node, [$2]);
|
||||
my $naval = $naent->{$2};
|
||||
$kcmdlinehack =~ s/#NODEATTRIB:([^:#]+):([^:#]+)#/$naval/;
|
||||
}
|
||||
while ($kcmdlinehack =~ /#TABLE:([^:#]+):([^:#]+):([^:#]+)#/) {
|
||||
my $tabname = $1;
|
||||
my $keyname = $2;
|
||||
my $colname = $3;
|
||||
if ($2 =~ /THISNODE/ or $2 =~ /\$NODE/) {
|
||||
my $natab = xCAT::Table->new($tabname);
|
||||
my $naent = $natab->getNodeAttribs($node, [$colname]);
|
||||
my $naval = $naent->{$colname};
|
||||
$kcmdlinehack =~ s/#TABLE:([^:#]+):([^:#]+):([^:#]+)#/$naval/;
|
||||
} else {
|
||||
my $msg = "Table key of $2 not yet supported by boottarget mini-template";
|
||||
$::XNBA_callback->({
|
||||
error => ["$msg"],
|
||||
errorcode => [1]
|
||||
});
|
||||
}
|
||||
}
|
||||
my $template_error;
|
||||
$kcmdlinehack = xCAT::BootUtils::expand_node_template(
|
||||
$node, $kcmdlinehack,
|
||||
sub { $template_error = shift; }
|
||||
);
|
||||
return (1, $template_error) if defined($template_error);
|
||||
|
||||
#$kern->{kcmdline} .= " ".$kern->{addkcmdline};
|
||||
$kern->{kcmdline} .= " " . $kcmdlinehack;
|
||||
|
||||
@@ -50,6 +50,7 @@ use xCAT::TLSPolicy qw(resolve_xcatd_tls_settings);
|
||||
use xCAT::TableUtils;
|
||||
use xCAT::NetworkUtils;
|
||||
use xCAT::MsgUtils;
|
||||
use xCAT::DiscoveryUtils;
|
||||
use xCAT::RespawnUtils;
|
||||
use xCAT::xcatd;
|
||||
use xCAT::CmdLog;
|
||||
@@ -3027,6 +3028,8 @@ sub service_connection {
|
||||
my $peerhostorg = shift;
|
||||
my $peerip = shift;
|
||||
my $peerport = $sock->peerport;
|
||||
# becomeuser and tokens replace $peername. Keep the certificate CN to tell the two apart.
|
||||
my $cert_cn = $peername;
|
||||
|
||||
# some paranoid measures could reduce a third party abusing stage3 image to attempting to get USER/PASS for BMCs:
|
||||
# -Well, minimally, ignore requests if requesting node is not in spconfig mode (stage3)
|
||||
@@ -3189,6 +3192,9 @@ sub service_connection {
|
||||
$request = "";
|
||||
if (xCAT::xcatd->validate($peername, $peerhost, $req, $peerhostorg, \@deferredmsgargs)) {
|
||||
$req->{'_xcat_authname'} = [$peername];
|
||||
delete $req->{'_xcat_certname'};
|
||||
my $certname = xCAT::DiscoveryUtils::client_certificate_name($cert_cn, $peername);
|
||||
$req->{'_xcat_certname'} = [$certname] if defined $certname;
|
||||
$req->{'_xcat_clienthost'} = [$peerhost];
|
||||
$req->{'_xcat_clientfqdn'} = [$peerfqdn];
|
||||
if ($req->{command}->[0] eq 'signx509cert') {
|
||||
|
||||
@@ -11,6 +11,9 @@ use File::Copy;
|
||||
use File::Find;
|
||||
use Getopt::Long;
|
||||
use Cwd qw(realpath);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use xCAT::ProfileUtils;
|
||||
|
||||
#use strict;
|
||||
Getopt::Long::Configure("bundling");
|
||||
@@ -1302,21 +1305,8 @@ sub get_profile_def_filename {
|
||||
my $ext = shift;
|
||||
my $dotpos = rindex($osver, ".");
|
||||
my $osbase = substr($osver, 0, $dotpos);
|
||||
if (-r "$base/$profile.$osver.$arch.$ext") {
|
||||
return "$base/$profile.$osver.$arch.$ext";
|
||||
} elsif (-r "$base/$profile.$osbase.$arch.$ext") {
|
||||
return "$base/$profile.$osbase.$arch.$ext";
|
||||
} elsif (-r "$base/$profile.$arch.$ext") {
|
||||
return "$base/$profile.$arch.$ext";
|
||||
} elsif (-r "$base/$profile.$osver.$ext") {
|
||||
return "$base/$profile.$osver.$ext";
|
||||
} elsif (-r "$base/$profile.$osbase.$ext") {
|
||||
return "$base/$profile.$osbase.$ext";
|
||||
} elsif (-r "$base/$profile.$ext") {
|
||||
return "$base/$profile.$ext";
|
||||
}
|
||||
|
||||
return "";
|
||||
return xCAT::ProfileUtils::find_profile_asset(
|
||||
$base, $profile, $arch, $ext, $osver, $osbase);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../imgutils/xCAT/ProfileUtils.pm
|
||||
@@ -11,6 +11,8 @@ use File::Copy qw(move);
|
||||
use File::Find;
|
||||
use File::Path;
|
||||
use Cwd qw(realpath);
|
||||
use lib dirname(__FILE__);
|
||||
use xCAT::ProfileUtils;
|
||||
use xCAT::SvrUtils;
|
||||
|
||||
sub el_major_version {
|
||||
@@ -241,33 +243,9 @@ sub get_profile_def_filename {
|
||||
if ($osver =~ /^leap15/) {
|
||||
$fallbackos = "sle15";
|
||||
}
|
||||
if (-r "$base/$profile.$osver.$arch.$ext") {
|
||||
return "$base/$profile.$osver.$arch.$ext";
|
||||
}
|
||||
foreach my $osbase (@osbase) {
|
||||
if (-r "$base/$profile.$osbase.$arch.$ext") {
|
||||
return "$base/$profile.$osbase.$arch.$ext";
|
||||
}
|
||||
}
|
||||
if ($fallbackos && -r "$base/$profile.$fallbackos.$arch.$ext") {
|
||||
return "$base/$profile.$fallbackos.$arch.$ext";
|
||||
} elsif (-r "$base/$profile.$arch.$ext") {
|
||||
return "$base/$profile.$arch.$ext";
|
||||
} elsif (-r "$base/$profile.$osver.$ext") {
|
||||
return "$base/$profile.$osver.$ext";
|
||||
}
|
||||
foreach my $osbase (@osbase) {
|
||||
if (-r "$base/$profile.$osbase.$ext") {
|
||||
return "$base/$profile.$osbase.$ext";
|
||||
}
|
||||
}
|
||||
if ($fallbackos && -r "$base/$profile.$fallbackos.$ext") {
|
||||
return "$base/$profile.$fallbackos.$ext";
|
||||
} elsif (-r "$base/$profile.$ext") {
|
||||
return "$base/$profile.$ext";
|
||||
}
|
||||
|
||||
return "";
|
||||
return xCAT::ProfileUtils::find_profile_asset(
|
||||
$base, $profile, $arch, $ext, $osver, @osbase,
|
||||
($fallbackos ? ($fallbackos) : ()));
|
||||
}
|
||||
|
||||
sub include_file
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package xCAT::ProfileUtils;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub find_profile_asset {
|
||||
my ($base, $profile, $arch, $ext, @versions) = @_;
|
||||
|
||||
my @suffixes = ((map { "$_.$arch" } @versions), $arch, @versions, '');
|
||||
foreach my $suffix (@suffixes) {
|
||||
my $file = "$base/$profile" . (length($suffix) ? ".$suffix" : '') . ".$ext";
|
||||
return $file if -r $file;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -52,19 +52,34 @@ Requires: perl-IO-Socket-SSL perl-XML-Simple perl-XML-Parser perl-Digest-SHA1 pe
|
||||
# Time::HiRes and Text::Balanced) are not pulled in transitively by perl-xCAT
|
||||
# either. List them here or the affected subcommands die at load time.
|
||||
Requires: perl-Net-Telnet perl-Net-DNS perl-Crypt-CBC perl-Crypt-Rijndael
|
||||
# openSUSE has no perl-generators, so no perl(...) requirement is generated here and nothing
|
||||
# installs the modules this code loads. xcatd stays inactive without them: xCAT::Table dies
|
||||
# loading JSON. EL and openEuler generate these automatically and need no list.
|
||||
%if 0%{?suse_version}
|
||||
Requires: perl(Date::Parse)
|
||||
Requires: perl(Expect)
|
||||
Requires: perl(JSON)
|
||||
Requires: perl(SNMP)
|
||||
%endif
|
||||
# DB_File is only used by the Confluent client (lib/xcat/Confluent/Client.pm). EL10
|
||||
# dropped libdb: EPEL still carries perl-DB_File for x86_64 and ppc64le, but riscv64 has
|
||||
# no EPEL at all, so on EL10 ask for the module weakly -- it is installed where it exists
|
||||
# and skipped where it cannot. The dependency generator still turns that "use DB_File"
|
||||
# into a hard perl(DB_File) requirement; drop it there too, appending to any filter the
|
||||
# build root already set. Every other platform keeps the hard requirement it has today.
|
||||
# openSUSE has no package of that name: Leap 15.6 calls it perl-core-DB_File and 42.3 has
|
||||
# neither, but both provide the capability, so ask for the capability there.
|
||||
%if 0%{?rhel} >= 10
|
||||
Recommends: perl-DB_File
|
||||
%global __requires_exclude %{?__requires_exclude:%{__requires_exclude}|}^perl\\(DB_File\\)$
|
||||
%else
|
||||
%if 0%{?suse_version}
|
||||
Requires: perl(DB_File)
|
||||
%else
|
||||
Requires: perl-DB_File
|
||||
%endif
|
||||
%endif
|
||||
%endif
|
||||
Obsoletes: atftp-xcat
|
||||
%endif
|
||||
|
||||
@@ -183,6 +198,11 @@ cp -hpR share/xcat/install/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/install/
|
||||
cp -hpR share/xcat/netboot/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/
|
||||
%endif
|
||||
|
||||
# Debian scripts must remain self-contained when copied from an installed package.
|
||||
rm -f $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/debian/xCAT/ProfileUtils.pm
|
||||
cp share/xcat/netboot/imgutils/xCAT/ProfileUtils.pm $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/debian/xCAT/ProfileUtils.pm
|
||||
chmod 644 $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/debian/xCAT/ProfileUtils.pm $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/imgutils/xCAT/ProfileUtils.pm
|
||||
|
||||
%ifos linux
|
||||
# pwd
|
||||
cp -d sbin/* $RPM_BUILD_ROOT/%{prefix}/sbin
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# mount_snapshot.sh [<file>]
|
||||
#
|
||||
# Print the mount table without the kernel's own on-demand mounts, so the diskless cases can
|
||||
# compare a snapshot taken before genimage with one taken after it.
|
||||
#
|
||||
# genimage bind mounts /proc, /sys and /dev inside the root image. A bind it fails to remove
|
||||
# leaves the next image built on top of the host, so comparing the two snapshots is worth doing.
|
||||
#
|
||||
# What the comparison must not assert is that nothing else mounted anything meanwhile.
|
||||
# binfmt_misc is an autofs stub that becomes a real mount the first time a process reads
|
||||
# /proc/sys/fs/binfmt_misc, and tracefs appears under /sys/kernel/debug the first time anything
|
||||
# opens debugfs tracing. Both are the kernel's doing and both can happen during genimage. On one
|
||||
# openEuler 22.03 run both did, and the case failed four minutes in while the provisioning that
|
||||
# followed succeeded.
|
||||
#
|
||||
# Filtering by filesystem type would hide the leak this guards, because a leaked genimage bind IS
|
||||
# a proc or sysfs mount. The mount POINT separates them: the kernel keeps its on-demand mounts
|
||||
# inside /proc and /sys, and a leaked bind sits under the root image directory.
|
||||
#
|
||||
# With a file argument, filter that file instead of asking the kernel, so the filter is testable.
|
||||
|
||||
set -e
|
||||
|
||||
if [ $# -ge 1 ]; then
|
||||
cat -- "$1"
|
||||
else
|
||||
mount
|
||||
fi | awk '$3 !~ /^\/(proc|sys)(\/|$)/' | sort
|
||||
@@ -1,5 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
# How many times to ask ICMP, and how long to wait between asks. Overridable so a test can drive
|
||||
# node_pingable without sleeping.
|
||||
PING_TRIES=${PING_TRIES:-5}
|
||||
PING_RETRY_SLEEP=${PING_RETRY_SLEEP:-2}
|
||||
|
||||
#--- node_pingable
|
||||
# Descriptions: whether the node answers ICMP, asked more than once.
|
||||
#
|
||||
# ICMP to a node is lossy for a few seconds after it finishes booting. One sample on an
|
||||
# openSUSE Leap 15.6 cluster lost 2 of 2 packets while xdsh to the same node succeeded a second
|
||||
# later; the caller ANDs both answers, so that one sample forced a second full rinstall and cost
|
||||
# 401 seconds. A second run of the same cell lost 2 of 3 packets at a moment that was not the
|
||||
# decision point and passed. The difference between the two runs was which side of a
|
||||
# two-packet sample landed, not the state of the node.
|
||||
#
|
||||
# So ask again before concluding. A node that never answers still reports non-pingable, because
|
||||
# that is a real defect and the caller must keep vetoing it.
|
||||
# Arguments: $1 - the node
|
||||
# Returns: 0 if the node answered, non-zero if it never did
|
||||
#---
|
||||
node_pingable() {
|
||||
local node=$1
|
||||
local i
|
||||
for (( i = 1; i <= PING_TRIES; ++i )); do
|
||||
if ping -c 2 "$node"; then
|
||||
return 0
|
||||
fi
|
||||
echo "[$i/$PING_TRIES] $node did not answer ICMP; asking again"
|
||||
if [ "$i" -lt "$PING_TRIES" ]; then
|
||||
sleep "$PING_RETRY_SLEEP"
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Sourcing stops here. BASH_SOURCE[0] differs from $0 only when this file is sourced, so a bats
|
||||
# test can drive node_pingable without running a provisioning loop -- and without the lsdef below,
|
||||
# which needs an xCAT database.
|
||||
if [ "${BASH_SOURCE[0]}" != "${0}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
declare -i installsuccess=0
|
||||
declare -i a=0
|
||||
declare -i tryreinstall=1
|
||||
@@ -64,7 +106,7 @@ do
|
||||
tobooted=$?
|
||||
echo "The tobooted is $tobooted"
|
||||
|
||||
ping -c 2 $node
|
||||
node_pingable $node
|
||||
pingable=$?
|
||||
echo "The pingable is $pingable"
|
||||
|
||||
|
||||
@@ -40,9 +40,13 @@
|
||||
XCAT_AVC_COMM='xcatd|genimage|packimage|nodeset|mknb|makedhcp|makedns|makehosts|makeknownhosts|copycds|liteimg|xdsh|xdcp|xcatprobe|xcatconfig'
|
||||
XCAT_AVC_PATH='/opt/xcat|/xcatpost|/tftpboot|/install|/var/log/xcat|/etc/xcat|/var/lib/xcat'
|
||||
|
||||
# The path must be one of those directories, or a file under one. A directory name is
|
||||
# not a string prefix: /var/lib/xcat-cluster-test holds the CI's own notification hook,
|
||||
# and matching it as /var/lib/xcat put an xcatd denial on a harness file into the count.
|
||||
# So the name starts at the quote and ends at a / or at the closing quote.
|
||||
selinux_avc_classify()
|
||||
{
|
||||
grep -E "(comm|exe)=\"[^\"]*(${XCAT_AVC_COMM})[^\"]*\"|(path|name)=\"[^\"]*(${XCAT_AVC_PATH})"
|
||||
grep -E "(comm|exe)=\"[^\"]*(${XCAT_AVC_COMM})[^\"]*\"|(path|name)=\"(${XCAT_AVC_PATH})(/|\")"
|
||||
}
|
||||
|
||||
# Report the denials ausearch answered with. An error message is not a clean window:
|
||||
|
||||
@@ -33,17 +33,84 @@ vm_machine_type_private_dir()
|
||||
fi
|
||||
}
|
||||
|
||||
vm_machine_type_for_arch()
|
||||
# alias -- the machine name qemu keeps pointed at the newest machine of a family.
|
||||
vm_machine_type_alias()
|
||||
{
|
||||
case "$1" in
|
||||
ppc64*) echo 'machine:pseries-rhel7.6.0' ;;
|
||||
x86_64) echo 'machine:pc' ;;
|
||||
riscv64) echo 'machine:virt' ;;
|
||||
aarch64) echo 'machine:virt' ;;
|
||||
ppc64*) echo 'pseries' ;;
|
||||
x86_64) echo 'pc' ;;
|
||||
riscv64) echo 'virt' ;;
|
||||
aarch64) echo 'virt' ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# libvirt and qemu call the ppc64le guest architecture ppc64. A node on an
|
||||
# Ubuntu cell names it ppc64el.
|
||||
vm_machine_type_libvirt_arch()
|
||||
{
|
||||
case "$1" in
|
||||
ppc64*) echo 'ppc64' ;;
|
||||
x86_64) echo 'x86_64' ;;
|
||||
riscv64) echo 'riscv64' ;;
|
||||
aarch64) echo 'aarch64' ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# virsh on <host>, or here when <host> is empty. kvm.pm reaches the vmhost over
|
||||
# qemu+ssh://root@<host>/system, so root can ssh there from this node.
|
||||
vm_machine_type_virsh()
|
||||
{
|
||||
local host="$1"
|
||||
shift
|
||||
if [ -n "$host" ]; then
|
||||
ssh -o BatchMode=yes -o ConnectTimeout=10 -n "$host" virsh "$@"
|
||||
else
|
||||
virsh "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# supported <host> <arch> <machine> -- whether libvirt on <host> accepts <machine>.
|
||||
vm_machine_type_supported()
|
||||
{
|
||||
vm_machine_type_virsh "$1" domcapabilities --arch "$2" --machine "$3" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# default <host> <arch> -- the machine type libvirt on <host> uses for <arch>.
|
||||
vm_machine_type_default()
|
||||
{
|
||||
vm_machine_type_virsh "$1" domcapabilities --arch "$2" 2>/dev/null |
|
||||
sed -n 's|.*<machine>\(.*\)</machine>.*|\1|p' | head -n 1
|
||||
}
|
||||
|
||||
# for_arch <arch> [<vmhost>] -- the machine type to write, as "machine:<name>".
|
||||
#
|
||||
# The vmhost is what refuses the domain, so its libvirt picks the name: the plain
|
||||
# alias when that libvirt accepts it, its own default when it does not, and the
|
||||
# alias again when the vmhost cannot be asked. A versioned name does not survive
|
||||
# a host upgrade -- no qemu on AlmaLinux 10 has a pseries-rhel machine type.
|
||||
vm_machine_type_for_arch()
|
||||
{
|
||||
local arch="$1" vmhost="${2-}" generic libvirt_arch name
|
||||
|
||||
generic="$(vm_machine_type_alias "$arch")" || return 1
|
||||
libvirt_arch="$(vm_machine_type_libvirt_arch "$arch")" || return 1
|
||||
if vm_machine_type_supported "$vmhost" "$libvirt_arch" "$generic"; then
|
||||
printf 'machine:%s\n' "$generic"
|
||||
return
|
||||
fi
|
||||
name="$(vm_machine_type_default "$vmhost" "$libvirt_arch")"
|
||||
printf 'machine:%s\n' "${name:-$generic}"
|
||||
}
|
||||
|
||||
# vmhost <node> -- the host whose libvirt runs the guest, empty when unset.
|
||||
vm_machine_type_vmhost()
|
||||
{
|
||||
lsdef "$1" -i vmhost 2>/dev/null |
|
||||
sed -n 's/^[[:space:]]*vmhost=//p' | head -n 1
|
||||
}
|
||||
|
||||
vm_machine_type_get()
|
||||
{
|
||||
local out
|
||||
@@ -109,7 +176,7 @@ vm_machine_type_apply()
|
||||
chdef "$node" "vmothersetting=$original"
|
||||
return
|
||||
fi
|
||||
if ! machine="$(vm_machine_type_for_arch "$arch")"; then
|
||||
if ! machine="$(vm_machine_type_for_arch "$arch" "$(vm_machine_type_vmhost "$node")")"; then
|
||||
echo "vm_machine_type.sh: no machine type for arch '$arch'" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -74,13 +74,13 @@ check:rc==0
|
||||
cmd:osimage="__GETNODEATTR($$SN,os)__-__GETNODEATTR($$SN,arch)__-netboot-service";otherpkglist=$(lsdef -t osimage $osimage -i otherpkglist -c|awk -F"=" '{print $2}'); cat $otherpkglist
|
||||
|
||||
cmd:if [ ! -d /tmp/mountoutput ]; then mkdir -p /tmp/mountoutput; fi
|
||||
cmd:mount |sort > /tmp/mountoutput/file.org
|
||||
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/mount_snapshot.sh > /tmp/mountoutput/file.org
|
||||
|
||||
cmd:genimage __GETNODEATTR($$SN,os)__-__GETNODEATTR($$SN,arch)__-netboot-service
|
||||
check:rc==0
|
||||
|
||||
cmd:mount |sort > /tmp/mountoutput/file.new
|
||||
cmd:diff -y /tmp/mountoutput/file.org /tmp/mountoutput/file.new --ignore-matching-lines="fusectl"
|
||||
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/mount_snapshot.sh > /tmp/mountoutput/file.new
|
||||
cmd:diff -y /tmp/mountoutput/file.org /tmp/mountoutput/file.new
|
||||
check:rc==0
|
||||
cmd:rm -rf /tmp/mountoutput
|
||||
|
||||
|
||||
@@ -31,16 +31,16 @@ cmd:if [[ -f /test.synclist ]] ;then mv -f /test.synclist /test.synclist.bak;fi;
|
||||
cmd:echo "/test.synclist -> /test.synclist" > /test.synclist;chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute synclists=/test.synclist
|
||||
check:rc==0
|
||||
cmd:if [ ! -d /tmp/mountoutput ]; then mkdir -p /tmp/mountoutput; fi
|
||||
cmd:mount |sort > /tmp/mountoutput/file.org
|
||||
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/mount_snapshot.sh > /tmp/mountoutput/file.org
|
||||
cmd:cat /tmp/mountoutput/file.org
|
||||
cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu18.04.2" ]] && [[ "__GETNODEATTR($$CN,arch)__" =~ ppc64(el|le) ]] && [[ "__GETNODEATTR($$CN,mgt)__" =~ "kvm" ]] ; then mkdir -p /install/custom/netboot/ubuntu; sed -e 's@linux-image-generic-hwe-18.04@linux-image-generic@g' </opt/xcat/share/xcat/netboot/ubuntu/compute.ubuntu18.04.2.ppc64el.pkglist >/install/custom/netboot/ubuntu/compute.ubuntu18.04.2.ppc64el.pkglist; chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute pkglist=/install/custom/netboot/ubuntu/compute.ubuntu18.04.2.ppc64el.pkglist; fi
|
||||
cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu16.04.5" ]] && [[ "__GETNODEATTR($$CN,arch)__" =~ "x86" ]]; then chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -p pkgdir="http://archive.ubuntu.com/ubuntu xenial universe main,http://archive.ubuntu.com/ubuntu xenial-updates universe main,http://security.ubuntu.com/ubuntu xenial-security main restricted";fi
|
||||
cmd:lsdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
|
||||
cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
|
||||
check:rc==0
|
||||
cmd:mount |sort > /tmp/mountoutput/file.new
|
||||
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/mount_snapshot.sh > /tmp/mountoutput/file.new
|
||||
cmd:cat /tmp/mountoutput/file.new
|
||||
cmd:diff /tmp/mountoutput/file.org /tmp/mountoutput/file.new --ignore-matching-lines="fusectl"
|
||||
cmd:diff /tmp/mountoutput/file.org /tmp/mountoutput/file.new
|
||||
check:rc==0
|
||||
cmd:rm -rf /tmp/mountoutput
|
||||
cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
|
||||
@@ -148,16 +148,16 @@ cmd:if [[ -f /test.synclist ]] ;then mv -f /test.synclist /test.synclist.bak;fi;
|
||||
cmd:echo "/test.synclist -> /test.synclist" > /test.synclist;chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute synclists=/test.synclist
|
||||
check:rc==0
|
||||
cmd:if [ ! -d /tmp/mountoutput ]; then mkdir -p /tmp/mountoutput; fi
|
||||
cmd:mount |sort > /tmp/mountoutput/file.org
|
||||
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/mount_snapshot.sh > /tmp/mountoutput/file.org
|
||||
cmd:cat /tmp/mountoutput/file.org
|
||||
cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu18.04.2" ]] && [[ "__GETNODEATTR($$CN,arch)__" =~ ppc64(el|le) ]] && [[ "__GETNODEATTR($$CN,mgt)__" =~ "kvm" ]] ; then mkdir -p /install/custom/netboot/ubuntu; sed -e 's@linux-image-generic-hwe-18.04@linux-image-generic@g' </opt/xcat/share/xcat/netboot/ubuntu/compute.ubuntu18.04.2.ppc64el.pkglist >/install/custom/netboot/ubuntu/compute.ubuntu18.04.2.ppc64el.pkglist; chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute pkglist=/install/custom/netboot/ubuntu/compute.ubuntu18.04.2.ppc64el.pkglist; fi
|
||||
cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu16.04.5" ]] && [[ "__GETNODEATTR($$CN,arch)__" =~ "x86" ]]; then chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -p pkgdir="http://archive.ubuntu.com/ubuntu xenial universe main,http://archive.ubuntu.com/ubuntu xenial-updates universe main,http://security.ubuntu.com/ubuntu xenial-security main restricted";fi
|
||||
cmd:lsdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
|
||||
cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
|
||||
check:rc==0
|
||||
cmd:mount |sort > /tmp/mountoutput/file.new
|
||||
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/mount_snapshot.sh > /tmp/mountoutput/file.new
|
||||
cmd:cat /tmp/mountoutput/file.new
|
||||
cmd:diff /tmp/mountoutput/file.org /tmp/mountoutput/file.new --ignore-matching-lines="fusectl"
|
||||
cmd:diff /tmp/mountoutput/file.org /tmp/mountoutput/file.new
|
||||
check:rc==0
|
||||
cmd:rm -rf /tmp/mountoutput
|
||||
|
||||
|
||||
+3
-3
@@ -35,15 +35,15 @@ cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arc
|
||||
check:rc==0
|
||||
|
||||
cmd:if [ ! -d /tmp/mountoutput ]; then mkdir -p /tmp/mountoutput; fi
|
||||
cmd:mount |sort > /tmp/mountoutput/file.org
|
||||
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/mount_snapshot.sh > /tmp/mountoutput/file.org
|
||||
cmd:cat /tmp/mountoutput/file.org
|
||||
cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu16.04.5" ]] && [[ "__GETNODEATTR($$CN,arch)__" =~ "x86" ]]; then chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -p pkgdir="http://archive.ubuntu.com/ubuntu xenial universe main,http://archive.ubuntu.com/ubuntu xenial-updates universe main,http://security.ubuntu.com/ubuntu xenial-security main restricted";fi
|
||||
cmd:lsdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
|
||||
cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
|
||||
check:rc==0
|
||||
cmd:mount |sort > /tmp/mountoutput/file.new
|
||||
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/mount_snapshot.sh > /tmp/mountoutput/file.new
|
||||
cmd:cat /tmp/mountoutput/file.new
|
||||
cmd:diff /tmp/mountoutput/file.org /tmp/mountoutput/file.new --ignore-matching-lines="fusectl"
|
||||
cmd:diff /tmp/mountoutput/file.org /tmp/mountoutput/file.new
|
||||
check:rc==0
|
||||
cmd:rm -rf /tmp/mountoutput
|
||||
cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
|
||||
|
||||
@@ -24,7 +24,9 @@ write_stub()
|
||||
# A PATH directory holding the commands getcert runs. openssl is absent unless it is asked for.
|
||||
stub_dir()
|
||||
{
|
||||
local with_openssl="${1:-0}" count=""
|
||||
# count defaults to a no-op: an empty value leaves "{ ; exit 1; }", which is a syntax
|
||||
# error, so the stub would fail for the wrong reason and report bash's message.
|
||||
local with_openssl="${1:-0}" count=":"
|
||||
local dir="${BATS_TEST_TMPDIR}/bin"
|
||||
|
||||
rm -rf "$dir"
|
||||
@@ -35,7 +37,7 @@ stub_dir()
|
||||
write_stub "$dir" sleep 'exec /bin/sleep "$@"'
|
||||
if [ "$with_openssl" = 1 ]; then
|
||||
[ -n "${COUNT_REQUESTS:-}" ] && count="echo req >> '$COUNTER'"
|
||||
write_stub "$dir" openssl "[ \"\$1\" = req ] && { $count ; exit 1; }
|
||||
write_stub "$dir" openssl "[ \"\$1\" = req ] && { $count ; echo \"\${OPENSSL_REQ_ERROR:-}\" >&2 ; exit 1; }
|
||||
exit 0"
|
||||
fi
|
||||
printf '%s\n' "$dir"
|
||||
@@ -70,3 +72,13 @@ run_getcert()
|
||||
[ -f "$COUNTER" ] && tries="$(grep -c req "$COUNTER")"
|
||||
[ "$tries" -gt 1 ]
|
||||
}
|
||||
|
||||
@test "the give up message repeats what openssl printed" {
|
||||
# OPENSSLDIR/openssl.cnf is absent more often than the key is broken, and the key is
|
||||
# usually intact. A message that names only certkey.pem sends the reader to the wrong file.
|
||||
export OPENSSL_REQ_ERROR="Can't open \"/usr/lib/ssl/openssl.cnf\" for reading, No such file or directory"
|
||||
run run_getcert "$(stub_dir 1)" 30 5
|
||||
[ "$status" -ne 124 ]
|
||||
[ "$status" -ne 0 ]
|
||||
[[ "$output" == *openssl.cnf* ]]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bats
|
||||
#
|
||||
# The Genesis payload must carry the openssl config file. openssl req reads
|
||||
# OPENSSLDIR/openssl.cnf and exits 1 when it is absent, so getcert makes no certificate
|
||||
# request and the node never reports a destiny.
|
||||
|
||||
load 'helpers/shell_source'
|
||||
|
||||
setup()
|
||||
{
|
||||
HOST_CNF="$(openssl version -d 2>/dev/null | sed -e 's/^OPENSSLDIR: *"*//' -e 's/"*$//')/openssl.cnf"
|
||||
[ -e "$HOST_CNF" ] || skip "this host has no $HOST_CNF to install"
|
||||
export HOST_CNF
|
||||
}
|
||||
|
||||
# Run the module's install() with every dracut helper replaced by a recorder, so the test reads
|
||||
# what the module asks the payload to carry rather than matching the module's source.
|
||||
record_install()
|
||||
{
|
||||
local module="$1" log="$2"
|
||||
: >"$log"
|
||||
(
|
||||
for helper in dracut_install inst inst_simple inst_multiple inst_binary inst_script \
|
||||
inst_symlink inst_dir inst_hook inst_rules instmods; do
|
||||
eval "$helper() { printf '%s\n' \"\$@\" >>'$log'; return 0; }"
|
||||
done
|
||||
# Anything the module calls that this host lacks must not stop install().
|
||||
command_not_found_handle() { return 0; }
|
||||
dfatal() { printf 'dfatal %s\n' "$*" >>"$log"; }
|
||||
moddir="${BATS_TEST_TMPDIR}"; hostonly=''; dracutsysrootdir=''; srcmods=''
|
||||
. "$module" >/dev/null 2>&1 || true
|
||||
install >/dev/null 2>&1 || true
|
||||
)
|
||||
}
|
||||
|
||||
@test "the ubuntu module installs the openssl config its own openssl names" {
|
||||
module="$(repo_path 'xCAT-genesis-base/dracut_105/ubuntu/module-setup.sh')"
|
||||
[ -r "$module" ] || skip "$module is required"
|
||||
record_install "$module" "${BATS_TEST_TMPDIR}/ubuntu.log"
|
||||
[ -s "${BATS_TEST_TMPDIR}/ubuntu.log" ]
|
||||
grep -q "$HOST_CNF" "${BATS_TEST_TMPDIR}/ubuntu.log"
|
||||
}
|
||||
|
||||
@test "the el module installs the openssl config its own openssl names" {
|
||||
module="$(repo_path 'xCAT-genesis-base/dracut_105/el/module-setup.sh')"
|
||||
[ -r "$module" ] || skip "$module is required"
|
||||
record_install "$module" "${BATS_TEST_TMPDIR}/el.log"
|
||||
[ -s "${BATS_TEST_TMPDIR}/el.log" ]
|
||||
grep -q "$HOST_CNF" "${BATS_TEST_TMPDIR}/el.log"
|
||||
}
|
||||
|
||||
@test "openssl itself is still installed, so the config is an addition" {
|
||||
module="$(repo_path 'xCAT-genesis-base/dracut_105/ubuntu/module-setup.sh')"
|
||||
[ -r "$module" ] || skip "$module is required"
|
||||
record_install "$module" "${BATS_TEST_TMPDIR}/u2.log"
|
||||
grep -qx 'openssl' "${BATS_TEST_TMPDIR}/u2.log"
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
#!/usr/bin/env bats
|
||||
#
|
||||
# The privilege separation directory sshd needs, at the moment doxcat starts sshd.
|
||||
#
|
||||
# Debian and Ubuntu build sshd with --with-privsep-path=/run/sshd. The Genesis image carries
|
||||
# /run and not /run/sshd, so sshd exited with "Missing privilege separation directory" and the
|
||||
# node answered no ssh at all. Every legacy Genesis case that reaches a booted node over xdsh
|
||||
# failed on "Connection refused" while sequential discovery, which needs no ssh, passed.
|
||||
#
|
||||
# doxcat already did this for the other family -- it creates /usr/share/empty.sshd, the EL
|
||||
# privsep path -- so this is the same line for Debian. The assertions are what SSHD IMPOSES,
|
||||
# read at the moment sshd runs: the path is a directory, its owner is the user that will run
|
||||
# sshd, and it is not group or world writable. sshd refuses a loose mode with the same message
|
||||
# as an absent directory, so a wrong mode is indistinguishable from the bug.
|
||||
#
|
||||
# Read from inside the sandbox on purpose. /run there is a tmpfs, exactly as it is on a running
|
||||
# system, so a directory made before that mount -- or baked into the image -- is not there when
|
||||
# sshd starts and cannot be seen from outside afterwards.
|
||||
|
||||
load 'helpers/doxcat_sandbox'
|
||||
|
||||
PRIVSEP_PATHS='/run/sshd /var/run/sshd'
|
||||
|
||||
# Record what each privsep path looks like AT THE MOMENT sshd runs.
|
||||
#
|
||||
# doxcat runs sshd as /usr/sbin/sshd, an absolute path, so a stub on PATH is never reached and
|
||||
# the recorder is bound over that path instead. Recording from a later PATH command instead --
|
||||
# openssl is the next one -- cannot see the ORDER: moving the directories after the sshd line
|
||||
# then passes, which is the one mutation that matters most here.
|
||||
record_privsep()
|
||||
{
|
||||
local stub="${BATS_TEST_TMPDIR}/sshd-recorder"
|
||||
|
||||
cat >"$stub" <<SH
|
||||
#!/bin/sh
|
||||
for d in $PRIVSEP_PATHS; do
|
||||
if [ -d "\$d" ]; then
|
||||
# ls, not stat: the sandbox carries only the utilities the helper copies, and a
|
||||
# command missing there silently does nothing. Field 1 is the mode string, field 3
|
||||
# the owner, numeric because ls has no passwd lookup here.
|
||||
ls -ld "\$d" | awk '{ printf "%s dir %s %s\\n", "'"\$d"'", \$1, \$3 }' \\
|
||||
>>/run/fixture/sshd-privsep
|
||||
else
|
||||
printf '%s absent\n' "\$d" >>/run/fixture/sshd-privsep
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
SH
|
||||
chmod 0755 "$stub"
|
||||
sandbox+=(--ro-bind "$stub" /usr/sbin/sshd)
|
||||
}
|
||||
|
||||
seen()
|
||||
{
|
||||
local path="$1"
|
||||
awk -v p="$path" '$1 == p { print; exit }' "$fixture/sshd-privsep"
|
||||
}
|
||||
|
||||
@test "doxcat makes every privilege separation directory before it starts sshd" {
|
||||
setup_doxcat
|
||||
record_privsep
|
||||
add_doxcat_link eth0 BROADCAST,MULTICAST,UP ether 02:bb:cc:dd:ee:ff
|
||||
run_genesis 0 --setenv BOOTIF 01-02-bb-cc-dd-ee-ff
|
||||
|
||||
# The recording ran, so it happened one statement after sshd was started.
|
||||
[ -s "$fixture/sshd-privsep" ]
|
||||
|
||||
for path in $PRIVSEP_PATHS; do
|
||||
local line mode owner
|
||||
line=$(seen "$path")
|
||||
[ -n "$line" ]
|
||||
[ "$(printf '%s\n' "$line" | cut -d' ' -f2)" = dir ]
|
||||
mode=$(printf '%s\n' "$line" | cut -d' ' -f3)
|
||||
owner=$(printf '%s\n' "$line" | cut -d' ' -f4)
|
||||
# Owned by whoever runs sshd: root in Genesis, the invoking user here. ls in
|
||||
# the sandbox has no passwd lookup, so the owner comes back numeric.
|
||||
[ "$owner" = "$(id -u)" ]
|
||||
# sshd refuses a group or world writable privsep directory. Positions 6 and 9 of the
|
||||
# mode string are the group and other write bits.
|
||||
[ "$(printf '%s\n' "$mode" | cut -c6)" = - ]
|
||||
[ "$(printf '%s\n' "$mode" | cut -c9)" = - ]
|
||||
done
|
||||
}
|
||||
|
||||
@test "a privilege separation directory left group writable is corrected, not kept" {
|
||||
# The directory can already exist from an earlier boot with a mode sshd will not accept,
|
||||
# and that failure prints the same message as an absent one. So the mode is set whether or
|
||||
# not doxcat had to create the directory.
|
||||
setup_doxcat
|
||||
record_privsep
|
||||
add_doxcat_link eth0 BROADCAST,MULTICAST,UP ether 02:bb:cc:dd:ee:ff
|
||||
# /var is bound from the fixture, so this one survives into the sandbox.
|
||||
mkdir -p "$fixture/var/run/sshd"
|
||||
chmod 0777 "$fixture/var/run/sshd"
|
||||
run_genesis 0 --setenv BOOTIF 01-02-bb-cc-dd-ee-ff
|
||||
|
||||
local mode
|
||||
mode=$(printf '%s\n' "$(seen /var/run/sshd)" | cut -d' ' -f3)
|
||||
[ -n "$mode" ]
|
||||
[ "$(printf '%s\n' "$mode" | cut -c6)" = - ]
|
||||
[ "$(printf '%s\n' "$mode" | cut -c9)" = - ]
|
||||
}
|
||||
|
||||
@test "every command doxcat runs resolves inside the sandbox" {
|
||||
# The sandbox curates PATH and does NOT include /usr/bin, so a command it does not copy
|
||||
# resolves to nothing. That fails silently: doxcat's chmod did nothing under test for as
|
||||
# long as this sandbox has existed, and an assertion about a mode could never pass. The
|
||||
# mode half of the privsep fix was unmeasurable until chmod was added to the helper.
|
||||
#
|
||||
# Derived, not a list: bash calls command_not_found_handle for anything it cannot resolve,
|
||||
# so this records whatever doxcat actually invokes and goes missing. A list here would go
|
||||
# stale the next time doxcat gains a command.
|
||||
#
|
||||
# Its reach is the commands doxcat runs ON THE PATH THIS TEST DRIVES, which is not every
|
||||
# command in the script -- a branch this boot does not take is not covered. It is a floor,
|
||||
# not a completeness check on the helper's list.
|
||||
setup_doxcat
|
||||
record_privsep
|
||||
local env_file="${BATS_TEST_TMPDIR}/bash_env"
|
||||
cat >"$env_file" <<'SH'
|
||||
command_not_found_handle()
|
||||
{
|
||||
printf '%s\n' "$1" >>/run/fixture/not-found
|
||||
return 127
|
||||
}
|
||||
SH
|
||||
sandbox+=(--ro-bind "$env_file" /run/bash_env --setenv BASH_ENV /run/bash_env)
|
||||
add_doxcat_link eth0 BROADCAST,MULTICAST,UP ether 02:bb:cc:dd:ee:ff
|
||||
run_genesis 0 --setenv BOOTIF 01-02-bb-cc-dd-ee-ff
|
||||
|
||||
# The handler was installed, so an absence would have been recorded.
|
||||
[ -s "$fixture/sshd-privsep" ]
|
||||
if [ -e "$fixture/not-found" ]; then
|
||||
printf 'doxcat runs commands the sandbox does not provide:\n%s\n' \
|
||||
"$(sort -u "$fixture/not-found")" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bats
|
||||
#
|
||||
# The awk the Ubuntu Genesis image carries.
|
||||
#
|
||||
# allowcred.awk, minixcatd.awk and udpcat.awk open a TCP stream with the gawk |& coprocess
|
||||
# and the /inet/ special file. mawk rejects both at parse time, and mawk is the awk
|
||||
# alternative on a Debian or Ubuntu build root, so the module cannot stage the host's
|
||||
# /usr/bin/awk.
|
||||
|
||||
load 'helpers/shell_source'
|
||||
|
||||
setup()
|
||||
{
|
||||
MODULE="$(repo_path 'xCAT-genesis-base/dracut_105/ubuntu/module-setup.sh')"
|
||||
[ -r "$MODULE" ] || skip "$MODULE is required"
|
||||
export MODULE
|
||||
}
|
||||
|
||||
# Run install() from the dracut module with the dracut helpers replaced by stubs. Sets
|
||||
# INSTALLED to one installed name per line, and INITDIR to the staged image root.
|
||||
run_install()
|
||||
{
|
||||
local dir="${BATS_TEST_TMPDIR}/module"
|
||||
|
||||
rm -rf "$dir"
|
||||
mkdir -p "$dir/initdir/usr/bin" "$dir/initdir/bin"
|
||||
|
||||
# No "set -u": _dracut_install_opt() in the module reads $2 unset, which real dracut
|
||||
# allows.
|
||||
cat >"$dir/drive.sh" <<'SH'
|
||||
initdir="$1"
|
||||
record="$2"
|
||||
moddir=/dev/null
|
||||
kernel=
|
||||
dracut_install() { for name in "$@"; do printf '%s\n' "$name" >>"$record"; done; }
|
||||
instmods() { :; }
|
||||
inst() { :; }
|
||||
inst_script() { :; }
|
||||
inst_dir() { :; }
|
||||
inst_hook() { :; }
|
||||
inst_symlink() { :; }
|
||||
. "$MODULE"
|
||||
install >/dev/null 2>&1
|
||||
SH
|
||||
|
||||
/bin/bash "$dir/drive.sh" "$dir/initdir" "$dir/installed" || true
|
||||
INSTALLED="$(read_file_or_empty "$dir/installed")"
|
||||
INITDIR="$dir/initdir"
|
||||
}
|
||||
|
||||
@test "the module installs gawk by name" {
|
||||
run_install
|
||||
printf '%s\n' "$INSTALLED" | grep -qx 'gawk'
|
||||
}
|
||||
|
||||
@test "the module does not stage the build host's awk alternative" {
|
||||
# On Ubuntu /usr/bin/awk resolves to mawk, so staging it ships an awk that cannot parse
|
||||
# the Genesis awk programs.
|
||||
run_install
|
||||
refute_grep -qx '/usr/bin/awk' <(printf '%s\n' "$INSTALLED")
|
||||
refute_grep -qx 'awk' <(printf '%s\n' "$INSTALLED")
|
||||
}
|
||||
|
||||
@test "awk in the image points at gawk" {
|
||||
# The awk programs start with #!/usr/bin/awk -f, so the name awk has to be gawk.
|
||||
run_install
|
||||
[ -L "$INITDIR/usr/bin/awk" ]
|
||||
[ "$(readlink "$INITDIR/usr/bin/awk")" = 'gawk' ]
|
||||
}
|
||||
@@ -10,8 +10,11 @@ setup_doxcat()
|
||||
fips=$(repo_path xCAT-genesis-scripts/usr/lib/xcat/fips.sh)
|
||||
[ -r "$fips" ]
|
||||
mkdir -p "$fixture"/{etc/ssh,etc/pki/tls,real,links,addrs}
|
||||
# chmod is in this list because doxcat runs it: the sandbox has no /usr/bin on PATH, so a
|
||||
# command that is missing here is a command that silently does nothing under test. doxcat's
|
||||
# chmod of the sshd privilege separation directory was not exercised until it was added.
|
||||
for utility in bash sh cat cp awk grep sed sort tr tail rm wc cut head uname \
|
||||
timeout env ls mkdir touch readlink basename sleep; do
|
||||
timeout env ls mkdir touch readlink basename sleep chmod; do
|
||||
cp -L "$(PATH=/usr/bin:/bin type -P "$utility")" "$fixture/bin/$utility"
|
||||
done
|
||||
if [ -x /usr/bin/coreutils ]; then
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bats
|
||||
#
|
||||
# Drive mount_snapshot.sh, which the diskless cases use to compare the mount table before and
|
||||
# after genimage. The comparison exists to catch a bind mount genimage leaves inside the root
|
||||
# image, and it must keep catching one.
|
||||
#
|
||||
# The snapshots below are real lines from an openEuler 22.03 management node. On that run
|
||||
# binfmt_misc and tracefs appeared between the two snapshots and failed the case, so the first
|
||||
# test holds down that they are ignored. The second test is the one that matters: a leaked
|
||||
# genimage bind must still be reported, which is why filtering by filesystem type is wrong.
|
||||
|
||||
load 'helpers/shell_source'
|
||||
|
||||
ROOTIMG=/install/netboot/openeuler22.03sp4/x86_64/compute/rootimg
|
||||
|
||||
setup()
|
||||
{
|
||||
SCRIPT="$(require_repo_file 'xCAT-test/autotest/testcase/commoncmd/mount_snapshot.sh')"
|
||||
BEFORE="${BATS_TEST_TMPDIR}/file.org"
|
||||
AFTER="${BATS_TEST_TMPDIR}/file.new"
|
||||
|
||||
cat >"$BEFORE" <<EOF
|
||||
/dev/vda2 on / type xfs (rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota)
|
||||
devtmpfs on /dev type devtmpfs (rw,nosuid,size=4096k,nr_inodes=1048576,mode=755)
|
||||
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
|
||||
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
|
||||
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=0)
|
||||
tmpfs on /run type tmpfs (rw,nosuid,nodev,size=1985536k,mode=755)
|
||||
tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)
|
||||
EOF
|
||||
}
|
||||
|
||||
# The kernel may mount either of these at any moment. Neither is xCAT's doing.
|
||||
@test "an on-demand kernel mount appearing during genimage is ignored" {
|
||||
cp "$BEFORE" "$AFTER"
|
||||
cat >>"$AFTER" <<EOF
|
||||
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)
|
||||
tracefs on /sys/kernel/debug/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)
|
||||
EOF
|
||||
|
||||
diff <("$SCRIPT" "$BEFORE") <("$SCRIPT" "$AFTER")
|
||||
}
|
||||
|
||||
# The discriminator. A leaked bind is a proc mount, so a type filter would drop it and the
|
||||
# comparison could never fail again.
|
||||
@test "a bind mount genimage left inside the root image is still reported" {
|
||||
cp "$BEFORE" "$AFTER"
|
||||
printf 'proc on %s/proc type proc (rw,nosuid,nodev,noexec,relatime)\n' "$ROOTIMG" >>"$AFTER"
|
||||
|
||||
run diff <("$SCRIPT" "$BEFORE") <("$SCRIPT" "$AFTER")
|
||||
[ "$status" -ne 0 ]
|
||||
[[ "$output" == *"$ROOTIMG/proc"* ]]
|
||||
}
|
||||
|
||||
# An ordinary mount outside /proc and /sys is the other half of the same requirement.
|
||||
@test "an NFS mount left behind is still reported" {
|
||||
cp "$BEFORE" "$AFTER"
|
||||
printf '192.0.2.1:/install on /mnt/install type nfs4 (rw,relatime)\n' >>"$AFTER"
|
||||
|
||||
run diff <("$SCRIPT" "$BEFORE") <("$SCRIPT" "$AFTER")
|
||||
[ "$status" -ne 0 ]
|
||||
[[ "$output" == *"/mnt/install"* ]]
|
||||
}
|
||||
|
||||
@test "the snapshot keeps the real mounts and drops only the kernel's own" {
|
||||
run "$SCRIPT" "$BEFORE"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *" on / type xfs"* ]]
|
||||
[[ "$output" == *" on /run type tmpfs"* ]]
|
||||
[[ "$output" == *" on /dev type devtmpfs"* ]]
|
||||
refute_grep -q ' on /proc ' <<<"$output"
|
||||
refute_grep -q ' on /sys ' <<<"$output"
|
||||
refute_grep -q '/sys/kernel/tracing' <<<"$output"
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env bats
|
||||
#
|
||||
# retry_install.sh decides a provision succeeded only if all three of tobooted, pingable and
|
||||
# canruncmd are 0. pingable came from a single `ping -c 2`, and ICMP to a node is lossy for a few
|
||||
# seconds after it finishes booting.
|
||||
#
|
||||
# Measured on an openSUSE Leap 15.6 cluster: one sample reported "2 packets transmitted, 0
|
||||
# received" while `xdsh <node> date` returned the node's own clock a second later, so the node was
|
||||
# up and answering SSH. The conjunction failed on ICMP alone and the case did a second full
|
||||
# rinstall, which cost 401 of the 404 seconds between two runs of the same cell. The second run
|
||||
# lost 2 of 3 packets at a moment that was not the decision point and passed first try. The
|
||||
# difference between the runs was which side of a two-packet sample landed.
|
||||
#
|
||||
# node_pingable asks again before concluding. These tests drive it with a stubbed ping, because
|
||||
# what matters is how many times it asks and what it answers -- not whether this host can reach
|
||||
# anything.
|
||||
#
|
||||
# The discriminator is "a node that never answers still reports non-pingable". Removing the
|
||||
# retry must fail the transient case and leave that one passing, or the change cannot be told
|
||||
# apart from deleting the check -- which would turn a flaky probe into one that cannot fail.
|
||||
|
||||
load 'helpers/shell_source'
|
||||
|
||||
NODE=cn01
|
||||
|
||||
setup()
|
||||
{
|
||||
SCRIPT="$(require_repo_file 'xCAT-test/autotest/testcase/commoncmd/retry_install.sh')"
|
||||
COUNT="${BATS_TEST_TMPDIR}/ping-calls"
|
||||
: >"$COUNT"
|
||||
# No sleeping: the retry interval is not what these tests are about.
|
||||
export PING_RETRY_SLEEP=0
|
||||
export PING_TRIES=5
|
||||
}
|
||||
|
||||
# Replaces the ping(8) the function calls. Answers non-zero for the first $1 calls, then zero.
|
||||
# A negative count never answers.
|
||||
stub_ping()
|
||||
{
|
||||
FAIL_FIRST="$1"
|
||||
ping()
|
||||
{
|
||||
local n
|
||||
n=$(( $(read_file_or_empty "$COUNT" | wc -l) + 1 ))
|
||||
echo "call $n" >>"$COUNT"
|
||||
if [ "$FAIL_FIRST" -lt 0 ] || [ "$n" -le "$FAIL_FIRST" ]; then
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
ping_calls()
|
||||
{
|
||||
read_file_or_empty "$COUNT" | wc -l | tr -d ' '
|
||||
}
|
||||
|
||||
@test "sourcing retry_install.sh defines node_pingable and runs no provisioning" {
|
||||
# The main-guard. Without it, sourcing runs lsdef and the rinstall loop.
|
||||
run bash -c "source '$SCRIPT'; type -t node_pingable"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "function" ]
|
||||
}
|
||||
|
||||
# `run` is required, not stylistic: bats fails a test on any non-zero command in its body, and
|
||||
# `set +e` does not suppress that. Asserting on a non-zero return without `run` aborts the test
|
||||
# instead of measuring it -- which made the veto assertion below fail under a mutation for the
|
||||
# wrong reason, so it could not discriminate.
|
||||
@test "a node whose first samples are lost is pingable once it answers" {
|
||||
# xcat20-mn, exactly: ICMP lost in the window after the boot, then fine.
|
||||
source "$SCRIPT"
|
||||
stub_ping 2
|
||||
run node_pingable "$NODE"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(ping_calls)" -eq 3 ]
|
||||
}
|
||||
|
||||
@test "a node that never answers is still not pingable, so a real defect keeps vetoing" {
|
||||
# THE DISCRIMINATOR, and it asserts ONE thing on purpose. Bundling the ask count in here made
|
||||
# it fail under the mutation as a retry property, which is the opposite of discriminating:
|
||||
# this assertion exists to show the change is not "delete the check", so it has to pass
|
||||
# whether or not the retry is present.
|
||||
source "$SCRIPT"
|
||||
stub_ping -1
|
||||
run node_pingable "$NODE"
|
||||
[ "$status" -ne 0 ]
|
||||
}
|
||||
|
||||
@test "a node that never answers is asked PING_TRIES times before giving up" {
|
||||
source "$SCRIPT"
|
||||
stub_ping -1
|
||||
run node_pingable "$NODE"
|
||||
[ "$(ping_calls)" -eq "$PING_TRIES" ]
|
||||
}
|
||||
|
||||
@test "a node that answers at once costs no extra asks" {
|
||||
# The happy path must not get slower: one ask, as before.
|
||||
source "$SCRIPT"
|
||||
stub_ping 0
|
||||
node_pingable "$NODE"
|
||||
[ "$(ping_calls)" -eq 1 ]
|
||||
}
|
||||
@@ -66,6 +66,31 @@ SSH_RECORD='type=AVC msg=audit(1759000002.333:444): avc: denied { siginh } for
|
||||
[[ "$output" == *'comm="genimage"'* ]]
|
||||
}
|
||||
|
||||
# The hook cluster-test.pl registers with regnotif, executed by an xcatd worker. The
|
||||
# harness wrote this file, not xCAT, and /var/lib/xcat-cluster-test is not /var/lib/xcat.
|
||||
# Captured on build 2 of xcat-test-el10-x86_64-selinux, where it was the one denial the
|
||||
# run attributed to xCAT and selinux_cn_diskful_enforcing failed on it.
|
||||
HARNESS_RECORD='type=AVC msg=audit(1792858690.329:3003): avc: denied { execute_no_trans } for pid=51342 comm=78636174643A204442204163636573 path="/var/lib/xcat-cluster-test/event-notify.pl" dev="vda4" ino=75521321 scontext=system_u:system_r:xcat_t:s0 tcontext=unconfined_u:object_r:var_lib_t:s0 tclass=file permissive=1'
|
||||
|
||||
@test "a path that merely starts with the name of an xCAT directory is not kept" {
|
||||
run classify "$HARNESS_RECORD"
|
||||
[ -z "$output" ]
|
||||
}
|
||||
|
||||
@test "an xCAT directory is kept when the path names the directory itself" {
|
||||
local record='type=AVC msg=audit(1759000005.666:777): avc: denied { search } for pid=6789 comm="httpd" path="/install" dev="vda2" ino=56 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:default_t:s0 tclass=dir permissive=0'
|
||||
run classify "$record"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *'path="/install"'* ]]
|
||||
}
|
||||
|
||||
@test "a file under an xCAT directory is kept" {
|
||||
local record='type=AVC msg=audit(1759000006.777:888): avc: denied { read } for pid=7890 comm="httpd" path="/var/lib/xcat/cert/server-cert.pem" dev="vda2" ino=57 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:var_lib_t:s0 tclass=file permissive=0'
|
||||
run classify "$record"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *'/var/lib/xcat/cert/server-cert.pem'* ]]
|
||||
}
|
||||
|
||||
@test "a program whose name merely contains a kept word is not matched by accident" {
|
||||
local record='type=AVC msg=audit(1759000004.555:666): avc: denied { execute } for pid=5678 comm="systemd-udevd" scontext=system_u:system_r:udev_t:s0 tcontext=system_u:object_r:bin_t:s0 tclass=file permissive=0'
|
||||
run classify "$record"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bats
|
||||
# vm_machine_type.sh sets machine:invalid, then a valid machine type, then clears it again.
|
||||
# lsdef and chdef are shell functions that read and write vmothersetting of node cn1 in a file.
|
||||
# virsh is a shell function that answers for the vmhost, and ssh runs the command it is given
|
||||
# so that function answers it. MACHINES is what that vmhost declares.
|
||||
|
||||
load 'helpers/shell_source'
|
||||
|
||||
@@ -14,6 +16,17 @@ setup()
|
||||
LSDEF_FAIL=0
|
||||
CHDEF_FAIL=0
|
||||
CHDEF_CALLS=0
|
||||
# The vmhost of cn1, and what its libvirt declares. Every plain alias is in the set, so a
|
||||
# test that does not care which host answers gets the alias.
|
||||
VMHOST=''
|
||||
MACHINES='pseries pseries-10.2 pc pc-i440fx-rhel10.0.0 q35 virt virt-10.2'
|
||||
DEFAULT_MACHINE=''
|
||||
SSH_FAIL=0
|
||||
VIRSH_ABSENT=0
|
||||
SSH_TARGETS="${BATS_TEST_TMPDIR}/ssh-targets"
|
||||
VIRSH_ARCHS="${BATS_TEST_TMPDIR}/virsh-archs"
|
||||
: >"$SSH_TARGETS"
|
||||
: >"$VIRSH_ARCHS"
|
||||
}
|
||||
|
||||
# lsdef prints no line for an attribute without a value.
|
||||
@@ -24,9 +37,16 @@ lsdef()
|
||||
return 1
|
||||
fi
|
||||
printf 'Object name: %s\n' "$1"
|
||||
if [ -s "$VMOTHER" ]; then
|
||||
printf ' vmothersetting=%s\n' "$(cat "$VMOTHER")"
|
||||
fi
|
||||
case "$3" in
|
||||
vmhost)
|
||||
[ -z "$VMHOST" ] || printf ' vmhost=%s\n' "$VMHOST"
|
||||
;;
|
||||
*)
|
||||
if [ -s "$VMOTHER" ]; then
|
||||
printf ' vmothersetting=%s\n' "$(cat "$VMOTHER")"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
chdef()
|
||||
@@ -40,6 +60,56 @@ chdef()
|
||||
CHDEF_CALLS=$((CHDEF_CALLS + 1))
|
||||
}
|
||||
|
||||
# virsh domcapabilities, as libvirt answers it: a --machine the host does not declare is an
|
||||
# error, and the <machine> element names the default machine of the architecture.
|
||||
virsh()
|
||||
{
|
||||
local arch='' machine=''
|
||||
|
||||
if [ "$VIRSH_ABSENT" -ne 0 ]; then
|
||||
echo "bash: virsh: command not found" >&2
|
||||
return 127
|
||||
fi
|
||||
[ "$1" = domcapabilities ] || return 1
|
||||
shift
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--arch) arch="$2"; shift 2 ;;
|
||||
--machine) machine="$2"; shift 2 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
done
|
||||
printf '%s\n' "$arch" >>"$VIRSH_ARCHS"
|
||||
if [ -n "$machine" ] && ! printf '%s\n' $MACHINES | grep -qx -- "$machine"; then
|
||||
echo "error: invalid argument: the machine '$machine' is not supported by emulator" >&2
|
||||
return 1
|
||||
fi
|
||||
echo '<domainCapabilities>'
|
||||
[ -z "$DEFAULT_MACHINE" ] || printf ' <machine>%s</machine>\n' "$DEFAULT_MACHINE"
|
||||
echo '</domainCapabilities>'
|
||||
}
|
||||
|
||||
# ssh records the host it was asked for and runs the command, so the virsh function above
|
||||
# answers it. Real ssh joins the command words with spaces for the remote shell.
|
||||
ssh()
|
||||
{
|
||||
local target=''
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
-o) shift 2 ;;
|
||||
-*) shift ;;
|
||||
*) target="$1"; shift; break ;;
|
||||
esac
|
||||
done
|
||||
printf '%s\n' "$target" >>"$SSH_TARGETS"
|
||||
if [ "$SSH_FAIL" -ne 0 ]; then
|
||||
echo "ssh: connect to host $target port 22: No route to host" >&2
|
||||
return 255
|
||||
fi
|
||||
"$@"
|
||||
}
|
||||
|
||||
set_vmother()
|
||||
{
|
||||
printf '%s' "$1" >"$VMOTHER"
|
||||
@@ -69,9 +139,9 @@ assert_arch()
|
||||
[ "$CHDEF_CALLS" -eq 3 ]
|
||||
}
|
||||
|
||||
@test "ppc64le: the case sets and clears pseries-rhel7.6.0" {
|
||||
assert_arch ppc64le pseries-rhel7.6.0 ''
|
||||
assert_arch ppc64le pseries-rhel7.6.0 'cpumode:host-passthrough'
|
||||
@test "ppc64le: the case sets and clears pseries" {
|
||||
assert_arch ppc64le pseries ''
|
||||
assert_arch ppc64le pseries 'cpumode:host-passthrough'
|
||||
}
|
||||
|
||||
@test "x86_64: the case sets and clears pc" {
|
||||
@@ -89,6 +159,84 @@ assert_arch()
|
||||
assert_arch aarch64 virt 'cpumode:host-passthrough'
|
||||
}
|
||||
|
||||
# The machine type comes from the vmhost, because the vmhost is what refuses the domain.
|
||||
# AlmaLinux 10 on the ppc64le vmhost declares pseries-5.0 to pseries-10.2 and no rhel machine
|
||||
# type at all, so a name from the RHEL 7.6 era is rejected at define time.
|
||||
|
||||
@test "ppc64le: the machine type is the alias the vmhost accepts" {
|
||||
MACHINES='pseries pseries-10.2 pseries-9.2'
|
||||
run vm_machine_type_for_arch ppc64le 192.0.2.10
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = 'machine:pseries' ]
|
||||
}
|
||||
|
||||
@test "ppc64le: the vmhost accepts the machine type that comes back" {
|
||||
local machine
|
||||
MACHINES='pseries pseries-10.0 pseries-10.1 pseries-10.2'
|
||||
machine="$(vm_machine_type_for_arch ppc64le 192.0.2.10)"
|
||||
[ "${machine#machine:}" != "$machine" ]
|
||||
run virsh domcapabilities --arch ppc64 --machine "${machine#machine:}"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "ppc64le: the libvirt default stands in when the vmhost refuses the alias" {
|
||||
MACHINES='pseries-10.2'
|
||||
DEFAULT_MACHINE='pseries-10.2'
|
||||
run vm_machine_type_for_arch ppc64le 192.0.2.10
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = 'machine:pseries-10.2' ]
|
||||
}
|
||||
|
||||
@test "ppc64le: the alias stands in when the vmhost cannot be reached" {
|
||||
SSH_FAIL=1
|
||||
run vm_machine_type_for_arch ppc64le 192.0.2.10
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = 'machine:pseries' ]
|
||||
}
|
||||
|
||||
@test "ppc64le: the alias stands in when the vmhost has no virsh" {
|
||||
VIRSH_ABSENT=1
|
||||
run vm_machine_type_for_arch ppc64le 192.0.2.10
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = 'machine:pseries' ]
|
||||
}
|
||||
|
||||
@test "ppc64el: the Debian architecture name gets the same machine type" {
|
||||
MACHINES='pseries pseries-10.2'
|
||||
run vm_machine_type_for_arch ppc64el 192.0.2.10
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = 'machine:pseries' ]
|
||||
}
|
||||
|
||||
@test "apply asks the vmhost of the node about architecture ppc64" {
|
||||
VMHOST=192.0.2.10
|
||||
MACHINES='pseries pseries-10.2'
|
||||
set_vmother ''
|
||||
vm_machine_type_main invalid cn1
|
||||
vm_machine_type_main apply cn1 ppc64le
|
||||
[ "$(vmother)" = 'machine:pseries' ]
|
||||
[ "$(sort -u "$SSH_TARGETS")" = '192.0.2.10' ]
|
||||
[ "$(sort -u "$VIRSH_ARCHS")" = 'ppc64' ]
|
||||
}
|
||||
|
||||
@test "apply reads the local libvirt when the node names no vmhost" {
|
||||
MACHINES='pseries pseries-10.2'
|
||||
set_vmother ''
|
||||
vm_machine_type_main invalid cn1
|
||||
vm_machine_type_main apply cn1 ppc64le
|
||||
[ "$(vmother)" = 'machine:pseries' ]
|
||||
[ ! -s "$SSH_TARGETS" ]
|
||||
[ "$(sort -u "$VIRSH_ARCHS")" = 'ppc64' ]
|
||||
}
|
||||
|
||||
@test "x86_64: the machine type stays pc, which the vmhost accepts" {
|
||||
MACHINES='pc pc-i440fx-rhel10.0.0 q35'
|
||||
DEFAULT_MACHINE='pc-i440fx-rhel10.0.0'
|
||||
run vm_machine_type_for_arch x86_64 192.0.2.10
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = 'machine:pc' ]
|
||||
}
|
||||
|
||||
# assert_round_trip <arch> <original> -- the case ends with the exact value it started with.
|
||||
assert_round_trip()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,10 @@ Homepage: https://xcat.org/
|
||||
|
||||
Package: xcat-test
|
||||
Architecture: all
|
||||
Depends: ${perl:Depends}, python3-scapy
|
||||
Depends: ${perl:Depends}, python3
|
||||
# blackboxtest needs python3. Only its DHCP steps need scapy, and dhcp.py reports a missing
|
||||
# scapy itself. A hard Depends: on scapy also installs about 255 MB of its Recommends.
|
||||
Recommends: python3-scapy
|
||||
Description: xCAT automated test tool
|
||||
Provides automated test tool and buckets to help test xCAT commands
|
||||
automatically.
|
||||
|
||||
@@ -49,6 +49,13 @@ sub current_os {
|
||||
if (-f "$root/etc/os-release") {
|
||||
my $text = _slurp("$root/etc/os-release") // '';
|
||||
return 'sles' if $text =~ /sles/;
|
||||
# openSUSE answers with the SLE family whose package set it shares: sles.pm claims
|
||||
# leap15 and xcat.org publishes the Leap dependencies under sles15. Leap's os-release
|
||||
# says ID="opensuse-leap" and carries no SLES string, and Leap ships no
|
||||
# /etc/SuSE-release, so without this arm the sub returns undef -- which matches no
|
||||
# case's os: restriction, so xcattest skips every os-restricted case and reports it as
|
||||
# "has an invalid OS option", blaming the case.
|
||||
return 'sles' if $text =~ /opensuse/i;
|
||||
if ($text =~ /^ID\s*=\s*"?openeuler"?\s*$/mi) {
|
||||
my ($version) = $text =~ /^VERSION\s*=\s*"?([^"\n]+?)"?\s*$/mi;
|
||||
my $release = _openeuler_release($version);
|
||||
|
||||
@@ -45,6 +45,15 @@ packages, execute target-architecture binaries or prove that the generated image
|
||||
|
||||
## Other native tests
|
||||
|
||||
`debian_genimage_profile_assets.t` runs the Debian genimage command in an
|
||||
isolated filesystem. It checks custom and shipped package lists,
|
||||
extra-package lists and postinstall scripts. Package tools and postinstall
|
||||
scripts stop with deliberate failures after recording the selected input.
|
||||
Only the Debian script directory is copied, with no installed xCAT libraries.
|
||||
Source-checkout copies follow symlinks. An optional directory argument checks
|
||||
a package payload without following symlinks.
|
||||
It does not install packages or build an initrd.
|
||||
|
||||
The pull-request workflow runs these packaging cases explicitly as an ordinary
|
||||
user:
|
||||
|
||||
@@ -63,6 +72,12 @@ they do not qualify package installation on every target architecture. On EL8,
|
||||
install both `python36` and `python3-rpm` to provide the interpreter and its RPM
|
||||
bindings.
|
||||
|
||||
The release case also runs source-only finalization with unsigned and signed
|
||||
binary RPMs, empty binary trees, and absent, retained and standalone aliases.
|
||||
It checks that binary files and aliases retain their bytes, modes and timestamps
|
||||
while source RPMs and metadata use a different signing key. This covers cached
|
||||
source RPMs; it does not run mock or publish a repository.
|
||||
|
||||
The Debian probe permission test has a separate pull-request CI step. It needs
|
||||
Debian build tools, BATS, bubblewrap, fakeroot, reprepro and
|
||||
libfile-slurper-perl. Run it as an ordinary user on a Debian or Ubuntu host
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use File::Path qw(make_path);
|
||||
use XCAT::Test::Lifecycle;
|
||||
|
||||
plan skip_all => 'Run as an ordinary user on Debian or Ubuntu'
|
||||
unless $^O eq 'linux' && $< != 0 && -f '/etc/debian_version';
|
||||
my %packages = map { $_ => XCAT::Test::Lifecycle::build_deb($_) }
|
||||
qw(xCAT-server xCATsn);
|
||||
|
||||
sub succeeds {
|
||||
my ($label, @result) = @_;
|
||||
is($result[0], 0, $label) or diag "$result[1]$result[2]";
|
||||
}
|
||||
|
||||
for my $mode (qw(without-proc live proc-chroot systemd-chroot)) {
|
||||
subtest $mode => sub {
|
||||
my $root = XCAT::Test::Lifecycle->new;
|
||||
$root->{live} = $mode ne 'without-proc';
|
||||
$root->{chroot} = $mode =~ /chroot/ ? 1 : 0;
|
||||
my $active = $mode eq 'live';
|
||||
{
|
||||
local $root->{deb} = $packages{'xCAT-server'};
|
||||
succeeds('unpack the server payload', $root->run('dpkg-deb', '-x', '/package.deb', '/unpacked'));
|
||||
}
|
||||
make_path(map { $root->path($_) } qw(/opt/xcat/lib /opt/xcat/sbin /opt/xcat/share/xcat /etc/apache2/conf-enabled));
|
||||
succeeds('stage packaged helpers', $root->run('cp', '-a',
|
||||
'/unpacked/opt/xcat/share/xcat/scripts', '/opt/xcat/share/xcat/'));
|
||||
succeeds('stage the packaged fast-restart command', $root->run('cp',
|
||||
'/unpacked/opt/xcat/sbin/restartxcatd', '/opt/xcat/sbin/'));
|
||||
symlink '/source/perl-xCAT', $root->path('/opt/xcat/lib/perl') or die "link Perl modules: $!";
|
||||
$root->write('/etc/os-release', $mode eq 'systemd-chroot'
|
||||
? "ID=ubuntu\nVERSION_ID=24.04\n" : "ID=ubuntu\nVERSION_ID=14.04\n");
|
||||
make_path($root->path('/run/systemd/system')) if $mode eq 'systemd-chroot';
|
||||
succeeds('install the packaged legacy init script', $root->run('cp',
|
||||
'/opt/xcat/share/xcat/scripts/xcatd', '/etc/init.d/xcatd'));
|
||||
if ($mode eq 'systemd-chroot') {
|
||||
for my $service (qw(xcatd xcat-uftp-listener)) {
|
||||
succeeds("stage the $service unit", $root->run('cp',
|
||||
"/unpacked/lib/systemd/system/$service.service", '/usr/lib/systemd/system/'));
|
||||
succeeds("enable $service in the image", $root->run('systemctl', 'enable', "$service.service"));
|
||||
ok(-l $root->path("/etc/systemd/system/multi-user.target.wants/$service.service"),
|
||||
"$service starts with an enabled link");
|
||||
}
|
||||
} else {
|
||||
succeeds('register xcatd in the image', $root->run('update-rc.d', 'xcatd', 'defaults'));
|
||||
my @enabled = glob $root->path('/etc/rc?.d/S??xcatd');
|
||||
ok(@enabled, 'xcatd starts with enabled runlevels');
|
||||
}
|
||||
$root->write('/etc/profile.d/xcat.sh',
|
||||
"export XCATROOT=/opt/xcat\nexport PATH=/opt/xcat/sbin:/usr/sbin:/usr/bin:/sbin:/bin\n");
|
||||
unlink $root->path('/usr/sbin/policy-rc.d') or die "unlink policy fixture: $!"
|
||||
if -l $root->path('/usr/sbin/policy-rc.d');
|
||||
$root->write('/usr/sbin/policy-rc.d', <<'SH', oct('755'));
|
||||
#!/bin/sh
|
||||
printf '%s\n' "$*" >> /policy-calls
|
||||
exit 101
|
||||
SH
|
||||
$root->record_command('/opt/xcat/sbin/xcatd');
|
||||
$root->record_command('/etc/init.d/apache2');
|
||||
$root->write('/etc/init.d/apache2', $root->read('/etc/init.d/apache2') . <<'SH', oct('755'));
|
||||
### BEGIN INIT INFO
|
||||
# Provides: apache2
|
||||
# Required-Start: $network
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Apache command boundary
|
||||
### END INIT INFO
|
||||
SH
|
||||
succeeds('register the Apache dependency', $root->run('update-rc.d', 'apache2', 'defaults'));
|
||||
$root->write('/calls', '');
|
||||
if ($root->{chroot}) {
|
||||
succeeds('proc is mounted inside a different process root', $root->run('/bin/sh', '-c',
|
||||
q{test -f /proc/cmdline && test "$(stat -c '%d:%i' /)" != "$(stat -c '%d:%i' /proc/1/root/.)"}));
|
||||
}
|
||||
if ($mode ne 'systemd-chroot') {
|
||||
succeeds('native service policy denies an explicit start',
|
||||
$root->run('invoke-rc.d', 'xcatd', 'start'));
|
||||
is($root->read('/calls'), '', 'the policy control cannot reach the daemon');
|
||||
like($root->read('/policy-calls'), qr/xcatd.*start/, 'the native dispatcher consulted policy');
|
||||
}
|
||||
succeeds('configure the service-node package',
|
||||
$root->deb_script($packages{'xCATsn'}, 'postinst', 'configure'));
|
||||
is($root->read('/calls'), $active
|
||||
? "xcatd <-p> </var/run/xcatd.pid>\napache2 <reload>\n" : '',
|
||||
'only the live root starts xcatd and reloads Apache');
|
||||
$root->write('/calls', '');
|
||||
succeeds('upgrade the Perl package through the real fast-restart command',
|
||||
$root->run('/bin/sh', '/source/perl-xCAT/debian/postrm', 'upgrade', '2.20.0'));
|
||||
is($root->read('/calls'), $active ? "xcatd <-p> </var/run/xcatd.pid>\n" : '',
|
||||
'only the live root reaches xcatd through restartxcatd');
|
||||
|
||||
$root->write('/sentinel.pl', <<'PERL');
|
||||
use strict;
|
||||
use warnings;
|
||||
$0 = 'xcatd: lifecycle sentinel';
|
||||
$SIG{TERM} = sub { open(my $fh, '>', '/stopped') or die $!; print {$fh} "TERM\n"; close($fh); exit 0; };
|
||||
open(my $pid, '>', '/var/run/xcatd.pid') or die $!;
|
||||
print {$pid} "$$\n";
|
||||
close($pid) or die $!;
|
||||
sleep 1 while 1;
|
||||
PERL
|
||||
local $root->{deb} = $packages{'xCAT-server'};
|
||||
succeeds('unpack the server control scripts',
|
||||
$root->run('dpkg-deb', '-e', '/package.deb', '/tmp/server-control'));
|
||||
succeeds('remove the server while an isolated process is running',
|
||||
$root->run('/bin/sh', '-c', <<'SH', 'remove', $active ? 'live' : 'image'));
|
||||
set -eu
|
||||
mkdir -p /var/run
|
||||
perl /sentinel.pl &
|
||||
daemon=$!
|
||||
trap 'kill -KILL "$daemon" 2>/dev/null || :; wait "$daemon" 2>/dev/null || :' EXIT
|
||||
attempt=0
|
||||
until test -s /var/run/xcatd.pid; do
|
||||
attempt=$((attempt + 1))
|
||||
test "$attempt" -lt 100 || exit 20
|
||||
sleep .05
|
||||
done
|
||||
/bin/sh /tmp/server-control/prerm remove
|
||||
if [ "$1" = live ]; then
|
||||
test -f /stopped
|
||||
test ! -f /var/run/xcatd.pid
|
||||
else
|
||||
kill -0 "$daemon"
|
||||
test ! -f /stopped
|
||||
test -f /var/run/xcatd.pid
|
||||
fi
|
||||
SH
|
||||
is(-e $root->path('/stopped') ? $root->read('/stopped') : '',
|
||||
$active ? "TERM\n" : '', 'only live-root removal signals the process');
|
||||
if ($mode eq 'systemd-chroot') {
|
||||
for my $service (qw(xcatd xcat-uftp-listener)) {
|
||||
ok(!-l $root->path("/etc/systemd/system/multi-user.target.wants/$service.service"),
|
||||
"removal disables $service without starting the image");
|
||||
}
|
||||
} else {
|
||||
my @links = glob $root->path('/etc/rc?.d/S??xcatd');
|
||||
is_deeply(\@links, [], 'removal still disables offline service registration');
|
||||
}
|
||||
};
|
||||
}
|
||||
done_testing;
|
||||
@@ -0,0 +1,113 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use File::Path qw(make_path);
|
||||
use Test::More;
|
||||
use XCAT::Test::File qw(repo_path);
|
||||
use XCAT::Test::ImageSandbox;
|
||||
use XCAT::Test::Process qw(run_command);
|
||||
|
||||
plan skip_all => 'Linux namespaces are required' unless $^O eq 'linux';
|
||||
die 'Run image tests as an unprivileged user' unless $>;
|
||||
|
||||
my $payload = shift @ARGV;
|
||||
my $source = $payload // repo_path('xCAT-server/share/xcat/netboot/debian');
|
||||
|
||||
sub standalone_image {
|
||||
my $box = XCAT::Test::ImageSandbox->new();
|
||||
make_path("$box->{root}/work/share/xcat/netboot");
|
||||
my @copy = ('-R', '--no-preserve=mode,ownership');
|
||||
push @copy, '-L' unless defined $payload;
|
||||
my ($rc, $output) = run_command('cp', @copy, $source, "$box->{root}/work/share/xcat/netboot/");
|
||||
die "copy Debian scripts: $output" if $rc;
|
||||
return $box;
|
||||
}
|
||||
|
||||
for my $extension (qw(pkglist otherpkgs.pkglist postinstall)) {
|
||||
for my $custom (0, 1) {
|
||||
subtest "$extension " . ($custom ? 'custom' : 'shipped') => sub {
|
||||
my $box = standalone_image();
|
||||
my $shipped = 'work/share/xcat/netboot/debian';
|
||||
my $customdir = 'install/custom/netboot/debian';
|
||||
$box->write('install/debian12.5/x86_64/Packages.gz', 'index');
|
||||
make_path("$box->{root}/install/debian12.5/x86_64/dists/bookworm");
|
||||
$box->write('work/image/rootimg/lib/modules/fixture/modules.dep', '');
|
||||
|
||||
my $file = "profile.debian12.5.x86_64.$extension";
|
||||
my $selected = $custom ? "/$customdir/profile.$extension"
|
||||
: "share/xcat/netboot/debian/$file";
|
||||
my $content = $extension eq 'postinstall'
|
||||
? "#!/bin/sh\nprintf '%s\\n' \"\$0\" \"\$@\" > /work/selected\nexit 23\n"
|
||||
: "selected-package\n";
|
||||
my $target = $box->write("$shipped/$file", $custom ? "wrong-package\n" : $content);
|
||||
chmod(0755, $target) or die "chmod: $!";
|
||||
if ($custom) {
|
||||
$target = $box->write("$customdir/profile.$extension", $content);
|
||||
chmod(0755, $target) or die "chmod: $!";
|
||||
}
|
||||
|
||||
$box->command('debootstrap', $extension eq 'pkglist' ? <<'SH' : 'exit 0');
|
||||
printf '%s\n' "$@" > /work/selected
|
||||
exit 23
|
||||
SH
|
||||
$box->command('yum', <<'SH');
|
||||
printf '%s\n' "$@" > /work/selected
|
||||
exit 23
|
||||
SH
|
||||
$box->write("$shipped/profile.pkglist", '') if $extension eq 'otherpkgs.pkglist';
|
||||
|
||||
my @args = ('-o', 'debian12.5', '-a', 'x86_64', '-p', 'profile',
|
||||
'-i', 'eth0', '-n', 'fixture', '-k', 'fixture',
|
||||
'--rootimgdir', '/work/image', '--noupdate');
|
||||
push @args, '--onlyinitrd' if $extension eq 'postinstall';
|
||||
my ($rc, $output, $error) = $box->run('env', 'PERL5LIB=', 'XCATROOT=/nonexistent',
|
||||
'perl', 'share/xcat/netboot/debian/genimage', @args);
|
||||
is($rc, 1, 'caller stops at the selected external command failure') or diag($output, $error);
|
||||
my $observed = -f "$box->{root}/work/selected" ? $box->read('work/selected') : '';
|
||||
if ($extension eq 'postinstall') {
|
||||
is($observed, "$selected\n/work/image/rootimg\ndebian12.5\nx86_64\nprofile\n",
|
||||
'postinstall gets the unchanged path spelling and arguments');
|
||||
like($output, qr/postinstall script \Q$selected\E failed/, 'caller reports the selected postinstall path');
|
||||
} elsif ($extension eq 'pkglist') {
|
||||
like($observed, qr/^--include=selected-package$/m, 'debootstrap receives the selected package');
|
||||
unlike($observed, qr/wrong-package/, 'custom directory takes precedence over a shipped exact match');
|
||||
like($output, qr/apt invocation failed/, 'caller reaches the bootstrap failure');
|
||||
} else {
|
||||
like($observed, qr/^selected-package$/m, 'extra-package installation consumes the selected list');
|
||||
unlike($observed, qr/wrong-package/, 'custom directory takes precedence over a shipped exact match');
|
||||
like($output, qr/yum invocation failed/, 'caller reaches the extra-package failure');
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
subtest 'missing package list' => sub {
|
||||
my $box = standalone_image();
|
||||
$box->write('install/debian12.5/x86_64/Packages.gz', 'index');
|
||||
make_path("$box->{root}/install/debian12.5/x86_64/dists/bookworm");
|
||||
my ($rc, $output, $error) = $box->run('env', 'PERL5LIB=', 'XCATROOT=/nonexistent',
|
||||
'perl', 'share/xcat/netboot/debian/genimage',
|
||||
'-o', 'debian12.5', '-a', 'x86_64', '-p', 'missing', '-n', 'fixture', '-i', 'eth0',
|
||||
'--rootimgdir', '/work/image');
|
||||
is($rc, 1, 'missing package list stops image creation') or diag($output, $error);
|
||||
like($output, qr/Unable to find package list for missing!/, 'original missing-list diagnostic remains');
|
||||
};
|
||||
|
||||
subtest 'standalone explicit image definition' => sub {
|
||||
my $box = standalone_image();
|
||||
my $postinstall = $box->write('work/postinstall', "#!/bin/sh\necho explicit > /work/selected\nexit 23\n");
|
||||
chmod(0755, $postinstall) or die "chmod: $!";
|
||||
$box->write('work/image/rootimg/lib/modules/fixture/modules.dep', '');
|
||||
my ($rc, $output, $error) = $box->run('env', 'PERL5LIB=', 'XCATROOT=/nonexistent',
|
||||
'perl', 'share/xcat/netboot/debian/genimage', '--onlyinitrd',
|
||||
'-o', 'debian12.5', '-a', 'x86_64', '-p', 'profile', '-n', 'fixture', '-i', 'eth0',
|
||||
'-k', 'fixture', '--postinstall', '/work/postinstall', '--rootimgdir', '/work/image', 'explicit-image');
|
||||
is($rc, 1, 'standalone command reaches the explicit postinstall failure') or diag($output, $error);
|
||||
is(-f "$box->{root}/work/selected" ? $box->read('work/selected') : '', "explicit\n",
|
||||
'an explicit image definition runs without installed xCAT modules');
|
||||
like($output, qr/postinstall script \/work\/postinstall failed/, 'failure comes from the explicit postinstall');
|
||||
};
|
||||
|
||||
done_testing();
|
||||
@@ -0,0 +1,183 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use File::Temp qw(tempdir);
|
||||
use File::Slurper qw(read_binary write_binary);
|
||||
use XCAT::Test::Lifecycle;
|
||||
|
||||
plan skip_all => 'Run as an ordinary user on Debian or Ubuntu'
|
||||
unless $^O eq 'linux' && $< != 0 && -f '/etc/debian_version';
|
||||
my $deb = XCAT::Test::Lifecycle::build_deb('xCAT');
|
||||
my $fault = tempdir(CLEANUP => 1);
|
||||
XCAT::Test::Lifecycle::checked('dpkg-deb', '-R', $deb, "$fault/package");
|
||||
write_binary("$fault/package/DEBIAN/preinst", "#!/bin/sh\nexit 17\n");
|
||||
chmod 0755, "$fault/package/DEBIAN/preinst" or die "chmod failing preinst: $!";
|
||||
XCAT::Test::Lifecycle::checked('dpkg-deb', '--root-owner-group', '-b', "$fault/package", "$fault/failure.deb");
|
||||
for my $script (qw(preinst postinst postrm)) {
|
||||
unlink "$fault/package/DEBIAN/$script" or die "remove legacy fixture script: $!"
|
||||
if -f "$fault/package/DEBIAN/$script";
|
||||
}
|
||||
my $control = read_binary("$fault/package/DEBIAN/control");
|
||||
$control =~ s/^Version:.*$/Version: 2.0/m or die 'legacy fixture has no Version';
|
||||
write_binary("$fault/package/DEBIAN/control", $control);
|
||||
XCAT::Test::Lifecycle::checked('dpkg-deb', '--root-owner-group', '-b', "$fault/package", "$fault/legacy.deb");
|
||||
|
||||
sub succeeds {
|
||||
my ($label, @result) = @_;
|
||||
is($result[0], 0, $label) or diag "$result[1]$result[2]";
|
||||
}
|
||||
|
||||
sub management_root {
|
||||
my $root = XCAT::Test::Lifecycle->new;
|
||||
$root->write('/opt/xcat/share/xcat/scripts/xHRM', '');
|
||||
$root->write('/opt/xcat/sbin/xcatconfig', <<'SH', oct('755'));
|
||||
#!/bin/sh
|
||||
printf '%s\n' "$*" >> /config-calls
|
||||
if [ -f /config-fail ]; then exit 17; fi
|
||||
SH
|
||||
$root->write('/etc/init.d/apache2', <<'SH', oct('755'));
|
||||
#!/bin/sh
|
||||
if [ -f /apache-fail ]; then exit 19; fi
|
||||
SH
|
||||
$root->write('/config-calls', '');
|
||||
return $root;
|
||||
}
|
||||
|
||||
for my $case (qw(fresh-retry fresh-reinstall fresh-abort-retry fresh-legacy-return removed-fresh-retry removed-fresh-abort removed-fresh-legacy-return upgrade-retry apache-retry cleared-tmp
|
||||
failed-remove failed-purge abort-remove abort-retry)) {
|
||||
subtest $case => sub {
|
||||
my $root = management_root();
|
||||
if ($case !~ /^fresh/) {
|
||||
succeeds('install the previous package', $root->install_deb(
|
||||
$case eq 'removed-fresh-legacy-return' ? "$fault/legacy.deb" : $deb));
|
||||
}
|
||||
if ($case =~ /^removed-fresh/) {
|
||||
succeeds('remove the configured package but keep its conffiles',
|
||||
$root->run('dpkg', '--force-depends', '--remove', 'xcat'));
|
||||
}
|
||||
my $fresh_install = $case =~ /^(?:fresh|removed-fresh)/;
|
||||
my $remove_after_failure = $case =~ /^(?:failed|abort)-(?:remove|purge)$/;
|
||||
$root->write('/config-calls', '');
|
||||
$root->write($case eq 'apache-retry' ? '/apache-fail' : '/config-fail', '')
|
||||
unless $case =~ /^abort/;
|
||||
my ($status, $out, $err) = $root->install_deb($case =~ /^abort/ ? "$fault/failure.deb" : $deb);
|
||||
isnt($status, 0, 'the injected transaction failure reaches dpkg');
|
||||
like($err, $case =~ /^abort/ ? qr/pre-installation script.*exit status 17/
|
||||
: $case eq 'apache-retry' ? qr/post-installation script.*exit status 19/
|
||||
: qr/post-installation script.*exit status 17/, 'failure comes from the intended boundary');
|
||||
is($root->read('/config-calls'), $case =~ /^abort/ ? ''
|
||||
: $fresh_install ? "-i\n" : "-u -V\n", 'the first attempt uses the intended configuration mode');
|
||||
unlink $root->path('/config-fail') if -f $root->path('/config-fail');
|
||||
unlink $root->path('/apache-fail') if -f $root->path('/apache-fail');
|
||||
if ($case eq 'fresh-abort-retry' || $case eq 'removed-fresh-abort') {
|
||||
my ($aborted, $out, $err) = $root->install_deb("$fault/failure.deb");
|
||||
isnt($aborted, 0, 'a later unpack can also fail before fresh configuration succeeds');
|
||||
like($err, qr/pre-installation script.*exit status 17/, 'the later failure reaches the intended preinst');
|
||||
}
|
||||
if ($case =~ /legacy-return$/) {
|
||||
succeeds('configure an older package without context hooks', $root->install_deb("$fault/legacy.deb"));
|
||||
}
|
||||
if ($case eq 'cleared-tmp') {
|
||||
unlink $root->path('/tmp/xCAT_upgrade.tmp') or die "clear temporary marker: $!";
|
||||
}
|
||||
$root->write('/config-calls', '');
|
||||
for my $service (qw(installservice udpservice mainservice)) {
|
||||
$root->write("/tmp/xcat/$service.pid", "$service\n");
|
||||
}
|
||||
my $fresh = $case eq 'fresh-retry' || $remove_after_failure;
|
||||
if ($remove_after_failure) {
|
||||
succeeds('remove the failed transaction', $root->run('dpkg', '--force-depends',
|
||||
$case eq 'failed-purge' ? '--purge' : '--remove', 'xcat'));
|
||||
succeeds('reinstall after removal', $root->install_deb($deb));
|
||||
} elsif ($case =~ /reinstall|abort|legacy-return|removed-fresh/) {
|
||||
succeeds('retry the package transaction', $root->install_deb($deb));
|
||||
} else {
|
||||
succeeds('retry configuration through dpkg',
|
||||
$root->run('dpkg', '--force-depends', '--configure', 'xcat'));
|
||||
}
|
||||
is($root->read('/config-calls'), $fresh ? "-i\n" : "-u -V\n",
|
||||
'configure retry retains context and a new transaction follows dpkg mode');
|
||||
for my $service (qw(installservice udpservice mainservice)) {
|
||||
my $directory = $fresh ? '/tmp/xcat' : '/var/run/xcat';
|
||||
my $file = "$directory/$service.pid";
|
||||
is(-f $root->path($file) ? $root->read($file) : undef,
|
||||
"$service\n", 'PID relocation follows the recovered mode');
|
||||
}
|
||||
ok(!-e $root->path('/var/lib/xcat/configure-state'), 'successful configuration clears persistent transaction state');
|
||||
ok(!-e $root->path('/tmp/xCAT_upgrade.tmp'), 'successful configuration clears the legacy marker');
|
||||
succeeds('the package is configured', $root->run('/bin/sh', '-c',
|
||||
q{test "$(dpkg-query -W -f='${Status}' xcat)" = 'install ok installed'}));
|
||||
};
|
||||
}
|
||||
|
||||
for my $case (qw(unpacked-reinstall unpacked-abort legacy-unpacked-reinstall upgrade-unpacked-marker-loss)) {
|
||||
subtest $case => sub {
|
||||
my $root = management_root();
|
||||
my $upgrade = $case eq 'upgrade-unpacked-marker-loss';
|
||||
succeeds('configure the package before an unpacked upgrade', $root->install_deb($deb)) if $upgrade;
|
||||
$root->write('/config-calls', '');
|
||||
local $root->{deb} = $case eq 'legacy-unpacked-reinstall' ? "$fault/legacy.deb" : $deb;
|
||||
succeeds('unpack without configuring the package',
|
||||
$root->run('dpkg', '--force-depends', '--unpack', '/package.deb'));
|
||||
is($root->read('/config-calls'), '', 'unpack does not run configuration');
|
||||
if ($upgrade) {
|
||||
unlink $root->path('/tmp/xCAT_upgrade.tmp') or die "clear temporary marker: $!";
|
||||
}
|
||||
if ($case eq 'unpacked-abort') {
|
||||
my ($status, $out, $err) = $root->install_deb("$fault/failure.deb");
|
||||
isnt($status, 0, 'an unpacked retry can fail');
|
||||
like($err, qr/pre-installation script.*exit status 17/, 'the retry fails at the intended preinst');
|
||||
}
|
||||
for my $service (qw(installservice udpservice mainservice)) {
|
||||
$root->write("/tmp/xcat/$service.pid", "$service\n");
|
||||
}
|
||||
if ($case eq 'unpacked-abort') {
|
||||
succeeds('configure after the aborted unpacked retry',
|
||||
$root->run('dpkg', '--force-depends', '--configure', 'xcat'));
|
||||
} else {
|
||||
succeeds('repeat the unpacked transaction and configure', $root->install_deb($deb));
|
||||
}
|
||||
is($root->read('/config-calls'), $upgrade ? "-u -V\n" : "-i\n",
|
||||
'never-configured packages stay fresh and unpacked upgrades retain context');
|
||||
for my $service (qw(installservice udpservice mainservice)) {
|
||||
my $directory = $upgrade ? '/var/run/xcat' : '/tmp/xcat';
|
||||
my $file = "$directory/$service.pid";
|
||||
is(-f $root->path($file) ? $root->read($file) : undef,
|
||||
"$service\n", 'PID relocation follows the pending configuration');
|
||||
}
|
||||
ok(!-e $root->path('/var/lib/xcat/configure-state'), 'configuration clears persistent transaction state');
|
||||
ok(!-e $root->path('/tmp/xCAT_upgrade.tmp'), 'configuration clears the legacy marker');
|
||||
};
|
||||
}
|
||||
|
||||
for my $parent_mode (undef, oct('750')) {
|
||||
subtest defined $parent_mode ? 'existing state parent' : 'new state parent' => sub {
|
||||
my $root = XCAT::Test::Lifecycle->new;
|
||||
if (defined $parent_mode) {
|
||||
$root->write('/var/lib/xcat/retained', 'unrelated state');
|
||||
chmod $parent_mode, $root->path('/var/lib/xcat') or die "chmod parent: $!";
|
||||
}
|
||||
local $root->{deb} = $deb;
|
||||
succeeds('unpack the management control scripts', $root->run('dpkg-deb', '-e', '/package.deb', '/tmp/control'));
|
||||
succeeds('record a fresh transaction with a normal umask', $root->run('/bin/sh', '-c',
|
||||
'umask 022; /bin/sh /tmp/control/preinst install'));
|
||||
is((stat($root->path('/var/lib/xcat')))[2] & oct('7777'), $parent_mode // oct('755'),
|
||||
'the shared parent retains its intended permissions');
|
||||
is((stat($root->path('/var/lib/xcat/configure-state')))[2] & oct('7777'), oct('700'),
|
||||
'transaction directory is private');
|
||||
is((stat($root->path('/var/lib/xcat/configure-state/context')))[2] & oct('7777'), oct('600'),
|
||||
'transaction context is private');
|
||||
$root->write('/var/lib/xcat/configure-state/context', "invalid\n");
|
||||
my ($status, $out, $err) = $root->deb_script($deb, 'postinst', 'configure', '2.0');
|
||||
isnt($status, 0, 'invalid context stops configuration');
|
||||
like($err, qr{Invalid xCAT configuration context in /var/lib/xcat/configure-state/context},
|
||||
'the diagnostic identifies the invalid file');
|
||||
$root->write('/tmp/xCAT_upgrade.tmp', '');
|
||||
succeeds('a new upgrade replaces stale context', $root->deb_script($deb, 'preinst', 'upgrade', '2.0'));
|
||||
};
|
||||
}
|
||||
|
||||
done_testing;
|
||||
@@ -46,7 +46,8 @@ for my $platform (@platforms) {
|
||||
like($requires, qr/^perl\(Digest::SHA\)$/m, "$name server s390x=$s390 requires Digest::SHA");
|
||||
next if $s390;
|
||||
my $recommends = query('xCAT-server', 'x86_64', $macro, '--recommends');
|
||||
is(scalar(grep { $_ eq 'perl-DB_File' } split /\n/, $requires), $name eq 'EL10' ? 0 : 1,
|
||||
my $db_file = $name =~ /^SLES/ ? 'perl(DB_File)' : 'perl-DB_File';
|
||||
is(scalar(grep { $_ eq $db_file } split /\n/, $requires), $name eq 'EL10' ? 0 : 1,
|
||||
"$name server hard DB_File dependency");
|
||||
is(scalar(grep { $_ eq 'perl-DB_File' } split /\n/, $recommends), $name eq 'EL10' ? 1 : 0,
|
||||
"$name server weak DB_File dependency");
|
||||
|
||||
@@ -57,7 +57,13 @@ SHELL
|
||||
my $failed = $case eq 'command-failure' || $case eq 'warning-failure';
|
||||
$root->write('/command-status', "17\n") if $failed;
|
||||
if ($case eq 'temporary-failure') {
|
||||
$root->write('/test-bin/mktemp', "#!/bin/sh\necho 'temporary allocation failed' >&2\nexit 19\n", 0755);
|
||||
$root->write('/test-bin/mktemp', <<'SH', oct('755'));
|
||||
#!/bin/sh
|
||||
case "$1" in
|
||||
/tmp/xcat-upgrade.*) echo 'temporary allocation failed' >&2; exit 19 ;;
|
||||
esac
|
||||
exec /usr/bin/mktemp "$@"
|
||||
SH
|
||||
}
|
||||
for my $service (qw(installservice udpservice mainservice)) {
|
||||
$root->write("/tmp/xcat/$service.pid", "$service pid\n");
|
||||
|
||||
@@ -48,6 +48,21 @@ my ($status, $output) = run_command($^X,
|
||||
repo_path('xCAT-test/unit/profile_customization.t'), "$root/opt/xcat");
|
||||
is($status, 0, 'packaged profiles resolve and remain independently customizable') or diag($output);
|
||||
|
||||
my $netboot = "$root/opt/xcat/share/xcat/netboot";
|
||||
for my $directory (qw(debian imgutils)) {
|
||||
my $helper = "$netboot/$directory/xCAT/ProfileUtils.pm";
|
||||
ok(-f $helper && !-l $helper, "$directory ships a regular profile helper") or next;
|
||||
is(sprintf('%04o', S_IMODE((stat($helper))[2])), '0644', "$directory helper is readable without write access for others");
|
||||
}
|
||||
for my $case (
|
||||
['unit/imgutils_standalone.t', 'imgutils'],
|
||||
['native/debian_genimage_profile_assets.t', 'debian'],
|
||||
) {
|
||||
my ($test, $directory) = @$case;
|
||||
my ($rc, $result) = run_command($^X, repo_path("xCAT-test/$test"), "$netboot/$directory");
|
||||
is($rc, 0, "packaged $directory works when copied without sibling directories") or diag($result);
|
||||
}
|
||||
|
||||
if (!-f '/etc/debian_version') {
|
||||
local $ENV{fsm} = 1;
|
||||
my $reduced = tempdir(CLEANUP => 1);
|
||||
@@ -65,7 +80,7 @@ if (!-f '/etc/debian_version') {
|
||||
my $data = 'install/rh/compute.rhels10.riscv64.pkglist';
|
||||
my $postinstall = 'netboot/rocky/compute.rocky10.riscv64.postinstall';
|
||||
chmod(oct('0666'), "$profiles/$data") == 1 or die "chmod: $!";
|
||||
for my $mask ('0022', '0002') {
|
||||
for my $mask ('0022', '0002', '0077') {
|
||||
subtest "Debian writable sources with umask $mask" => sub {
|
||||
my $previous = umask oct($mask);
|
||||
my $deb = XCAT::Test::Lifecycle::build_deb('xCAT-server', $fixture);
|
||||
@@ -80,6 +95,12 @@ if (!-f '/etc/debian_version') {
|
||||
my $payload = tempdir(CLEANUP => 1);
|
||||
XCAT::Test::Lifecycle::checked('dpkg-deb', '-x', $deb, $payload);
|
||||
check_assets($payload, '', @assets);
|
||||
for my $directory (qw(debian imgutils)) {
|
||||
my $helper = "$payload/opt/xcat/share/xcat/netboot/$directory/xCAT/ProfileUtils.pm";
|
||||
ok(-f $helper && !-l $helper, "$directory ships a regular helper with umask $mask");
|
||||
is(sprintf('%04o', S_IMODE((stat($helper))[2])), '0644',
|
||||
"$directory helper retains readable permissions with umask $mask");
|
||||
}
|
||||
for my $path (qw(install install/rh netboot netboot/rocky netboot/ubuntu/genimage)) {
|
||||
is(sprintf('%04o', S_IMODE((stat("$payload/opt/xcat/share/xcat/$path"))[2])),
|
||||
'0755', "$path remains executable without group or other write access");
|
||||
|
||||
@@ -4,7 +4,8 @@ use warnings;
|
||||
use Digest::SHA qw(sha256_hex);
|
||||
use File::Basename qw(dirname);
|
||||
use File::Copy qw(copy);
|
||||
use File::Path qw(make_path);
|
||||
use File::Find qw(find);
|
||||
use File::Path qw(make_path remove_tree);
|
||||
use File::Slurper qw(read_binary write_text);
|
||||
use File::Temp qw(tempdir);
|
||||
use FindBin;
|
||||
@@ -117,6 +118,73 @@ my $schedule = command("$root/work", 'unshare', '--user', '--map-root-user', '--
|
||||
is(scalar(grep { $_ eq "scheduled xCAT-release-$target" } split /\n/, $schedule), 1,
|
||||
'default build schedules the release package once');
|
||||
|
||||
command($root, 'gpg', '--batch', '--pinentry-mode', 'loopback', '--passphrase', '',
|
||||
'--quick-generate-key', 'Source Test <source@example.test>', 'rsa2048', 'sign', '0');
|
||||
my $source_key = command($root, 'gpg', '--armor', '--export', 'source@example.test');
|
||||
write_text("$root/source.key", $source_key);
|
||||
command($root, 'rpm', '--dbpath', "$root/source-rpmdb", '--import', "$root/source.key");
|
||||
command($root, 'gpg', '--output', "$root/source-keyring.gpg", '--export', 'source@example.test');
|
||||
for my $state (qw(empty unsigned signed no-alias alias-only)) {
|
||||
subtest "source-only with $state binaries" => sub {
|
||||
remove_tree($cached);
|
||||
make_path("$cached/SRPMS");
|
||||
copy("$root/SRPMS/$srpm", "$cached/SRPMS/$srpm") or die $!;
|
||||
if ($state ne 'empty' && $state ne 'alias-only') {
|
||||
command($root, 'cp', '-a', "$root/output/.", $cached);
|
||||
copy("$root/SRPMS/$srpm", "$cached/SRPMS/$srpm") or die $!;
|
||||
if ($state eq 'unsigned') {
|
||||
copy("$root/RPMS/noarch/$rpm", "$cached/$rpm") or die $!;
|
||||
command($root, 'createrepo_c', '--excludes', 'SRPMS/*',
|
||||
'--excludes', 'xCAT-release-latest.noarch.rpm', $cached);
|
||||
command($root, 'gpg', '--batch', '--yes', '--armor', '--detach-sign',
|
||||
'--default-key', 'package@example.test', "$cached/repodata/repomd.xml");
|
||||
}
|
||||
check_package_index($cached, $rpm, 'initial binary repository');
|
||||
}
|
||||
if ($state eq 'no-alias') {
|
||||
unlink "$cached/xCAT-release-latest.noarch.rpm" or die $!;
|
||||
} elsif ($state ne 'empty') {
|
||||
# Keep an older alias to detect replacement even when the versioned RPM still exists.
|
||||
copy("$root/RPMS/noarch/$rpm", "$cached/xCAT-release-latest.noarch.rpm") or die $!;
|
||||
chmod 0600, "$cached/xCAT-release-latest.noarch.rpm" or die $!;
|
||||
utime 1600000000, 1600000000, "$cached/xCAT-release-latest.noarch.rpm" or die $!;
|
||||
}
|
||||
my $before = binary_snapshot($cached);
|
||||
for my $attempt (0, 1, 2) {
|
||||
my $signed = $attempt > 0 ? 1 : 0;
|
||||
my $label = "$state source-only signed=$signed run=$attempt";
|
||||
my ($rc, $out, $err) = run_in("$root/work", 'unshare', '--user', '--map-root-user', '--mount',
|
||||
'bash', repo_path('xCAT-test/native/fixtures/buildrpms-namespace.sh'),
|
||||
'sh', '-c', 'trap \'gpgconf --homedir "$GNUPGHOME" --kill gpg-agent\' EXIT; "$@"',
|
||||
'source-test', $^X, 'buildrpms.pl', '--package', 'xCAT-release', '--target', $target,
|
||||
'--release', '1', '--nproc', '1', '--source-only',
|
||||
$signed ? ('--gpg-sign', '--gpg-key-name', 'source@example.test') : ());
|
||||
unless (is($rc, 0, "$label completes")) {
|
||||
diag($out, $err);
|
||||
return;
|
||||
}
|
||||
is_deeply(binary_snapshot($cached), $before,
|
||||
"$label preserves all binary file bytes, modes and mtimes");
|
||||
check_package_index("$cached/SRPMS", $srpm, $label);
|
||||
if ($signed) {
|
||||
my $signature = command($root, 'rpmkeys', '--dbpath', "$root/source-rpmdb",
|
||||
'--checksig', "$cached/SRPMS/$srpm");
|
||||
like($signature, qr/\bsignatures OK\b/, "$label verifies the source RPM signature");
|
||||
command($root, 'gpgv', '--keyring', "$root/source-keyring.gpg",
|
||||
"$cached/SRPMS/repodata/repomd.xml.asc",
|
||||
"$cached/SRPMS/repodata/repomd.xml");
|
||||
is(read_binary("$cached/SRPMS/repodata/repomd.xml.key"), $source_key,
|
||||
"$label exports the source signing key");
|
||||
isnt(read_binary("$cached/SRPMS/$srpm"), read_binary("$root/SRPMS/$srpm"),
|
||||
"$label signs the source RPM");
|
||||
} else {
|
||||
is(read_binary("$cached/SRPMS/$srpm"), read_binary("$root/SRPMS/$srpm"),
|
||||
"$label leaves the source RPM unsigned");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
unlink "$root/input/$rpm" or die $!;
|
||||
command("$root/work", $^X, 'buildrpms.pl', '--merge-core-repos',
|
||||
'--target', $target, '--release', '1', '--output-dir', "$root/output",
|
||||
@@ -156,6 +224,35 @@ sub package_stats {
|
||||
return {map { $_ => [(stat("$directory/$_"))[7, 9]] } ($rpm, "SRPMS/$srpm")};
|
||||
}
|
||||
|
||||
sub binary_snapshot {
|
||||
my ($directory) = @_;
|
||||
my %files;
|
||||
find({no_chdir => 1, wanted => sub {
|
||||
if ($File::Find::name eq "$directory/SRPMS") {
|
||||
$File::Find::prune = 1;
|
||||
return;
|
||||
}
|
||||
return unless -f $File::Find::name;
|
||||
my $relative = substr($File::Find::name, length($directory) + 1);
|
||||
$files{$relative} = [sha256_hex(read_binary($File::Find::name)), (stat($File::Find::name))[2, 9]];
|
||||
}}, $directory);
|
||||
return \%files;
|
||||
}
|
||||
|
||||
sub check_package_index {
|
||||
my ($repo, $filename, $label) = @_;
|
||||
my @indexed = primary_packages($repo);
|
||||
is(scalar(@indexed), 1, "$label indexes one $filename");
|
||||
for my $package (@indexed) {
|
||||
my ($location) = $package->findnodes('./*[local-name()="location"]');
|
||||
is($location->getAttribute('href'), $filename, "$label locates $filename");
|
||||
my ($checksum) = $package->findnodes('./*[local-name()="checksum"]');
|
||||
is($checksum->getAttribute('type'), 'sha256', "$label uses SHA256 for $filename");
|
||||
is($checksum->textContent, sha256_hex(read_binary("$repo/$filename")),
|
||||
"$label metadata matches final $filename bytes");
|
||||
}
|
||||
}
|
||||
|
||||
sub check_repository {
|
||||
my ($directory, $signed, $label, $before) = @_;
|
||||
is_deeply(package_stats($directory), $before, "$label signing preserves package sizes and mtimes")
|
||||
@@ -165,17 +262,7 @@ sub check_repository {
|
||||
is(read_binary($alias), read_binary("$directory/$rpm"), "$label alias has final RPM bytes");
|
||||
is((stat($alias))[2] & 0777, 0644, "$label alias is readable");
|
||||
for my $entry ([$directory, $rpm], ["$directory/SRPMS", $srpm]) {
|
||||
my ($repo, $filename) = @$entry;
|
||||
my @indexed = primary_packages($repo);
|
||||
is(scalar(@indexed), 1, "$label indexes one $filename");
|
||||
for my $package (@indexed) {
|
||||
my ($location) = $package->findnodes('./*[local-name()="location"]');
|
||||
is($location->getAttribute('href'), $filename, "$label locates $filename");
|
||||
my ($checksum) = $package->findnodes('./*[local-name()="checksum"]');
|
||||
is($checksum->getAttribute('type'), 'sha256', "$label uses SHA256 for $filename");
|
||||
is($checksum->textContent, sha256_hex(read_binary("$repo/$filename")),
|
||||
"$label metadata matches final $filename bytes");
|
||||
}
|
||||
check_package_index(@$entry, $label);
|
||||
}
|
||||
if ($signed) {
|
||||
for my $repo ($directory, "$directory/SRPMS") {
|
||||
|
||||
@@ -0,0 +1,333 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use lib "$FindBin::Bin/../../perl-xCAT";
|
||||
use lib "$FindBin::Bin/../../xCAT-server/lib/perl";
|
||||
use File::Path qw(make_path);
|
||||
use File::Slurper qw(read_text write_binary write_text);
|
||||
use File::Temp qw(tempdir);
|
||||
use Storable qw(dclone);
|
||||
use Test::More;
|
||||
use XCAT::Test::File qw(repo_path);
|
||||
|
||||
my $root = tempdir(CLEANUP => 1);
|
||||
my $tftp = "$root/tftp";
|
||||
$ENV{XCATROOT} = repo_path('xCAT-server');
|
||||
$ENV{XCATCFG} = "$root/config";
|
||||
make_path($ENV{XCATCFG}, $tftp);
|
||||
write_text("$tftp/pxelinux.0", 'loader');
|
||||
require xCAT::TableUtils;
|
||||
{
|
||||
no warnings qw(redefine once);
|
||||
local *xCAT::TableUtils::getTftpDir = sub { return $tftp; };
|
||||
for my $plugin (qw(pxe xnba ipxe boottarget)) {
|
||||
require(repo_path("xCAT-server/lib/xcat/plugins/$plugin.pm"));
|
||||
}
|
||||
}
|
||||
|
||||
my (%rows, %written, %kernels);
|
||||
my @responses;
|
||||
sub render {
|
||||
my ($method, $input, %options) = @_;
|
||||
my @nodes = @{ $options{nodes} || ['192.0.2.10'] };
|
||||
my $node = $nodes[0];
|
||||
%written = ();
|
||||
@responses = ();
|
||||
%kernels = ($node => {
|
||||
kernel => $options{kernel} || 'vmlinuz', initrd => 'initrd', kcmdline => 'quiet',
|
||||
addkcmdline => $input,
|
||||
});
|
||||
%rows = (
|
||||
noderes => {$node => {tftpdir => $tftp}},
|
||||
chain => {$node => {currstate => 'install'}},
|
||||
nodetype => {$node => {os => 'boottarget', profile => 'custom',
|
||||
provmethod => $options{image} ? 'image' : 'install'}},
|
||||
mac => {}, iscsi => {}, bootparams => {}, nodehm => {},
|
||||
boottarget => {custom => {kernel => 'vmlinuz', initrd => 'initrd', kcmdline => $input}},
|
||||
linuximage => {image => {addkcmdline => $options{image}, boottarget => $options{boottarget}}},
|
||||
hosts => {$node => {
|
||||
ip => $node, empty => '', zero => '0',
|
||||
nested => '#NODEATTRIB:hosts:ip#',
|
||||
table => '#TABLE:hosts:THISNODE:ip#',
|
||||
special => 'a$1\\b&c',
|
||||
selfref => '#NODEATTRIB:hosts:selfref#',
|
||||
tableself => '#TABLE:hosts:THISNODE:tableself#',
|
||||
cycle_a => '#NODEATTRIB:hosts:cycle_b#',
|
||||
cycle_b => '#NODEATTRIB:hosts:cycle_a#',
|
||||
table_a => '#TABLE:hosts:THISNODE:table_b#',
|
||||
table_b => '#TABLE:hosts:THISNODE:table_a#',
|
||||
growing => 'x#NODEATTRIB:hosts:growing#',
|
||||
tablegrow => 'x#TABLE:hosts:THISNODE:tablegrow#',
|
||||
(map { ("depth$_" => $_ == 16 ? $node : '#NODEATTRIB:hosts:depth' . ($_ + 1) . '#') } 0 .. 16),
|
||||
(map { ("tabledepth$_" => $_ == 16 ? $node : '#TABLE:hosts:THISNODE:tabledepth' . ($_ + 1) . '#') } 0 .. 16),
|
||||
}},
|
||||
);
|
||||
for my $other (@nodes) {
|
||||
next if $other eq $node;
|
||||
$kernels{$other} = dclone($kernels{$node});
|
||||
for my $table (qw(noderes chain nodetype hosts)) {
|
||||
$rows{$table}{$other} = dclone($rows{$table}{$node});
|
||||
}
|
||||
$rows{hosts}{$other}{ip} = $other;
|
||||
}
|
||||
if ($options{bad_node}) {
|
||||
my $bad = $options{bad_node};
|
||||
$kernels{$bad}{addkcmdline} = $options{bad_input};
|
||||
$rows{nodetype}{$bad}{profile} = 'bad';
|
||||
$rows{boottarget}{bad} = {kernel => 'vmlinuz', initrd => 'initrd', kcmdline => $options{bad_input}};
|
||||
}
|
||||
no warnings qw(redefine once);
|
||||
local @ARGV;
|
||||
local $::myxcatname = 'mn.example';
|
||||
local *xCAT::Table::new = sub {
|
||||
my ($class, $table) = @_;
|
||||
die "Unexpected table $table" unless exists $rows{$table};
|
||||
return bless {table => $table}, 'Local::TemplateTable';
|
||||
};
|
||||
local *xCAT::TableUtils::getTftpDir = sub { return $tftp; };
|
||||
local *xCAT::TableUtils::getInstallDir = sub { return "$root/install"; };
|
||||
local *xCAT::TableUtils::get_site_attribute = sub {
|
||||
return ('n') if $_[1] eq 'dhcpsetup';
|
||||
return () if $_[1] eq 'httpport';
|
||||
die "Unexpected site attribute $_[1]";
|
||||
};
|
||||
local *xCAT::NetworkUtils::determinehostname = sub { return ('mn.example'); };
|
||||
local *xCAT::NetworkUtils::checkNodeIPaddress = sub { return {ip => $_[1]}; };
|
||||
local *xCAT::MsgUtils::trace = sub { return; };
|
||||
my $callback = sub {
|
||||
die "too many callback responses\n" if @responses == 5;
|
||||
push @responses, dclone($_[0]);
|
||||
};
|
||||
my $completed = eval {
|
||||
local $SIG{ALRM} = sub { die "template expansion timed out\n"; };
|
||||
alarm(2);
|
||||
"xCAT_plugin::$method"->can('process_request')->(
|
||||
{command => [$method eq 'boottarget' ? 'mknetboot' : 'nodeset'],
|
||||
node => \@nodes, arg => ['install']},
|
||||
$callback,
|
||||
sub {
|
||||
my ($request, $reply) = @_;
|
||||
if ($request->{command}[0] eq 'setdestiny') {
|
||||
$request->{bootparams}{$_} = [$kernels{$_}] for @nodes;
|
||||
$reply->({node => [{name => [$node], _addkcmdlinehandled => 1}]})
|
||||
if $options{handled};
|
||||
} elsif ($request->{command}[0] !~ /\A(?:runbeginpre|runendpre)\z/) {
|
||||
die "Unexpected command $request->{command}[0]";
|
||||
}
|
||||
},
|
||||
);
|
||||
alarm(0);
|
||||
1;
|
||||
};
|
||||
my $exception = $@;
|
||||
alarm(0);
|
||||
return $exception if $options{bad_node};
|
||||
die $exception unless $completed;
|
||||
is_deeply(\@responses, [], "$method reports no errors");
|
||||
return $written{$node}{kcmdline} if $method eq 'boottarget';
|
||||
return $kernels{$node}{kcmdline};
|
||||
}
|
||||
|
||||
my @cases = (
|
||||
['undefined', undef, undef, 'quiet'],
|
||||
['empty', '', '', 'quiet'],
|
||||
['zero', '0', '0', 'quiet'],
|
||||
['literal', 'console=ttyS0', 'console=ttyS0', 'quiet console=ttyS0 '],
|
||||
['node attribute', 'ip=#NODEATTRIB:hosts:ip#', 'ip=192.0.2.10', 'quiet ip=192.0.2.10 '],
|
||||
['table key', 'ip=#TABLE:hosts:THISNODE:ip#', 'ip=192.0.2.10', 'quiet ip=192.0.2.10 '],
|
||||
['dollar key', 'ip=#TABLE:hosts:$NODE:ip#', 'ip=192.0.2.10', 'quiet ip=192.0.2.10 '],
|
||||
['node selector', '#TABLE:hosts:node=$NODE:ip#', '192.0.2.10', 'quiet 192.0.2.10 '],
|
||||
['mixed order', '#TABLE:hosts:THISNODE:ip#,#NODEATTRIB:hosts:zero#,#TABLE:hosts:$NODE:ip#', '192.0.2.10,0,192.0.2.10', 'quiet 192.0.2.10,0,192.0.2.10 '],
|
||||
['missing', 'a=#NODEATTRIB:hosts:missing# b=#TABLE:hosts:THISNODE:missing#', 'a= b=', 'quiet a= b= '],
|
||||
['empty and zero', 'a=#NODEATTRIB:hosts:empty# b=#NODEATTRIB:hosts:zero#', 'a= b=0', 'quiet a= b=0 '],
|
||||
['repeat', '#NODEATTRIB:hosts:ip#,#NODEATTRIB:hosts:ip#', '192.0.2.10,192.0.2.10', 'quiet 192.0.2.10,192.0.2.10 '],
|
||||
['nested node', '#NODEATTRIB:hosts:nested#', '192.0.2.10', 'quiet 192.0.2.10 '],
|
||||
['node replacement limit', '#NODEATTRIB:hosts:depth1#', '192.0.2.10', 'quiet 192.0.2.10 '],
|
||||
['table replacement limit', '#TABLE:hosts:THISNODE:tabledepth1#', '192.0.2.10', 'quiet 192.0.2.10 '],
|
||||
['shared node budget', '#NODEATTRIB:hosts:depth0#,#NODEATTRIB:hosts:ip#',
|
||||
'192.0.2.10,192.0.2.10', 'quiet 192.0.2.10,192.0.2.10 '],
|
||||
['shared table budget', '#TABLE:hosts:THISNODE:tabledepth0#,#TABLE:hosts:THISNODE:ip#',
|
||||
'192.0.2.10,192.0.2.10', 'quiet 192.0.2.10,192.0.2.10 '],
|
||||
['many independent nodes', join(',', ('#NODEATTRIB:hosts:ip#') x 20),
|
||||
join(',', ('192.0.2.10') x 20), 'quiet ' . join(',', ('192.0.2.10') x 20) . ' '],
|
||||
['many independent tables', join(',', ('#TABLE:hosts:THISNODE:ip#') x 20),
|
||||
join(',', ('192.0.2.10') x 20), 'quiet ' . join(',', ('192.0.2.10') x 20) . ' '],
|
||||
['node then table', '#NODEATTRIB:hosts:table#', '192.0.2.10', 'quiet 192.0.2.10 '],
|
||||
['table recursion', '#TABLE:hosts:THISNODE:table#', '192.0.2.10', 'quiet 192.0.2.10 '],
|
||||
['table does not restart node pass', '#TABLE:hosts:THISNODE:nested#', '#NODEATTRIB:hosts:ip#', 'quiet #NODEATTRIB:hosts:ip# '],
|
||||
['literal replacement', '#NODEATTRIB:hosts:special#', 'a$1\\b&c', 'quiet a$1\\b&c '],
|
||||
['persistent', 'R::keep=1 marker=#NODEATTRIB:hosts:ip#', 'R::keep=1 marker=192.0.2.10', 'quiet marker=192.0.2.10 '],
|
||||
['persistent only', 'R::keep=1', 'R::keep=1', 'quiet '],
|
||||
['partial token', '#NODEATTRIB:hosts:ip', '#NODEATTRIB:hosts:ip', 'quiet #NODEATTRIB:hosts:ip '],
|
||||
);
|
||||
|
||||
for my $method (qw(pxe xnba ipxe boottarget)) {
|
||||
for my $case (@cases) {
|
||||
my ($name, $input, $target, $netboot) = @$case;
|
||||
subtest "$method $name" => sub {
|
||||
my $expected = $method eq 'boottarget' ? $target : $netboot;
|
||||
is(render($method, $input), $expected, 'expansion keeps the caller contract');
|
||||
if ($method eq 'pxe') {
|
||||
is(read_text("$tftp/pxelinux.cfg/192.0.2.10"),
|
||||
"#install\nDEFAULT xCAT\nLABEL xCAT\n KERNEL vmlinuz\n APPEND initrd=initrd $expected\n IPAPPEND 2\n",
|
||||
'PXE writes the complete expected configuration');
|
||||
} elsif ($method ne 'boottarget') {
|
||||
like(read_text("$tftp/xcat/$method/nodes/192.0.2.10"),
|
||||
qr/^imgargs kernel \Q$expected\E BOOTIF=01-\$\{netX\/mac:hexhyp\}$/m,
|
||||
'the selected method writes the expanded BIOS arguments');
|
||||
like(read_text("$tftp/xcat/$method/nodes/192.0.2.10.elilo"),
|
||||
qr/append="\Q$expected\E BOOTIF=%B"/,
|
||||
'the selected method writes the expanded UEFI fallback arguments');
|
||||
} else {
|
||||
is_deeply($written{'192.0.2.10'},
|
||||
{kernel => 'vmlinuz', initrd => 'initrd', kcmdline => $expected},
|
||||
'boottarget persists the kernel, initrd and expanded arguments');
|
||||
}
|
||||
};
|
||||
}
|
||||
next if $method eq 'boottarget';
|
||||
subtest "$method image arguments" => sub {
|
||||
is(render($method, 'node=#NODEATTRIB:hosts:ip#', image => 'R::keep=1 image=#TABLE:hosts:$NODE:ip#'),
|
||||
'quiet node=192.0.2.10 image=192.0.2.10 ', 'node and image arguments retain their order');
|
||||
};
|
||||
subtest "$method handled arguments" => sub {
|
||||
is(render($method, '#TABLE:hosts:unsupported:ip#', handled => 1),
|
||||
'quiet', 'a prior owner can suppress mini-template expansion');
|
||||
};
|
||||
next if $method eq 'pxe';
|
||||
subtest "$method direct UEFI" => sub {
|
||||
write_binary("$tftp/modern-kernel", "\0" x 64 . pack('H*', '504500006486') . "\0" x 440);
|
||||
is(render($method, 'marker=#NODEATTRIB:hosts:ip#', kernel => 'modern-kernel'), 'quiet marker=192.0.2.10 ',
|
||||
'a modern kernel gets the same expansion');
|
||||
like(read_text("$tftp/xcat/$method/nodes/192.0.2.10.uefi"),
|
||||
qr/^imgargs kernel quiet marker=192\.0\.2\.10 BOOTIF=01-\$\{netX\/mac:hexhyp\} initrd=initrd$/m,
|
||||
'direct UEFI boot receives the expanded arguments');
|
||||
unlink("$tftp/modern-kernel") or die "unlink kernel: $!";
|
||||
};
|
||||
}
|
||||
|
||||
my @failures;
|
||||
for my $position (0, 1, 2) {
|
||||
for my $existing (0, 1) {
|
||||
push @failures, [$position, $existing, 'unsupported key',
|
||||
'before=#NODEATTRIB:hosts:ip# #TABLE:hosts:unsupported:ip# #TABLE:hosts:other:ip#',
|
||||
'Table key of unsupported not yet supported by boottarget mini-template'];
|
||||
}
|
||||
}
|
||||
for my $case (
|
||||
['node self-reference', '#NODEATTRIB:hosts:selfref#'],
|
||||
['table self-reference', '#TABLE:hosts:THISNODE:tableself#'],
|
||||
['node cycle', '#NODEATTRIB:hosts:cycle_a#'],
|
||||
['table cycle', '#TABLE:hosts:THISNODE:table_a#'],
|
||||
['growing node', '#NODEATTRIB:hosts:growing#'],
|
||||
['growing table', '#TABLE:hosts:THISNODE:tablegrow#'],
|
||||
['node over limit', '#NODEATTRIB:hosts:depth0#', '#NODEATTRIB:hosts:depth16#'],
|
||||
['table over limit', '#TABLE:hosts:THISNODE:tabledepth0#', '#TABLE:hosts:THISNODE:tabledepth16#'],
|
||||
['node budget stays separate', '#NODEATTRIB:hosts:depth0#,#TABLE:hosts:THISNODE:ip#',
|
||||
'#NODEATTRIB:hosts:depth16#'],
|
||||
['table budget stays separate', '#NODEATTRIB:hosts:ip#,#TABLE:hosts:THISNODE:tabledepth0#',
|
||||
'#TABLE:hosts:THISNODE:tabledepth16#'],
|
||||
) {
|
||||
my ($name, $input, $token) = @$case;
|
||||
$token //= $input;
|
||||
push @failures, [1, 1, $name, $input,
|
||||
"Node template expansion exceeded its replacement limit at $token"];
|
||||
}
|
||||
|
||||
for my $method (qw(pxe xnba ipxe boottarget)) {
|
||||
for my $failure (@failures) {
|
||||
my ($position, $existing, $name, $input, $message) = @$failure;
|
||||
subtest "$method $name at $position existing=$existing" => sub {
|
||||
my @nodes = qw(192.0.2.20 192.0.2.21 192.0.2.22);
|
||||
my $bad = $nodes[$position];
|
||||
for my $good (grep { $_ ne $bad } @nodes) {
|
||||
next if $method eq 'boottarget';
|
||||
my $file = $method eq 'pxe' ? "$tftp/pxelinux.cfg/$good"
|
||||
: "$tftp/xcat/$method/nodes/$good";
|
||||
write_text($file, "previous boot configuration\n");
|
||||
}
|
||||
my @files = $method eq 'pxe' ? ("$tftp/pxelinux.cfg/$bad")
|
||||
: $method eq 'boottarget' ? ()
|
||||
: map { "$tftp/xcat/$method/nodes/$bad$_" } ('', '.pxelinux', '.uefi', '.elilo');
|
||||
for my $file (@files) {
|
||||
if ($existing) {
|
||||
write_text($file, "previous boot configuration\n");
|
||||
} else {
|
||||
unlink($file) or die "unlink $file: $!" if -e $file;
|
||||
}
|
||||
}
|
||||
my $link;
|
||||
if ($method eq 'pxe') {
|
||||
$link = "$tftp/pxelinux.cfg/" . sprintf('%02X%02X%02X%02X', split(/\./, $bad));
|
||||
unlink($link) or die "unlink $link: $!" if -e $link || -l $link;
|
||||
symlink($bad, $link) or die "symlink $link: $!" if $existing;
|
||||
}
|
||||
my $exception = render($method, 'marker=#NODEATTRIB:hosts:ip#',
|
||||
nodes => \@nodes, bad_node => $bad,
|
||||
bad_input => $input);
|
||||
is($exception, '', 'request completes before the timeout');
|
||||
my @expected = ({node => [{name => [$bad], errorcode => [1], error => [$message]}]});
|
||||
push @expected, {errorcode => [1], error =>
|
||||
['Failed to generate xnba configurations for some node(s) on mn.example. Check xCAT log file for more details.']}
|
||||
if $method eq 'xnba' || $method eq 'ipxe';
|
||||
is_deeply(\@responses, \@expected,
|
||||
'responses contain the node error and only the caller-required summary');
|
||||
for my $file (@files) {
|
||||
if ($existing) {
|
||||
ok(-f $file, 'failure keeps the existing artifact') or next;
|
||||
is(read_text($file), "previous boot configuration\n", 'failure preserves the existing artifact');
|
||||
} else {
|
||||
ok(!-e $file, 'failure creates no artifact');
|
||||
}
|
||||
}
|
||||
if ($link) {
|
||||
if ($existing) {
|
||||
ok(-l $link, 'failure preserves the existing boot symlink');
|
||||
is(readlink($link), $bad, 'failure preserves the boot symlink target');
|
||||
} else {
|
||||
ok(!-e $link && !-l $link, 'failure creates no boot symlink');
|
||||
}
|
||||
}
|
||||
if ($method eq 'boottarget') {
|
||||
ok(!exists($written{$bad}), 'failure does not update bootparams');
|
||||
} else {
|
||||
is($kernels{$bad}{kcmdline}, 'quiet', 'failure does not append a partial expansion');
|
||||
}
|
||||
for my $good (grep { $_ ne $bad } @nodes) {
|
||||
if ($method eq 'boottarget') {
|
||||
is($written{$good}{kcmdline}, "marker=$good", 'other nodes still update bootparams');
|
||||
} else {
|
||||
my $file = $method eq 'pxe' ? "$tftp/pxelinux.cfg/$good"
|
||||
: "$tftp/xcat/$method/nodes/$good";
|
||||
like(read_text($file), qr/marker=\Q$good\E /, 'other nodes still get boot artifacts');
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
done_testing();
|
||||
|
||||
package Local::TemplateTable;
|
||||
sub getNodesAttribs {
|
||||
my ($self, $nodes) = @_;
|
||||
return {map { $_ => [$rows{$self->{table}}{$_} || {}] } @$nodes};
|
||||
}
|
||||
sub getNodeAttribs {
|
||||
my ($self, $node) = @_;
|
||||
return $rows{$self->{table}}{$node} || {};
|
||||
}
|
||||
sub getAttribs {
|
||||
my ($self, $key) = @_;
|
||||
my ($value) = values %$key;
|
||||
return $rows{$self->{table}}{$value};
|
||||
}
|
||||
sub setNodeAttribs {
|
||||
my ($self, $node, $attributes) = @_;
|
||||
die "Unexpected write to $self->{table}" unless $self->{table} eq 'bootparams';
|
||||
$written{$node} = Storable::dclone($attributes);
|
||||
return;
|
||||
}
|
||||
sub close { return; }
|
||||
@@ -0,0 +1,20 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use JSON::PP qw(encode_json);
|
||||
|
||||
BEGIN {
|
||||
*CORE::GLOBAL::exit = sub { die "genimage exit $_[0]\n" };
|
||||
}
|
||||
|
||||
my ($script, $osver, $profile, $arch, $base, $ext) = @ARGV;
|
||||
@ARGV = ('-o', $osver, '-p', $profile, '-a', $arch);
|
||||
my $startup;
|
||||
{
|
||||
local $0 = $script;
|
||||
local *STDOUT;
|
||||
open STDOUT, '>', \$startup or die "capture stdout: $!";
|
||||
do $script;
|
||||
die "genimage did not stop at argument validation: $@ $!\n"
|
||||
unless $@ eq "genimage exit 1\n";
|
||||
}
|
||||
print encode_json([main::get_profile_def_filename($base, $ext)]);
|
||||
@@ -19,6 +19,12 @@ use XCAT::GenesisPayload qw(module_commands missing_paths check_payload);
|
||||
my $OPENSSH_99 = "OpenSSH_9.9p1\n/usr/libexec/openssh/sshd-session\n";
|
||||
my $OPENSSH_80 = "OpenSSH_8.0p1\n";
|
||||
|
||||
# The two awk programs name themselves in their own binary.
|
||||
my $GAWK = "GNU Awk 5.2.2, API 3.2\n";
|
||||
my $MAWK = "mawk 1.3.4 20240123\n";
|
||||
my $AWK_NOT_GAWK =
|
||||
'usr/bin/awk is not gawk (allowcred.awk opens its TCP stream with the gawk /inet/ coprocess)';
|
||||
|
||||
# A complete payload: OpenSSH 9.9 sshd plus its session helper, tmux plus a UTF-8 locale.
|
||||
my @COMPLETE = qw(
|
||||
usr/sbin/sshd usr/libexec/openssh/sshd-session usr/bin/tmux
|
||||
@@ -72,6 +78,18 @@ is_deeply([ missing_paths(all_but('usr/libexec/openssh/sshd-session'), sshd => $
|
||||
is_deeply([ missing_paths(all_but('usr/lib/locale/C.utf8/LC_CTYPE', 'usr/bin/tmux'), sshd => $OPENSSH_99) ],
|
||||
[], 'a payload without tmux needs no locale');
|
||||
|
||||
# allowcred.awk, minixcatd.awk and udpcat.awk open a TCP stream with the gawk |& coprocess
|
||||
# and the /inet/ special file. mawk rejects both at parse time, so the node asks for no
|
||||
# credential and reports no flag, and nothing in the build says why.
|
||||
is_deeply([ missing_paths(carries(@COMPLETE), sshd => $OPENSSH_99, awk => $GAWK) ],
|
||||
[], 'a payload whose awk is gawk passes');
|
||||
is_deeply([ missing_paths(carries(@COMPLETE), sshd => $OPENSSH_99, awk => $MAWK) ],
|
||||
[$AWK_NOT_GAWK], 'a payload whose awk is mawk fails and says so');
|
||||
|
||||
# An awk with no name in it is not gawk either. busybox awk has no /inet/ support.
|
||||
is_deeply([ missing_paths(carries(@COMPLETE), sshd => $OPENSSH_99, awk => "busybox\n") ],
|
||||
[$AWK_NOT_GAWK], 'an awk that is neither gawk nor mawk fails too');
|
||||
|
||||
# dracut_install reports a missing binary and returns, so every name the dracut module
|
||||
# installs has to be checked against the payload. A name starting with "/" is installed at
|
||||
# that same path; the rest are commands.
|
||||
@@ -149,6 +167,20 @@ is_deeply([ check_payload($nohelper) ],
|
||||
[ 1, "verify-genesis-payload: $nohelper is incomplete:\n"
|
||||
. " usr/libexec/openssh/sshd-session (this sshd execs it for every connection)\n" ],
|
||||
'the command line reads usr/sbin/sshd to decide on sshd-session');
|
||||
|
||||
my $mawk = payload_tree(@COMPLETE);
|
||||
write_text("$mawk/usr/sbin/sshd", $OPENSSH_99);
|
||||
write_text("$mawk/usr/bin/awk", $MAWK);
|
||||
is_deeply([ check_payload($mawk) ],
|
||||
[ 1, "verify-genesis-payload: $mawk is incomplete:\n $AWK_NOT_GAWK\n" ],
|
||||
'the command line reads usr/bin/awk back out of the payload');
|
||||
|
||||
my $gawk = payload_tree(@COMPLETE);
|
||||
write_text("$gawk/usr/sbin/sshd", $OPENSSH_99);
|
||||
write_text("$gawk/usr/bin/awk", $GAWK);
|
||||
is_deeply([ check_payload($gawk) ],
|
||||
[ 0, "verify-genesis-payload: $gawk is complete\n" ],
|
||||
'a payload whose awk is gawk passes on the command line');
|
||||
is_deeply([ check_payload('--commands-from', $module, $nodhcp) ],
|
||||
[ 0, "verify-genesis-payload: $nodhcp is complete\n" ],
|
||||
'--commands-from does not require a name installed under a condition');
|
||||
|
||||
@@ -31,6 +31,10 @@ my %PACKAGES_FOR = (
|
||||
dhclient => ['isc-dhcp-client'],
|
||||
ifenslave => ['ifenslave'],
|
||||
hwclock => [ 'util-linux-extra', 'util-linux' ],
|
||||
|
||||
# mawk is the awk alternative on a Debian or Ubuntu root, and it rejects the gawk
|
||||
# /inet/ coprocess at parse time, so the module names gawk rather than awk.
|
||||
gawk => ['gawk'],
|
||||
);
|
||||
|
||||
# A release carries exactly the names in its list.
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
#!/usr/bin/env perl
|
||||
# getpostscript correlates a node-initiated request to a node. When the reverse lookup of the
|
||||
# peer socket fails, the CN of the validated client certificate is the only other identity.
|
||||
# A password or token login, and the request's own node attribute, must never select a node.
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FindBin;
|
||||
use File::Spec;
|
||||
use Test::More;
|
||||
use lib File::Spec->catdir($FindBin::Bin, '..', '..', 'perl-xCAT'),
|
||||
File::Spec->catdir($FindBin::Bin, '..', '..', 'xCAT-server', 'lib', 'perl');
|
||||
use xCAT::DiscoveryUtils;
|
||||
|
||||
# Ninety xCAT modules put "$::XCATROOT/lib/perl" in @INC, so an installed product can shadow
|
||||
# the checkout. Say which file answered.
|
||||
my $under_test = $INC{'xCAT/DiscoveryUtils.pm'} // '';
|
||||
ok(length $under_test, 'xCAT::DiscoveryUtils was loaded at all');
|
||||
unlike($under_test, qr{^/opt/xcat/}, "the module under test is this checkout's, not an installed one ($under_test)");
|
||||
can_ok('xCAT::DiscoveryUtils', qw(request_client_names request_client_node client_certificate_name));
|
||||
|
||||
sub names_for { return xCAT::DiscoveryUtils::request_client_names($_[0]) }
|
||||
|
||||
# --- client_certificate_name: what xcatd records as _xcat_certname -------------------------
|
||||
|
||||
is(xCAT::DiscoveryUtils::client_certificate_name('xcat59-cn', 'xcat59-cn'), 'xcat59-cn',
|
||||
'a request authenticated by its certificate records the certificate CN');
|
||||
is(xCAT::DiscoveryUtils::client_certificate_name(undef, 'compute'), undef,
|
||||
'a token or password login without a certificate records no certificate name');
|
||||
is(xCAT::DiscoveryUtils::client_certificate_name('root', 'compute'), undef,
|
||||
'becomeuser to another account records no certificate name');
|
||||
is(xCAT::DiscoveryUtils::client_certificate_name('', ''), undef,
|
||||
'an empty certificate CN is not a name');
|
||||
|
||||
# --- request_client_names: the names logged and tried -------------------------------------
|
||||
|
||||
is_deeply([ names_for({ _xcat_clienthost => ['xcat58-cn'],
|
||||
_xcat_clientfqdn => ['xcat58-cn.xcat58.lab'],
|
||||
_xcat_certname => ['xcat58-cn'] }) ],
|
||||
[ 'xcat58-cn', 'xcat58-cn.xcat58.lab' ],
|
||||
'the resolved peer host comes first, and the certificate name adds no duplicate');
|
||||
|
||||
is_deeply([ names_for({ _xcat_clienthost => [''],
|
||||
_xcat_clientfqdn => [''],
|
||||
_xcat_certname => ['xcat59-cn'] }) ],
|
||||
[ 'xcat59-cn' ],
|
||||
'an empty peer host is skipped and the certificate name is offered instead');
|
||||
|
||||
is_deeply([ names_for({ _xcat_clientfqdn => ['xcat59-cn.xcat59.lab'] }) ],
|
||||
[ 'xcat59-cn.xcat59.lab' ],
|
||||
'the fully qualified peer name is offered when the short name is missing');
|
||||
|
||||
is_deeply([ names_for({ _xcat_clienthost => [''], _xcat_authname => ['compute'] }) ], [],
|
||||
'the authenticated name of a password or token login is never offered');
|
||||
|
||||
for my $request ({ node => ['xcat59-cn'] },
|
||||
{ node => ['xcat59-cn'], _xcat_clienthost => [''] },
|
||||
{ node => ['some-other-node'], _xcat_certname => ['xcat59-cn'] }) {
|
||||
my @got = names_for($request);
|
||||
ok(!grep({ $_ eq ($request->{node}->[0]) } @got),
|
||||
"the request's own node attribute is never offered as an identity ("
|
||||
. join(',', @got) . ')');
|
||||
}
|
||||
|
||||
is_deeply([ names_for({}) ], [], 'a request with no identity at all offers no name');
|
||||
is_deeply([ names_for(undef) ], [], 'an undefined request offers no name');
|
||||
is_deeply([ names_for('string') ], [], 'a request that is not a hash offers no name');
|
||||
my @unwrapped = eval { names_for({ _xcat_clienthost => 'xcat59-cn' }) };
|
||||
is($@, '', 'a value xcatd did not wrap in an array ref does not kill the lookup');
|
||||
is_deeply(\@unwrapped, [], 'and is ignored rather than dereferenced');
|
||||
|
||||
# --- request_client_node: the node selected -------------------------------------------------
|
||||
|
||||
# node01 and node02 are nodes, compute is a group of both.
|
||||
my %groups = (compute => [qw(node01 node02)]);
|
||||
my %nodes = map { $_ => 1 } qw(node01 node02);
|
||||
sub expand {
|
||||
my ($range) = @_;
|
||||
return @{ $groups{$range} } if $groups{$range};
|
||||
return ('node01', 'node02') if $range eq 'node0[1-2]';
|
||||
return $nodes{$range} ? ($range) : ();
|
||||
}
|
||||
sub node_for { return xCAT::DiscoveryUtils::request_client_node($_[0], \&expand) }
|
||||
|
||||
is(node_for({ _xcat_clienthost => ['node01'] }), 'node01', 'a resolved peer host selects its node');
|
||||
is(node_for({ _xcat_clienthost => [''], _xcat_certname => ['node02'] }), 'node02',
|
||||
'a certificate CN that names exactly one node selects it');
|
||||
is(node_for({ _xcat_clienthost => [''], _xcat_certname => ['compute'] }), undef,
|
||||
'a certificate CN that names a group selects no node');
|
||||
is(node_for({ _xcat_clienthost => [''], _xcat_certname => ['node0[1-2]'] }), undef,
|
||||
'a certificate CN that is a node range selects no node');
|
||||
is(node_for({ _xcat_clienthost => [''], _xcat_certname => ['nosuchnode'] }), undef,
|
||||
'a certificate CN that is not a node selects no node');
|
||||
is(node_for({ _xcat_clienthost => [''], _xcat_authname => ['node01'] }), undef,
|
||||
'the authenticated name alone selects no node');
|
||||
is(node_for({ _xcat_clienthost => ['node01'], _xcat_certname => ['node02'] }), 'node01',
|
||||
'the resolved peer host wins over the certificate CN');
|
||||
|
||||
# --- the plugin -----------------------------------------------------------------------------
|
||||
|
||||
require File::Spec->catfile($FindBin::Bin, '..', '..', 'xCAT-server', 'lib', 'xcat', 'plugins', 'getpostscript.pm');
|
||||
require xCAT::Postage;
|
||||
|
||||
sub served {
|
||||
my ($request) = @_;
|
||||
my @served;
|
||||
no warnings qw(redefine once);
|
||||
local $::XCATSITEVALS{nodeauthentication} = 0;
|
||||
local *xCAT_plugin::getpostscript::noderange = \&expand;
|
||||
local *xCAT::Postage::makescript = sub { push @served, @{ $_[0] }; return ('#script') };
|
||||
local *xCAT::MsgUtils::trace = sub { };
|
||||
xCAT_plugin::getpostscript::process_request(
|
||||
{ command => ['getpostscript'], node => [], %$request }, sub { });
|
||||
return @served;
|
||||
}
|
||||
|
||||
is_deeply([ served({ _xcat_clienthost => [''], _xcat_authname => ['compute'] }) ], [],
|
||||
'the plugin serves no node to a password or token login named after a group');
|
||||
is_deeply([ served({ _xcat_clienthost => [''], _xcat_authname => ['node01'] }) ], [],
|
||||
'the plugin serves no node to a password or token login named after a node');
|
||||
is_deeply([ served({ _xcat_clienthost => [''], _xcat_certname => ['compute'] }) ], [],
|
||||
'the plugin serves no node to a certificate named after a group');
|
||||
is_deeply([ served({ _xcat_clienthost => [''], _xcat_certname => ['node02'] }) ], ['node02'],
|
||||
'the plugin serves the node its certificate names when the reverse lookup fails');
|
||||
is_deeply([ served({ _xcat_clienthost => ['node01'] }) ], ['node01'],
|
||||
'the plugin serves the node its peer host resolves to');
|
||||
|
||||
done_testing();
|
||||
@@ -0,0 +1,36 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Cwd qw(realpath);
|
||||
use File::Path qw(make_path);
|
||||
use File::Slurper qw(write_text);
|
||||
use File::Temp qw(tempdir);
|
||||
use Test::More;
|
||||
use XCAT::Test::File qw(repo_path);
|
||||
use XCAT::Test::Process qw(run_command);
|
||||
|
||||
my $source = shift @ARGV // repo_path('xCAT-server/share/xcat/netboot/imgutils');
|
||||
my $root = tempdir(CLEANUP => 1);
|
||||
my ($status, $output) = run_command('cp', '-R', $source, "$root/imgutils");
|
||||
die "copy imgutils: $output" if $status;
|
||||
make_path("$root/assets");
|
||||
my $assets = realpath("$root/assets");
|
||||
|
||||
local $ENV{PERL5LIB} = '';
|
||||
local $ENV{XCATROOT} = '/nonexistent';
|
||||
for my $extension (qw(pkglist otherpkgs.pkglist postinstall)) {
|
||||
my $selected = "$assets/compute.debian12.x86_64.$extension";
|
||||
write_text($selected, "selected\n");
|
||||
write_text("$root/assets/compute.$extension", "fallback\n");
|
||||
my ($rc, $result) = run_command($^X,
|
||||
'-I' . repo_path('perl-xCAT'), '-I' . repo_path('xCAT-server/lib/perl'),
|
||||
'-e', 'require shift @ARGV; print imgutils::get_profile_def_filename(@ARGV)',
|
||||
"$root/imgutils/imgutils.pm",
|
||||
'debian12.5', 'compute', 'x86_64', "$root/assets", $extension);
|
||||
is($rc, 0, "copied imgutils loads without any sibling distro directory") or diag($result);
|
||||
is($result, $selected, "copied imgutils selects the $extension version fallback");
|
||||
}
|
||||
|
||||
done_testing();
|
||||
Executable
+125
@@ -0,0 +1,125 @@
|
||||
#!/usr/bin/env perl
|
||||
# xCAT cannot be installed on either openSUSE management node:
|
||||
#
|
||||
# leap15.6: nothing provides 'perl-DB_File' needed by xCAT-server
|
||||
# sles12: nothing provides (/usr/sbin/dhcpd if openEuler-release else
|
||||
# ((kea and kea-hooks) if (system-release >= 10) else /usr/sbin/dhcpd))
|
||||
# needed by xCAT
|
||||
#
|
||||
# Both requirements are written for EL and have no answer on openSUSE.
|
||||
#
|
||||
# perl-DB_File: no package of that name exists on Leap 15.6 or 42.3. Leap 15.6 calls it
|
||||
# perl-core-DB_File and 42.3 has no such package either, but BOTH provide the capability
|
||||
# perl(DB_File), so the capability is the portable name.
|
||||
#
|
||||
# The dhcpd expression: the sles12 cell is an openSUSE 42.3 management node whose rpm is 4.11,
|
||||
# which has no rich dependencies -- it reports the whole expression as a capability nothing
|
||||
# provides. Neither Leap release carries kea, and both carry chrony, ntp and ISC dhcpd, so the
|
||||
# plain names are what these expressions resolve to on openSUSE anyway.
|
||||
#
|
||||
# A spec is a packaging manifest: the text IS the contract, there is nothing to execute, and
|
||||
# these assertions are on package names in it. The build that proves the requirements resolve is
|
||||
# the openSUSE core build plus the install step on each management node.
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FindBin qw($RealBin);
|
||||
use Test::More;
|
||||
use File::Slurper qw(read_text);
|
||||
|
||||
my $root = "$RealBin/../..";
|
||||
|
||||
# Each entry: the spec, and what its openSUSE branch must and must not ask for.
|
||||
my @cases = (
|
||||
{
|
||||
spec => 'xCAT/xCAT.spec',
|
||||
require => [ 'chrony', '/usr/sbin/dhcpd' ],
|
||||
},
|
||||
{
|
||||
spec => 'xCATsn/xCATsn.spec',
|
||||
require => [ '/usr/sbin/dhcpd' ],
|
||||
},
|
||||
{
|
||||
# openSUSE has no perl-generators, so no perl(...) requirement is auto-generated and the
|
||||
# modules each package loads must be named. Measured on xcat20-mn after a successful
|
||||
# install: xcatd stayed inactive because xCAT::Table dies loading JSON, and Date::Parse,
|
||||
# Expect, HTML::Form and SNMP were absent too. The other 80 modules the EL build
|
||||
# auto-requires were present. Each list below mirrors what EL's generator emits for that
|
||||
# package.
|
||||
spec => 'xCAT-server/xCAT-server.spec',
|
||||
require => [ 'perl(DB_File)',
|
||||
'perl(Date::Parse)', 'perl(Expect)', 'perl(JSON)', 'perl(SNMP)' ],
|
||||
},
|
||||
{
|
||||
spec => 'perl-xCAT/perl-xCAT.spec',
|
||||
require => [ 'perl(Expect)', 'perl(HTML::Form)', 'perl(JSON)', 'perl(SNMP)' ],
|
||||
},
|
||||
{
|
||||
spec => 'xCAT-client/xCAT-client.spec',
|
||||
require => [ 'perl(Expect)' ],
|
||||
},
|
||||
);
|
||||
|
||||
for my $c (@cases) {
|
||||
my $path = "$root/$c->{spec}";
|
||||
ok(-f $path, "$c->{spec} exists") or next;
|
||||
my $text = read_text($path);
|
||||
|
||||
# The openSUSE branch is the region guarded by %if 0%{?suse_version}. Collect those regions
|
||||
# so an assertion cannot be satisfied by a line that only EL ever sees.
|
||||
my @suse;
|
||||
my $depth = 0;
|
||||
for my $line (split /\n/, $text) {
|
||||
if ($line =~ /^\s*%if\s+0%\{\?suse_version\}/) { $depth = 1; next }
|
||||
if ($depth) {
|
||||
if ($line =~ /^\s*%(?:endif|else)/) { $depth = 0; next }
|
||||
push @suse, $line;
|
||||
}
|
||||
}
|
||||
my $suse = join "\n", @suse;
|
||||
|
||||
for my $want (@{ $c->{require} }) {
|
||||
# a Requires: line may name several capabilities, so match the token anywhere on it
|
||||
my $found = grep { /^\s*Requires:/ && /(?:^|\s)\Q$want\E(?:\s|$)/ } @suse;
|
||||
ok($found, "$c->{spec} asks openSUSE for $want");
|
||||
}
|
||||
}
|
||||
|
||||
subtest 'no rich dependency reaches an openSUSE build' => sub {
|
||||
# rpm 4.11 on the sles12 management node cannot evaluate one, and a single core build serves
|
||||
# both the sles15 and sles12 cells, so the openSUSE branch must carry none.
|
||||
for my $spec (qw(xCAT/xCAT.spec xCATsn/xCATsn.spec)) {
|
||||
my $path = "$root/$spec";
|
||||
my $text = read_text($path);
|
||||
my @suse;
|
||||
my $depth = 0;
|
||||
for my $line (split /\n/, $text) {
|
||||
if ($line =~ /^\s*%if\s+0%\{\?suse_version\}/) { $depth = 1; next }
|
||||
if ($depth) {
|
||||
if ($line =~ /^\s*%(?:endif|else)/) { $depth = 0; next }
|
||||
push @suse, $line;
|
||||
}
|
||||
}
|
||||
my @rich = grep { /^\s*Requires:\s*\(/ } @suse;
|
||||
is(scalar @rich, 0, "$spec gives openSUSE no rich dependency");
|
||||
diag("rich dependency in the openSUSE branch: $_") for @rich;
|
||||
}
|
||||
};
|
||||
|
||||
# The EL and openEuler expressions must survive: this is an addition for openSUSE, not a
|
||||
# replacement of the behaviour every other platform has today.
|
||||
subtest 'EL and openEuler keep the expressions they have' => sub {
|
||||
my $xcat = read_text("$root/xCAT/xCAT.spec");
|
||||
like($xcat, qr/\Qif openEuler-release else\E/,
|
||||
'xCAT.spec still carries the openEuler/EL10 dhcpd expression');
|
||||
like($xcat, qr/\Q(chrony or ntp)\E/,
|
||||
'xCAT.spec still offers EL the choice of chrony or ntp');
|
||||
my $sn = read_text("$root/xCATsn/xCATsn.spec");
|
||||
like($sn, qr/\Qif openEuler-release else\E/,
|
||||
'xCATsn.spec still carries the openEuler/EL10 dhcpd expression');
|
||||
my $srv = read_text("$root/xCAT-server/xCAT-server.spec");
|
||||
like($srv, qr/^\s*Recommends:\s*perl-DB_File\s*$/m,
|
||||
'xCAT-server.spec still asks EL10 weakly for perl-DB_File');
|
||||
};
|
||||
|
||||
done_testing();
|
||||
@@ -0,0 +1,95 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib", "$FindBin::Bin/../../perl-xCAT",
|
||||
"$FindBin::Bin/../../xCAT-server/lib/perl",
|
||||
"$FindBin::Bin/../../xCAT-server/share/xcat/netboot/imgutils";
|
||||
use Cwd qw(getcwd realpath);
|
||||
use File::Path qw(make_path);
|
||||
use File::Slurper qw(write_text);
|
||||
use File::Temp qw(tempdir);
|
||||
use JSON::PP qw(decode_json);
|
||||
use Test::More;
|
||||
use XCAT::Test::File qw(repo_path);
|
||||
use XCAT::Test::Process qw(run_command);
|
||||
use imgutils;
|
||||
|
||||
my $root = tempdir(CLEANUP => 1);
|
||||
my $original_dir = getcwd();
|
||||
chdir($root) or die "chdir $root: $!";
|
||||
make_path('assets');
|
||||
symlink('assets', 'alias') or die "symlink: $!";
|
||||
|
||||
sub lookup {
|
||||
my ($owner, $version, $arch, $base, $extension) = @_;
|
||||
return imgutils::get_profile_def_filename($version, 'compute', $arch, $base, $extension)
|
||||
if $owner eq 'imgutils';
|
||||
local $ENV{PERL5LIB} = '';
|
||||
local $ENV{XCATROOT} = '/nonexistent';
|
||||
my ($rc, $output) = run_command($^X,
|
||||
repo_path('xCAT-test/unit/fixtures/debian_profile_lookup.pl'),
|
||||
repo_path('xCAT-server/share/xcat/netboot/debian/genimage'),
|
||||
$version, 'compute', $arch, $base, $extension);
|
||||
die "Debian lookup failed ($rc): $output" if $rc;
|
||||
return decode_json($output)->[0];
|
||||
}
|
||||
|
||||
for my $owner (qw(debian imgutils)) {
|
||||
for my $arch (qw(x86_64 ppc64le s390x)) {
|
||||
for my $extension (qw(pkglist otherpkgs.pkglist postinstall)) {
|
||||
subtest "$owner $arch $extension priority" => sub {
|
||||
my @names = (
|
||||
"compute.debian12.5.$arch.$extension",
|
||||
"compute.debian12.$arch.$extension",
|
||||
"compute.$arch.$extension",
|
||||
"compute.debian12.5.$extension",
|
||||
"compute.debian12.$extension",
|
||||
"compute.$extension",
|
||||
);
|
||||
write_text("assets/$_", "fixture\n") for @names;
|
||||
for my $name (@names) {
|
||||
for my $base ('assets', './alias', realpath('assets')) {
|
||||
my $expected_base = $owner eq 'debian' ? $base : realpath($base);
|
||||
is(lookup($owner, 'debian12.5', $arch, $base, $extension),
|
||||
"$expected_base/$name", "selects $name through $base");
|
||||
}
|
||||
unlink("assets/$name") or die "unlink $name: $!";
|
||||
}
|
||||
is(lookup($owner, 'debian12.5', $arch, 'assets', $extension), '', 'miss returns an empty string');
|
||||
is(lookup($owner, 'debian12.5', $arch, 'missing', $extension), '', 'missing directory returns an empty string');
|
||||
SKIP: {
|
||||
skip 'root can read mode-0000 files', 1 unless $>;
|
||||
write_text("assets/$names[0]", 'unreadable');
|
||||
chmod(0000, "assets/$names[0]") or die "chmod: $!";
|
||||
write_text("assets/$names[-1]", 'readable');
|
||||
is(lookup($owner, 'debian12.5', $arch, 'assets', $extension),
|
||||
($owner eq 'debian' ? 'assets' : realpath('assets')) . "/$names[-1]",
|
||||
'an unreadable exact match does not hide the generic asset');
|
||||
unlink(map { "assets/$_" } @names[0, -1]) == 2 or die "unlink: $!";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for my $case (
|
||||
['debian', 'debian12.5', 'compute.debian12.x86_64.pkglist', 'compute.debian12.4.x86_64.pkglist'],
|
||||
['debian', 'debian12.5.1', 'compute.debian12.5.x86_64.pkglist', 'compute.debian12.x86_64.pkglist'],
|
||||
['imgutils', 'rocky9.6', 'compute.rocky9.5.x86_64.pkglist', 'compute.rocky9.x86_64.pkglist'],
|
||||
['imgutils', 'ubuntu24.04', 'compute.pkglist', 'compute.ubuntu24.x86_64.pkglist'],
|
||||
['imgutils', 'sles11sp1', 'compute.sles11.x86_64.pkglist', 'compute.pkglist'],
|
||||
['imgutils', 'leap15.6', 'compute.sle15.x86_64.pkglist', 'compute.x86_64.pkglist'],
|
||||
['imgutils', 'leap15.6', 'compute.sle15.pkglist', 'compute.pkglist'],
|
||||
['debian', 'debian12', 'compute.debian12.x86_64.pkglist', 'compute.pkglist'],
|
||||
) {
|
||||
my ($owner, $version, $wanted, $other) = @$case;
|
||||
write_text("assets/$_", "fixture\n") for ($wanted, $other);
|
||||
is(lookup($owner, $version, 'x86_64', 'assets', 'pkglist'),
|
||||
($owner eq 'debian' ? 'assets' : realpath('assets')) . "/$wanted",
|
||||
"$owner retains its $version fallback policy");
|
||||
unlink("assets/$wanted", "assets/$other") == 2 or die "unlink: $!";
|
||||
}
|
||||
|
||||
chdir($original_dir) or die "chdir $original_dir: $!";
|
||||
done_testing();
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env perl
|
||||
# SCAPY IS OPTIONAL, AND THE TWO PACKAGINGS MUST AGREE THAT IT IS.
|
||||
#
|
||||
# Only blackboxtest's DHCP steps need scapy. dhcp.py is the single module that imports it, and it
|
||||
# does so inside scapy_module(), which raises UnsupportedError naming python3-scapy when the import
|
||||
# fails -- so the package installs and every other blackboxtest step runs without it.
|
||||
#
|
||||
# xCAT-test.spec says exactly that and only RECOMMENDS the package, with the reason in a comment:
|
||||
# a hard Requires: would make xCAT-test uninstallable on a management node without EPEL.
|
||||
# debian/control said `Depends:`, which is the same claim with the opposite answer.
|
||||
#
|
||||
# The cost is not theoretical. `apt-get install -y xcat-test` installs Recommends by default, and
|
||||
# python3-scapy recommends matplotlib, scipy and ipython3: 54 packages and about 255 MB, inside a
|
||||
# step the GitHub workflow caps at 1200 seconds. On 2026-10-23 that download stalled and killed
|
||||
# xcat_pr_test on xcat-core/#7974 at exactly 1200s, while a sibling run on another runner did the
|
||||
# same install in 19 seconds.
|
||||
#
|
||||
# A packaging manifest is the artifact here -- there is nothing to execute and the text is the
|
||||
# contract -- which is why this asserts on the files rather than on a build.
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
use FindBin;
|
||||
use File::Slurper qw(read_text);
|
||||
|
||||
my $root = "$FindBin::Bin/../..";
|
||||
my $control = "$root/xCAT-test/debian/control";
|
||||
my $spec = "$root/xCAT-test/xCAT-test.spec";
|
||||
ok(-f $control, 'xCAT-test/debian/control is present') or die "no control file\n";
|
||||
ok(-f $spec, 'xCAT-test/xCAT-test.spec is present') or die "no spec\n";
|
||||
|
||||
my $ctext = read_text($control);
|
||||
my $stext = read_text($spec);
|
||||
|
||||
# The xcat-test stanza, not the source stanza: Build-Depends lives above it.
|
||||
my ($stanza) = $ctext =~ /^Package:\s*xcat-test\s*$(.*?)(?:^Package:|\z)/ms;
|
||||
ok(defined $stanza && length $stanza, 'the xcat-test binary stanza is found')
|
||||
or die "cannot isolate the xcat-test stanza\n";
|
||||
|
||||
my ($depends) = $stanza =~ /^Depends:\s*(.*)$/m;
|
||||
my ($recommends) = $stanza =~ /^Recommends:\s*(.*)$/m;
|
||||
|
||||
ok(defined $depends, 'xcat-test declares Depends');
|
||||
unlike($depends // '', qr/python3-scapy/,
|
||||
'python3-scapy is NOT a hard Depends of xcat-test');
|
||||
like($recommends // '', qr/python3-scapy/,
|
||||
'python3-scapy is Recommended instead');
|
||||
# The perl dependency is what makes the package work at all and must survive the change.
|
||||
like($depends // '', qr/\$\{perl:Depends\}/, 'the perl dependency is still a Depends');
|
||||
# blackboxtest is a python3 program. Without scapy, nothing else pulls in the interpreter.
|
||||
my @hard = map { s/^\s+|\s+$//gr } split /,/, $depends // '';
|
||||
ok((grep { /^python3(?:\s|$)/ } @hard), 'python3 is a hard Depends of xcat-test');
|
||||
|
||||
# PARITY. The two packagings answer the same question, so they must answer it the same way: the
|
||||
# spec has recommended it since the tool was added, and the asymmetry is what this fixes.
|
||||
like($stext, qr/^Recommends:\s*python3-scapy\s*$/m, 'the EL spec recommends python3-scapy');
|
||||
unlike($stext, qr/^Requires:[^\n]*python3-scapy/m, '... and does not require it');
|
||||
|
||||
# The reason belongs next to the decision, in both files, or the next person reverts it.
|
||||
like($stanza, qr/scapy/i, 'the control stanza explains the choice');
|
||||
|
||||
done_testing;
|
||||
@@ -60,6 +60,56 @@ is(xCAT::Test::OS::current_os(a_system('lsb-release' => "DISTRIB_ID=Ubuntu\n")),
|
||||
'Ubuntu is named from lsb-release');
|
||||
is(xCAT::Test::OS::current_os(a_system('os-release' => qq{ID="sles"\nVERSION="15-SP6"\n})), 'sles',
|
||||
'SLES is named from os-release');
|
||||
|
||||
# openSUSE. /etc/os-release carries ID="opensuse-leap" and no "sles" anywhere, and Leap ships
|
||||
# none of redhat-release, lsb-release or SuSE-release, so current_os fell through its os-release
|
||||
# arm and returned undef. xcattest then warned "Use of uninitialized value $currentos" four
|
||||
# times per case and rejected every one: "Test case reg_linux_diskfull_installation_flat has an
|
||||
# invalid OS option - Linux / There is no valid case to run". 328 of the shipped cases declare
|
||||
# os:Linux, so an openSUSE management node ran none of them, and the two cases were skipped
|
||||
# rather than failed -- no result at all.
|
||||
#
|
||||
# Measured 2026-10-24 on xcat20-mn, an openSUSE Leap 15.6 management node: current_os answered
|
||||
# UNDEF, /etc/os-release holds ID="opensuse-leap" and VERSION_ID="15.6", and none of the three
|
||||
# fallback files exist.
|
||||
#
|
||||
# openSUSE answers with the SLE family rather than a name of its own, which was decided on
|
||||
# 2026-09-18 for the same bug against the routine xcattest carried before xCAT::Test::OS
|
||||
# existed. Leap and SLE of the same major share a package set, sles.pm claims leap15, and
|
||||
# xcat.org publishes the Leap dependencies under sles15. It also lets the 18 cases written
|
||||
# os:sles select a Leap node, which a separate name would not.
|
||||
my $LEAP_OS_RELEASE = <<'REL';
|
||||
NAME="openSUSE Leap"
|
||||
VERSION="15.6"
|
||||
ID="opensuse-leap"
|
||||
ID_LIKE="suse opensuse"
|
||||
VERSION_ID="15.6"
|
||||
PRETTY_NAME="openSUSE Leap 15.6"
|
||||
REL
|
||||
|
||||
is(xCAT::Test::OS::current_os(a_system('os-release' => $LEAP_OS_RELEASE)), 'sles',
|
||||
'openSUSE Leap is the SLE family whose package set it shares');
|
||||
|
||||
my $leap16 = $LEAP_OS_RELEASE;
|
||||
$leap16 =~ s/15\.6/16.0/g;
|
||||
is(xCAT::Test::OS::current_os(a_system('os-release' => $leap16)), 'sles',
|
||||
'at any Leap version, so a new release needs no change here');
|
||||
|
||||
# Leap 42.3, which the sles12 cell runs, spells its ID without the -leap suffix.
|
||||
my $leap42 = $LEAP_OS_RELEASE;
|
||||
$leap42 =~ s/ID="opensuse-leap"/ID="opensuse"/;
|
||||
$leap42 =~ s/15\.6/42.3/g;
|
||||
is(xCAT::Test::OS::current_os(a_system('os-release' => $leap42)), 'sles',
|
||||
'the older spelling, ID="opensuse", is recognised too');
|
||||
|
||||
is(xCAT::Test::OS::current_os(
|
||||
a_system('os-release' => qq{NAME="openSUSE Tumbleweed"\nID="opensuse-tumbleweed"\n})),
|
||||
'sles', 'Tumbleweed answers rather than falling through silently');
|
||||
|
||||
# The thing that actually broke: an empty answer matches no os: restriction at all.
|
||||
my @linux = xCAT::Test::OS::linux_aliases();
|
||||
ok(scalar(grep { xCAT::Test::OS::current_os(a_system('os-release' => $LEAP_OS_RELEASE)) =~ /$_/i } @linux),
|
||||
'an openSUSE Leap management node matches an os:Linux case');
|
||||
is(xCAT::Test::OS::current_os(a_system()), 'aix',
|
||||
'a system with none of the release files is aix, as before');
|
||||
|
||||
|
||||
+23
-2
@@ -20,11 +20,28 @@ set -e
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
state_dir=/var/lib/xcat/configure-state
|
||||
if [ -L "$state_dir" ] || [ -L "$state_dir/context" ] ||
|
||||
{ [ -e "$state_dir" ] && [ ! -d "$state_dir" ]; }; then
|
||||
echo "Invalid xCAT configuration state: $state_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -f "$state_dir/context" ]; then
|
||||
context=$(cat "$state_dir/context")
|
||||
case "$context" in
|
||||
fresh|upgrade) ;;
|
||||
*) echo "Invalid xCAT configuration context in $state_dir/context: $context" >&2; exit 1 ;;
|
||||
esac
|
||||
elif [ -f /tmp/xCAT_upgrade.tmp ]; then
|
||||
context=upgrade
|
||||
else
|
||||
context=fresh
|
||||
fi
|
||||
# Make dir for the current pid
|
||||
mkdir -p /var/run/xcat
|
||||
cp -f /opt/xcat/share/xcat/scripts/xHRM /install/postscripts/
|
||||
. /etc/profile.d/xcat.sh
|
||||
if [ -f /tmp/xCAT_upgrade.tmp ]
|
||||
if [ "$context" = upgrade ]
|
||||
then
|
||||
if [ -r "/tmp/xcat/installservice.pid" ]; then
|
||||
mv /tmp/xcat/installservice.pid /var/run/xcat/installservice.pid
|
||||
@@ -36,7 +53,6 @@ case "$1" in
|
||||
mv /tmp/xcat/mainservice.pid /var/run/xcat/mainservice.pid
|
||||
fi
|
||||
xcat_run_upgrade xcatconfig -u -V
|
||||
rm /tmp/xCAT_upgrade.tmp
|
||||
else
|
||||
xcatconfig -i
|
||||
fi
|
||||
@@ -75,4 +91,9 @@ esac
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
if [ "$1" = configure ]; then
|
||||
rm -f "$state_dir/context" /tmp/xCAT_upgrade.tmp
|
||||
rmdir "$state_dir" 2>/dev/null || :
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
remove|purge|abort-install|disappear)
|
||||
state_dir=/var/lib/xcat/configure-state
|
||||
if [ -L "$state_dir" ]; then
|
||||
echo "Invalid xCAT configuration state directory: $state_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$state_dir/context" "$state_dir"/context.* /tmp/xCAT_upgrade.tmp
|
||||
rmdir "$state_dir" 2>/dev/null || :
|
||||
;;
|
||||
upgrade|failed-upgrade|abort-upgrade) ;;
|
||||
*) echo "postrm called with unknown argument: $1" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
state_dir=/var/lib/xcat/configure-state
|
||||
|
||||
case "$1" in
|
||||
install) context=fresh ;;
|
||||
upgrade) context=upgrade ;;
|
||||
abort-upgrade) context= ;;
|
||||
*) echo "preinst called with unknown argument: $1" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
if [ -n "$context" ]; then
|
||||
if [ -L "$state_dir" ] || [ -L "$state_dir/context" ] ||
|
||||
{ [ -e "$state_dir" ] && [ ! -d "$state_dir" ]; }; then
|
||||
echo "Invalid xCAT configuration state directory: $state_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
# dpkg skips prerm when the previous package was only unpacked.
|
||||
if [ "$context" = upgrade ] && [ ! -f /tmp/xCAT_upgrade.tmp ]; then
|
||||
if [ -f "$state_dir/context" ]; then
|
||||
context=$(cat "$state_dir/context")
|
||||
case "$context" in
|
||||
fresh|upgrade) ;;
|
||||
*) echo "Invalid xCAT configuration context in $state_dir/context: $context" >&2; exit 1 ;;
|
||||
esac
|
||||
else
|
||||
context=fresh
|
||||
fi
|
||||
fi
|
||||
mkdir -p -m 700 "$state_dir"
|
||||
chmod 700 "$state_dir"
|
||||
temporary=$(mktemp "$state_dir/context.XXXXXX")
|
||||
trap 'rm -f "$temporary"' EXIT
|
||||
trap 'exit 1' HUP INT TERM
|
||||
printf '%s\n' "$context" > "$temporary"
|
||||
mv -f "$temporary" "$state_dir/context"
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
+10
-1
@@ -78,9 +78,18 @@ Requires: net-tools
|
||||
Requires: /usr/bin/killall
|
||||
# makentp/setupntp configure the MN as an NTP server for its compute nodes and support chronyd/ntpd
|
||||
# only. chrony is the default on EL7+/SLES15+ (and the only option on EL8+); ntp covers the rest.
|
||||
Requires: (chrony or ntp)
|
||||
# openEuler's system-release version does not identify an EL release.
|
||||
#
|
||||
# openSUSE takes plain names. The sles12 cell is an openSUSE 42.3 node whose rpm is 4.11, which
|
||||
# has no rich dependencies and reports the whole expression as an unprovided capability. Neither
|
||||
# Leap release carries kea, so these expressions resolve to chrony and ISC dhcpd there anyway.
|
||||
%if 0%{?suse_version}
|
||||
Requires: chrony
|
||||
Requires: /usr/sbin/dhcpd
|
||||
%else
|
||||
Requires: (chrony or ntp)
|
||||
Requires: (/usr/sbin/dhcpd if openEuler-release else ((kea and kea-hooks) if (system-release >= 10) else /usr/sbin/dhcpd))
|
||||
%endif
|
||||
# On RHEL this pulls in openssh-server, on SLES it pulls in openssh
|
||||
Requires: /usr/bin/ssh
|
||||
%if %nots390x
|
||||
|
||||
@@ -64,7 +64,8 @@ case "$1" in
|
||||
a2enmod -q headers >/dev/null 2>&1 || :
|
||||
fi
|
||||
|
||||
if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image
|
||||
if [ -f /proc/cmdline ] &&
|
||||
[ "$(stat -c '%d:%i' /)" = "$(stat -c '%d:%i' /proc/1/root/. 2>/dev/null)" ]; then
|
||||
if [ -d /run/systemd/system ] && command -v systemctl >/dev/null 2>&1; then
|
||||
systemctl start xcatd.service
|
||||
elif [ -x /etc/init.d/xcatd ]; then
|
||||
|
||||
@@ -63,7 +63,14 @@ Requires: /usr/bin/killall
|
||||
# yaboot-xcat is pulled in so any SN can manage ppc nodes
|
||||
Requires: httpd nfs-utils nmap bind
|
||||
# openEuler's system-release version does not identify an EL release.
|
||||
#
|
||||
# openSUSE takes the plain name: rpm 4.11 on the sles12 node has no rich dependencies, and
|
||||
# neither Leap release carries kea, so the expression resolves to ISC dhcpd there anyway.
|
||||
%if 0%{?suse_version}
|
||||
Requires: /usr/sbin/dhcpd
|
||||
%else
|
||||
Requires: (/usr/sbin/dhcpd if openEuler-release else ((kea and kea-hooks) if (system-release >= 10) else /usr/sbin/dhcpd))
|
||||
%endif
|
||||
# On RHEL this pulls in openssh-server, on SLES it pulls in openssh
|
||||
Requires: /usr/bin/ssh
|
||||
%ifnarch s390x
|
||||
|
||||
Reference in New Issue
Block a user