mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-20 17:32:15 +00:00
Merge upstream/master into fix/buildrpms-lock-recovery
Clean against the master that now carries xcat-core/#7968, #7970, #7971, #7975, #7978 and #7980. #7968 touches buildrpms.pl and release_repository.t as this branch does, in disjoint regions -- the locking sites here, createrepo_dir, index_repo and sign_repo_dir there -- which a review of #7968 measured before it landed.
This commit is contained in:
@@ -49,6 +49,7 @@ jobs:
|
||||
sudo cp -R xCAT-test xCAT-server perl-xCAT xCAT "$workdir/"
|
||||
status=0
|
||||
sudo sh -c 'cd "$1" && bats xCAT-test/native/getinstdisk_selection.bats' sh "$workdir" || status=1
|
||||
sudo sh -c 'cd "$1" && bats xCAT-test/native/syslog_log_directory.bats' sh "$workdir" || status=1
|
||||
sudo sh -c 'cd "$1" && prove -v xCAT-test/native/getinstdisk_installer.t xCAT-test/native/enablekdump_per_node.t xCAT-test/native/sudoer_password_source.t xCAT-test/native/remoteshell_credentials.t' sh "$workdir" || status=1
|
||||
exit "$status"
|
||||
- name: Prepare xCAT syslog directory
|
||||
@@ -102,7 +103,7 @@ jobs:
|
||||
run: |
|
||||
log=$(mktemp)
|
||||
trap 'rm -f -- "$log"' EXIT
|
||||
prove -v xCAT-test/native/install_profile_riscv64.t xCAT-test/native/netboot_profile_riscv64.t xCAT-test/native/builddebs_riscv64.t xCAT-test/native/ubuntu_subiquity_template.t | tee "$log"
|
||||
prove -v xCAT-test/native/install_profile_riscv64.t xCAT-test/native/netboot_profile_riscv64.t xCAT-test/native/netboot_profile_postinstall.t xCAT-test/native/builddebs_riscv64.t xCAT-test/native/ubuntu_subiquity_template.t | tee "$log"
|
||||
! grep -qi skipped "$log"
|
||||
rpm_lifecycle_test:
|
||||
runs-on: ubuntu-24.04
|
||||
@@ -123,7 +124,7 @@ jobs:
|
||||
- name: Install lifecycle test dependencies
|
||||
run: |
|
||||
dnf install -y epel-release
|
||||
dnf --enablerepo=${{ matrix.repository }} install -y perl perl-Capture-Tiny perl-File-Slurper perl-Test-Simple perl-DBI perl-DBD-SQLite perl-JSON perl-XML-Simple rpm-build bubblewrap systemd chkconfig initscripts tar gzip bzip2 which diffutils httpd curl procps-ng openssl
|
||||
dnf --enablerepo=${{ matrix.repository }} install -y perl perl-Capture-Tiny perl-File-Slurper perl-Test-Simple perl-DBI perl-DBD-SQLite perl-JSON perl-XML-Simple rpm-build bubblewrap dash systemd chkconfig initscripts tar gzip bzip2 which diffutils httpd curl procps-ng openssl
|
||||
- name: Enable lifecycle test namespaces
|
||||
run: sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
|
||||
- name: Test RPM package lifecycle
|
||||
@@ -131,3 +132,6 @@ jobs:
|
||||
- name: Test FIPS package artifacts
|
||||
if: ${{ !cancelled() }}
|
||||
run: su -s /bin/sh nobody -c 'prove -v xCAT-test/native/fips_package_payload.t'
|
||||
- name: Test netboot postinstall profiles
|
||||
if: ${{ !cancelled() }}
|
||||
run: su -s /bin/sh nobody -c 'prove -v xCAT-test/native/netboot_profile_postinstall.t'
|
||||
|
||||
+8
-7
@@ -677,9 +677,10 @@ sub setup_local_repos {
|
||||
#
|
||||
# Nothing this project ships reads the sqlite metadata. dnf on el8+ and zypper both read the XML.
|
||||
sub createrepo_dir {
|
||||
my ($dir, $extra) = @_;
|
||||
my ($dir, $extra, $fresh) = @_;
|
||||
$extra //= '';
|
||||
sh_or_die(qq(createrepo_c --update )
|
||||
my $update = $fresh ? '' : '--update';
|
||||
sh_or_die(qq(createrepo_c $update )
|
||||
. qq(--revision "$SOURCE_DATE_EPOCH" --set-timestamp-to-revision $extra "$dir"),
|
||||
"Failed to createrepo_c $dir\n");
|
||||
}
|
||||
@@ -690,7 +691,7 @@ sub createrepo_dir {
|
||||
# top-level strays; then index the binaries EXCLUDING the SRPMS/ subdir so no
|
||||
# src.rpm enters the binary repomd, and index the SRPMS repo separately.
|
||||
sub index_repo {
|
||||
my ($repodir) = @_;
|
||||
my ($repodir, $fresh) = @_;
|
||||
my $alias = "$repodir/xCAT-release-latest.noarch.rpm";
|
||||
|
||||
# The stable bootstrap filename is a direct-download convenience, not a
|
||||
@@ -706,9 +707,9 @@ sub index_repo {
|
||||
# replace good metadata with metadata for an empty repo -- publishing a repo that
|
||||
# resolves nothing. Leave it exactly as the last binary build left it and index
|
||||
# only the srpms.
|
||||
createrepo_dir($repodir, "--excludes 'SRPMS/*' --excludes '*.src.rpm'")
|
||||
createrepo_dir($repodir, "--excludes 'SRPMS/*' --excludes '*.src.rpm'", $fresh)
|
||||
unless $opts{source_only};
|
||||
createrepo_dir("$repodir/SRPMS") if -d "$repodir/SRPMS";
|
||||
createrepo_dir("$repodir/SRPMS", '', $fresh) if -d "$repodir/SRPMS";
|
||||
}
|
||||
|
||||
sub update_repo {
|
||||
@@ -756,8 +757,8 @@ sub sign_repo_dir {
|
||||
"Failed to sign SRPMs in $repodir/SRPMS");
|
||||
}
|
||||
|
||||
# Regenerate both indexes (binary + SRPMS) after signing, before signing repomd.
|
||||
index_repo($repodir);
|
||||
# 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",
|
||||
(-d "$repodir/SRPMS/repodata" ? ("$repodir/SRPMS/repodata") : ())) {
|
||||
|
||||
@@ -890,6 +890,21 @@ sub x86_san_loader_present {
|
||||
return ( -f "$tftpdir/undionly.kpxe" || -f "$tftpdir/$loader->{bios}" ) ? 1 : 0;
|
||||
}
|
||||
|
||||
# Some aarch64 UEFI firmware ignores a boot file name without the .efi suffix and requests grubaa64.efi.
|
||||
my %GRUB2_NODE_LOADER_SUFFIX = ( aarch64 => '.efi' );
|
||||
|
||||
# The file in boot/grub2 that DHCP names as the boot file of a grub2 node. With tftpdir, the name is
|
||||
# grub2-<node> until nodeset creates the suffixed link there: a node set by an older xCAT has only that.
|
||||
sub grub2_node_loader {
|
||||
my ( $class, %opts ) = @_;
|
||||
|
||||
my $loader = "grub2-$opts{node}";
|
||||
my $suffix = $GRUB2_NODE_LOADER_SUFFIX{ $opts{arch} // '' } // '';
|
||||
return $loader if $suffix eq '';
|
||||
return $loader if defined $opts{tftpdir} && !-e "$opts{tftpdir}/boot/grub2/$loader$suffix";
|
||||
return "$loader$suffix";
|
||||
}
|
||||
|
||||
# The ISC host statements that choose the boot file of a node with netboot ipxe, xnba or pxe. They
|
||||
# reach dhcpd through omshell, so their quotes are escaped.
|
||||
sub isc_node_boot_statements {
|
||||
|
||||
@@ -1251,7 +1251,9 @@ sub addnode
|
||||
} elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'yaboot') {
|
||||
$lstatements = 'filename = \"/yb/node/yaboot-' . $node . '\";' . $lstatements;
|
||||
} elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} =~ /^grub2[-]?.*$/) {
|
||||
$lstatements = 'filename = \"/boot/grub2/grub2-' . $node . '\";' . $lstatements;
|
||||
my $loader = xCAT::DHCP::BootPolicy->grub2_node_loader(node => $node, arch => $ntent && $ntent->{arch},
|
||||
tftpdir => ($nrent->{tftpdir} || $tftpdir));
|
||||
$lstatements = 'filename = \"/boot/grub2/' . $loader . '\";' . $lstatements;
|
||||
} elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'petitboot') {
|
||||
$lstatements = 'option conf-file \"http://' . $nxtsrv . $portsuffix . '/tftpboot/petitboot/' . $node . '\";' . $lstatements;
|
||||
} elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'onie') {
|
||||
@@ -2621,11 +2623,11 @@ sub process_request
|
||||
} else {
|
||||
$chainents = undef;
|
||||
}
|
||||
$nrhash = $nrtab->getNodesAttribs($req->{node}, [ 'tftpserver', 'netboot', 'proxydhcp', 'xcatmaster', 'servicenode']);
|
||||
$nrhash = $nrtab->getNodesAttribs($req->{node}, [ 'tftpserver', 'netboot', 'proxydhcp', 'xcatmaster', 'servicenode', 'tftpdir']);
|
||||
my $nodetypetab;
|
||||
$nodetypetab = xCAT::Table->new('nodetype', -create => 0);
|
||||
if ($nodetypetab) {
|
||||
$nodetypeents = $nodetypetab->getNodesAttribs($req->{node}, [qw(os provmethod)]);
|
||||
$nodetypeents = $nodetypetab->getNodesAttribs($req->{node}, [qw(os provmethod arch)]);
|
||||
}
|
||||
my $iscsitab = xCAT::Table->new('iscsi', -create => 0);
|
||||
if ($iscsitab) {
|
||||
@@ -3708,7 +3710,7 @@ sub kea_build_node_reservations
|
||||
my $mactab = xCAT::Table->new('mac');
|
||||
|
||||
$chainents = $chaintab ? $chaintab->getNodesAttribs($nodes, ['currstate']) : undef;
|
||||
$nrhash = $nrtab->getNodesAttribs($nodes, [ 'tftpserver', 'netboot', 'proxydhcp', 'xcatmaster', 'servicenode' ]);
|
||||
$nrhash = $nrtab->getNodesAttribs($nodes, [ 'tftpserver', 'netboot', 'proxydhcp', 'xcatmaster', 'servicenode', 'tftpdir' ]);
|
||||
$nodetypeents = $nodetypetab ? $nodetypetab->getNodesAttribs($nodes, [qw(os provmethod arch)]) : undef;
|
||||
$iscsients = $iscsitab ? $iscsitab->getNodesAttribs($nodes, [qw(server target lun iname)]) : undef;
|
||||
$machash = $mactab ? $mactab->getNodesAttribs($nodes, ['mac']) : undef;
|
||||
@@ -4408,7 +4410,9 @@ sub kea_boot_for_node
|
||||
} elsif ($netboot and $netboot eq 'yaboot') {
|
||||
$boot{'boot-file-name'} = "/yb/node/yaboot-$node";
|
||||
} elsif ($netboot and $netboot =~ /^grub2[-]?.*$/) {
|
||||
$boot{'boot-file-name'} = "/boot/grub2/grub2-$node";
|
||||
$boot{'boot-file-name'} = '/boot/grub2/'
|
||||
. xCAT::DHCP::BootPolicy->grub2_node_loader( node => $node, arch => $ntent && $ntent->{arch},
|
||||
tftpdir => ( $nrent->{tftpdir} || $tftpdir ) );
|
||||
} elsif ($netboot and $netboot eq 'nimol') {
|
||||
$boot{'boot-file-name'} = "/vios/nodes/$node";
|
||||
} elsif ($netboot and $netboot eq 'petitboot') {
|
||||
|
||||
@@ -5,6 +5,7 @@ use Sys::Syslog;
|
||||
use xCAT::Scope;
|
||||
use xCAT::Utils;
|
||||
use xCAT::TableUtils;
|
||||
use xCAT::DHCP::BootPolicy;
|
||||
use xCAT::ServiceNodeUtils;
|
||||
use xCAT::NetworkUtils;
|
||||
use xCAT::MsgUtils;
|
||||
@@ -311,9 +312,14 @@ sub setstate {
|
||||
return (1, "Stop grub2 configuration for this node, \"$grub2bin\" does not exits.");
|
||||
}
|
||||
|
||||
# grub2-<node> stays for DHCP configurations that makedhcp did not write.
|
||||
my @loaders = ("grub2-$node");
|
||||
my $dhcp_loader = xCAT::DHCP::BootPolicy->grub2_node_loader(node => $node, arch => $nodearch);
|
||||
push @loaders, $dhcp_loader if ($dhcp_loader ne $loaders[0]);
|
||||
|
||||
chdir("$bootloader_root");
|
||||
if ($cref->{currstate} eq "offline" or $cref->{currstate} eq "boot") {
|
||||
unlink("grub2-$node");
|
||||
unlink(@loaders);
|
||||
} elsif ($cref->{currstate} eq "standby" and $nodeos =~ /^sle/i) {
|
||||
my $os_version = $nodeos;
|
||||
$os_version =~ s/sles//i; # Strip sles if there
|
||||
@@ -321,10 +327,12 @@ sub setstate {
|
||||
if ($os_version >= "15") {
|
||||
# Make sure for SLES15 or higher can still boot
|
||||
# from disk in "standby" state
|
||||
unlink("grub2-$node");
|
||||
unlink(@loaders);
|
||||
}
|
||||
} else {
|
||||
foreach my $loader (grep { !-e $_ } @loaders) {
|
||||
symlink("grub2." . $nodearch, $loader);
|
||||
}
|
||||
} elsif (! -e "grub2-$node") {
|
||||
symlink("grub2." . $nodearch, "grub2-$node");
|
||||
}
|
||||
|
||||
my $ip = xCAT::NetworkUtils->getipaddr($node);
|
||||
|
||||
@@ -73,14 +73,15 @@ sub process_request
|
||||
$::RCP=$options{'node-rcp'};
|
||||
}
|
||||
|
||||
if ($client) { ($client) = noderange($client) }
|
||||
unless ($client) { #Not able to do identify the host in question
|
||||
my $node;
|
||||
if ($client) { ($node) = noderange($client) }
|
||||
unless ($node) { #Not able to do identify the host in question
|
||||
xCAT::MsgUtils->message("S", "Received syncfiles from $client, which couldn't be correlated to a node (domain mismatch?)");
|
||||
return;
|
||||
}
|
||||
|
||||
require xCAT::Postage;
|
||||
&syncfiles($client, $callback, $subreq);
|
||||
&syncfiles($node, $callback, $subreq);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,19 +37,19 @@ END
|
||||
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
|
||||
if [ -f "$installroot/etc/selinux/config" ]
|
||||
then
|
||||
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
|
||||
sed -i 's/^\([[:blank:]]*SELINUX=\)\(enforcing\|permissive\)\([[:blank:]]*\(#.*\)\{0,1\}\)$/\1disabled\3/' "$installroot/etc/selinux/config"
|
||||
fi
|
||||
#--for redhat 8 and 8.1
|
||||
#-- Need to disable firewalld, otherwise, the remoteshell script will not able to get all the SSH keys
|
||||
FIREWALLD="$installroot/etc/systemd/system/multi-user.target.wants/firewalld.service"
|
||||
if [[ -f "$FIREWALLD" || -L "$FIREWALLD" ]]
|
||||
if [ -f "$FIREWALLD" ] || [ -L "$FIREWALLD" ]
|
||||
then
|
||||
rm -f $FIREWALLD
|
||||
rm -f "$FIREWALLD"
|
||||
fi
|
||||
FIREWALLD1="$installroot/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service"
|
||||
if [[ -f "$FIREWALLD1" || -L "$FIREWALLD1" ]]
|
||||
if [ -f "$FIREWALLD1" ] || [ -L "$FIREWALLD1" ]
|
||||
then
|
||||
rm -f $FIREWALLD1
|
||||
rm -f "$FIREWALLD1"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -37,20 +37,20 @@ echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab
|
||||
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
|
||||
if [ -f "$installroot/etc/selinux/config" ]
|
||||
then
|
||||
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
|
||||
sed -i 's/^\([[:blank:]]*SELINUX=\)\(enforcing\|permissive\)\([[:blank:]]*\(#.*\)\{0,1\}\)$/\1disabled\3/' "$installroot/etc/selinux/config"
|
||||
fi
|
||||
|
||||
#--for redhat 8 and 8.1
|
||||
#-- Need to disable firewalld, otherwise, the remoteshell script will not able to get all the SSH keys
|
||||
FIREWALLD="$installroot/etc/systemd/system/multi-user.target.wants/firewalld.service"
|
||||
if [[ -f "$FIREWALLD" || -L "$FIREWALLD" ]]
|
||||
if [ -f "$FIREWALLD" ] || [ -L "$FIREWALLD" ]
|
||||
then
|
||||
rm -f $FIREWALLD
|
||||
rm -f "$FIREWALLD"
|
||||
fi
|
||||
FIREWALLD1="$installroot/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service"
|
||||
if [[ -f "$FIREWALLD1" || -L "$FIREWALLD1" ]]
|
||||
if [ -f "$FIREWALLD1" ] || [ -L "$FIREWALLD1" ]
|
||||
then
|
||||
rm -f $FIREWALLD1
|
||||
rm -f "$FIREWALLD1"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -37,19 +37,19 @@ END
|
||||
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
|
||||
if [ -f "$installroot/etc/selinux/config" ]
|
||||
then
|
||||
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
|
||||
sed -i 's/^\([[:blank:]]*SELINUX=\)\(enforcing\|permissive\)\([[:blank:]]*\(#.*\)\{0,1\}\)$/\1disabled\3/' "$installroot/etc/selinux/config"
|
||||
fi
|
||||
#--for redhat 8 and 8.1
|
||||
#-- Need to disable firewalld, otherwise, the remoteshell script will not able to get all the SSH keys
|
||||
FIREWALLD="$installroot/etc/systemd/system/multi-user.target.wants/firewalld.service"
|
||||
if [[ -f "$FIREWALLD" || -L "$FIREWALLD" ]]
|
||||
if [ -f "$FIREWALLD" ] || [ -L "$FIREWALLD" ]
|
||||
then
|
||||
rm -f $FIREWALLD
|
||||
rm -f "$FIREWALLD"
|
||||
fi
|
||||
FIREWALLD1="$installroot/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service"
|
||||
if [[ -f "$FIREWALLD1" || -L "$FIREWALLD1" ]]
|
||||
if [ -f "$FIREWALLD1" ] || [ -L "$FIREWALLD1" ]
|
||||
then
|
||||
rm -f $FIREWALLD1
|
||||
rm -f "$FIREWALLD1"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab
|
||||
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
|
||||
if [ -f "$installroot/etc/selinux/config" ]
|
||||
then
|
||||
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
|
||||
sed -i 's/^\([[:blank:]]*SELINUX=\)\(enforcing\|permissive\)\([[:blank:]]*\(#.*\)\{0,1\}\)$/\1disabled\3/' "$installroot/etc/selinux/config"
|
||||
fi
|
||||
|
||||
#-- Example of booted image versioning
|
||||
|
||||
@@ -37,7 +37,7 @@ END
|
||||
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
|
||||
if [ -f "$installroot/etc/selinux/config" ]
|
||||
then
|
||||
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
|
||||
sed -i 's/^\([[:blank:]]*SELINUX=\)\(enforcing\|permissive\)\([[:blank:]]*\(#.*\)\{0,1\}\)$/\1disabled\3/' "$installroot/etc/selinux/config"
|
||||
fi
|
||||
|
||||
#-- Example of booted image versioning
|
||||
|
||||
@@ -37,20 +37,20 @@ echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab
|
||||
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
|
||||
if [ -f "$installroot/etc/selinux/config" ]
|
||||
then
|
||||
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
|
||||
sed -i 's/^\([[:blank:]]*SELINUX=\)\(enforcing\|permissive\)\([[:blank:]]*\(#.*\)\{0,1\}\)$/\1disabled\3/' "$installroot/etc/selinux/config"
|
||||
fi
|
||||
|
||||
#--for redhat 8 and 8.1
|
||||
#-- Need to disable firewalld, otherwise, the remoteshell script will not able to get all the SSH keys
|
||||
FIREWALLD="$installroot/etc/systemd/system/multi-user.target.wants/firewalld.service"
|
||||
if [[ -f "$FIREWALLD" || -L "$FIREWALLD" ]]
|
||||
if [ -f "$FIREWALLD" ] || [ -L "$FIREWALLD" ]
|
||||
then
|
||||
rm -f $FIREWALLD
|
||||
rm -f "$FIREWALLD"
|
||||
fi
|
||||
FIREWALLD1="$installroot/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service"
|
||||
if [[ -f "$FIREWALLD1" || -L "$FIREWALLD1" ]]
|
||||
if [ -f "$FIREWALLD1" ] || [ -L "$FIREWALLD1" ]
|
||||
then
|
||||
rm -f $FIREWALLD1
|
||||
rm -f "$FIREWALLD1"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -37,19 +37,19 @@ END
|
||||
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
|
||||
if [ -f "$installroot/etc/selinux/config" ]
|
||||
then
|
||||
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
|
||||
sed -i 's/^\([[:blank:]]*SELINUX=\)\(enforcing\|permissive\)\([[:blank:]]*\(#.*\)\{0,1\}\)$/\1disabled\3/' "$installroot/etc/selinux/config"
|
||||
fi
|
||||
#--for redhat 8 and 8.1
|
||||
#-- Need to disable firewalld, otherwise, the remoteshell script will not able to get all the SSH keys
|
||||
FIREWALLD="$installroot/etc/systemd/system/multi-user.target.wants/firewalld.service"
|
||||
if [[ -f "$FIREWALLD" || -L "$FIREWALLD" ]]
|
||||
if [ -f "$FIREWALLD" ] || [ -L "$FIREWALLD" ]
|
||||
then
|
||||
rm -f $FIREWALLD
|
||||
rm -f "$FIREWALLD"
|
||||
fi
|
||||
FIREWALLD1="$installroot/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service"
|
||||
if [[ -f "$FIREWALLD1" || -L "$FIREWALLD1" ]]
|
||||
if [ -f "$FIREWALLD1" ] || [ -L "$FIREWALLD1" ]
|
||||
then
|
||||
rm -f $FIREWALLD1
|
||||
rm -f "$FIREWALLD1"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -37,20 +37,20 @@ echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab
|
||||
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
|
||||
if [ -f "$installroot/etc/selinux/config" ]
|
||||
then
|
||||
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
|
||||
sed -i 's/^\([[:blank:]]*SELINUX=\)\(enforcing\|permissive\)\([[:blank:]]*\(#.*\)\{0,1\}\)$/\1disabled\3/' "$installroot/etc/selinux/config"
|
||||
fi
|
||||
|
||||
#--for redhat 8 and 8.1
|
||||
#-- Need to disable firewalld, otherwise, the remoteshell script will not able to get all the SSH keys
|
||||
FIREWALLD="$installroot/etc/systemd/system/multi-user.target.wants/firewalld.service"
|
||||
if [[ -f "$FIREWALLD" || -L "$FIREWALLD" ]]
|
||||
if [ -f "$FIREWALLD" ] || [ -L "$FIREWALLD" ]
|
||||
then
|
||||
rm -f $FIREWALLD
|
||||
rm -f "$FIREWALLD"
|
||||
fi
|
||||
FIREWALLD1="$installroot/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service"
|
||||
if [[ -f "$FIREWALLD1" || -L "$FIREWALLD1" ]]
|
||||
if [ -f "$FIREWALLD1" ] || [ -L "$FIREWALLD1" ]
|
||||
then
|
||||
rm -f $FIREWALLD1
|
||||
rm -f "$FIREWALLD1"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -37,19 +37,19 @@ END
|
||||
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
|
||||
if [ -f "$installroot/etc/selinux/config" ]
|
||||
then
|
||||
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
|
||||
sed -i 's/^\([[:blank:]]*SELINUX=\)\(enforcing\|permissive\)\([[:blank:]]*\(#.*\)\{0,1\}\)$/\1disabled\3/' "$installroot/etc/selinux/config"
|
||||
fi
|
||||
#--for redhat 8 and 8.1
|
||||
#-- Need to disable firewalld, otherwise, the remoteshell script will not able to get all the SSH keys
|
||||
FIREWALLD="$installroot/etc/systemd/system/multi-user.target.wants/firewalld.service"
|
||||
if [[ -f "$FIREWALLD" || -L "$FIREWALLD" ]]
|
||||
if [ -f "$FIREWALLD" ] || [ -L "$FIREWALLD" ]
|
||||
then
|
||||
rm -f $FIREWALLD
|
||||
rm -f "$FIREWALLD"
|
||||
fi
|
||||
FIREWALLD1="$installroot/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service"
|
||||
if [[ -f "$FIREWALLD1" || -L "$FIREWALLD1" ]]
|
||||
if [ -f "$FIREWALLD1" ] || [ -L "$FIREWALLD1" ]
|
||||
then
|
||||
rm -f $FIREWALLD1
|
||||
rm -f "$FIREWALLD1"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab
|
||||
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
|
||||
if [ -f "$installroot/etc/selinux/config" ]
|
||||
then
|
||||
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
|
||||
sed -i 's/^\([[:blank:]]*SELINUX=\)\(enforcing\|permissive\)\([[:blank:]]*\(#.*\)\{0,1\}\)$/\1disabled\3/' "$installroot/etc/selinux/config"
|
||||
fi
|
||||
|
||||
#-- Example of booted image versioning
|
||||
|
||||
@@ -37,19 +37,19 @@ END
|
||||
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
|
||||
if [ -f "$installroot/etc/selinux/config" ]
|
||||
then
|
||||
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
|
||||
sed -i 's/^\([[:blank:]]*SELINUX=\)\(enforcing\|permissive\)\([[:blank:]]*\(#.*\)\{0,1\}\)$/\1disabled\3/' "$installroot/etc/selinux/config"
|
||||
fi
|
||||
#--for redhat 8 and 8.1
|
||||
#-- Need to disable firewalld, otherwise, the remoteshell script will not able to get all the SSH keys
|
||||
FIREWALLD="$installroot/etc/systemd/system/multi-user.target.wants/firewalld.service"
|
||||
if [[ -f "$FIREWALLD" || -L "$FIREWALLD" ]]
|
||||
if [ -f "$FIREWALLD" ] || [ -L "$FIREWALLD" ]
|
||||
then
|
||||
rm -f $FIREWALLD
|
||||
rm -f "$FIREWALLD"
|
||||
fi
|
||||
FIREWALLD1="$installroot/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service"
|
||||
if [[ -f "$FIREWALLD1" || -L "$FIREWALLD1" ]]
|
||||
if [ -f "$FIREWALLD1" ] || [ -L "$FIREWALLD1" ]
|
||||
then
|
||||
rm -f $FIREWALLD1
|
||||
rm -f "$FIREWALLD1"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ os:Linux
|
||||
label:mn_only,ci_test,integration
|
||||
cmd:prove -I/opt/xcat/lib/perl -I/opt/xcat/lib/perl/xCAT -r /opt/xcat/share/xcat/tools/autotest/integration
|
||||
check:rc==0
|
||||
check:output=~Files=10,
|
||||
check:output=~Files=11,
|
||||
end
|
||||
|
||||
start:xcatd_dispatch_redaction
|
||||
|
||||
@@ -28,6 +28,11 @@ fixtures. They require Bubblewrap, Bash, GNU core utilities, grep, sed, and
|
||||
permission to create user namespaces. The CI workflow installs Bubblewrap and
|
||||
enables those namespaces.
|
||||
|
||||
`routeop_linklocal.bats` also needs iproute2 and kernel support for dummy
|
||||
network interfaces. It maps root and grants `CAP_NET_ADMIN` only inside a
|
||||
new user and network namespace. It runs as an ordinary user and changes
|
||||
real kernel routes only in that private network namespace.
|
||||
|
||||
Missing prerequisites fail these tests without stopping unrelated test files.
|
||||
Non-Linux hosts report a skip. Set `TMPDIR` to a writable, executable filesystem
|
||||
if the default temporary directory is mounted with `noexec`.
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load 'helpers/script_sandbox'
|
||||
|
||||
setup()
|
||||
{
|
||||
setup_script_sandbox cat dirname grep sed tr uname logger awk cut head rm touch mkdir mv
|
||||
local ip_binary
|
||||
ip_binary=$(PATH=/usr/sbin:/sbin:/usr/bin:/bin type -P ip) || return 1
|
||||
cp -L "$ip_binary" "$fixture/bin/ip"
|
||||
mkdir -p "$fixture/etc/sysconfig/network"
|
||||
printf '%s\n' SLE VERSION=15 >"$fixture/etc/SUSE-brand"
|
||||
sandbox+=(--ro-bind "$(repo_path xCAT/postscripts)" /tmp/postscripts
|
||||
--setenv OSVER sles15 --uid 0 --gid 0 --cap-add CAP_NET_ADMIN)
|
||||
cat >"$fixture/bin/route-test" <<'SH'
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
ip link set lo up
|
||||
for dev in test0 test1; do
|
||||
ip link add "$dev" type dummy
|
||||
ip link set "$dev" up
|
||||
ip -6 address add fe80::2/64 dev "$dev" nodad
|
||||
ip -6 address add 2001:db8:1::2/64 dev "$dev" nodad
|
||||
done
|
||||
exec /bin/bash -eu -c "$1"
|
||||
SH
|
||||
chmod +x "$fixture/bin/route-test"
|
||||
}
|
||||
|
||||
run_routes()
|
||||
{
|
||||
run "${sandbox[@]}" /bin/bash /bin/route-test "$1"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test 'routeop installs and repeats a link-local gateway route on its device' {
|
||||
run_routes '
|
||||
for pass in 1 2; do
|
||||
/tmp/postscripts/routeop add 2001:db8:2:: 64 fe80::1 test0
|
||||
ip -6 route show 2001:db8:2::/64 |
|
||||
grep -q "2001:db8:2::/64 via fe80::1 dev test0"
|
||||
done
|
||||
test "$(grep -c "^2001:db8:2::/64 fe80::1 - test0$" /etc/sysconfig/network/routes)" = 1
|
||||
'
|
||||
}
|
||||
|
||||
@test 'routeop does not confuse a link-local route on another device' {
|
||||
run_routes '
|
||||
ip -6 route add 2001:db8:2::/64 via fe80::1 dev test1 metric 2000
|
||||
/tmp/postscripts/routeop add 2001:db8:2:: 64 fe80::1 test0
|
||||
ip -6 route show 2001:db8:2::/64 | grep -q "2001:db8:2::/64 via fe80::1 dev test0"
|
||||
ip -6 route show 2001:db8:2::/64 | grep -q "2001:db8:2::/64 via fe80::1 dev test1"
|
||||
'
|
||||
}
|
||||
|
||||
@test 'routeop replaces and deletes the scoped gateway without deleting a neighbor' {
|
||||
run_routes '
|
||||
/tmp/postscripts/routeop replace 2001:db8:2:: 64 fe80::1 test0
|
||||
ip -6 route show 2001:db8:2::/64 | grep -q "2001:db8:2::/64 via fe80::1 dev test0"
|
||||
/tmp/postscripts/routeop replace 2001:db8:2:: 64 fe80::3 test0
|
||||
ip -6 route show 2001:db8:2::/64 | grep -q "2001:db8:2::/64 via fe80::3 dev test0"
|
||||
grep -qx "2001:db8:2::/64 fe80::3 - test0" /etc/sysconfig/network/routes
|
||||
ip -6 route add 2001:db8:2::/64 via fe80::3 dev test1 metric 512
|
||||
/tmp/postscripts/routeop delete 2001:db8:2:: 64 fe80::3 test0
|
||||
test -z "$(ip -6 route show 2001:db8:2::/64 via fe80::3 dev test0)"
|
||||
ip -6 route show 2001:db8:2::/64 | grep -q "2001:db8:2::/64 via fe80::3 dev test1"
|
||||
test -z "$(sed "/^[[:space:]]*$/d" /etc/sysconfig/network/routes)"
|
||||
'
|
||||
}
|
||||
|
||||
@test 'routeop scopes expanded and upper-case link-local gateways' {
|
||||
run_routes '
|
||||
/tmp/postscripts/routeop replace 2001:db8:2:: 64 FE80:0000:0000:0000:0000:0000:0000:0001 test0
|
||||
ip -6 route show 2001:db8:2::/64 | grep -q "2001:db8:2::/64 via fe80::1 dev test0"
|
||||
grep -qx "2001:db8:2::/64 FE80:0000:0000:0000:0000:0000:0000:0001 - test0" /etc/sysconfig/network/routes
|
||||
'
|
||||
}
|
||||
|
||||
@test 'routeop leaves persistence unchanged when a scoped replacement fails' {
|
||||
run_routes '
|
||||
echo "2001:db8:2::/64 fe80::1 - test0" >/etc/sysconfig/network/routes
|
||||
if /tmp/postscripts/routeop replace 2001:db8:2:: 64 fe80::3 missing0; then exit 1; fi
|
||||
grep -qx "2001:db8:2::/64 fe80::1 - test0" /etc/sysconfig/network/routes
|
||||
test -z "$(ip -6 route show 2001:db8:2::/64)"
|
||||
'
|
||||
}
|
||||
|
||||
@test 'routeop retains global-gateway and connected-route behavior' {
|
||||
run_routes '
|
||||
/tmp/postscripts/routeop replace 2001:db8:2:: 64 2001:db8:1::1 test0
|
||||
ip -6 route show 2001:db8:2::/64 | grep -q "via 2001:db8:1::1"
|
||||
grep -qx "2001:db8:2::/64 2001:db8:1::1 - -" /etc/sysconfig/network/routes
|
||||
/tmp/postscripts/routeop replace 2001:db8:3:: 64 :: test0
|
||||
ip -6 route show 2001:db8:3::/64 | grep -q "dev test0"
|
||||
grep -qx "2001:db8:3::/64 :: - test0" /etc/sysconfig/network/routes
|
||||
'
|
||||
}
|
||||
|
||||
@test 'routeop deletes exact SLES records and older unscoped entries' {
|
||||
run_routes '
|
||||
printf "%s\n" "2001:db8:2::/64 fe80::1 - test0" \
|
||||
"2001:db8:2::/64 fe80::1 - test01" \
|
||||
"2001:db8:3::/64 fe80::1 - -" >/etc/sysconfig/network/routes
|
||||
/tmp/postscripts/routeop delete 2001:db8:2:: 64 fe80::1 test0
|
||||
/tmp/postscripts/routeop delete 2001:db8:3:: 64 fe80::1 test0
|
||||
test "$(cat /etc/sysconfig/network/routes)" = "2001:db8:2::/64 fe80::1 - test01"
|
||||
'
|
||||
}
|
||||
|
||||
@test 'routeop replaces an unscoped SLES entry without matching another device' {
|
||||
run_routes '
|
||||
printf "%s\n" "2001:db8:2::/64 fe80::1 - -" \
|
||||
"2001:db8:2::/64 fe80::1 - test01" >/etc/sysconfig/network/routes
|
||||
/tmp/postscripts/routeop add 2001:db8:2:: 64 fe80::1 test0
|
||||
test "$(grep -c "^2001:db8:2::/64 fe80::1 - test0$" /etc/sysconfig/network/routes)" = 1
|
||||
grep -qx "2001:db8:2::/64 fe80::1 - test01" /etc/sysconfig/network/routes
|
||||
test "$(grep -c " - -$" /etc/sysconfig/network/routes)" = 0
|
||||
'
|
||||
}
|
||||
|
||||
@test 'routeop treats dotted interface names literally in saved routes' {
|
||||
run_routes '
|
||||
ip link add test0.1 type dummy
|
||||
ip link set test0.1 up
|
||||
printf "%s\n" "2001:db8:2::/64 fe80::1 - test0x1" >/etc/sysconfig/network/routes
|
||||
/tmp/postscripts/routeop add 2001:db8:2:: 64 fe80::1 test0.1
|
||||
grep -Fqx "2001:db8:2::/64 fe80::1 - test0.1" /etc/sysconfig/network/routes
|
||||
/tmp/postscripts/routeop delete 2001:db8:2:: 64 fe80::1 test0.1
|
||||
test "$(sed "/^#/d;/^$/d" /etc/sysconfig/network/routes)" = "2001:db8:2::/64 fe80::1 - test0x1"
|
||||
'
|
||||
}
|
||||
|
||||
@test 'routeop retains the device in legacy Red Hat route6 files' {
|
||||
run_routes '
|
||||
rm /etc/SUSE-brand
|
||||
touch /etc/redhat-release
|
||||
mkdir -p /etc/sysconfig/network-scripts
|
||||
export OSVER=rhels8
|
||||
/tmp/postscripts/routeop replace 2001:db8:2:: 64 fe80::1 test0
|
||||
test "$(cat /etc/sysconfig/network-scripts/route6-test0)" = "2001:db8:2::/64 via fe80::1 dev test0"
|
||||
ip -6 route show 2001:db8:2::/64 | grep -q "via fe80::1 dev test0"
|
||||
printf "%s\n" "test0 2001:db8:2::/64 fe80::1" "test01 2001:db8:2::/64 fe80::1" >/etc/sysconfig/static-routes-ipv6
|
||||
/tmp/postscripts/routeop delete 2001:db8:2:: 64 fe80::1 test0
|
||||
test ! -s /etc/sysconfig/network-scripts/route6-test0
|
||||
test "$(cat /etc/sysconfig/static-routes-ipv6)" = "test01 2001:db8:2::/64 fe80::1"
|
||||
test -z "$(ip -6 route show 2001:db8:2::/64)"
|
||||
echo "2001:db8:2::/64 via fe80::1" >/etc/sysconfig/network-scripts/route6-test0
|
||||
/tmp/postscripts/routeop delete 2001:db8:2:: 64 fe80::1 test0
|
||||
test ! -s /etc/sysconfig/network-scripts/route6-test0
|
||||
'
|
||||
}
|
||||
|
||||
@test 'routeop scopes Debian interface up and down gateway commands' {
|
||||
run_routes '
|
||||
rm /etc/SUSE-brand
|
||||
touch /etc/debian_version
|
||||
mkdir -p /etc/network/interfaces.d
|
||||
printf "%s\n" "#XCAT_CONFIG" "source /etc/network/interfaces.d/*" >/etc/network/interfaces
|
||||
export OSVER=ubuntu24.04
|
||||
for layout in last middle; do
|
||||
printf "%s\n" "auto test0" "iface test0 inet manual" >/etc/network/interfaces.d/test0
|
||||
printf "%s\n" " up route -A inet6 add 2001:db8:2::/64 gw fe80::1" \
|
||||
" down route -A inet6 del 2001:db8:2::/64 gw fe80::1" \
|
||||
"post-up ip -6 route replace 2001:db8:2::/64 via fe80::1" >>/etc/network/interfaces.d/test0
|
||||
if [ "$layout" = middle ]; then echo "iface test1 inet manual" >>/etc/network/interfaces.d/test0; fi
|
||||
/tmp/postscripts/routeop add 2001:db8:2:: 64 fe80::1 test0
|
||||
grep -Fxq " up route -A inet6 add 2001:db8:2::/64 gw fe80::1 dev test0" /etc/network/interfaces.d/test0
|
||||
grep -Fxq " down route -A inet6 del 2001:db8:2::/64 gw fe80::1 dev test0" /etc/network/interfaces.d/test0
|
||||
if grep -Fxq "post-up ip -6 route replace 2001:db8:2::/64 via fe80::1" /etc/network/interfaces.d/test0; then exit 1; fi
|
||||
/tmp/postscripts/routeop delete 2001:db8:2:: 64 fe80::1 test0
|
||||
test "$(grep -c "2001:db8:2::" /etc/network/interfaces.d/test0)" = 0
|
||||
/tmp/postscripts/routeop replace 2001:db8:2:: 64 fe80::1 test0
|
||||
grep -Fxq "post-up ip -6 route replace 2001:db8:2::/64 via fe80::1 dev test0" /etc/network/interfaces.d/test0
|
||||
ip -6 route show 2001:db8:2::/64 | grep -q "via fe80::1 dev test0"
|
||||
/tmp/postscripts/routeop delete 2001:db8:2:: 64 fe80::1 test0
|
||||
test "$(grep -c "2001:db8:2::" /etc/network/interfaces.d/test0)" = 0
|
||||
done
|
||||
'
|
||||
}
|
||||
@@ -27,8 +27,8 @@ against it.
|
||||
Note the `-I` flags: unlike the unit tests these run from the installed location, so
|
||||
they pick up xCAT modules from `/opt/xcat/lib/perl` rather than from a source tree.
|
||||
|
||||
The case checks `rc==0` and `output=~Files=10,`. The file count checks that `prove`
|
||||
found all ten files, which catches a packaging regression or a test renamed away from
|
||||
The case checks `rc==0` and `output=~Files=11,`. The file count checks that `prove`
|
||||
found all eleven files, which catches a packaging regression or a test renamed away from
|
||||
`.t` without updating the count. It does not prove that environment-gated cases ran;
|
||||
inspect the TAP output for skips. **Add to that number when you add a test.** A missing
|
||||
directory is already caught by `rc==0` -- `prove -r` on a path that does not exist exits
|
||||
@@ -55,6 +55,7 @@ A test belongs in `integration/` when it needs something the checkout cannot pro
|
||||
| `html_form_runtime_dependency.t` | the installed `HTML::Form` module |
|
||||
| `openeuler_package_postscripts.t` | Linux root, private mount namespaces and DNF; tests complete package postscripts with command doubles and an isolated repository directory |
|
||||
| `openeuler_postscript_repositories.t` | Linux root, private mount namespaces, DNF and RPM signing tools; tests actual signed repository transactions in isolated install roots |
|
||||
| `syncfiles_delivery.t` | a disposable management node, service node and compute node, certificate policies and SSH copy access; opt-in |
|
||||
| `wsapi_apache_access.t` | an Apache binary and its modules; reads `xcat-ws.conf` from the source tree, so `github_action_xcat_test.pl` runs it from the checkout and the installed copy skips |
|
||||
| `xcatd_dispatch_redaction.sh` | a live `xcatd`, syslog delivery to `/var/log/xcat/cluster.log`, and root |
|
||||
|
||||
@@ -96,6 +97,80 @@ plan skip_all => 'set XCAT_KEA_LIVE_SMOKE=1 to run live Kea daemon smoke test'
|
||||
It starts real Kea daemons, so it stays off unless asked for. Do not enable it on a
|
||||
node whose DHCP service is in use.
|
||||
|
||||
## Syncfiles delivery lab
|
||||
|
||||
Run `syncfiles_delivery.t` only in a disposable three-node lab. It sends real
|
||||
`syncfiles` and `updatenode -F` requests, and runs real SSH/rsync copies. Do not
|
||||
point it at a shared or production cluster.
|
||||
|
||||
Prepare the lab before enabling the test:
|
||||
|
||||
- Install xCAT on the management and service nodes, and the xCAT Perl client
|
||||
modules on the compute node. Install Perl `File::Slurper`, `Capture::Tiny`,
|
||||
`JSON::PP`, `timeout`, SSH/SFTP and rsync. The management and service nodes
|
||||
must have the normal `updatenode` postscript files and reachability tools.
|
||||
- Configure name resolution and route the compute node through the service node
|
||||
in `noderes.servicenode` and `noderes.xcatmaster`. Give the compute node a
|
||||
dedicated osimage with exactly one synclist: `<work>/synclist`.
|
||||
- Configure the service-node cache prefix in the test to match
|
||||
`site.SNsyncfiledir` (default `/var/xcat/syncfiles`). Keep the daemon environment
|
||||
free of `DSH_*`, `DCP_*` and `RSYNC*` overrides.
|
||||
- Use a lab CA and valid client certificates for `operator` and `denied`.
|
||||
Allow `operator` to run `syncfiles`, `updatenode` and `xdcp`. Leave `denied`
|
||||
unauthorized. On both the management and service nodes, remove the default
|
||||
unnamed `syncfiles` allow rule and any other rule that allows `denied`.
|
||||
This certificate-only fixture intentionally differs from the default policy,
|
||||
which allows the certificate-free `startsyncfiles` postscript request.
|
||||
Configure the normal trusted MN/SN certificate relationship.
|
||||
Store the client credentials and CA on the compute node; the test does not
|
||||
create certificates or change policy.
|
||||
- Create the `operator`, `sender` and `receiver` Unix accounts. Give the
|
||||
management node root SSH access to the service and compute nodes, and give
|
||||
the service node SSH copy access to the compute node as `root`, `operator`
|
||||
and `sender`. Use lab-only keys and pinned host keys. Do not enable password
|
||||
authentication for this test.
|
||||
|
||||
Create a JSON configuration on the management node. For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"management": "mn",
|
||||
"service": "sn",
|
||||
"node": "cn",
|
||||
"work": "/tmp/xcat-syncfiles-fixture1",
|
||||
"cache": "/var/xcat/syncfiles",
|
||||
"operator": "/root/lab-certs/operator.pem",
|
||||
"denied": "/root/lab-certs/denied.pem",
|
||||
"ca": "/root/lab-certs/ca.pem"
|
||||
}
|
||||
```
|
||||
|
||||
Each client PEM contains its certificate and private key. Keep the credentials
|
||||
private. The three host names must be distinct. The work path must be a new
|
||||
directory directly under `/tmp`, named `xcat-syncfiles-` followed by letters or
|
||||
digits. The test refuses existing work and cache paths, removes its request and
|
||||
payload directories on exit, and fails if that cleanup fails. xCAT can retain
|
||||
cache parent directories and generated `/tmp/rsync_*` command files outside
|
||||
those directories. Remove the disposable nodes and credentials after testing.
|
||||
|
||||
Run as root on the management node:
|
||||
|
||||
```sh
|
||||
XCAT_SYNCFILES_LIVE_CONFIG=/root/syncfiles-lab.json \
|
||||
prove -v xCAT-test/integration/syncfiles_delivery.t
|
||||
```
|
||||
|
||||
The certificate cases check authorization under that restricted policy, MN/SN
|
||||
staging, delivered bytes and file ownership. `syncfiles` requests root copies
|
||||
regardless of the authenticated user; `updatenode` retains the authenticated
|
||||
user unless its environment overrides the sender. The inherited-environment
|
||||
cases call the real copy consumer on the service node without TLS; they test
|
||||
copy identity precedence, not authentication. The unit test
|
||||
`syncfiles_consumer_identity.t` checks both parsed identity variables and rejects
|
||||
changes that overwrite nonempty inherited values.
|
||||
|
||||
This fixture does not cover the default certificate-free `startsyncfiles` path.
|
||||
|
||||
## What does not belong here
|
||||
|
||||
Anything that only needs the checkout. Those go in [`../unit`](../unit/README.md) and
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Slurper qw(read_text);
|
||||
use JSON::PP qw(decode_json encode_json);
|
||||
use xCAT::Client;
|
||||
|
||||
my ($input) = @ARGV;
|
||||
my $case = decode_json(read_text($input));
|
||||
my @responses;
|
||||
my $callback = sub { push @responses, $_[0]; };
|
||||
delete $ENV{XCATBYPASS};
|
||||
local $SIG{ALRM} = sub { die "Syncfiles request timed out\n"; };
|
||||
alarm 60;
|
||||
if ($case->{consumer}) {
|
||||
require xCAT_plugin::syncfiles;
|
||||
require xCAT_plugin::xdsh;
|
||||
delete @ENV{qw(DSH_FROM_USERID DSH_TO_USERID)};
|
||||
@ENV{keys %{$case->{inherited}}} = values %{$case->{inherited}};
|
||||
xCAT_plugin::syncfiles::process_request($case->{request}, $callback, sub {
|
||||
my ($request, $response) = @_;
|
||||
xCAT_plugin::xdsh::preprocess_request($request, $response, sub { die 'Unexpected remote dispatch'; });
|
||||
});
|
||||
} else {
|
||||
$ENV{XCATHOST} = $case->{endpoint};
|
||||
xCAT::Client::submit_request($case->{request}, $callback,
|
||||
$case->{credential}, $case->{credential}, $case->{ca});
|
||||
}
|
||||
alarm 0;
|
||||
print encode_json(\@responses), "\n";
|
||||
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use FindBin;
|
||||
use lib '/opt/xcat/lib/perl';
|
||||
use File::Path qw(remove_tree);
|
||||
use File::Slurper qw(read_text write_text);
|
||||
use JSON::PP qw(decode_json encode_json);
|
||||
use Test::More;
|
||||
|
||||
plan skip_all => 'set XCAT_SYNCFILES_LIVE_CONFIG for a disposable MN/SN/node lab'
|
||||
unless $ENV{XCAT_SYNCFILES_LIVE_CONFIG};
|
||||
require Capture::Tiny;
|
||||
die 'Run as root on the disposable management node' unless $> == 0;
|
||||
my $config = decode_json(read_text($ENV{XCAT_SYNCFILES_LIVE_CONFIG}));
|
||||
my ($node, $service, $work, $cache) = @{$config}{qw(node service work cache)};
|
||||
die 'Unsafe fixture path' unless $work =~ m{\A/tmp/xcat-syncfiles-[A-Za-z0-9]+\z};
|
||||
die 'Unsafe cache path' unless $cache =~ m{\A/[A-Za-z0-9/_-]+\z} && $cache ne '/';
|
||||
for ($node, $service, $config->{management}) { die 'Unsafe host name' unless /\A[A-Za-z0-9][A-Za-z0-9.-]*\z/; }
|
||||
die 'Fixture hosts must be distinct' if $node eq $service || $node eq $config->{management} || $service eq $config->{management};
|
||||
for my $key (qw(operator denied ca)) {
|
||||
die "Unsafe $key credential path" unless $config->{$key} =~ m{\A/[A-Za-z0-9/_.-]+\z};
|
||||
}
|
||||
require xCAT::SvrUtils;
|
||||
my $lists = xCAT::SvrUtils->getsynclistfile([$node]);
|
||||
die 'The fixture node must use only the fixture synclist'
|
||||
unless $lists->{$node} eq "$work/synclist";
|
||||
|
||||
sub command {
|
||||
my (@args) = @_;
|
||||
my ($out, $err, $status) = Capture::Tiny::capture(sub { system('timeout', '90', @args) });
|
||||
die "Command failed (@args): $status\n$out$err" if $status;
|
||||
return $out;
|
||||
}
|
||||
sub remote {
|
||||
my ($host, @args) = @_;
|
||||
return command('ssh', '-oBatchMode=yes', "root\@$host", @args);
|
||||
}
|
||||
sub copy_to {
|
||||
my ($host, $file, $target) = @_;
|
||||
command('scp', '-q', $file, "root\@$host:$target");
|
||||
return;
|
||||
}
|
||||
my %created;
|
||||
END {
|
||||
my $status = $?;
|
||||
my $failed = 0;
|
||||
for my $host (grep { $_ ne 'local' } keys %created) {
|
||||
eval { remote($host, 'rm', '-rf', '--', $work, "$cache$work"); 1 }
|
||||
or do { warn "Fixture cleanup failed on $host: $@"; $failed = 1; };
|
||||
}
|
||||
if ($created{local}) {
|
||||
remove_tree($work, {error => \my $errors});
|
||||
if (@$errors) { warn "Local fixture cleanup failed\n"; $failed = 1; }
|
||||
}
|
||||
$? = $status || $failed;
|
||||
}
|
||||
die 'Fixture path already exists locally' if -e $work;
|
||||
for my $host ($node, $service) {
|
||||
remote($host, 'test', '!', '-e', $work);
|
||||
remote($host, 'test', '!', '-e', "$cache$work");
|
||||
}
|
||||
mkdir($work, 0700) or die "Cannot create $work: $!";
|
||||
$created{local} = 1;
|
||||
for my $host ($node, $service) {
|
||||
remote($host, 'mkdir', '-m', '0755', $work);
|
||||
$created{$host} = 1;
|
||||
copy_to($host, "$FindBin::Bin/fixtures/syncfiles-request.pl", "$work/request.pl");
|
||||
}
|
||||
my $payload = "$work/payload";
|
||||
my $destination = "$work/delivered/payload";
|
||||
write_text("$work/synclist", "$payload -> $destination\n");
|
||||
|
||||
sub request {
|
||||
my ($host, $case) = @_;
|
||||
write_text("$work/request.json", encode_json($case));
|
||||
copy_to($host, "$work/request.json", "$work/request.json");
|
||||
my $out = remote($host, 'perl', '-I/opt/xcat/lib/perl', "$work/request.pl", "$work/request.json");
|
||||
return decode_json($out);
|
||||
}
|
||||
sub errors {
|
||||
my ($responses) = @_;
|
||||
my @errors;
|
||||
for my $response (@$responses) {
|
||||
my $codes = $response->{errorcode};
|
||||
$codes = [$codes] unless ref($codes) eq 'ARRAY';
|
||||
push @errors, $response if $response->{error} ||
|
||||
grep { defined($_) && $_ ne '0' && length($_) } @$codes;
|
||||
}
|
||||
return \@errors;
|
||||
}
|
||||
sub authenticated {
|
||||
my ($endpoint, $principal, $request) = @_;
|
||||
return request($node, {
|
||||
endpoint => "$endpoint:3001", credential => $config->{$principal},
|
||||
ca => $config->{ca}, request => $request,
|
||||
});
|
||||
}
|
||||
sub delivered {
|
||||
my ($text, $user) = @_;
|
||||
is(remote($node, 'cat', $destination), $text, 'destination has the new payload');
|
||||
is(remote($node, 'stat', '-c', '%U', $destination), "$user\n", 'destination ownership matches the copy identity');
|
||||
return;
|
||||
}
|
||||
sub prepare_destination {
|
||||
my ($user) = @_;
|
||||
remote($node, 'mkdir', '-p', "$work/delivered");
|
||||
remote($node, 'rm', '-f', $destination);
|
||||
remote($node, 'chown', $user, "$work/delivered");
|
||||
return;
|
||||
}
|
||||
|
||||
subtest 'authenticated node request traverses the MN/SN hierarchy' => sub {
|
||||
write_text($payload, "hierarchy payload\n");
|
||||
prepare_destination('root');
|
||||
my $responses = authenticated($config->{management}, 'operator', {command => ['syncfiles'], arg => [], username => ['denied']});
|
||||
is_deeply(errors($responses), [], 'the authorized certificate is accepted despite the supplied username');
|
||||
delivered("hierarchy payload\n", 'root');
|
||||
is(remote($service, 'cat', "$cache$payload"), "hierarchy payload\n", 'the service node receives the staged payload');
|
||||
};
|
||||
|
||||
subtest 'authenticated node request consumes the service-node cache' => sub {
|
||||
write_text($payload, "service cache payload\n");
|
||||
copy_to($service, $payload, "$cache$payload");
|
||||
prepare_destination('root');
|
||||
my $responses = authenticated($service, 'operator', {command => ['syncfiles'], arg => []});
|
||||
is_deeply(errors($responses), [], 'the service node accepts the certificate');
|
||||
delivered("service cache payload\n", 'root');
|
||||
};
|
||||
|
||||
subtest 'unauthorized certificate cannot trigger a copy' => sub {
|
||||
write_text($payload, "must not be delivered\n");
|
||||
copy_to($service, $payload, "$cache$payload");
|
||||
my $responses = authenticated($service, 'denied', {command => ['syncfiles'], arg => [], username => ['root']});
|
||||
my @denials = map { @{$_->{error} || []} } @{errors($responses)};
|
||||
ok(scalar(grep { $_ eq 'Permission denied for request' } @denials),
|
||||
'authorization rejects the certificate despite the supplied root username');
|
||||
delivered("service cache payload\n", 'root');
|
||||
};
|
||||
|
||||
for my $case (
|
||||
['unset', {}, 'root'],
|
||||
['empty', {DSH_FROM_USERID => '', DSH_TO_USERID => ''}, 'root'],
|
||||
['sender only', {DSH_FROM_USERID => 'sender'}, 'sender'],
|
||||
['receiver only', {DSH_TO_USERID => 'receiver'}, 'root'],
|
||||
['both', {DSH_FROM_USERID => 'sender', DSH_TO_USERID => 'receiver'}, 'sender'],
|
||||
) {
|
||||
my ($name, $inherited, $user) = @$case;
|
||||
subtest "real copy consumer with $name inherited" => sub {
|
||||
my $text = "consumer $name\n";
|
||||
write_text($payload, $text);
|
||||
copy_to($service, $payload, "$cache$payload");
|
||||
prepare_destination($user);
|
||||
my $responses = request($service, {
|
||||
consumer => 1, inherited => $inherited,
|
||||
request => {command => ['syncfiles'], arg => [], _xcat_clienthost => [$node]},
|
||||
});
|
||||
is_deeply(errors($responses), [], 'the real copy consumer reports no error');
|
||||
delivered($text, $user);
|
||||
};
|
||||
}
|
||||
|
||||
subtest 'updatenode preserves the authenticated non-root identity across the hierarchy' => sub {
|
||||
write_text($payload, "updatenode payload\n");
|
||||
prepare_destination('operator');
|
||||
my $responses = authenticated($config->{management}, 'operator', {
|
||||
command => ['updatenode'], noderange => [$node], arg => ['-F'], username => ['root'],
|
||||
});
|
||||
is_deeply(errors($responses), [], 'updatenode completes without an earlier error being hidden');
|
||||
delivered("updatenode payload\n", 'operator');
|
||||
};
|
||||
|
||||
done_testing();
|
||||
@@ -56,11 +56,12 @@ prove xCAT-test/native/probe_package_payload.t \
|
||||
|
||||
They need RPM build/query tools, cpio, createrepo_c, zstd, rsync, GnuPG, Python 3
|
||||
with RPM bindings, user/mount namespaces, and the Perl modules Capture::Tiny,
|
||||
File::Slurper, Parallel::ForkManager and XML::LibXML. The probe command also
|
||||
needs `which`. The release test uses an ephemeral signing key and removes its
|
||||
agent. These checks inspect real packages and repository output; 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.
|
||||
Digest::SHA, File::Slurper, Parallel::ForkManager and XML::LibXML. The probe
|
||||
command also needs `which`. The release test uses an ephemeral signing key and
|
||||
removes its agent. These checks inspect real packages and repository output;
|
||||
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 Debian probe permission test has a separate pull-request CI step. It needs
|
||||
Debian build tools, BATS, bubblewrap, fakeroot, reprepro and
|
||||
@@ -374,6 +375,7 @@ user with Bubblewrap and unprivileged user namespaces enabled:
|
||||
```
|
||||
prove xCAT-test/native/install_profile_riscv64.t \
|
||||
xCAT-test/native/netboot_profile_riscv64.t \
|
||||
xCAT-test/native/netboot_profile_postinstall.t \
|
||||
xCAT-test/native/builddebs_riscv64.t \
|
||||
xCAT-test/native/ubuntu_subiquity_template.t
|
||||
```
|
||||
@@ -386,13 +388,21 @@ The Debian case needs debhelper, devscripts, fakeroot, and reprepro, and skips
|
||||
on non-Debian hosts. Each case creates its own temporary files and database.
|
||||
The temporary directory must allow execution; set TMPDIR if /tmp is noexec.
|
||||
Sandbox commands require GNU timeout and have a 45-second limit.
|
||||
Pull-request CI runs these cases and rejects whole-file skips. The permissive
|
||||
SELinux case records an existing postinstall defect as TODO, without changing
|
||||
production behavior.
|
||||
Pull-request CI runs these cases and rejects whole-file skips.
|
||||
|
||||
The netboot case executes the selected postinstall file directly. Its private
|
||||
/bin/sh uses Bash, as on EL, including when the test host uses another shell.
|
||||
|
||||
`netboot_profile_postinstall.t` runs the affected EL postinstall owners and
|
||||
their distro and service aliases. It checks the resulting SELinux settings,
|
||||
missing files, comments, repeated execution, permissions, ownership and host
|
||||
sentinels. It uses the same sandbox and Perl dependencies. CI runs it on
|
||||
Ubuntu, EL8 and EL10. It executes host tools against private image roots;
|
||||
it does not boot the target architecture or verify kernel SELinux state.
|
||||
Both Bash and dash are required. The firewalld cases cover regular files,
|
||||
valid and dangling symlinks, absent entries and directories under both shells.
|
||||
The unit files, unrelated links and host entries must remain unchanged.
|
||||
|
||||
The Subiquity case replaces downloads and external commands, and uses a
|
||||
loopback install-monitor peer. It does not install an operating system.
|
||||
Architecture names in these fixtures do not qualify native firmware or boot
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
# Preserve timestamps so checksum coverage does not depend on signing within one clock tick.
|
||||
timestamps=$(mktemp -d)
|
||||
trap 'rm -rf -- "$timestamps"' EXIT
|
||||
index=0
|
||||
for package do
|
||||
if [ -f "$package" ]; then
|
||||
touch -r "$package" "$timestamps/$index"
|
||||
fi
|
||||
index=$((index + 1))
|
||||
done
|
||||
|
||||
"$XCAT_TEST_RPMSIGN" "$@"
|
||||
|
||||
index=0
|
||||
for package do
|
||||
if [ -f "$timestamps/$index" ]; then
|
||||
touch -r "$timestamps/$index" "$package"
|
||||
fi
|
||||
index=$((index + 1))
|
||||
done
|
||||
@@ -0,0 +1,201 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Cwd qw(abs_path);
|
||||
use File::Basename qw(basename dirname);
|
||||
use File::Find qw(find);
|
||||
use File::Path qw(make_path);
|
||||
use File::Slurper qw(read_text write_text);
|
||||
use File::Spec;
|
||||
use Test::More;
|
||||
use XCAT::Test::File qw(repo_path);
|
||||
use XCAT::Test::Sandbox qw(sandbox_root sandbox_run);
|
||||
|
||||
plan skip_all => 'postinstall execution requires Linux' unless $^O eq 'linux';
|
||||
my $netboot = repo_path('xCAT-server/share/xcat/netboot');
|
||||
my @owners = qw(
|
||||
rh/compute.rhels7.ppc64.postinstall
|
||||
rh/compute.rhels7.x86_64.postinstall
|
||||
rh/compute.rhels8.ppc64le.postinstall
|
||||
rh/compute.rhels8.x86_64.postinstall
|
||||
rh/compute.rhels9.ppc64le.postinstall
|
||||
rh/compute.rhels9.x86_64.postinstall
|
||||
rh/compute.rhels10.aarch64.postinstall
|
||||
rh/compute.rhels10.ppc64le.postinstall
|
||||
rh/compute.rhels10.x86_64.postinstall
|
||||
rh/service.postinstall
|
||||
rocky/compute.rocky10.riscv64.postinstall
|
||||
);
|
||||
my %owners;
|
||||
|
||||
for my $owner (@owners) {
|
||||
ok( -x "$netboot/$owner", "$owner is executable" );
|
||||
$owners{ abs_path("$netboot/$owner") } = 1;
|
||||
}
|
||||
my @aliases;
|
||||
find(
|
||||
{
|
||||
no_chdir => 1,
|
||||
wanted => sub {
|
||||
return unless -l $_ && /[.]postinstall$/;
|
||||
my $target = abs_path($_);
|
||||
push @aliases, substr( $_, length($netboot) + 1 ) if defined $target && $owners{$target};
|
||||
}
|
||||
},
|
||||
$netboot
|
||||
);
|
||||
ok( @aliases, 'finds profile aliases for the affected owners' );
|
||||
my %firewalld = map { abs_path("$netboot/$_") => 1 } qw(
|
||||
rh/compute.rhels8.ppc64le.postinstall
|
||||
rh/compute.rhels8.x86_64.postinstall
|
||||
rh/compute.rhels9.ppc64le.postinstall
|
||||
rh/compute.rhels9.x86_64.postinstall
|
||||
rh/compute.rhels10.aarch64.postinstall
|
||||
rh/compute.rhels10.ppc64le.postinstall
|
||||
rh/compute.rhels10.x86_64.postinstall
|
||||
rocky/compute.rocky10.riscv64.postinstall
|
||||
);
|
||||
my @shells = qw(/bin/bash /bin/dash);
|
||||
|
||||
sub shell_options {
|
||||
my ($shell) = @_;
|
||||
return { read_only => { repo_path('.') => repo_path('.'), $shell => '/bin/' . basename( abs_path('/bin/sh') ) } };
|
||||
}
|
||||
|
||||
for my $shell (@shells) {
|
||||
BAIL_OUT("Install $shell to run this test") unless -x $shell;
|
||||
my $root = sandbox_root();
|
||||
write_text( "$root/bin/shell-probe", "#!/bin/sh\nprintf '%s\\n' \"\${BASH_VERSION:+bash}\"\n" );
|
||||
chmod 0755, "$root/bin/shell-probe" or die "chmod shell probe: $!";
|
||||
my ( $status, $output ) = sandbox_run( $root, shell_options($shell), '/fixture/bin/shell-probe' );
|
||||
my $expected = $shell eq '/bin/bash' ? "bash\n" : "\n";
|
||||
is( $status, 0, "$shell probe executes through its shebang" ) or diag($output);
|
||||
is( $output, $expected, "/bin/sh runs the selected $shell" );
|
||||
BAIL_OUT("The sandbox did not select $shell") if $status || $output ne $expected;
|
||||
}
|
||||
|
||||
sub run_profile {
|
||||
my ( $root, $relative, $shell ) = @_;
|
||||
my ( $profile, $osver, $arch ) = split /[.]/, basename($relative);
|
||||
return sandbox_run( $root, shell_options($shell), "$netboot/$relative", '/target', $osver, $arch // '', $profile );
|
||||
}
|
||||
|
||||
my $unchanged =
|
||||
"# SELINUX=enforcing or permissive\nSELINUXTYPE=targeted\n" . "OTHER_SELINUX=permissive\n#SELINUX=permissive\n";
|
||||
my @cases = (
|
||||
[ 'enforcing', "SELINUX=enforcing\n", "SELINUX=disabled\n" ],
|
||||
[ 'permissive', "SELINUX=permissive\n", "SELINUX=disabled\n" ],
|
||||
[ 'disabled', "SELINUX=disabled\n", "SELINUX=disabled\n" ],
|
||||
[ 'absent', undef, undef ],
|
||||
[ 'no assignment', '', '' ],
|
||||
[ 'whitespace and comments', "\tSELINUX=permissive \t# image policy\n", "\tSELINUX=disabled \t# image policy\n" ],
|
||||
[ 'enforcing comment', "SELINUX=enforcing # image policy\n", "SELINUX=disabled # image policy\n" ],
|
||||
);
|
||||
|
||||
for my $shell (@shells) {
|
||||
for my $relative ( @owners, sort @aliases ) {
|
||||
my @selected = -l "$netboot/$relative" ? ( $cases[1] ) : @cases;
|
||||
for my $case (@selected) {
|
||||
my ( $label, $input, $expected ) = @$case;
|
||||
subtest "$relative: $shell SELinux $label" => sub {
|
||||
my $root = sandbox_root();
|
||||
my $image = "$root/target";
|
||||
make_path( "$image/etc/selinux", "$root/etc/selinux" );
|
||||
my $host_policy = "SELINUX=enforcing\n# host policy\n";
|
||||
write_text( "$root/etc/selinux/config", $host_policy );
|
||||
write_text( "$root/etc/fstab", "host fstab\n" );
|
||||
write_text( "$root/etc/inittab", "host inittab\n" );
|
||||
my $config = "$image/etc/selinux/config";
|
||||
|
||||
if ( defined $input ) {
|
||||
write_text( $config, $input . $unchanged );
|
||||
chmod 0640, $config or die "chmod $config: $!";
|
||||
}
|
||||
my @metadata = defined $input ? ( stat($config) )[ 2, 4, 5 ] : ();
|
||||
for my $pass ( 1, 2 ) {
|
||||
my ( $status, $output ) = run_profile( $root, $relative, $shell );
|
||||
is( $status, 0, "pass $pass executes the profile" ) or diag($output);
|
||||
is( $output, '', "pass $pass has no shell errors" );
|
||||
is( read_text("$root/etc/selinux/config"), $host_policy, 'host policy is unchanged' );
|
||||
is( read_text("$root/etc/fstab"), "host fstab\n", 'host fstab is unchanged' );
|
||||
is( read_text("$root/etc/inittab"), "host inittab\n", 'host inittab is unchanged' );
|
||||
if ( defined $input ) {
|
||||
is(
|
||||
read_text($config),
|
||||
$expected . $unchanged,
|
||||
"pass $pass changes only the active SELinux mode"
|
||||
);
|
||||
is_deeply( [ ( stat($config) )[ 2, 4, 5 ] ],
|
||||
\@metadata, 'policy permissions and ownership are preserved' );
|
||||
}
|
||||
else {
|
||||
ok( !-e $config, 'absent policy remains absent' );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
my @kinds = -l "$netboot/$relative" ? ('dangling') : qw(regular symlink dangling absent directory);
|
||||
for my $kind (@kinds) {
|
||||
subtest "$relative: $shell firewalld $kind" => sub {
|
||||
my $root = sandbox_root();
|
||||
my $image = "$root/target";
|
||||
my $unit = "$image/usr/lib/systemd/system/firewalld.service";
|
||||
make_path( dirname($unit) );
|
||||
write_text( $unit, "[Service]\nExecStart=/usr/bin/true\n" );
|
||||
my @links = qw(etc/systemd/system/multi-user.target.wants/firewalld.service
|
||||
etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service);
|
||||
my %targets;
|
||||
|
||||
for my $relative_link (@links) {
|
||||
my $link = "$image/$relative_link";
|
||||
make_path( dirname($link), dirname("$root/$relative_link") );
|
||||
write_text( "$root/$relative_link", "host firewalld\n" );
|
||||
$targets{$link} =
|
||||
File::Spec->abs2rel( $unit . ( $kind eq 'dangling' ? '.missing' : '' ), dirname($link) );
|
||||
if ( $kind eq 'regular' ) {
|
||||
write_text( $link, "image firewalld\n" );
|
||||
}
|
||||
elsif ( $kind eq 'symlink' || $kind eq 'dangling' ) {
|
||||
symlink( $targets{$link}, $link ) or die "symlink $link: $!";
|
||||
}
|
||||
elsif ( $kind eq 'directory' ) {
|
||||
make_path($link);
|
||||
write_text( "$link/keep", "directory contents\n" );
|
||||
}
|
||||
symlink( $targets{$link}, "$link.unrelated" ) or die "symlink: $!";
|
||||
}
|
||||
for my $pass ( 1, 2 ) {
|
||||
my ( $status, $output ) = run_profile( $root, $relative, $shell );
|
||||
is( $status, 0, "pass $pass executes the profile" ) or diag($output);
|
||||
is( $output, '', 'both shell conditions execute without errors' );
|
||||
for my $relative_link (@links) {
|
||||
my $link = "$image/$relative_link";
|
||||
if ( ( $firewalld{ abs_path("$netboot/$relative") } && $kind ne 'directory' )
|
||||
|| $kind eq 'absent' )
|
||||
{
|
||||
ok( !-e $link && !-l $link, 'firewalld entry is absent' );
|
||||
}
|
||||
elsif ( $kind eq 'regular' ) {
|
||||
is( read_text($link), "image firewalld\n", 'older profile retains the entry' );
|
||||
}
|
||||
elsif ( $kind eq 'directory' ) {
|
||||
is( read_text("$link/keep"), "directory contents\n", 'directory contents are retained' );
|
||||
}
|
||||
else {
|
||||
is( readlink($link), $targets{$link}, 'older profile retains the link' );
|
||||
}
|
||||
is( readlink("$link.unrelated"), $targets{$link}, 'unrelated link is unchanged' );
|
||||
is( read_text("$root/$relative_link"), "host firewalld\n", 'host entry is unchanged' );
|
||||
}
|
||||
is( read_text($unit), "[Service]\nExecStart=/usr/bin/true\n", 'unit target is unchanged' );
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done_testing();
|
||||
@@ -4,6 +4,8 @@ use warnings;
|
||||
## no critic (Modules::RequireFilenameMatchesPackage)
|
||||
|
||||
use FindBin;
|
||||
use Cwd qw(abs_path);
|
||||
use File::Basename qw(basename);
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use lib "$FindBin::Bin/../../perl-xCAT";
|
||||
use lib "$FindBin::Bin/../../xCAT-server/lib/perl";
|
||||
@@ -80,7 +82,7 @@ for my $family (@families) {
|
||||
for my $pass (1, 2) {
|
||||
# EL uses Bash as /bin/sh for these postinstall scripts.
|
||||
my ($status, $output) = sandbox_run($root,
|
||||
{read_only => {repo_path('.') => repo_path('.'), '/bin/bash' => '/bin/sh'}},
|
||||
{read_only => {repo_path('.') => repo_path('.'), '/bin/bash' => '/bin/' . basename(abs_path('/bin/sh'))}},
|
||||
$postinstall, '/target', $osver, 'riscv64', $profile);
|
||||
is($status, 0, "pass $pass executes the selected script") or diag($output);
|
||||
is(read_text("$root/etc/fstab"), "host fstab\n", "pass $pass leaves the host fstab unchanged");
|
||||
@@ -88,8 +90,6 @@ for my $family (@families) {
|
||||
if ($mode eq 'absent') {
|
||||
ok(!-e "$image/etc/selinux/config", "pass $pass leaves absent SELinux configuration absent");
|
||||
} else {
|
||||
local $TODO = 'The existing postinstall duplicates SELINUX= for permissive mode'
|
||||
if $mode eq 'permissive';
|
||||
is(read_text("$image/etc/selinux/config"), "SELINUX=disabled\nSELINUXTYPE=targeted\n",
|
||||
"pass $pass disables SELinux without changing the policy type");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Digest::SHA qw(sha256_hex);
|
||||
use File::Basename qw(dirname);
|
||||
use File::Copy qw(copy);
|
||||
use File::Path qw(make_path);
|
||||
@@ -56,13 +57,26 @@ copy("$root/RPMS/noarch/$rpm", "$root/input/$rpm") or die $!;
|
||||
copy("$root/SRPMS/$srpm", "$root/input/SRPMS/$srpm") or die $!;
|
||||
copy("$root/RPMS/noarch/$rpm", "$root/input/xCAT-release-latest.noarch.rpm") or die $!;
|
||||
|
||||
my $rpmsign = command($root, 'sh', '-c', 'command -v rpmsign');
|
||||
chomp $rpmsign;
|
||||
make_path("$root/bin");
|
||||
copy(repo_path('xCAT-test/native/fixtures/rpmsign-preserve-mtime.sh'), "$root/bin/rpmsign") or die $!;
|
||||
chmod 0755, "$root/bin/rpmsign" or die $!;
|
||||
local $ENV{XCAT_TEST_RPMSIGN} = $rpmsign;
|
||||
local $ENV{PATH} = "$root/bin:$ENV{PATH}";
|
||||
|
||||
for my $signed (0, 1) {
|
||||
for my $attempt (1, 2) {
|
||||
my $before = $signed && $attempt == 1 ? package_stats("$root/input") : undef;
|
||||
command("$root/work", $^X, 'buildrpms.pl', '--merge-core-repos',
|
||||
'--target', 'alma+epel-10-x86_64', '--release', '1',
|
||||
'--output-dir', "$root/output", '--input-core-repos', "$root/input",
|
||||
$signed ? ('--gpg-sign', '--gpg-key-name', 'package@example.test') : ());
|
||||
check_repository("$root/output", $signed, "merge signed=$signed run=$attempt");
|
||||
check_repository("$root/output", $signed, "merge signed=$signed run=$attempt", $before);
|
||||
if ($signed) {
|
||||
copy("$root/output/$rpm", "$root/input/$rpm") or die $!;
|
||||
copy("$root/output/SRPMS/$srpm", "$root/input/SRPMS/$srpm") or die $!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,12 +89,15 @@ command($root, 'cp', '-a', repo_path('xCAT-release'), "$root/work/xCAT-release")
|
||||
write_text("$root/mock/xCAT-release-$target.cfg", "# cached build\n");
|
||||
write_text("$root/os-release", "ID=almalinux\nVERSION_ID=10\n");
|
||||
local $ENV{BUILD_FIXTURE} = $root;
|
||||
command("$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; "$@"', 'sign-test',
|
||||
$^X, 'buildrpms.pl', '--package', 'xCAT-release', '--target', $target,
|
||||
'--release', '1', '--nproc', '1', '--gpg-sign', '--gpg-key-name', 'package@example.test');
|
||||
check_repository($cached, 1, 'cached build finalization');
|
||||
for my $attempt (1, 2) {
|
||||
my $before = $attempt == 1 ? package_stats($cached) : undef;
|
||||
command("$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; "$@"', 'sign-test',
|
||||
$^X, 'buildrpms.pl', '--package', 'xCAT-release', '--target', $target,
|
||||
'--release', '1', '--nproc', '1', '--gpg-sign', '--gpg-key-name', 'package@example.test');
|
||||
check_repository($cached, 1, "cached build finalization run=$attempt", $before);
|
||||
}
|
||||
|
||||
write_text("$root/work/schedule.pl", <<'PERL');
|
||||
BEGIN {
|
||||
@@ -135,17 +152,31 @@ sub primary_packages {
|
||||
return XML::LibXML->load_xml(string => $xml)->findnodes('//*[local-name()="package"]');
|
||||
}
|
||||
|
||||
sub package_stats {
|
||||
my ($directory) = @_;
|
||||
return {map { $_ => [(stat("$directory/$_"))[7, 9]] } ($rpm, "SRPMS/$srpm")};
|
||||
}
|
||||
|
||||
sub check_repository {
|
||||
my ($directory, $signed, $label) = @_;
|
||||
my ($directory, $signed, $label, $before) = @_;
|
||||
is_deeply(package_stats($directory), $before, "$label signing preserves package sizes and mtimes")
|
||||
if $before;
|
||||
my $alias = "$directory/xCAT-release-latest.noarch.rpm";
|
||||
ok(-f $alias, "$label publishes the alias") or die('missing bootstrap alias');
|
||||
is(read_binary($alias), read_binary("$directory/$rpm"), "$label alias has final RPM bytes");
|
||||
is((stat($alias))[2] & 0777, 0644, "$label alias is readable");
|
||||
my @packages = primary_packages($directory);
|
||||
is(scalar(@packages), 1, "$label indexes the release package once");
|
||||
for my $package (@packages) {
|
||||
my ($location) = $package->findnodes('./*[local-name()="location"]');
|
||||
is($location->getAttribute('href'), $rpm, "$label indexes the versioned filename only");
|
||||
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");
|
||||
}
|
||||
}
|
||||
if ($signed) {
|
||||
for my $repo ($directory, "$directory/SRPMS") {
|
||||
@@ -154,5 +185,7 @@ sub check_repository {
|
||||
my $signature = command($root, 'rpm', '-qp', '--qf', '%{RSAHEADER:pgpsig}', $alias);
|
||||
like($signature, qr/RSA.*Key ID/i, "$label alias carries the package signature");
|
||||
isnt(read_binary($alias), read_binary("$root/RPMS/noarch/$rpm"), "$label signing changed the unsigned RPM");
|
||||
isnt(read_binary("$directory/SRPMS/$srpm"), read_binary("$root/SRPMS/$srpm"),
|
||||
"$label signing changed the unsigned SRPM");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load '../bats/helpers/script_sandbox'
|
||||
|
||||
setup()
|
||||
{
|
||||
[ "$(id -u)" -eq 0 ] || skip 'native syslog ownership checks require root'
|
||||
setup_script_sandbox cat cp dirname grep egrep sed tr uname awk cut head touch mkdir \
|
||||
chown chmod stat id sleep logger rm date mktemp
|
||||
local index daemon
|
||||
# Keep real account IDs so rsyslog can drop its privileges.
|
||||
for index in "${!sandbox[@]}"; do
|
||||
if [ "${sandbox[$index]}" = --unshare-all ]; then
|
||||
sandbox[$index]=--unshare-pid
|
||||
fi
|
||||
done
|
||||
sandbox+=(--unshare-net --unshare-ipc --unshare-uts
|
||||
--ro-bind "$(repo_path xCAT/postscripts)" /tmp/postscripts
|
||||
--ro-bind "$(repo_path xCAT/xcat-upgrade-functions.sh)" /tmp/upgrade.sh)
|
||||
daemon=$(PATH=/usr/sbin:/sbin:/usr/bin:/bin type -P rsyslogd) || return 1
|
||||
cp -L "$daemon" "$fixture/bin/rsyslogd-real"
|
||||
daemon=$(PATH=/usr/sbin:/sbin:/usr/bin:/bin type -P ip) || return 1
|
||||
cp -L "$daemon" "$fixture/bin/ip"
|
||||
cp /etc/passwd /etc/group /etc/nsswitch.conf "$fixture/etc/"
|
||||
id syslog >/dev/null || return 1
|
||||
mkdir -p "$fixture/etc/rsyslog.d" "$fixture/etc/default" \
|
||||
"$fixture/etc/systemd/system" "$fixture/var/log" "$fixture/var/lib/rsyslog"
|
||||
touch "$fixture/etc/systemd/system/rsyslog.service"
|
||||
cat >"$fixture/etc/rsyslog.conf" <<'CONF'
|
||||
$PrivDropToUser syslog
|
||||
$PrivDropToGroup syslog
|
||||
module(load="imudp")
|
||||
input(type="imudp" address="127.0.0.1" port="1514")
|
||||
local4.* /var/log/xcat/cluster.log
|
||||
$IncludeConfig /etc/rsyslog.d/*.conf
|
||||
CONF
|
||||
cat >"$fixture/bin/rsyslogd" <<'SH'
|
||||
#!/bin/sh
|
||||
if [ "$1" = -v ] && [ "$SYSLOG_TEST_VERSION" != 8 ]; then
|
||||
echo "rsyslogd $SYSLOG_TEST_VERSION.0"
|
||||
else
|
||||
exec /bin/rsyslogd-real "$@"
|
||||
fi
|
||||
SH
|
||||
cat >"$fixture/bin/systemctl" <<'SH'
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
[ "$*" = 'restart rsyslog' ]
|
||||
if [ -s /run/rsyslog.pid ]; then
|
||||
previous=$(cat /run/rsyslog.pid)
|
||||
kill "$previous"
|
||||
for ((i=0; i<100; i++)); do
|
||||
[ -d "/proc/$previous" ] || break
|
||||
sleep .02
|
||||
done
|
||||
[ ! -d "/proc/$previous" ]
|
||||
rm -f /run/rsyslog.pid
|
||||
fi
|
||||
/bin/rsyslogd-real -n -i /run/rsyslog.pid -f /etc/rsyslog.conf >>/run/daemon.log 2>&1 </dev/null &
|
||||
for ((i=0; i<100; i++)); do
|
||||
[ ! -s /run/rsyslog.pid ] || exit 0
|
||||
sleep .02
|
||||
done
|
||||
exit 1
|
||||
SH
|
||||
cat >"$fixture/bin/check-delivery" <<'SH'
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
uid=$(id -u syslog)
|
||||
expected="^Uid:[[:space:]]+$uid[[:space:]]+$uid[[:space:]]+$uid[[:space:]]+$uid$"
|
||||
for ((i=0; i<100; i++)); do
|
||||
if grep -Eq "$expected" /proc/$(cat /run/rsyslog.pid)/status; then break; fi
|
||||
sleep .02
|
||||
done
|
||||
grep -Eq "$expected" /proc/$(cat /run/rsyslog.pid)/status
|
||||
logger -n 127.0.0.1 -P 1514 -d -p local4.info "$1"
|
||||
for ((i=0; i<100; i++)); do
|
||||
if grep -q "$1" /var/log/xcat/cluster.log; then break; fi
|
||||
sleep .02
|
||||
done
|
||||
grep -q "$1" /var/log/xcat/cluster.log
|
||||
SH
|
||||
cat >"$fixture/bin/log-test" <<'SH'
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
ip link set lo up
|
||||
rm -f /run/rsyslog.pid
|
||||
if [ "$SYSLOG_TEST_ROLE" = mn ]; then touch /etc/xCATMN; fi
|
||||
if [ "$SYSLOG_TEST_VERSION" = 3 ]; then
|
||||
echo 'SYSLOGD_OPTIONS="-c 3"' >/etc/default/rsyslog
|
||||
fi
|
||||
case "$SYSLOG_TEST_DIRECTORY" in
|
||||
absent) ;;
|
||||
blocked) touch /var/log/xcat ;;
|
||||
*)
|
||||
mkdir -m "$SYSLOG_TEST_DIRECTORY" /var/log/xcat
|
||||
echo preserved >/var/log/xcat/old.log
|
||||
chmod 0600 /var/log/xcat/old.log
|
||||
;;
|
||||
esac
|
||||
exec /bin/bash -eu -c "$1"
|
||||
SH
|
||||
chmod +x "$fixture/bin/rsyslogd" "$fixture/bin/systemctl" \
|
||||
"$fixture/bin/log-test" "$fixture/bin/check-delivery"
|
||||
}
|
||||
|
||||
run_syslog()
|
||||
{
|
||||
local role=$1 directory=$2 version=$3 osver=$4 code=$5
|
||||
run "${sandbox[@]}" --setenv OSVER "$osver" --setenv SYSLOG '' \
|
||||
--setenv NTYPE service --setenv SVLOGLOCAL "$([ "$role" = forward ] && echo 0 || echo 1)" \
|
||||
--setenv MASTER 127.0.0.1:1515 --setenv SYSLOG_TEST_ROLE "$role" \
|
||||
--setenv SYSLOG_TEST_DIRECTORY "$directory" --setenv SYSLOG_TEST_VERSION "$version" \
|
||||
/bin/bash /bin/log-test "$code"
|
||||
if [ "$status" -ne 0 ]; then
|
||||
cat "$fixture/run/daemon.log" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@test 'syslog creates a local log directory and delivers as syslog on MN and SN' {
|
||||
local role osver
|
||||
for role in mn sn; do
|
||||
for osver in ubuntu24.04 debian12; do
|
||||
run_syslog "$role" absent 8 "$osver" '
|
||||
for pass in 1 2; do
|
||||
/tmp/postscripts/syslog
|
||||
test "$(stat -c %U:%G:%a /var/log/xcat)" = syslog:adm:750
|
||||
check-delivery "directory-test-$pass"
|
||||
done
|
||||
'
|
||||
rm -rf "$fixture/var/log/xcat"
|
||||
rm -f "$fixture/etc/xCATMN"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
@test 'syslog preserves existing directory modes and log file ownership' {
|
||||
local mode
|
||||
for mode in 0700 0750; do
|
||||
run_syslog mn "$mode" 8 ubuntu24.04 '
|
||||
before=$(stat -c %u:%g:%a /var/log/xcat/old.log)
|
||||
/tmp/postscripts/syslog
|
||||
test "$(stat -c %a /var/log/xcat)" = "${SYSLOG_TEST_DIRECTORY#0}"
|
||||
test "$(stat -c %U:%G /var/log/xcat)" = syslog:adm
|
||||
test "$(stat -c %u:%g:%a /var/log/xcat/old.log)" = "$before"
|
||||
test "$(cat /var/log/xcat/old.log)" = preserved
|
||||
check-delivery restricted-directory-test
|
||||
'
|
||||
rm -rf "$fixture/var/log/xcat"
|
||||
done
|
||||
}
|
||||
|
||||
@test 'syslog prepares the log directory after the real upgrade wrapper' {
|
||||
run_syslog mn absent 8 ubuntu24.04 '
|
||||
. /tmp/upgrade.sh
|
||||
xcat_run_upgrade /tmp/postscripts/syslog
|
||||
test "$(stat -c %U:%G /var/log/xcat)" = syslog:adm
|
||||
test -s /var/log/xcat/upgrade.log
|
||||
check-delivery upgrade-directory-test
|
||||
'
|
||||
}
|
||||
|
||||
@test 'syslog retains rsyslog compatibility-mode directory ownership' {
|
||||
run_syslog mn absent 3 ubuntu24.04 '
|
||||
/tmp/postscripts/syslog
|
||||
test "$(stat -c %U:%G:%a /var/log/xcat)" = syslog:adm:750
|
||||
check-delivery compatibility-directory-test
|
||||
'
|
||||
}
|
||||
|
||||
@test 'syslog retains the legacy reference-directory ownership' {
|
||||
run_syslog mn absent 5 ubuntu24.04 '
|
||||
chown root:syslog /var/log
|
||||
chmod 0775 /var/log
|
||||
/tmp/postscripts/syslog
|
||||
test "$(stat -c %u:%g /var/log/xcat)" = "$(stat -c %u:%g /var/log)"
|
||||
test "$(stat -c %a /var/log/xcat)" = 775
|
||||
check-delivery legacy-directory-test
|
||||
'
|
||||
}
|
||||
|
||||
@test 'syslog does not create a local directory on forwarding nodes' {
|
||||
run_syslog forward absent 8 ubuntu24.04 '
|
||||
/tmp/postscripts/syslog
|
||||
test ! -e /var/log/xcat
|
||||
grep -qx "\*\.\* @127.0.0.1:1515" /etc/rsyslog.d/remote.conf
|
||||
'
|
||||
}
|
||||
|
||||
@test 'syslog reports failure when the directory path is a file' {
|
||||
run_syslog mn blocked 8 ubuntu24.04 '
|
||||
if /tmp/postscripts/syslog; then exit 1; fi
|
||||
test -f /var/log/xcat
|
||||
test ! -e /run/rsyslog.pid
|
||||
'
|
||||
}
|
||||
@@ -38,6 +38,11 @@ skip. The CI takes a copy of the checkout before the build for this reason; see
|
||||
|
||||
## Running commands from Perl tests
|
||||
|
||||
`syncfiles_consumer_identity.t` also requires `/usr/bin/rsync` on Linux. The
|
||||
real copy parser checks that executable before the test intercepts copy
|
||||
execution. Install rsync with the test dependencies; this test does not run it
|
||||
or connect to another node. The CI management-node install already includes it.
|
||||
|
||||
Use `XCAT::Test::Process` when a test needs a command's exit code and combined
|
||||
standard output and standard error:
|
||||
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
#!/usr/bin/env perl
|
||||
# The boot file both DHCP backends name for a grub2 node. An aarch64 node gets a name that ends in
|
||||
# .efi once nodeset has created it: some aarch64 UEFI firmware ignores any other name and requests
|
||||
# grubaa64.efi instead.
|
||||
use strict;
|
||||
use warnings;
|
||||
## no critic (TestingAndDebugging::ProhibitNoWarnings)
|
||||
no warnings 'once';
|
||||
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use lib "$FindBin::Bin/../../xCAT-server/lib";
|
||||
use lib "$FindBin::Bin/../../xCAT-server/lib/perl";
|
||||
use lib "$FindBin::Bin/../../perl-xCAT";
|
||||
|
||||
use File::Path qw(make_path);
|
||||
use File::Temp qw(tempdir);
|
||||
use Test::More;
|
||||
use XCAT::Test::File qw(repo_path);
|
||||
|
||||
BEGIN {
|
||||
$ENV{XCATROOT} = repo_path('xCAT-server');
|
||||
$ENV{XCATCFG} = 'SQLite:' . tempdir( CLEANUP => 1 );
|
||||
}
|
||||
|
||||
use xCAT::DHCP::BootPolicy;
|
||||
use xCAT::TableUtils;
|
||||
|
||||
# dhcp.pm reads the site TFTP directory once, when it loads. noderes.tftpdir moves one node elsewhere.
|
||||
my $site_tftp = tempdir( CLEANUP => 1 );
|
||||
my $node_tftp = tempdir( CLEANUP => 1 );
|
||||
{
|
||||
no warnings 'redefine';
|
||||
*xCAT::TableUtils::getTftpDir = sub { return $site_tftp; };
|
||||
}
|
||||
require( repo_path('xCAT-server/lib/xcat/plugins/dhcp.pm') );
|
||||
|
||||
for my $dir ( $site_tftp, $node_tftp ) {
|
||||
make_path("$dir/boot/grub2");
|
||||
open( my $loader, '>', "$dir/boot/grub2/grub2.aarch64" ) or die "Cannot create the loader: $!";
|
||||
close($loader) or die "Cannot close the loader: $!";
|
||||
}
|
||||
|
||||
# The node loader links in a TFTP directory, as a nodeset left them.
|
||||
sub publish {
|
||||
my ( $dir, @names ) = @_;
|
||||
unlink( glob("$dir/boot/grub2/grub2-cn1*") );
|
||||
for my $name (@names) {
|
||||
symlink( 'grub2.aarch64', "$dir/boot/grub2/$name" ) or die "Cannot create $dir/boot/grub2/$name: $!";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# A table returns only the columns the plugin asks for, like the real one.
|
||||
{
|
||||
package GrubLoaderTable;
|
||||
|
||||
our %rows;
|
||||
sub new { my ( $class, $name ) = @_; return bless { name => $name }, $class; }
|
||||
|
||||
sub getNodesAttribs {
|
||||
my ( $self, $nodes, $cols ) = @_;
|
||||
my %out;
|
||||
for my $node (@$nodes) {
|
||||
my $row = $rows{ $self->{name} }{$node} or next;
|
||||
$out{$node} = [ { map { exists $row->{$_} ? ( $_ => $row->{$_} ) : () } @$cols } ];
|
||||
}
|
||||
return \%out;
|
||||
}
|
||||
sub getNodeAttribs { return; }
|
||||
sub getAllAttribs { return; }
|
||||
sub getAttribs { return { username => 'xcat_key', password => 'dGVzdA==' }; }
|
||||
sub close { return; }
|
||||
|
||||
package GrubLoaderISCBackend;
|
||||
sub name { return 'isc'; }
|
||||
|
||||
package GrubLoaderKeaBackend;
|
||||
sub subnet_id_for_ip { return 1; }
|
||||
}
|
||||
|
||||
sub node_rows {
|
||||
my ( $arch, $netboot, $tftpdir ) = @_;
|
||||
return (
|
||||
noderes => { cn1 => { netboot => $netboot, tftpserver => '192.0.2.1', ( $tftpdir ? ( tftpdir => $tftpdir ) : () ) } },
|
||||
chain => { cn1 => { currstate => 'install' } },
|
||||
mac => { cn1 => { mac => '02:00:00:00:00:11' } },
|
||||
nodetype => { cn1 => { os => 'rhels9.4', provmethod => 'install', ( defined $arch ? ( arch => $arch ) : () ) } },
|
||||
);
|
||||
}
|
||||
|
||||
my @errors;
|
||||
no warnings 'redefine';
|
||||
local *xCAT::Table::new = sub { return GrubLoaderTable->new( $_[1] ); };
|
||||
local *xCAT::TableUtils::get_site_attribute = sub { return; };
|
||||
local *xCAT::MsgUtils::trace = sub { return; };
|
||||
local *xCAT_plugin::dhcp::getipaddr = sub { return '192.0.2.11'; };
|
||||
local *xCAT::NetworkUtils::getipaddr = sub { return '192.0.2.11'; };
|
||||
local *xCAT_plugin::dhcp::ipIsDynamic = sub { return 0; };
|
||||
local $xCAT_plugin::dhcp::callback = sub { push @errors, @{ $_[0]->{error} || [] }; };
|
||||
use warnings 'redefine';
|
||||
|
||||
# The boot file of the reservation the Kea backend builds for cn1.
|
||||
sub kea_boot_file {
|
||||
my ( $arch, $netboot, $tftpdir ) = @_;
|
||||
local %GrubLoaderTable::rows = node_rows( $arch, $netboot, $tftpdir );
|
||||
my $reservations = xCAT_plugin::dhcp::kea_build_node_reservations( bless( {}, 'GrubLoaderKeaBackend' ), {}, ['cn1'] );
|
||||
return [ map { $_->{'boot-file-name'} } @$reservations ];
|
||||
}
|
||||
|
||||
my $dir = tempdir( CLEANUP => 1 );
|
||||
my $conf = "$dir/dhcpd.conf";
|
||||
open( my $fh, '>', $conf ) or die "Cannot create $conf: $!";
|
||||
print {$fh} "#xCAT generated dhcp configuration\n",
|
||||
"option space gpxe;\n",
|
||||
@{ xCAT::DHCP::BootPolicy->isc_ipxe_feature_option_lines() },
|
||||
"subnet 192.0.2.0 netmask 255.255.255.0 {\n",
|
||||
"} # 192.0.2.0/255.255.255.0 subnet_end\n";
|
||||
close($fh) or die "Cannot close $conf: $!";
|
||||
|
||||
# The boot file of every host that makedhcp creates for cn1 through OMAPI.
|
||||
sub isc_boot_files {
|
||||
my ( $arch, $netboot, $tftpdir ) = @_;
|
||||
local %GrubLoaderTable::rows = node_rows( $arch, $netboot, $tftpdir );
|
||||
my $commands = '';
|
||||
no warnings 'redefine';
|
||||
local *xCAT::DHCP::Backend::new_backend = sub { return bless {}, 'GrubLoaderISCBackend'; };
|
||||
local *xCAT::Utils::isServiceNode = sub { return 0; };
|
||||
local *xCAT::Utils::isLinux = sub { return 1; };
|
||||
local *xCAT::Utils::isFIPS = sub { return 0; };
|
||||
local *xCAT::Utils::checkservicestatus = sub { return 0; };
|
||||
local *xCAT::NetworkUtils::determinehostname = sub { return ('mn'); };
|
||||
local *xCAT::NetworkUtils::nodeonmynet = sub { return 1; };
|
||||
local *xCAT::DBobjUtils::getnodetype = sub { return {}; };
|
||||
local *xCAT::DBobjUtils::getNetwkInfo = sub { return ( cn1 => { mgtifname => 'eth0' } ); };
|
||||
local *xCAT_plugin::dhcp::addnic = sub { return; };
|
||||
local *xCAT_plugin::dhcp::addnet = sub { return; };
|
||||
local *xCAT_plugin::dhcp::addnet6 = sub { return; };
|
||||
local *xCAT_plugin::dhcp::writeout = sub { return; };
|
||||
local *xCAT_plugin::dhcp::_open_omshell_writer = sub {
|
||||
open( my $out, '>', \$commands ) or die "Cannot open an omshell buffer: $!";
|
||||
return $out;
|
||||
};
|
||||
local *xCAT_plugin::dhcp::_close_omshell_writer = sub { return; };
|
||||
local $::XCATSITEVALS{externaldhcpservers};
|
||||
local $xCAT_plugin::dhcp::dhcpconffile = $conf;
|
||||
local $xCAT_plugin::dhcp::distro = 'rhels9.4';
|
||||
use warnings 'redefine';
|
||||
|
||||
open( my $printed, '>', \my $text ) or die "Cannot open an output buffer: $!";
|
||||
my $selected = select($printed);
|
||||
my $died;
|
||||
eval {
|
||||
xCAT_plugin::dhcp::process_request( { _xcatpreprocessed => [1], node => ['cn1'], arg => [] },
|
||||
sub { push @errors, @{ $_[0]->{error} || [] }; } );
|
||||
1;
|
||||
} or $died = $@;
|
||||
select($selected);
|
||||
die "makedhcp died: $died" if $died;
|
||||
|
||||
return [ map { /filename = \\"([^\\"]*)\\"/g } $commands =~ /^set statements = "(.*)"$/mg ];
|
||||
}
|
||||
|
||||
my @both = qw(grub2-cn1 grub2-cn1.efi);
|
||||
my @old = qw(grub2-cn1);
|
||||
|
||||
# Architecture, links in the site TFTP directory, links in the node's own one (none: no noderes.tftpdir),
|
||||
# the boot file DHCP names, and the case.
|
||||
my @cases = (
|
||||
[ 'aarch64', \@both, undef, '/boot/grub2/grub2-cn1.efi', 'after nodeset' ],
|
||||
[ 'aarch64', \@old, undef, '/boot/grub2/grub2-cn1', 'set by an older nodeset' ],
|
||||
[ 'aarch64', [], undef, '/boot/grub2/grub2-cn1', 'without loader links' ],
|
||||
[ 'aarch64', \@old, \@both, '/boot/grub2/grub2-cn1.efi', 'after nodeset in its own TFTP directory' ],
|
||||
[ 'aarch64', \@both, \@old, '/boot/grub2/grub2-cn1', 'set by an older nodeset in its own TFTP directory' ],
|
||||
[ 'x86_64', \@old, undef, '/boot/grub2/grub2-cn1', 'after nodeset' ],
|
||||
[ 'x86_64', \@both, undef, '/boot/grub2/grub2-cn1', 'with a stray .efi link' ],
|
||||
[ 'riscv64', \@old, undef, '/boot/grub2/grub2-cn1', 'after nodeset' ],
|
||||
[ 'ppc64', \@old, undef, '/boot/grub2/grub2-cn1', 'after nodeset' ],
|
||||
[ 'ppc64le', \@old, undef, '/boot/grub2/grub2-cn1', 'after nodeset' ],
|
||||
[ '', \@both, undef, '/boot/grub2/grub2-cn1', 'with a .efi link' ],
|
||||
[ undef, \@both, undef, '/boot/grub2/grub2-cn1', 'with a .efi link' ],
|
||||
);
|
||||
|
||||
for my $case (@cases) {
|
||||
my ( $arch, $site_links, $node_links, $expected, $state ) = @$case;
|
||||
my $label = ( defined $arch ? ( $arch eq '' ? 'a blank arch' : $arch ) : 'no arch' ) . " $state";
|
||||
publish( $site_tftp, @$site_links );
|
||||
publish( $node_tftp, @{ $node_links || [] } );
|
||||
my $tftpdir = $node_links ? $node_tftp : undef;
|
||||
|
||||
for my $netboot (qw(grub2 grub2-tftp grub2-http)) {
|
||||
@errors = ();
|
||||
is_deeply( kea_boot_file( $arch, $netboot, $tftpdir ), [$expected], "Kea: $netboot node with $label" )
|
||||
or diag("errors: @errors");
|
||||
}
|
||||
@errors = ();
|
||||
is_deeply( isc_boot_files( $arch, 'grub2', $tftpdir ), [$expected], "ISC: grub2 node with $label" )
|
||||
or diag("errors: @errors");
|
||||
}
|
||||
|
||||
publish( $site_tftp, @both );
|
||||
is( xCAT_plugin::dhcp::kea_boot_for_node( 'cn1', { netboot => 'grub2' }, undef, undef, undef, '192.0.2.1' )->{'boot-file-name'},
|
||||
'/boot/grub2/grub2-cn1', 'Kea: grub2 node without a nodetype entry' );
|
||||
is( xCAT_plugin::dhcp::kea_boot_for_node(
|
||||
'cn1', { netboot => 'grub2' }, { currstate => 'boot' }, { arch => 'aarch64' }, undef, '192.0.2.1'
|
||||
)->{'boot-file-name'},
|
||||
'', 'Kea: aarch64 grub2 node in boot state still gets no boot file' );
|
||||
|
||||
done_testing();
|
||||
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env perl
|
||||
# The per-node loader links nodeset publishes in boot/grub2. An aarch64 node also gets
|
||||
# grub2-<node>.efi, the name DHCP hands it, and grub2-<node> stays for DHCP that makedhcp did not write.
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'once';
|
||||
|
||||
use Cwd qw(getcwd);
|
||||
use File::Path qw(make_path);
|
||||
use File::Slurper qw(write_text);
|
||||
use File::Temp qw(tempdir);
|
||||
use FindBin;
|
||||
use Test::More;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use lib "$FindBin::Bin/../../perl-xCAT";
|
||||
use lib "$FindBin::Bin/../../xCAT-server/lib/perl";
|
||||
use XCAT::Test::File qw(repo_path);
|
||||
|
||||
my $root = tempdir(CLEANUP => 1);
|
||||
local $ENV{XCATROOT} = repo_path('xCAT-server');
|
||||
local $ENV{XCATCFG} = "$root/config";
|
||||
make_path($ENV{XCATCFG});
|
||||
local %::XCATSITEVALS = (tftpdir => "$root/tftpboot", xcatdebugmode => 0);
|
||||
require xCAT::Table;
|
||||
require xCAT::NetworkUtils;
|
||||
|
||||
no warnings 'redefine';
|
||||
local *xCAT::Table::new = sub { die 'Unexpected database access'; };
|
||||
local *xCAT::NetworkUtils::getipaddr = sub {
|
||||
my ($class, $host) = @_;
|
||||
return '192.0.2.1' if $host eq 'server';
|
||||
return '192.0.2.2' if $host eq 'node';
|
||||
die "Unexpected hostname: $host";
|
||||
};
|
||||
use warnings 'redefine';
|
||||
|
||||
require(repo_path('xCAT-server/lib/xcat/plugins/grub2.pm'));
|
||||
|
||||
sub new_bootdir {
|
||||
my ($arch) = @_;
|
||||
my $tftpdir = tempdir(DIR => $root, CLEANUP => 1);
|
||||
make_path("$tftpdir/boot/grub2");
|
||||
write_text("$tftpdir/boot/grub2/grub2.$arch", "fixture loader\n");
|
||||
return $tftpdir;
|
||||
}
|
||||
|
||||
sub nodeset {
|
||||
my ($tftpdir, $arch, $currstate, $os) = @_;
|
||||
my $cwd = getcwd();
|
||||
my @result = xCAT_plugin::grub2::setstate(
|
||||
'node',
|
||||
{node => [{kernel => 'images/vmlinuz', initrd => 'images/initrd.img', kcmdline => 'quiet'}]},
|
||||
{node => [{currstate => $currstate}]},
|
||||
{node => [{mac => '02:00:00:00:00:02'}]},
|
||||
$tftpdir, {node => [{tftpserver => 'server', netboot => 'grub2'}]}, {}, $arch, $os // 'rhels9.4',
|
||||
);
|
||||
chdir($cwd) or die "Cannot restore working directory: $!";
|
||||
is_deeply(\@result, [0, ''], "nodeset $currstate succeeds");
|
||||
return;
|
||||
}
|
||||
|
||||
sub links {
|
||||
my ($tftpdir) = @_;
|
||||
opendir(my $dh, "$tftpdir/boot/grub2") or die "Cannot read $tftpdir/boot/grub2: $!";
|
||||
my %links = map { $_ => readlink("$tftpdir/boot/grub2/$_") } grep { -l "$tftpdir/boot/grub2/$_" } readdir($dh);
|
||||
closedir($dh);
|
||||
return \%links;
|
||||
}
|
||||
|
||||
for my $case (['aarch64', 'aarch64'], ['x86_64', 'x86_64'], ['riscv64', 'riscv64'], ['ppc64', 'ppc']) {
|
||||
my ($arch, $loader_arch) = @$case;
|
||||
subtest "$arch: install" => sub {
|
||||
my $tftpdir = new_bootdir($loader_arch);
|
||||
nodeset($tftpdir, $arch, 'install');
|
||||
my %expected = ('grub2-node' => "grub2.$loader_arch");
|
||||
$expected{'grub2-node.efi'} = 'grub2.aarch64' if $arch eq 'aarch64';
|
||||
is_deeply(links($tftpdir), \%expected, 'the node loader links point at the architecture loader');
|
||||
|
||||
nodeset($tftpdir, $arch, 'install');
|
||||
is_deeply(links($tftpdir), \%expected, 'a second nodeset leaves the same links');
|
||||
};
|
||||
}
|
||||
|
||||
subtest 'aarch64: install after an older nodeset' => sub {
|
||||
my $tftpdir = new_bootdir('aarch64');
|
||||
symlink('grub2.aarch64', "$tftpdir/boot/grub2/grub2-node") or die "Cannot create the old link: $!";
|
||||
nodeset($tftpdir, 'aarch64', 'install');
|
||||
is_deeply(links($tftpdir), {'grub2-node' => 'grub2.aarch64', 'grub2-node.efi' => 'grub2.aarch64'},
|
||||
'the .efi link is added beside the old one');
|
||||
};
|
||||
|
||||
for my $case (['boot'], ['offline'], ['standby', 'sles15.5']) {
|
||||
my ($state, $os) = @$case;
|
||||
subtest "aarch64: $state after install" . ($os ? " on $os" : '') => sub {
|
||||
my $tftpdir = new_bootdir('aarch64');
|
||||
nodeset($tftpdir, 'aarch64', 'install', $os);
|
||||
nodeset($tftpdir, 'aarch64', $state, $os);
|
||||
is_deeply(links($tftpdir), {}, 'both node loader links are removed');
|
||||
};
|
||||
}
|
||||
|
||||
subtest 'aarch64: standby on an older SLES keeps both links' => sub {
|
||||
my $tftpdir = new_bootdir('aarch64');
|
||||
nodeset($tftpdir, 'aarch64', 'install', 'sles12.5');
|
||||
nodeset($tftpdir, 'aarch64', 'standby', 'sles12.5');
|
||||
is_deeply(links($tftpdir), {'grub2-node' => 'grub2.aarch64', 'grub2-node.efi' => 'grub2.aarch64'},
|
||||
'the node loader links stay');
|
||||
};
|
||||
|
||||
done_testing();
|
||||
@@ -0,0 +1,124 @@
|
||||
#!/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(write_text);
|
||||
use File::Temp qw(tempdir);
|
||||
use Storable qw(dclone);
|
||||
use Test::More;
|
||||
use XCAT::Test::File qw(repo_path);
|
||||
|
||||
my $work = tempdir(CLEANUP => 1);
|
||||
make_path("$work/db");
|
||||
local $ENV{XCATROOT} = $work;
|
||||
local $ENV{XCATCFG} = "SQLite:$work/db";
|
||||
for my $mapping (
|
||||
[ xCAT_plugin => 'xCAT-server/lib/xcat/plugins' ],
|
||||
[ xCAT_monitoring => 'xCAT-server/lib/xcat/monitoring' ],
|
||||
) {
|
||||
symlink(repo_path($mapping->[1]), "$work/$mapping->[0]") or die $!;
|
||||
}
|
||||
unshift @INC, $work;
|
||||
require xCAT_plugin::syncfiles;
|
||||
require xCAT_plugin::xdsh;
|
||||
require xCAT_plugin::updatenode;
|
||||
|
||||
my $source = "$work/payload";
|
||||
my $list = "$work/synclist";
|
||||
write_text($source, "identity fixture\n");
|
||||
write_text($list, "$source -> /tmp/syncfiles-identity/payload\n");
|
||||
|
||||
sub exercise {
|
||||
my ($producer, $case) = @_;
|
||||
local %ENV = %ENV;
|
||||
delete @ENV{grep { /\A(?:DSH_|DCP_|RSYNC)/ } keys %ENV};
|
||||
@ENV{keys %{$case->{inherited}}} = values %{$case->{inherited}};
|
||||
no warnings qw(once redefine);
|
||||
local $::RCP;
|
||||
local $::USER;
|
||||
local $::fanout;
|
||||
local $::timeout;
|
||||
local $::REPORTSTATUS = 'N';
|
||||
local @::SUCCESSFULLNODES;
|
||||
local @::FAILEDNODES;
|
||||
local @ARGV;
|
||||
local *xCAT::Utils::isServiceNode = sub { return 0; };
|
||||
local *xCAT::Utils::isMN = sub { return 0; };
|
||||
local *xCAT::TableUtils::get_site_attribute = sub { return; };
|
||||
local *xCAT::SvrUtils::getsynclistfile = sub { return {node1 => $list}; };
|
||||
local *xCAT_plugin::syncfiles::noderange = sub { return 'node1'; };
|
||||
my (@executions, @responses, @requests);
|
||||
local *xCAT::DSHCLI::execute_dcp = sub {
|
||||
my ($class, $options) = @_;
|
||||
push @executions, {
|
||||
options => dclone($options),
|
||||
from => $ENV{DSH_FROM_USERID},
|
||||
to => $ENV{DSH_TO_USERID},
|
||||
};
|
||||
return 0;
|
||||
};
|
||||
my $callback = sub { push @responses, dclone($_[0]); };
|
||||
my $dispatch = sub {
|
||||
my ($request, $response) = @_;
|
||||
push @requests, dclone($request);
|
||||
xCAT_plugin::xdsh::process_request($request, $response, sub { die 'Unexpected nested request'; });
|
||||
};
|
||||
my $request = {
|
||||
command => [$producer], node => ['node1'], arg => [],
|
||||
username => ['operator'], _xcat_clienthost => ['node1.example.test'],
|
||||
environment => $case->{environment} || [],
|
||||
SNFileSyncing => ['no'], FileSyncing => ['yes'],
|
||||
};
|
||||
if ($producer eq 'syncfiles') {
|
||||
xCAT_plugin::syncfiles::process_request($request, $callback, $dispatch);
|
||||
} else {
|
||||
xCAT_plugin::updatenode::updatenodesyncfiles($request, $dispatch, $callback);
|
||||
}
|
||||
is(scalar @executions, 1, 'one parsed copy reaches the execution boundary');
|
||||
is(scalar @requests, 1, 'one producer request reaches the real xdsh plugin');
|
||||
my $copy = $executions[0] || {options => {}};
|
||||
is($copy->{from}, $case->{from}, 'consumer preserves the expected sending identity');
|
||||
is($copy->{to}, $case->{to}, 'consumer preserves the expected receiving identity');
|
||||
is($copy->{options}->{user}, $case->{from}, 'xdcp selects the sending identity for its copy user');
|
||||
is($copy->{options}->{nodes}, 'node1', 'copy targets the resolved node');
|
||||
is_deeply(
|
||||
$copy->{options}->{destDir_srcFile},
|
||||
{node1 => {'/tmp/syncfiles-identity' => {same_dest_name => [$source]}}},
|
||||
'the real synclist parser supplies the payload and destination',
|
||||
);
|
||||
is_deeply($requests[0]->{username}, [$producer eq 'syncfiles' ? 'root' : 'operator'],
|
||||
'the producer retains its request identity contract');
|
||||
my @errors = grep {
|
||||
$_->{error} || grep { $_ } ref($_->{errorcode}) eq 'ARRAY'
|
||||
? @{$_->{errorcode}} : ($_->{errorcode} || 0)
|
||||
} @responses;
|
||||
is_deeply(\@errors, [], 'the request has no consumer error');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $case (
|
||||
{name => 'unset', inherited => {}, from => 'root', to => 'root'},
|
||||
{name => 'empty', inherited => {DSH_FROM_USERID => '', DSH_TO_USERID => ''}, from => 'root', to => 'root'},
|
||||
{name => 'sending identity only', inherited => {DSH_FROM_USERID => 'sender'}, from => 'sender', to => 'root'},
|
||||
{name => 'receiving identity only', inherited => {DSH_TO_USERID => 'receiver'}, from => 'root', to => 'receiver'},
|
||||
{name => 'both inherited', inherited => {DSH_FROM_USERID => 'sender', DSH_TO_USERID => 'receiver'}, from => 'sender', to => 'receiver'},
|
||||
) {
|
||||
subtest "syncfiles: $case->{name}" => sub { exercise('syncfiles', $case); };
|
||||
}
|
||||
|
||||
for my $case (
|
||||
{name => 'certificate identity', inherited => {}, from => 'operator', to => 'operator'},
|
||||
{name => 'certificate overrides inherited sender', inherited => {DSH_FROM_USERID => 'sender', DSH_TO_USERID => 'receiver'}, from => 'operator', to => 'receiver'},
|
||||
{name => 'explicit sending identity', inherited => {}, environment => ['DSH_FROM_USERID=sender'], from => 'sender', to => 'operator'},
|
||||
{name => 'first explicit sender wins', inherited => {}, environment => ['DSH_FROM_USERID=sender', 'DSH_FROM_USERID=other'], from => 'sender', to => 'operator'},
|
||||
{name => 'empty explicit sender falls back at consumer', inherited => {DSH_FROM_USERID => 'sender'}, environment => ['DSH_FROM_USERID='], from => 'operator', to => 'operator'},
|
||||
) {
|
||||
subtest "updatenode: $case->{name}" => sub { exercise('updatenode', $case); };
|
||||
}
|
||||
|
||||
done_testing();
|
||||
@@ -183,9 +183,25 @@ push @cases,
|
||||
args => [],
|
||||
synclist => { node1 => '/install/custom/sync-a' },
|
||||
expected => [],
|
||||
messages => [ qr/couldn't be correlated to a node/ ],
|
||||
messages => [ qr/\AReceived syncfiles from unknown\.example\.test, which couldn't be correlated to a node \(domain mismatch\?\)\z/ ],
|
||||
};
|
||||
|
||||
for my $client ( 'other.example.test', '', undef ) {
|
||||
my $name = defined($client) ? $client : '';
|
||||
my $label = !defined($client) ? 'missing' : length($client) ? $client : 'blank';
|
||||
push @cases, {
|
||||
name => "unresolved client '$label' retains its diagnostic and sends no request",
|
||||
request => {
|
||||
command => ['syncfiles'],
|
||||
arg => [],
|
||||
( defined($client) ? ( _xcat_clienthost => [$client] ) : () ),
|
||||
},
|
||||
synclist => { node1 => '/install/custom/sync-a' },
|
||||
expected => [],
|
||||
messages => [ qr/\AReceived syncfiles from \Q$name\E, which couldn't be correlated to a node \(domain mismatch\?\)\z/ ],
|
||||
};
|
||||
}
|
||||
|
||||
for my $case (@cases) {
|
||||
subtest $case->{name} => sub {
|
||||
local $RCP;
|
||||
|
||||
+62
-15
@@ -143,7 +143,7 @@ route_exists()
|
||||
# ipv6
|
||||
if is_ipv6_route "$route_net"
|
||||
then
|
||||
result=`ip -6 route show $route_net/$route_mask`
|
||||
result=`ip -6 route show $route_net/$route_mask ${gateway_device:+via $route_gw dev $gateway_device}`
|
||||
if [ $? -ne 0 ] || [ -z "$result" ]
|
||||
then
|
||||
ret=0
|
||||
@@ -449,6 +449,15 @@ nmcli_persistent_route()
|
||||
fi
|
||||
}
|
||||
|
||||
remove_route_record()
|
||||
{
|
||||
local filename=$1
|
||||
local pattern
|
||||
[ -f "$filename" ] || return 0
|
||||
pattern=$(printf '%s\n' "$2" | sed 's/[][\\.^$*#]/\\&/g')
|
||||
sed -i "\#^[[:space:]]*${pattern}[[:space:]]*\$#d" "$filename"
|
||||
}
|
||||
|
||||
# handle the route replace operation that adding the setting to configuration file
|
||||
replace_persistent_route()
|
||||
{
|
||||
@@ -491,8 +500,8 @@ replace_persistent_route()
|
||||
route="$net/$mask :: - $ifname"
|
||||
route1="$net\/$mask :: - $ifname";
|
||||
else
|
||||
route="$net/$mask $gw - -"
|
||||
route1="$net\/$mask $gw - -";
|
||||
route="$net/$mask $gw - ${gateway_device:--}"
|
||||
route1="$net\/$mask $gw - ${gateway_device:--}";
|
||||
fi
|
||||
else
|
||||
# for ipv4
|
||||
@@ -549,8 +558,8 @@ replace_persistent_route()
|
||||
route="$net/$mask dev $ifname"
|
||||
route1="$net\/$mask dev $ifname"
|
||||
else
|
||||
route="$net/$mask via $gw"
|
||||
route1="$net\/$mask via $gw"
|
||||
route="$net/$mask via $gw${gateway_device:+ dev $gateway_device}"
|
||||
route1="$net\/$mask via $gw${gateway_device:+ dev $gateway_device}"
|
||||
fi
|
||||
else
|
||||
# ipv4
|
||||
@@ -696,8 +705,8 @@ add_persistent_route()
|
||||
route="$net/$mask :: - $ifname"
|
||||
route1="$net\/$mask :: - $ifname";
|
||||
else
|
||||
route="$net/$mask $gw - -"
|
||||
route1="$net\/$mask $gw - -";
|
||||
route="$net/$mask $gw - ${gateway_device:--}"
|
||||
route1="$net\/$mask $gw - ${gateway_device:--}";
|
||||
fi
|
||||
else
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
@@ -728,8 +737,13 @@ add_persistent_route()
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
local match_flags=
|
||||
if is_ipv6_route "$net" && [ -n "$gateway_device" ]; then
|
||||
remove_route_record "$filename" "$net/$mask $gw - -" || return $?
|
||||
match_flags=-Fx
|
||||
fi
|
||||
if [ -f $filename ]; then
|
||||
grep "$route" $filename 2>&1 1>/dev/null
|
||||
grep $match_flags "$route" $filename 2>&1 1>/dev/null
|
||||
if [ $? -ne 0 ]; then #route does not exist
|
||||
grep "$xcat_config_start" $filename 2>&1 1>/dev/null
|
||||
if [ $? -ne 0 ]; then #no xCAT section
|
||||
@@ -782,6 +796,11 @@ add_persistent_route()
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$gateway_device" ] && [ "$v6flag" -eq 1 ]; then
|
||||
remove_route_record "$filename" "up route -A inet6 add $net/$mask gw $gw" || return $?
|
||||
remove_route_record "$filename" "down route -A inet6 del $net/$mask gw $gw" || return $?
|
||||
remove_route_record "$filename" "post-up ip -6 route replace $net/$mask via $gw" || return $?
|
||||
fi
|
||||
grep "$matchstr" $filename 2>&1 1>/dev/null
|
||||
if [ $? -ne 0 ];then
|
||||
foundflag=0
|
||||
@@ -796,8 +815,8 @@ add_persistent_route()
|
||||
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
|
||||
else
|
||||
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
|
||||
echo " up route -A inet6 add $net/$mask gw $gw${gateway_device:+ dev $gateway_device}" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask gw $gw${gateway_device:+ dev $gateway_device}" >> $tempfile
|
||||
fi
|
||||
else
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
@@ -824,8 +843,8 @@ add_persistent_route()
|
||||
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
|
||||
else
|
||||
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
|
||||
echo " up route -A inet6 add $net/$mask gw $gw${gateway_device:+ dev $gateway_device}" >> $tempfile
|
||||
echo " down route -A inet6 del $net/$mask gw $gw${gateway_device:+ dev $gateway_device}" >> $tempfile
|
||||
fi
|
||||
else
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
@@ -924,6 +943,11 @@ rm_persistent_route()
|
||||
sles)
|
||||
#echo "sles"
|
||||
filename="/etc/sysconfig/network/routes";
|
||||
if is_ipv6_route "$net" && [ -n "$gateway_device" ]; then
|
||||
remove_route_record "$filename" "$net/$mask $gw - $gateway_device" || return $?
|
||||
remove_route_record "$filename" "$net/$mask $gw - -"
|
||||
return $?
|
||||
fi
|
||||
# ipv6 net
|
||||
if is_ipv6_route "$net"
|
||||
then
|
||||
@@ -984,6 +1008,15 @@ rm_persistent_route()
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$gateway_device" ] && [ "$v6flag" -eq 1 ]; then
|
||||
local device_suffix
|
||||
for device_suffix in " dev $gateway_device" ""; do
|
||||
remove_route_record "$filename" "up route -A inet6 add $net/$mask gw $gw$device_suffix" || return $?
|
||||
remove_route_record "$filename" "down route -A inet6 del $net/$mask gw $gw$device_suffix" || return $?
|
||||
remove_route_record "$filename" "post-up ip -6 route replace $net/$mask via $gw$device_suffix" || return $?
|
||||
done
|
||||
return 0
|
||||
fi
|
||||
grep "$matchstr" $filename
|
||||
if [ $? -eq 0 ];then
|
||||
sed -i -e "/$matchstr/d" $filename
|
||||
@@ -998,6 +1031,13 @@ rm_persistent_route()
|
||||
nmcli_persistent_route delete "$net" "$mask" "$gw" "$ifname"
|
||||
return $?
|
||||
fi
|
||||
if is_ipv6_route "$net" && [ -n "$gateway_device" ]; then
|
||||
filename="/etc/sysconfig/network-scripts/route6-$ifname"
|
||||
remove_route_record "$filename" "$net/$mask via $gw dev $gateway_device" || return $?
|
||||
remove_route_record "$filename" "$net/$mask via $gw" || return $?
|
||||
remove_route_record /etc/sysconfig/static-routes-ipv6 "$ifname $net/$mask $gw"
|
||||
return $?
|
||||
fi
|
||||
#ipv6
|
||||
if is_ipv6_route "$net"
|
||||
then
|
||||
@@ -1048,6 +1088,13 @@ rm_persistent_route()
|
||||
|
||||
|
||||
|
||||
gateway_device=
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
case "$gw" in
|
||||
[fF][eE][89aAbB][[:xdigit:]]:*) gateway_device=$ifname ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if command -v xcat_is_openeuler >/dev/null 2>&1 && xcat_is_openeuler "$OSVER"; then
|
||||
case "$op" in
|
||||
add|delete|replace)
|
||||
@@ -1071,7 +1118,7 @@ if [ "$op" = "add" ]; then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
cmd="ip -6 route add $net/$mask dev $ifname"
|
||||
else
|
||||
cmd="ip -6 route add $net/$mask via $gw"
|
||||
cmd="ip -6 route add $net/$mask via $gw${gateway_device:+ dev $gateway_device}"
|
||||
fi
|
||||
else
|
||||
# AIX TODO
|
||||
@@ -1127,7 +1174,7 @@ elif [ "$op" = "delete" ]; then
|
||||
if [ "$gw" = "" -o "$gw" = "::" ] ; then
|
||||
cmd="ip -6 route delete $net/$mask dev $ifname"
|
||||
else
|
||||
cmd="ip -6 route delete $net/$mask via $gw"
|
||||
cmd="ip -6 route delete $net/$mask via $gw${gateway_device:+ dev $gateway_device}"
|
||||
fi
|
||||
else
|
||||
# AIX TODO
|
||||
@@ -1183,7 +1230,7 @@ elif [ "$op" = "replace" ]; then
|
||||
if [ "$net" = "default" ]; then
|
||||
cmd="ip -6 route replace default via $gw"
|
||||
else
|
||||
cmd="ip -6 route replace $net/$mask via $gw"
|
||||
cmd="ip -6 route replace $net/$mask via $gw${gateway_device:+ dev $gateway_device}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
+11
-3
@@ -83,6 +83,14 @@ is_lsb_ubuntu ()
|
||||
# failure (not Ubuntu), which is the correct outcome.
|
||||
}
|
||||
|
||||
set_log_directory_owner()
|
||||
{
|
||||
local mode=$1
|
||||
shift
|
||||
mkdir -p -m "$mode" /var/log/xcat || exit $?
|
||||
chown "$@" /var/log/xcat
|
||||
}
|
||||
|
||||
config_Rsyslog_C3()
|
||||
{
|
||||
isReceiving=0
|
||||
@@ -127,7 +135,7 @@ config_Rsyslog_C3()
|
||||
touch /var/log/messages
|
||||
chown syslog:adm /var/log/messages
|
||||
sed -i 's/\$PrivDropToGroup syslog/\$PrivDropToGroup adm/' $2
|
||||
chown syslog:adm /var/log/xcat
|
||||
set_log_directory_owner 0750 syslog:adm
|
||||
fi
|
||||
else
|
||||
sed -i 's/^\(\*\..*\)/\#\1/;
|
||||
@@ -286,7 +294,7 @@ config_rsyslog_V8()
|
||||
if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then
|
||||
chown syslog:adm /var/log/messages
|
||||
sed -i 's/\$PrivDropToGroup syslog/\$PrivDropToGroup adm/' $conf_file
|
||||
chown syslog:adm /var/log/xcat
|
||||
set_log_directory_owner 0750 syslog:adm
|
||||
fi
|
||||
|
||||
# Mark the start of xCAT section
|
||||
@@ -523,7 +531,7 @@ else
|
||||
touch /var/log/messages
|
||||
if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then
|
||||
chown --reference=/var/log /var/log/messages
|
||||
chown --reference=/var/log /var/log/xcat
|
||||
set_log_directory_owner "$(stat -c %a /var/log)" --reference=/var/log
|
||||
fi
|
||||
if [ $ng -eq 0 ]; then
|
||||
if [ ! -f $conf_file.XCATORIG ]; then
|
||||
|
||||
Reference in New Issue
Block a user