NAME

SDP::SUSE - The Support Diagnostic Pattern perl library for SUSE OS


SYNOPSIS

use SDP::SUSE;


DESCRIPTION

Provides necessary functions specific to patterns developed against supportconfig running on SUSE servers.


CONSTANTS

Kernel Versions

SLE9GA, SLE9SP1, SLE9SP2, SLE9SP3, SLE9SP4, SLE9SP5, SLE10GA, SLE10SP1, SLE10SP2, SLE10SP3, SLE10SP4, SLE10SP5, SLE11GA, SLE11SP1, SLE11SP2, SLE11SP3, SLE11SP4, SLE12GA

SUSE Linux Enterprise Server/Desktop kernel versions


FUNCTIONS: Information Gathering


getHostInfo

Description

Returns a hash containing host and OES information.

Usage
        my %HOST_INFO = SDP::SUSE::getHostInfo();
        if ( $HOST_INFO{'oes'} ) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "OES Installed on $HOST_INFO{'hostname'}");
        } else {
                SDP::Core::updateStatus(STATUS_WARNING, "OES NOT Installed on $HOST_INFO{'hostname'}");
        }
Input

None

Output

Hash with host information.

Requires

None

Hash Keys

architecture, hostname, kernel, distribution, patchlevel, oes, oesversion, oesmajor, oesdistribution, oespatchlevel, oesbuild, nows, nowsversion


getDriverInfo

Description

Returns a hash containing loaded kernel module information.

Usage
        my $DRIVER_NAME = 'zapi';
        my %DRIVER_INFO = SDP::SUSE::getDriverInfo($DRIVER_NAME);
        if ( $DRIVER_INFO{'loaded'} ) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "Driver $DRIVER_NAME is loaded and supported = $DRIVER_INFO{'supported'}");
        } else {
                SDP::Core::updateStatus(STATUS_WARNING, "Driver $DRIVER_NAME is NOT loaded");
        }
Input

$DRIVER_NAME (The name of the driver about which you want information.)

Output

Hash with load kernel driver information.

Requires

None

Hash Keys

name, loaded, filename, version, license, description, srcversion, supported, vermagic


getServiceInfo

Description

Returns a hash containing loaded kernel module information.

Usage
        my $SERVICE_NAME = 'novell-nss';
        my %SERVICE_INFO = SDP::SUSE::getServiceInfo($SERVICE_NAME);
        if ( $SERVICE_INFO{'running'} > 0 ) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "Service $SERVICE_INFO{'name'} is running");
        } else {
                SDP::Core::updateStatus(STATUS_WARNING, "Service $SERVICE_INFO{'name'} is NOT running");
        }
Input

$SERVICE_NAME (The system service about which you want information.)

Output

Hash with service information information.

Requires

None

Hash Keys

name (The service name)

running (-1=Unknown, 0=Unused or Dead, 1=Running)

bootlevels (A list of runlevel numbers in which the service is turned on for boot. An empty string means the service is turned off at boot for all runlevels.)

runlevel (The current system runlevel)

runlevelstatus (0=Service is turned off for the current runlevel, 1=Service is turned on for the current runlevel)


portInfo

Description

Gathers information about the service listening on $PORT_NUMBER

Usage
        my $PORT_NUMBER = '22';
        my %PORT_INFO = SDP::SUSE::portInfo($PORT_NUMBER);
        if ( %PORT_INFO ) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "Port $PORT_NUMBER Is listening");
        } else {
                SDP::Core::updateStatus(STATUS_WARNING, "Port $PORT_NUMBER Is NOT listening");
        }
Input

$PORT_NUMBER (The network port number to check)

Output

Hash with port information

Hash Keys

port, service

Requires

None


getBoundIPs

Description

Identifies all IPv4 IP addresses bound to the server.

Usage
        my $i = '';
        my @BOUND_IP = ();
        my $TYPE = '';
        my $PRI = 0;
        my $SEC = 0;
        my $ALL = 0;
        if ( SDP::SUSE::getBoundIPs(\@BOUND_IP) ) {
                for $i ( 0 .. $#BOUND_IP ) {
                        if ( $BOUND_IP[$i]{'issec'} ) {
                                $TYPE = 'Secondary';
                                $SEC++;;
                        } else {
                                $TYPE = 'Primary';
                                $PRI++;
                        }
                        SDP::Core::updateStatus(STATUS_PARTIAL, "$TYPE $BOUND_IP[$i]{'interface'} addr:$BOUND_IP[$i]{'addr'}");
                }
                $ALL = scalar(@BOUND_IP);
                SDP::Core::updateStatus(STATUS_ERROR, "Bound IP Addresses: Primary=$PRI, Secondary=$SEC, TOTAL=$ALL");
        } else {
                SDP::Core::updateStatus(STATUS_ERROR, "Error: No IP addresses bound to the server");
        }
Input

Array address

Output

Array of hashes containing the address details

Hash Keys

interface, addr, bcast, mask, mac, irq, config, issec

Requires

None


netRouteTable

Description

Gathers information from the routing table.

Usage
        my $i = '';
        my @NETWORK_ROUTES = ();
        if ( SDP::SUSE::netRouteTable(\@NETWORK_ROUTES) ) {
                for $i ( 0 .. $#NETWORK_ROUTES ) {
                        SDP::Core::printDebug('ROUTE', "$i of $#NETWORK_ROUTES: $NETWORK_ROUTES[$i]{'gateway'} - $NETWORK_ROUTES[$i]{'flags'}");
                }
        }
Input

Array address

Output

Array of hashes

Hash Keys

destination, gateway, genmask, flags, mss, window, irtt, interface

Requires

None


getFileSystems

Description

Gets all fields from the mounted file systems and the fstab file. Information is returned as an array of hashes.

Usage
        my @MOUNTS = SDP::SUSE::getFileSystems();
        my $TMP;
        my $FOUND = 0;
        foreach $TMP (@MOUNTS) {
                if ( $TMP->{'MPT'} eq '/' ) {
                        SDP::Core::updateStatus(STATUS_SUCCESS, "Found root device $TMP->{'DEV'} mounted on $TMP->{'MPT'} with file system $TMP->{'TYPE'}");
                        $FOUND = 1;
                }
        }
        SDP::Core::setStatus(STATUS_CRITICAL, 'Root file system not found') if ( ! $FOUND );
Input

None

Output

Array of hashes

Hash Keys

DEV, DEVM, DEVF, MPT, TYPE, OPTIONS, DUMP, FSCK, MOUNTED, SIZE, USED, AVAIL, USEPCT

        DEV     = The active device path
        DEVM    = The device path from the mount command
        DEVF    = The device path from /etc/fstab
        MPT     = The mount point
        TYPE    = File system type
        OPTIONS = Options used when mounted or mounting
        DUMP    = /etc/fstab dump field, -1 if unknown
        FSCK    = /etc/fstab fsck field, -1 if unknown
        MOUNTED = -1 Unknown, 0 Not mounted, 1 Mounted
        SIZE    = -1 Unknown, file system size in bytes
        USED    = -1 Unknown, file system space used in bytes
        AVAIL   = -1 Unknown, file system space available in bytes
        USEPCT  = -1 Unknown, file system percent used
Requires

None


getSCInfo

Description

Returns a hash containing supportconfig information.

Usage
        my $REQUIRED_VERSION = '2.25-173';
        my %SC_INFO = SDP::SUSE::getSCInfo();
        if ( SDP::Core::compareVersions($SC_INFO{'version'}, $REQUIRED_VERSION) >= 0 ) {
                SDP::Core::updateStatus(STATUS_ERROR, "Supportconfig v$SC_INFO{'version'} meets minimum requirement");
        } else {
                SDP::Core::updateStatus(STATUS_WARNING, "Supportconfig v$SC_INFO{'version'} NOT sufficient, $REQUIRED_VERSION or higher needed");
        }
Input

None

Output

Hash with supportconfig information.

Requires

None

Hash Keys

version, scriptdate, cmdline, config, envalue, kernvalue, rundate


FUNCTIONS: Comparisons


compareKernel

Description

Uses SDP::Core::compareVersions to compare $test_version against the running kernel version. Only the most significant version components are compared. For example, if 2.6.5 is compared with 2.6.16.60-0.23, then only 2.6.5 and 2.6.16 will be used for the comparison.

Usage
        if ( SDP::SUSE::compareKernel(SLE10SP1) >= 0 && SDP::SUSE::compareKernel(SLE10SP2) < 0) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "Running SLES10 SP1 Kernel");
        } else {
                SDP::Core::updateStatus(STATUS_ERROR, "ABORT: Outside the kernel scope");
        }
Input

$test_version (The version string to which the running kernel's version is compared.)

Output

-1 if kernel_version < $test_version

0 if kernel_version == $test_version

1 if kernel_version > $test_version

Requires

None


compareDriver

Description

Uses SDP::Core::compareVersions to compare the $DRIVER_NAME and $TEST_VERSION against the loaded driver version. Only the most significant version components are compared. For example, if 2.6.5 is compared with 2.6.16.60-0.23, then only 2.6.5 and 2.6.16 will be used for the comparison.

Usage
        my $DRIVER_NAME = 'mptctl';
        my $TEST_VERSION = '5.25';
        if ( SDP::SUSE::compareDriver($DRIVER_NAME, $TEST_VERSION) >= 0 ) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "$DRIVER_NAME version meets minimum requirement");
        } else {
                SDP::Core::updateStatus(STATUS_WARNING, "$DRIVER_NAME version NOT sufficient, $TEST_VERSION or higher needed");
        }
Input

$DRIVER_NAME (The driver name that needs to be compared.)

$TEST_VERSION (The version string to which the loaded driver's version is compared.)

Output

-1 if driver_version < $TEST_VERSION

0 if driver_version == $TEST_VERSION

1 if driver_version > $TEST_VERSION

Requires

None


compareSupportconfig

Description

Uses SDP::Core::compareVersions to compare $TEST_VERSION against the supportconfig version. Only the most significant version components are compared. For example, if 2.6.5 is compared with 2.6.16.60-0.23, then only 2.6.5 and 2.6.16 will be used for the comparison.

Usage
        my $TEST_VERSION = '2.25-173';
        if ( SDP::SUSE::compareSupportconfig($TEST_VERSION) >= 0 ) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "Supportconfig version meets minimum requirement");
        } else {
                SDP::Core::updateStatus(STATUS_WARNING, "Supportconfig version NOT sufficient, $TEST_VERSION or higher needed");
        }
Input

$TEST_VERSION (The version string to which supportconfig's version is compared.)

Output

-1 if supportconfig_version < $TEST_VERSION

0 if supportconfig_version == $TEST_VERSION

1 if supportconfig_version > $TEST_VERSION

Requires

None


compareRpm

Description

Uses SDP::Core::compareVersions to compare $test_version against the installed RPM version. Comparisons are only valid on a single installed RPM; the comparison is skipped if multiple RPMs of the same name are installed. Only the most significant version components are compared. For example, if 2.6.5 is compared with 2.6.16.60-0.23, then only 2.6.5 and 2.6.16 will be used for the comparison. Letters in version strings are compared as separate elements. So 2.6SP3 would be compared as 2.6.SP.3. Letters are compared as a string comparison, and are case sensitive.

Usage
        my $RPM_NAME = 'autofs';
        my $VERSION_TO_COMPARE = '1.1.2';
        my $RPM_COMPARISON = SDP::SUSE::compareRpm($RPM_NAME, $VERSION_TO_COMPARE);
        if ( $RPM_COMPARISON == 2 ) {
                SDP::Core::updateStatus(STATUS_ERROR, "ERROR: RPM $RPM_NAME Not Installed");
        } elsif ( $RPM_COMPARISON > 2 ) {
                SDP::Core::updateStatus(STATUS_ERROR, "ERROR: Multiple Versions of $RPM_NAME RPM are Installed");
        } else {
                if ( $RPM_COMPARISON < 0 ) {
                        SDP::Core::updateStatus(STATUS_WARNING, "The installed $RPM_NAME RPM version is less than version $VERSION_TO_COMPARE");
                } else {
                        SDP::Core::updateStatus(STATUS_ERROR, "The installed $RPM_NAME RPM version meets or exceeds version $VERSION_TO_COMPARE");
                }                       
        }
Input

$rpm_name (The RPM name you are testing)

$test_version (The RPM version string to which the installed RPM version is compared.)

Output

-1 if installed_rpm_version < $test_version

0 if installed_rpm_version == $test_version

1 if installed_rpm_version > $test_version

2 if RPM is not installed

3 if Multiple RPM versions exist

Requires

None


FUNCTIONS: RPM Packages


getRpmInfo

Description

Returns an array of hashes containing RPM information. If the RPM is not installed, then @RPM_INFO is not set.

Usage
        my $RPM_NAME = 'kernel-xen';
        my @RPM_INFO = SDP::SUSE::getRpmInfo($RPM_NAME);
        if ( $#RPM_INFO < 0 ) {
                SDP::Core::updateStatus(STATUS_ERROR, "ERROR: RPM $RPM_NAME Not Installed");
        } elsif ( $#RPM_INFO > 0 ) {
                SDP::Core::updateStatus(STATUS_ERROR, "ERROR: Multiple $RPM_NAME RPMs Installed");
        } else {
                SDP::Core::updateStatus(STATUS_SUCCESS, "RPM $RPM_INFO[0]{'name'}-$RPM_INFO[0]{'version'} installed on $RPM_INFO[0]{'installed'}");
        }
Input

$rpm_name

Output

@RPM_INFO (An array of hashes containing RPM information)

Requires

None

RPM Hash Keys

name, version, vendor, installed


packageInstalled

Description

Confirms $PKG_NAME is installed on the system

Usage
        my $PKG_NAME = 'supportutils';
        if ( SDP::SUSE::packageInstalled($PKG_NAME) ) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "Package Installed: $PKG_NAME");
        } else {
                SDP::Core::updateStatus(STATUS_CRITICAL, "Package NOT Installed: $PKG_NAME");
        }
Input

$pacakge_name (The package name to validate)

Output

1 if Package is installed

0 if Package is NOT installed

Requires

None


haeEnabled

Description

Checks for a corosync.conf to show HAE is enabled.

Usage
        if ( SDP::SUSE::haeEnabled() ) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "HAE Enabled");
        } else {
                SDP::Core::updateStatus(STATUS_ERROR, "HAE Disabled");
        }
Input

None

Output

0 if HAE is disabled, corosync.conf missing

1 if HAE is enabled, corosync.conf found

Requires

None


packageVerify

Description

Checks if the named package passed it's RPM validation check.

Usage
        my $FILE_OPEN = 'fs-autofs.txt';
        my $PKG_NAME = 'autofs';
        my @EXCEPTION_LIST = ();
        if ( SDP::SUSE::packageVerify($FILE_OPEN, $PKG_NAME, \@EXCEPTION_LIST) > 1 ) {
                SDP::Core::updateStatus(STATUS_CRITICAL, "Failed RPM Validation: $PKG_NAME");
        } else {
                SDP::Core::updateStatus(STATUS_SUCCESS, "Passed RPM Validation: $PKG_NAME");
        }
Input

$FILE_OPEN (The file in which the rpm -V was executed.)

$PKG_NAME (The package name to validate)

$EXCEPTION_LIST (An address to an array of files or directories to exclude from the check. OPTIONAL)

Output

0 if Package is valid, no differences found

1 if Package is valid, or only docs or configuration files have been modified

2 if Package is not valid, non-doc or non-configuration files have been modified

3 if Package is not valid, binaries or library files have been modified

4 if Package is not valid, unknown reason

Requires

None


securityPackageCheck

Description

A function specific to checking packages in a Security Advisory type format. The function will trigger a script exit if the @rpms_to_check are not installed. It is assumed that the @rpms_to_check are different packages with the same $fixed_rpm_version for each. For example, @rpms_to_check might be cups and cups-devel, but the fix is version 1.1.0 for each (cups-1.1.0 and cups-devel-1.1.0). This function is not intended to check two different versions on the same server. For example, java-1_4_2 and java-1_5_0 on the same server should not be checked with this function because securityPackageCheck will abort if it finds any occurance of a package not installed.

Usage

SDP::SUSE::securityPackageCheck($title, $advisory_number, $advisory_description, \@rpms_to_check, $fixed_rpm_version);

Input

$title (Short one or two word title of the Advisory; ie Kerberos, CUPS or IBM Java)

$advisory_number (The security advisory "Announcement ID," ie SUSE-SA:2009:007)

$advisory_description (The security advisory "Vulnerability Type," ie "Local privilege escalation")

\@rpms_to_check (An array of rpm packages with the same version that are affected by the security advisory; ie cups, cups-libs, cups-devel)

$fixed_rpm_version (The version of the @rpms_to_check in which the security vulnerabilty has been fixed, ie 1.1.23-40.38)

Output

1 if Package is confirmed to be installed and fixed

0 if Package cannot be confirmed as installed and fixed

@PATTERN_RESULTS (Adds the CVE key value pair)

Requires

None


securitySeverityPackageCheck

Description

A function specific to checking packages in a Security Advisory type format. The function will trigger a script exit if the @rpms_to_check are not installed. It is assumed that the @rpms_to_check are different packages with the same $fixed_rpm_version for each. For example, @rpms_to_check might be cups and cups-devel, but the fix is version 1.1.0 for each (cups-1.1.0 and cups-devel-1.1.0). This function is not intended to check two different versions on the same server. For example, java-1_4_2 and java-1_5_0 on the same server should not be checked with this function because securityPackageCheck will abort if it finds any occurance of a package not installed.

Usage

SDP::SUSE::securitySeverityPackageCheck($TITLE, $SEVERITY, $VULNERABILITY_TYPE, \@RPMS_TO_CHECK, $FIXED_RPM_VERSION);

Input

$PRODUCT (Short one or two word title of the Advisory; ie Kerberos, CUPS or IBM Java)

$SEVERITY (The CVSS v2 Base Score number)

$VULNERABILITY_TYPE (The security advisory "Vulnerability Type," ie "Local privilege escalation")

\@RPMS_TO_CHECK (An array of rpm packages with the same version that are affected by the security advisory; ie cups, cups-libs, cups-devel)

$FIXED_RPM_VERSION (The version of the @rpms_to_check in which the security vulnerabilty has been fixed, ie 1.1.23-40.38)

Output

1 if Package is confirmed to be installed and fixed

0 if Package cannot be confirmed as installed and fixed

@PATTERN_RESULTS (Adds the CVE key value pair)

Requires

None


securityPackageCheckNoError

Description

A function specific to checking packages in a Security Advisory type format. No script exists are triggered. SDP::Core::setStatus is not called. If no @rpms_to_check are found, then STATUS_PARTIAL is returned. It is assumed that the @rpms_to_check are different packages with the same $fixed_rpm_version for each. For example, @rpms_to_check might be cups and cups-devel, but the fix is version 1.1.0 for each (cups-1.1.0 and cups-devel-1.1.0).

Usage

SDP::SUSE::securityPackageCheckNoError($title, $advisory_number, $advisory_description, \@rpms_to_check, $fixed_rpm_version);

Input

$title (Short one or two word title of the Advisory; ie Kerberos, CUPS or IBM Java)

$advisory_number (The security advisory "Announcement ID," ie SUSE-SA:2009:007)

$advisory_description (The security advisory "Vulnerability Type," ie "Local privilege escalation")

\@rpms_to_check (An array of rpm packages with the same version that are affected by the security advisory; ie cups, cups-libs, cups-devel)

$fixed_rpm_version (The version of the @rpms_to_check in which the security vulnerabilty has been fixed, ie 1.1.23-40.38)

Output

1 if Package(s) is confirmed to be installed and fixed

0 if Package(s) cannot be confirmed as installed and fixed

@PATTERN_RESULTS (Adds the PKG key value pair)

Requires

SDP::Core::setStatus()


securityAnnouncementPackageCheck

Description

Goes here...

Usage

SDP::SUSE::securityAnnouncementPackageCheck($NAME, $SEVERITY, $TAG, %PACKAGES);

Input

$NAME (The product name being checked, like PostgreSQL, Acroread, or Firefix)

$MAIN (The main rpm package name that must be installed to indicate $NAME is found OR leave empty to check all packages.)

$SEVERITY (Critical, Important, etc. A single word shown in the Rating field of the security announcement)

$TAG (The security announcement ID, like SUSE-SU-2013:0633-1)

%PACKAGES (A hash of packages and their version numbers in which this issue is fixed to be checked. The key is the package name and the value is the fixed version string)

Output

1 if Package(s) is confirmed to be installed and fixed

0 if Package(s) cannot be confirmed as installed and fixed


securitySeverityPackageCheckNoError

Description

A function specific to checking packages in a Security Advisory type format. No script exists are triggered. SDP::Core::setStatus is not called. If no @rpms_to_check are found, then STATUS_PARTIAL is returned. It is assumed that the @rpms_to_check are different packages with the same $fixed_rpm_version for each. For example, @rpms_to_check might be cups and cups-devel, but the fix is version 1.1.0 for each (cups-1.1.0 and cups-devel-1.1.0).

Usage

SDP::SUSE::securitySeverityPackageCheckNoError($title, $advisory_severity, $advisory_description, \@rpms_to_check, $fixed_rpm_version);

Input

$title (Short one or two word title of the Advisory; ie Kerberos, CUPS or IBM Java)

$advisory_severity (The CVSS v2 Base Score Number)

$advisory_description (The security advisory "Vulnerability Type," ie "Local privilege escalation")

\@rpms_to_check (An array of rpm packages with the same version that are affected by the security advisory; ie cups, cups-libs, cups-devel)

$fixed_rpm_version (The version of the @rpms_to_check in which the security vulnerabilty has been fixed, ie 1.1.23-40.38)

Output

1 if Package(s) is confirmed to be installed and fixed

0 if Package(s) cannot be confirmed as installed and fixed

@PATTERN_RESULTS (Adds the PKG key value pair)

Requires

SDP::Core::setStatus()


securityKernelCheck

Description

A function specific to checking kernel packages in a Security Advisory type format. The function returns a 1 if the system kernel is outside the scope specified.

Usage

SDP::SUSE::securityKernelCheck($kernelMin, $kernelMax, $kernelFix, $advisoryNumber, $advisoryDescription);

Input

$kernelMin (The minimum kernel version in which the vulnerability is found. Provides the beginning scope in which to look.)

$kernelMax (The maximum kernel version in which the vulnerability is found. Provides the ending scope in which to look.)

$kernelFix (The kernel version in which the vulnerability is fixed.)

$advisoryNumber (The security advisory "Announcement ID," ie SUSE-SA:2009:007)

$advisoryDescription (The security advisory "Vulnerability Type," ie "Local privilege escalation")

Output

0 if $kernelMin <= System Kernel < $kernelMax

1 if System Kernel is outside $kernelMin/$kernelMax scope

@PATTERN_RESULTS (Adds the CVE key value pair)

Requires

None


securitySeverityKernelCheck

Description

A function specific to checking kernel packages in a Security Advisory type format. The function returns a 1 if the system kernel is outside the scope specified.

Usage

SDP::SUSE::securitySeverityKernelCheck($kernelMin, $kernelMax, $kernelFix, $severityValue, $advisoryDescription);

Input

$kernelMin (The minimum kernel version in which the vulnerability is found. Provides the beginning scope in which to look.)

$kernelMax (The maximum kernel version in which the vulnerability is found. Provides the ending scope in which to look.)

$kernelFix (The kernel version in which the vulnerability is fixed.)

$severityValue (The CVSS v2 Base Score Number)

$advisoryDescription (The security advisory "Vulnerability Type," ie "Local privilege escalation")

Output

0 if $kernelMin <= System Kernel < $kernelMax

1 if System Kernel is outside $kernelMin/$kernelMax scope

@PATTERN_RESULTS (Adds the CVE key value pair)

Requires

None


securitySeverityKernelAnnouncement

Description

A function specific to checking kernel packages in a Security announcement type format. The function returns a 1 if the system kernel is outside the scope specified.

Usage

SDP::SUSE::securitySeverityKernelAnnouncement($kernelMin, $kernelMax, $kernelFix, $severityValue, $advisoryID);

Input

$kernelMin (The minimum kernel version in which the vulnerability is found. Provides the beginning scope in which to look.)

$kernelMax (The maximum kernel version in which the vulnerability is found. Provides the ending scope in which to look.)

$kernelFix (The kernel version in which the vulnerability is fixed.)

$severityValue (A severity string like "Important")

$announcementID (The security announcement ID, like "SUSE-SU-2012:0153-2")

Output

0 if $kernelMin <= System Kernel < $kernelMax

1 if System Kernel is outside $kernelMin/$kernelMax scope

@PATTERN_RESULTS (Adds the CVE key value pair)

Requires

None


FUNCTIONS: General


serviceBootstate

Description

Checks if the daemon, boot or xinetd service is turned on at boot.

Usage
        my $service_name = 'autofs';
        if ( SDP::SUSE::serviceBootstate($service_name) ) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "Turned on at boot: $service_name");
        } else {
                SDP::Core::updateStatus(STATUS_WARNING, "Turned off at boot: $service_name");
        }
Input

$service_name (The daemon or service to check)

Output

1 if Service is turned on at boot

0 if Service is turned off at boot

Requires

None


serviceStatus

Description

Checks if the specified service is currently running

Usage
        my $file_name = 'fs-autofs.txt';
        my $service_name = 'autofs';
        if ( SDP::SUSE::serviceStatus($file_name, $service_name) > 0 ) {
                SDP::Core::updateStatus(STATUS_WARNING, "NOT Running: $service_name");
        } else {
                SDP::Core::updateStatus(STATUS_ERROR, "Running: $service_name");
        }
Input

$file_name (The file in which the "$service_name status" command was run)

$service_name (The daemon or service to check)

Output

0 if Service is running

1 if Service is unused

2 if Service is down or dead

3 if Service is in an unknown state

Requires

None


serviceHealth

Description

Checks the basic service health; checking RPM validation, run state and chkconfig state. Limited to specific services that have dedicated information files.

Usage
        my $FILE_OPEN = "dns.txt";
        my $CHECK_PACKAGE = "bind";
        my $CHECK_SERVICE = "named";
        my @EXCLUDES = ();
        if ( packageInstalled($CHECK_PACKAGE) ) {
                SDP::SUSE::serviceHealth($FILE_OPEN, $CHECK_PACKAGE, $CHECK_SERVICE, \@EXCLUDES);
        } else {
                SDP::Core::updateStatus(STATUS_ERROR, "Basic Service Health; Package Not Installed: $CHECK_PACKAGE");
        }
Input

$FILE_OPEN (The file that contains the basic service health information)

$CHECK_PACKAGE (The package name to check)

$CHECK_SERVICE (The service name to check)

@EXCLUDES (Array of files to exclude from an RPM validation check)

Output

0 if Service is healthy

1 if Service is unhealthy

Requires

None


xenDomU

Description

Identifies a Xen DomU virtual machine

Usage
        if ( SDP::SUSE::xenDomU() ) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "The server is a Xen DomU virtual machine");
        } else {
                SDP::Core::updateStatus(STATUS_ERROR, "ABORT: Not a Xen DomU");
        }
Input

Non

Output

0 if server is NOT a DomU

1 if server is a DomU

Requires

None


xenDom0installed

Description

Identifies an installed Xen Dom0 virtual machine server

Usage
        if ( SDP::SUSE::xenDom0installed() ) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "The server has Xen Dom0 installed, buy may or may not be running.");
        } else {
                SDP::Core::updateStatus(STATUS_ERROR, "ABORT: The server does not have Xen Dom0 installed");
        }
Input

Non

Output

0 if Xen Dom0 is NOT installed

1 if Xen Dom0 is installed

Requires

None


xenDom0running

Description

Identifies an installed Xen Dom0 virtual machine server

Usage
        if ( SDP::SUSE::xenDom0running() ) {
                SDP::Core::updateStatus(STATUS_SUCCESS, "The server has Xen Dom0 running.");
        } else {
                SDP::Core::updateStatus(STATUS_ERROR, "ABORT: The server does not have Xen Dom0 running.");
        }
Input

Non

Output

0 if Xen Dom0 is NOT running

1 if Xen Dom0 is running

Requires

None


getSupportconfigRunDate

Description

Returns the year, month and day that the supportconfig was run on the server. It also returns the number of days from 1970 Jan 01 to the run date.

Usage
        my (undef, $SC_YEAR, $SC_MONTH, $SC_DAY) = split(/\t/, SDP::SUSE::getSupportconfigRunDate());
        SDP::Core::updateStatus(STATUS_PARTIAL, "Supportconfig run date: $SC_YEAR $SC_MONTH $SC_DAY");
Input

None

Output

$DAYS

$YEAR

$MONTH

$DAY

Requires

None


appCores

Description

Returns an array of hashes regarding application core file images found on the server.

Usage
        my @APP_CORE_INFO = ();
        my $ROLE;
        push(@APP_CORE_INFO, { filename => "/core.5083", month => "Aug", day => "14", year => "2009", days => "1427717.81125", application => "httpd" } );
        if ( SDP::SUSE::appCores(\@APP_CORE_INFO) ) {
                for ( my $I=0; $I<=$#APP_CORE_INFO; $I++) {
                        print(" ARRAY $I                        = ");
                        for $ROLE ( keys %{ $APP_CORE_INFO[$I] } ) {
                                print("'$ROLE' => '$APP_CORE_INFO[$I]->{$ROLE}'  ");
                        }
                        print("\n");
                }
        } else {
                SDP::Core::updateStatus(STATUS_ERROR, "Application core files NOT found");
        }
Input

Address to an array

Output

Modifies the array reference given

Requires

None


CONTRIBUTORS

Jason Record <lt>jrecord@suse.com


COPYRIGHT

Copyright (C) 2013 SUSE Linux Products GmbH

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.