Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fedora 40 bug on detecting systemd-analyze version #1525

Open
garberw opened this issue Jul 23, 2024 · 6 comments
Open

fedora 40 bug on detecting systemd-analyze version #1525

garberw opened this issue Jul 23, 2024 · 6 comments

Comments

@garberw
Copy link

garberw commented Jul 23, 2024

The question is why does awk fail in the command below. It gives an error message.
I already posted this. It seems someone has deleted it so I will post it again.

I run this script from /etc/cron.daily

#!/bin/sh                                                                                           

set -u
DATE=$(date +%Y%m%d)
HOST=$(hostname)
LOG_DIR="/var/log/lynis"
REPORT="$LOG_DIR/report-${HOST}.${DATE}"
DATA="$LOG_DIR/report-data-${HOST}.${DATE}.txt"

#cd /usr/local/lynis                                                                                
cd /var/log/lynis

# Run Lynis                                                                                         
#./lynis audit system --cronjob > ${REPORT}                                                         
/usr/bin/lynis audit system --cronjob > ${REPORT}

# Optional step: Move report file if it exists                                                      
if [ -f /var/log/lynis-report.dat ]; then
    mv /var/log/lynis-report.dat ${DATA}
fi
# The End                                                                                           

The cron job gives the error:

/etc/cron.daily/lynis.garberw:
/usr/bin/grep: warning: stray \ before -

ANSWER / SOLUTION / FIX

in /usr/share/lynis/include there is a file tests_boot_services which does not detect SYSTEMD_VERSION on my system correctly. So I fixed it by brute force:

(line 1086)
        # garberw                                                                                   
        # echo "garberw SYSTEMDANALYZEBINARY=${SYSTEMDANALYZEBINARY}"                               
        # echo "garberw AWKBINARY           =${AWKBINARY}"                                          
        # SYSTEMD_VERSION=$("${SYSTEMDANALYZEBINARY}" --version | ${AWKBINARY} '/^systemd/ {print $2}')                                                                                                
        # echo "garberw SYSTEMD_VERSION     =${SYSTEMD_VERSION}"                                    
        # garberw added next line                                                                   
        SYSTEMD_VERSION=251
        if [ "${SYSTEMD_VERSION}" -ge 240 ]; then PREQS_MET="YES"; else SKIPREASON="systemd-analyze too old (v${SYSTEMD_VERSION}), need at least v240"; PREQS_MET="NO"; fi
    fi

using the rpm version the awk command fails so I just manually overrided SYSTEMD_VERSION.

@Felipe-53
Copy link

Issue opened with no description? Can you elaborate a bit?

@jwadodson
Copy link

try this,
grep -E "GREP.\-" /usr/share/lynis/include/

you will see 9 places where a slosh (backslash) preceeds a - (minus)
the fedora grep complains about them. vis.

    /usr/bin/grep: warning: stray \ before -

previously a number of these "errors" occured, but on FC40 it's down to one.
It's hard to know exactly which one of the 9 examples left.

I guess that if there is still a version of grep out there that requires "-" escaped by ""
then a fix might be problematic - hopefully not!

@jwadodson
Copy link

Sorry that should have been,
grep -E "GREP.-" /usr/share/lynis/include/*

@jwadodson
Copy link

Version in fedora40 is,
lynis.noarch 3.1.1-1.fc40 @fedora

@jwadodson
Copy link

Once fixed we have to try to persuade the packager to include it in the next release or
hopefully FC40!

@garberw
Copy link
Author

garberw commented Sep 6, 2024

think it is fixed in fedora 40.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants