mirror of
https://github.com/fspc/gbootroot.git
synced 2025-02-22 08:33:24 -05:00
* improvements in error output from yard_chrooted_tests to verbosity box
This commit is contained in:
parent
2aa648a220
commit
8f683e0545
150
Yard.pm
150
Yard.pm
@ -34,8 +34,8 @@ use Exporter;
|
|||||||
@EXPORT = qw(start_logging_output info kernel_version_check verbosity
|
@EXPORT = qw(start_logging_output info kernel_version_check verbosity
|
||||||
read_contents_file extra_links library_dependencies hard_links
|
read_contents_file extra_links library_dependencies hard_links
|
||||||
space_check create_filesystem find_file_in_path sys
|
space_check create_filesystem find_file_in_path sys
|
||||||
text_insert logadj error *LOGFILE which_tests check_termcap
|
text_insert logadj *LOGFILE which_tests check_termcap
|
||||||
warning scan_command_file check_getty_type_call);
|
scan_command_file check_getty_type_call);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
@ -73,6 +73,9 @@ BEGIN {
|
|||||||
|
|
||||||
STDOUT->autoflush(1);
|
STDOUT->autoflush(1);
|
||||||
|
|
||||||
|
$SIG{__WARN__} =
|
||||||
|
sub { warn @_ unless $_[0] =~ /Subroutine [\w:]+ redefined/io };
|
||||||
|
|
||||||
sub warning {
|
sub warning {
|
||||||
info(0, "Warning: ", @_);
|
info(0, "Warning: ", @_);
|
||||||
$Warnings++;
|
$Warnings++;
|
||||||
@ -922,6 +925,11 @@ sub create_filesystem {
|
|||||||
info(0, "\nDone making the root filesystem. $Warnings warnings.\n",
|
info(0, "\nDone making the root filesystem. $Warnings warnings.\n",
|
||||||
"$device is now umounted from $mount_point\n\n");
|
"$device is now umounted from $mount_point\n\n");
|
||||||
|
|
||||||
|
#info(0, "All done!\n");
|
||||||
|
#info(0, "You can run more tests with the UML kernel\n",
|
||||||
|
# "or construct a distribution by using this root\n",
|
||||||
|
# "filesystem with a boot method.");
|
||||||
|
|
||||||
} # end sub create_filesystem
|
} # end sub create_filesystem
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
@ -1092,6 +1100,11 @@ my($proc_dev) = (stat("/proc"))[0];
|
|||||||
|
|
||||||
sub info {
|
sub info {
|
||||||
my($level, @msgs) = @_;
|
my($level, @msgs) = @_;
|
||||||
|
|
||||||
|
if ($level != 3) {
|
||||||
|
print LOGFILE @msgs;
|
||||||
|
}
|
||||||
|
$level = 0x if $level == 3;
|
||||||
|
|
||||||
my $output = join("",@msgs);
|
my $output = join("",@msgs);
|
||||||
if ($verbosity >= $level) {
|
if ($verbosity >= $level) {
|
||||||
@ -1108,7 +1121,6 @@ sub info {
|
|||||||
while (Gtk->events_pending) { Gtk->main_iteration; }
|
while (Gtk->events_pending) { Gtk->main_iteration; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print LOGFILE @msgs;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1141,15 +1153,31 @@ sub start_logging_output {
|
|||||||
##### Same as system() but obeys $verbosity setting for both STDOUT
|
##### Same as system() but obeys $verbosity setting for both STDOUT
|
||||||
##### and STDERR.
|
##### and STDERR.
|
||||||
sub sys {
|
sub sys {
|
||||||
open(SYS, "@_ 2>&1 |") or die "open on sys(@_) failed: $!";
|
my $error;
|
||||||
while (<SYS>) {
|
|
||||||
print LOGFILE unless $_ =~ m,\/.*file\n$,;
|
# when using sys on yard_chrooted_tests
|
||||||
if ($verbosity > 0) {
|
my $dont = pop @_;
|
||||||
info(1,$_) unless $_ =~ m,\/.*file\n$,;
|
if ($dont ne "TESTING") {
|
||||||
}
|
push @_, $dont;
|
||||||
}
|
}
|
||||||
close(SYS) or return $?;
|
|
||||||
0; # like system()
|
open(SYS, "@_ 2>&1 |") or ($error = error("open on sys(@_) failed: $!"));
|
||||||
|
return "ERROR"if $error && $error eq "ERROR";
|
||||||
|
while (<SYS>) {
|
||||||
|
if ($dont ne "TESTING") {
|
||||||
|
print LOGFILE unless $_ =~ m,\/.*file\n$,;
|
||||||
|
}
|
||||||
|
if ($verbosity > 0) {
|
||||||
|
if ($dont ne "TESTING") {
|
||||||
|
info(1,$_) unless $_ =~ m,\/.*file\n$,;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
info(3,$_) unless $_ =~ m,\/.*file\n$,;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(SYS) or return $?;
|
||||||
|
0; # like system()
|
||||||
}
|
}
|
||||||
|
|
||||||
# This is history, simply because the mount point is unique to
|
# This is history, simply because the mount point is unique to
|
||||||
@ -1458,7 +1486,8 @@ sub kernel_version {
|
|||||||
## HISTORY
|
## HISTORY
|
||||||
##### Eventually move this into configure since it doesn't have to be
|
##### Eventually move this into configure since it doesn't have to be
|
||||||
##### done with every make_root_fs. But yard_glob would have to be
|
##### done with every make_root_fs. But yard_glob would have to be
|
||||||
##### configured, and yard_utils.pl isn't configured.
|
##### configured, and yard_utils.pl isn't configured. Will use for
|
||||||
|
##### other things, though.
|
||||||
my($glob_broken);
|
my($glob_broken);
|
||||||
sub test_glob {
|
sub test_glob {
|
||||||
my($globbed) = join(' ', glob("/*"));
|
my($globbed) = join(' ', glob("/*"));
|
||||||
@ -1619,6 +1648,10 @@ my($checked_for_getty_files); # Scalar -- have we checked getty files yet?
|
|||||||
my(%checked); # Hash table of files we've already checked
|
my(%checked); # Hash table of files we've already checked
|
||||||
my $login_binary;
|
my $login_binary;
|
||||||
|
|
||||||
|
sub warning_test {
|
||||||
|
info(0, "\n", @_);
|
||||||
|
}
|
||||||
|
|
||||||
sub which_tests {
|
sub which_tests {
|
||||||
|
|
||||||
my ($chosen_tests) = @_;
|
my ($chosen_tests) = @_;
|
||||||
@ -1642,33 +1675,35 @@ sub which_tests {
|
|||||||
check_termcap();
|
check_termcap();
|
||||||
|
|
||||||
##### Here are the tests.
|
##### Here are the tests.
|
||||||
# fork_chroot_and(\&check_fstab) if $chosen_tests->{30}{test_fstab} == 1;
|
|
||||||
# fork_chroot_and(\&check_inittab)if $chosen_tests->{31}{test_inittab} == 1;
|
|
||||||
# fork_chroot_and(\&check_scripts)if $chosen_tests->{32}{test_scripts} == 1;
|
|
||||||
|
|
||||||
my $t_fstab = $chosen_tests->{30}{test_fstab};
|
my $t_fstab = $chosen_tests->{30}{test_fstab};
|
||||||
my $t_inittab = $chosen_tests->{31}{test_inittab};
|
my $t_inittab = $chosen_tests->{31}{test_inittab};
|
||||||
my $t_scripts = $chosen_tests->{32}{test_scripts};
|
my $t_scripts = $chosen_tests->{32}{test_scripts};
|
||||||
|
|
||||||
|
sys("yard_chrooted_tests $mount_point $t_fstab $t_inittab $t_scripts",
|
||||||
|
"TESTING");
|
||||||
|
|
||||||
sys("yard_chrooted_tests $mount_point $t_fstab $t_inittab $t_scripts");
|
if ( $chosen_tests->{33}{test_links} == 1 ) {
|
||||||
check_links() if $chosen_tests->{33}{test_links} == 1;
|
info(0,"\nTEST: links\n");
|
||||||
check_passwd() if $chosen_tests->{34}{test_passwd} == 1;
|
check_links();
|
||||||
check_pam() if $chosen_tests->{35}{test_pam} == 1;
|
}
|
||||||
check_nss() if $chosen_tests->{36}{test_nss} == 1;
|
if ( $chosen_tests->{34}{test_passwd} == 1 ) {
|
||||||
|
info(0,"\nTEST: passwd\n");
|
||||||
|
check_passwd();
|
||||||
|
}
|
||||||
|
if ( $chosen_tests->{35}{test_pam} == 1 ) {
|
||||||
|
info(0,"\nTEST: pam\n");
|
||||||
|
check_pam();
|
||||||
|
}
|
||||||
|
if ( $chosen_tests->{36}{test_nss} == 1 ) {
|
||||||
|
info(0,"\nTEST: nss\n");
|
||||||
|
check_nss();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return "ERROR" if errum(sys("umount $mount_point")) == 2;
|
return "ERROR" if errum(sys("umount $mount_point")) == 2;
|
||||||
|
|
||||||
info(0, "All done!\n");
|
|
||||||
info(0, "You can run more tests with the UML kernel\n",
|
|
||||||
"or construct a distribution by using this root\n",
|
|
||||||
"filesystem with a boot method.");
|
|
||||||
|
|
||||||
} # end sub which_tests
|
} # end sub which_tests
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### This could be made much more complete, but for typical rc type
|
##### This could be made much more complete, but for typical rc type
|
||||||
##### files it seems to catch the common problems.
|
##### files it seems to catch the common problems.
|
||||||
sub scan_command_file {
|
sub scan_command_file {
|
||||||
@ -1690,7 +1725,7 @@ sub scan_command_file {
|
|||||||
# next if $abs_file =~ m/[*?]/; # Skip meta chars - we don't trust glob
|
# next if $abs_file =~ m/[*?]/; # Skip meta chars - we don't trust glob
|
||||||
next if $warned{$abs_file}; # Only warn once per file
|
next if $warned{$abs_file}; # Only warn once per file
|
||||||
if (!-e $abs_file) {
|
if (!-e $abs_file) {
|
||||||
warning("$cmdfile($.): $line\n\t$1: missing on root filesystem\n");
|
warning_test("$cmdfile($.): $line\n\t$1: missing on root filesystem\n");
|
||||||
$warned{$abs_file} = 1;
|
$warned{$abs_file} = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1704,8 +1739,12 @@ sub scan_command_file {
|
|||||||
|
|
||||||
##### Check_passwd is NOT run under chroot.
|
##### Check_passwd is NOT run under chroot.
|
||||||
sub check_passwd {
|
sub check_passwd {
|
||||||
|
my $error;
|
||||||
my($passwd_file) = "$mount_point/etc/passwd";
|
my($passwd_file) = "$mount_point/etc/passwd";
|
||||||
open(PASSWD, "<$passwd_file") or error("Can't read passwd file: $!\n");
|
open(PASSWD, "<$passwd_file") or
|
||||||
|
($error = error("Can't read passwd file: $!\n"));
|
||||||
|
return if $error && $error eq "ERROR";
|
||||||
|
|
||||||
info(0, "\nChecking passwd file $passwd_file\n");
|
info(0, "\nChecking passwd file $passwd_file\n");
|
||||||
|
|
||||||
while (<PASSWD>) {
|
while (<PASSWD>) {
|
||||||
@ -1718,10 +1757,10 @@ sub check_passwd {
|
|||||||
next if $passwd eq "*"; # Skip warnings if user can't login
|
next if $passwd eq "*"; # Skip warnings if user can't login
|
||||||
|
|
||||||
-d ($mount_point . $home) or
|
-d ($mount_point . $home) or
|
||||||
warning "$passwd_file($.): $line\n",
|
warning_test "$passwd_file($.): $line\n",
|
||||||
"\tHome directory of $login_name ($mount_point$home) is missing\n";
|
"\tHome directory of $login_name ($mount_point$home) is missing\n";
|
||||||
-e ($mount_point . $shell) or
|
-e ($mount_point . $shell) or
|
||||||
warning "$passwd_file($.): $line\n",
|
warning_test "$passwd_file($.): $line\n",
|
||||||
"\tShell of $login_name ($mount_point$shell) doesn't exist\n";
|
"\tShell of $login_name ($mount_point$shell) doesn't exist\n";
|
||||||
|
|
||||||
check_init_files($login_name, $home, $shell);
|
check_init_files($login_name, $home, $shell);
|
||||||
@ -1750,7 +1789,7 @@ sub check_pam {
|
|||||||
next if /^\#/ or /^\s*$/; # Skip comments and empty lines
|
next if /^\#/ or /^\s*$/; # Skip comments and empty lines
|
||||||
my($file) = (split)[3]; # Get fourth field
|
my($file) = (split)[3]; # Get fourth field
|
||||||
if (!-e "$mount_point/$file") {
|
if (!-e "$mount_point/$file") {
|
||||||
warning "$pam_conf($.): $_\n",
|
warning_test "$pam_conf($.): $_\n",
|
||||||
"\tLibrary $file does not exist on root fs\n";
|
"\tLibrary $file does not exist on root fs\n";
|
||||||
}
|
}
|
||||||
# That's all we check for now
|
# That's all we check for now
|
||||||
@ -1774,8 +1813,8 @@ sub check_pam {
|
|||||||
my($file) = (split)[3]; # Get fourth field
|
my($file) = (split)[3]; # Get fourth field
|
||||||
$pam_configured = 1;
|
$pam_configured = 1;
|
||||||
if (!-e "$mount_point/$file") {
|
if (!-e "$mount_point/$file") {
|
||||||
#warning "$file2($.): $_\n",
|
warning_test "$file2($.): $_\n",
|
||||||
# "\tLibrary $file does not exist on root fs\n";
|
"\tLibrary $file does not exist on root fs\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(PF);
|
close(PF);
|
||||||
@ -1787,7 +1826,7 @@ sub check_pam {
|
|||||||
if (!$pam_configured and -e $login_binary) {
|
if (!$pam_configured and -e $login_binary) {
|
||||||
my($dependencies) = scalar(`ldd $login_binary`);
|
my($dependencies) = scalar(`ldd $login_binary`);
|
||||||
if (defined($dependencies) and $dependencies =~ /libpam/) {
|
if (defined($dependencies) and $dependencies =~ /libpam/) {
|
||||||
warning "Warning: login ($login_binary) needs PAM, but you haven't\n",
|
warning_test "Warning: login ($login_binary) needs PAM, but you haven't\n",
|
||||||
"\tconfigured it (in /etc/pam.conf or /etc/pam.d/)\n",
|
"\tconfigured it (in /etc/pam.conf or /etc/pam.d/)\n",
|
||||||
"\tYou probably won't be able to login.\n";
|
"\tYou probably won't be able to login.\n";
|
||||||
}
|
}
|
||||||
@ -1814,7 +1853,7 @@ sub check_nss {
|
|||||||
my($libc) = yard_glob("$mount_point/lib/libc-2*");
|
my($libc) = yard_glob("$mount_point/lib/libc-2*");
|
||||||
my($libc_version) = $libc =~ m|/lib/libc-2.(\d)|;
|
my($libc_version) = $libc =~ m|/lib/libc-2.(\d)|;
|
||||||
if (!defined($libc_version)) {
|
if (!defined($libc_version)) {
|
||||||
warning "Can't determine your libc version\n";
|
warning_test "Can't determine your libc version\n";
|
||||||
} else {
|
} else {
|
||||||
info(0, "You're using $libc\n");
|
info(0, "You're using $libc\n");
|
||||||
}
|
}
|
||||||
@ -1837,7 +1876,7 @@ sub check_nss {
|
|||||||
next if $entry =~ /^\[/; # ignore action specifiers
|
next if $entry =~ /^\[/; # ignore action specifiers
|
||||||
my($lib) = "$mount_point/lib/libnss_${entry}.so.${X}";
|
my($lib) = "$mount_point/lib/libnss_${entry}.so.${X}";
|
||||||
if (!-e $lib) {
|
if (!-e $lib) {
|
||||||
warning "$nss_conf($.):\n$line\n",
|
warning_test "$nss_conf($.):\n$line\n",
|
||||||
"\tRoot filesystem needs $lib to support $entry\n";
|
"\tRoot filesystem needs $lib to support $entry\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1850,7 +1889,7 @@ sub check_nss {
|
|||||||
my($libc_version) = ($dependencies =~ /libc\.so\.(\d+)/m);
|
my($libc_version) = ($dependencies =~ /libc\.so\.(\d+)/m);
|
||||||
if ($libc_version > 5) {
|
if ($libc_version > 5) {
|
||||||
# Needs libc 6 or greater
|
# Needs libc 6 or greater
|
||||||
warning "Warning: $login_binary on rescue disk needs libc.so.$libc_version,\n"
|
warning_test "Warning: $login_binary on rescue disk needs libc.so.$libc_version,\n"
|
||||||
. "\tbut there is no NSS configuration file ($nss_conf)\n"
|
. "\tbut there is no NSS configuration file ($nss_conf)\n"
|
||||||
. "\ton root filesystem.\n";
|
. "\ton root filesystem.\n";
|
||||||
}
|
}
|
||||||
@ -1859,8 +1898,6 @@ sub check_nss {
|
|||||||
info(0, "Done with NSS\n");
|
info(0, "Done with NSS\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sub check_links {
|
sub check_links {
|
||||||
info(0, "\nChecking links relative to $mount_point\n");
|
info(0, "\nChecking links relative to $mount_point\n");
|
||||||
|
|
||||||
@ -1878,7 +1915,7 @@ sub check_links {
|
|||||||
chase_link($::target, 16);
|
chase_link($::target, 16);
|
||||||
|
|
||||||
} elsif (!-e $::target) {
|
} elsif (!-e $::target) {
|
||||||
warning "Warning: Unresolved link: $File::Find::name -> $::raw_link\n";
|
warning_test "Warning: Unresolved link: $File::Find::name -> $::raw_link\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1891,7 +1928,7 @@ sub chase_link {
|
|||||||
my($file, $link_depth) = @_;
|
my($file, $link_depth) = @_;
|
||||||
|
|
||||||
if ($link_depth == 0) {
|
if ($link_depth == 0) {
|
||||||
warning "Warning: Probable link circularity involving $file\n";
|
warning_test "Warning: Probable link circularity involving $file\n";
|
||||||
|
|
||||||
} elsif (-l $file) {
|
} elsif (-l $file) {
|
||||||
chase_link(make_link_absolute($file, readlink($file)),
|
chase_link(make_link_absolute($file, readlink($file)),
|
||||||
@ -1911,9 +1948,9 @@ sub check_scripts {
|
|||||||
chomp($firstline = <SCRIPT>);
|
chomp($firstline = <SCRIPT>);
|
||||||
if (($prog) = $firstline =~ /^\#!\s*(\S+)/) {
|
if (($prog) = $firstline =~ /^\#!\s*(\S+)/) {
|
||||||
if (!-e $prog) {
|
if (!-e $prog) {
|
||||||
warning "Warning: $File::Find::name needs $prog, which is missing\n";
|
warning_test "Warning: $File::Find::name needs $prog, which is missing\n";
|
||||||
} elsif (!-x $prog) {
|
} elsif (!-x $prog) {
|
||||||
warning "Warning: $File::Find::name needs $prog, " .
|
warning_test "Warning: $File::Find::name needs $prog, " .
|
||||||
"which is not executable.\n";
|
"which is not executable.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1931,10 +1968,10 @@ sub check_getty_type_call {
|
|||||||
my($tty, $speed, $type) = @args;
|
my($tty, $speed, $type) = @args;
|
||||||
|
|
||||||
if (!-e "$mount_point/dev/$tty") {
|
if (!-e "$mount_point/dev/$tty") {
|
||||||
warning "\tLine $.: $prog for $tty, but /dev/$tty doesn't exist.\n";
|
warning_test "\tLine $.: $prog for $tty, but /dev/$tty doesn't exist.\n";
|
||||||
}
|
}
|
||||||
if (!defined($Termcap{$type})) {
|
if (!defined($Termcap{$type})) {
|
||||||
warning "\tLine $.: Type $type not defined in termcap\n";
|
warning_test "\tLine $.: Type $type not defined in termcap\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
## If getty or getty_ps, look for /etc/gettydefs, /etc/issue
|
## If getty or getty_ps, look for /etc/gettydefs, /etc/issue
|
||||||
@ -1942,16 +1979,15 @@ sub check_getty_type_call {
|
|||||||
|
|
||||||
if ($prog =~ /^getty/) {
|
if ($prog =~ /^getty/) {
|
||||||
if (!$checked_for_getty_files) {
|
if (!$checked_for_getty_files) {
|
||||||
warning "\tLine $.: $prog expects /etc/gettydefs, which is missing.\n"
|
warning_test "\tLine $.: $prog expects /etc/gettydefs, which is missing.\n"
|
||||||
unless -e "$mount_point/etc/gettydefs";
|
unless -e "$mount_point/etc/gettydefs";
|
||||||
warning "\tLine $.: $prog expects /etc/issue, which is missing.\n"
|
warning_test "\tLine $.: $prog expects /etc/issue, which is missing.\n"
|
||||||
unless -e "$mount_point/etc/issue";
|
unless -e "$mount_point/etc/issue";
|
||||||
$checked_for_getty_files = 1;
|
$checked_for_getty_files = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
### NB. This is *not* run under chroot
|
### NB. This is *not* run under chroot
|
||||||
###
|
###
|
||||||
@ -2016,7 +2052,7 @@ sub check_init_files {
|
|||||||
if ($cmd and ($hd_abs = find_file_in_path($cmd, @path))) {
|
if ($cmd and ($hd_abs = find_file_in_path($cmd, @path))) {
|
||||||
# If it's here, see if it's on the rescue disk
|
# If it's here, see if it's on the rescue disk
|
||||||
if (!(-e "$mount_point/$hd_abs" and -x _)) {
|
if (!(-e "$mount_point/$hd_abs" and -x _)) {
|
||||||
warning "$init_file($.): $_\n\t\t$cmd looks like a command but\n",
|
warning_test "$init_file($.): $_\n\t\t$cmd looks like a command but\n",
|
||||||
"\t\tdoes not exist on the root filesystem.\n";
|
"\t\tdoes not exist on the root filesystem.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2028,9 +2064,9 @@ sub check_init_files {
|
|||||||
# Note that this could mislead if the user moved it to a different
|
# Note that this could mislead if the user moved it to a different
|
||||||
# dir on the root fs.
|
# dir on the root fs.
|
||||||
if (!-e "$mount_point/$hd_abs") {
|
if (!-e "$mount_point/$hd_abs") {
|
||||||
warning "${init_file}($.): $_\n\t$cmd: missing from root fs.\n";
|
warning_test "${init_file}($.): $_\n\t$cmd: missing from root fs.\n";
|
||||||
} elsif (!-x _) {
|
} elsif (!-x _) {
|
||||||
warning "$init_file($.): $_\n\t$cmd: not executable on root fs.\n";
|
warning_test "$init_file($.): $_\n\t$cmd: not executable on root fs.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2043,8 +2079,11 @@ sub check_init_files {
|
|||||||
|
|
||||||
|
|
||||||
sub check_termcap {
|
sub check_termcap {
|
||||||
|
my $error;
|
||||||
open(TERMCAP, "<$mount_point/etc/termcap") or
|
open(TERMCAP, "<$mount_point/etc/termcap") or
|
||||||
warning "No file $mount_point/etc/termcap";
|
( $error = error("No file $mount_point/etc/termcap"))
|
||||||
|
;
|
||||||
|
return if $error && $error eq "ERROR";
|
||||||
while (<TERMCAP>) {
|
while (<TERMCAP>) {
|
||||||
chomp;
|
chomp;
|
||||||
next unless $_;
|
next unless $_;
|
||||||
@ -2074,3 +2113,4 @@ sub check_termcap {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
package YardChroot;
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
##
|
##
|
||||||
## YARD_CHROOT_TEST
|
## YARD_CHROOT_TEST
|
||||||
@ -50,11 +48,20 @@ sub which_test {
|
|||||||
my $test_inittab = $ARGV[2];
|
my $test_inittab = $ARGV[2];
|
||||||
my $test_scripts = $ARGV[3];
|
my $test_scripts = $ARGV[3];
|
||||||
|
|
||||||
fork_chroot_and(\&check_fstab) if $test_fstab == 1;
|
|
||||||
fork_chroot_and(\&check_inittab) if $test_inittab == 1;
|
|
||||||
fork_chroot_and(\&check_scripts) if $test_scripts == 1;
|
|
||||||
|
|
||||||
}
|
if ( $test_fstab == 1 ) {
|
||||||
|
print "\nTEST: fstab";
|
||||||
|
fork_chroot_and(\&check_fstab);
|
||||||
|
}
|
||||||
|
if ( $test_inittab == 1 ) {
|
||||||
|
print "\nTEST: inittab";
|
||||||
|
fork_chroot_and(\&check_inittab);
|
||||||
|
}
|
||||||
|
if ( $test_scripts == 1 ) {
|
||||||
|
print "\nTEST: scripts";
|
||||||
|
fork_chroot_and(\&check_scripts);
|
||||||
|
}
|
||||||
|
} # end sub which_test
|
||||||
|
|
||||||
# This takes a procedure call, forks off a subprocess, chroots to
|
# This takes a procedure call, forks off a subprocess, chroots to
|
||||||
# $mount_point and runs the procedure.
|
# $mount_point and runs the procedure.
|
||||||
@ -65,8 +72,7 @@ sub fork_chroot_and {
|
|||||||
|
|
||||||
unless (defined $Godot) {
|
unless (defined $Godot) {
|
||||||
|
|
||||||
my $error = error("Can't fork: $!");
|
die "Can't fork: $!";
|
||||||
return "ERROR" if $error && $error eq "ERROR";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$Godot) {
|
if (!$Godot) {
|
||||||
@ -86,7 +92,10 @@ sub check_fstab {
|
|||||||
my($proc_seen);
|
my($proc_seen);
|
||||||
|
|
||||||
|
|
||||||
open(FSTAB, "<$FSTAB") or error ("$FSTAB: $!");
|
open(FSTAB, "<$FSTAB") or error_test ("$FSTAB: $!");
|
||||||
|
if (-z $FSTAB) {
|
||||||
|
error_test ("fstab is an empty file");
|
||||||
|
}
|
||||||
print "\nChecking $FSTAB\n";
|
print "\nChecking $FSTAB\n";
|
||||||
|
|
||||||
while (<FSTAB>) {
|
while (<FSTAB>) {
|
||||||
@ -140,6 +149,9 @@ sub check_inittab {
|
|||||||
warning("$INITTAB: $!\n");
|
warning("$INITTAB: $!\n");
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (-z $INITTAB) {
|
||||||
|
error_test ("fstab is an empty file");
|
||||||
|
}
|
||||||
|
|
||||||
my($default_rl, $saw_line_for_default_rl);
|
my($default_rl, $saw_line_for_default_rl);
|
||||||
|
|
||||||
@ -168,7 +180,7 @@ sub check_inittab {
|
|||||||
} elsif (!-x $exec) {
|
} elsif (!-x $exec) {
|
||||||
print "$INITTAB($.): $line\n";
|
print "$INITTAB($.): $line\n";
|
||||||
print "\tMaking $exec executable\n";
|
print "\tMaking $exec executable\n";
|
||||||
chmod(0777, $exec) or error("chmod failed: $!");
|
chmod(0777, $exec) or error_test("chmod failed: $!");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
##### executable but not binary ==> script
|
##### executable but not binary ==> script
|
||||||
@ -180,7 +192,7 @@ sub check_inittab {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(INITTAB) or error("close(INITTAB): $!");
|
close(INITTAB) or error_test("close(INITTAB): $!");
|
||||||
|
|
||||||
if (!$saw_line_for_default_rl) {
|
if (!$saw_line_for_default_rl) {
|
||||||
warning("\tDefault runlevel is $default_rl, but no entry for it.\n");
|
warning("\tDefault runlevel is $default_rl, but no entry for it.\n");
|
||||||
@ -194,26 +206,30 @@ sub check_scripts {
|
|||||||
|
|
||||||
sub check_interpreter {
|
sub check_interpreter {
|
||||||
if (-x $File::Find::name and -f _ and -T _) {
|
if (-x $File::Find::name and -f _ and -T _) {
|
||||||
open(SCRIPT, $File::Find::name) or error "$File::Find::name: $!";
|
open(SCRIPT, $File::Find::name) or error_test("$File::Find::name: $!");
|
||||||
my($prog, $firstline);
|
my($prog, $firstline);
|
||||||
|
|
||||||
chomp($firstline = <SCRIPT>);
|
chomp($firstline = <SCRIPT>);
|
||||||
if (($prog) = $firstline =~ /^\#!\s*(\S+)/) {
|
if (($prog) = $firstline =~ /^\#!\s*(\S+)/) {
|
||||||
if (!-e $prog) {
|
if (!-e $prog) {
|
||||||
warning "Warning: $File::Find::name needs $prog, which is missing\n";
|
warning("Warning: \$File::Find::name needs $prog which is missing\n");
|
||||||
} elsif (!-x $prog) {
|
} elsif (!-x $prog) {
|
||||||
warning "Warning: $File::Find::name needs $prog, " .
|
warning("Warning: \$File::Find::name needs $prog, " .
|
||||||
"which is not executable.\n";
|
"which is not executable.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(SCRIPT);
|
close(SCRIPT);
|
||||||
}
|
}
|
||||||
}; # End of sub check_interpreter
|
} # End of sub check_interpreter
|
||||||
|
|
||||||
find(\&check_interpreter, "/");
|
find(\&check_interpreter, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub warning {
|
||||||
|
print "\n", @_;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub error_test {
|
||||||
|
print STDERR "\nError: ", @_, "\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user