Bug 1146717 - rkhunter fails with dash as the /bin/sh shell
Summary: rkhunter fails with dash as the /bin/sh shell
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: rkhunter
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kevin Fenzi
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-25 21:03 UTC by Wolfgang Rupprecht
Modified: 2014-09-26 18:17 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2014-09-26 18:17:54 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Wolfgang Rupprecht 2014-09-25 21:03:32 UTC
Description of problem:

rkhunter fails with dash as the /bin/sh shell.   It runs fine when running under bash as /bin/sh.

    /etc/cron.daily/rkhunter:

    /etc/cron.daily/rkhunter: 22: [: no: unexpected operator

dash claims to be a posix compliant shell.  Either that is false, or the rkhunter script has a bash-ism that crept in.

Version-Release number of selected component (if applicable):

bash.x86_64                          4.2.47-4.fc20                      @koji   
dash.x86_64                          0.5.7-8.fc20                       @fedora 
rkhunter.noarch                      1.4.2-2.fc20                       @updates

How reproducible:
always

Steps to Reproduce:
1. yum install dash 
2. l -l /bin/sh ;  cd /bin ; ln -sf dash sh ; ls -l /bin/sh
3. /etc/cron.daily/rkhunter

Actual results:
an error about a botched [ test.

Expected results:
no error about a botched [ test.

Additional info:

Comment 1 Kevin Fenzi 2014-09-25 21:34:10 UTC
I know of no promise one way or another that rkhunter should work with any posix shell. 

I've asked upstream to clarify.

Comment 2 Wolfgang Rupprecht 2014-09-25 21:36:36 UTC
The first line is #!/bin/sh which implies it runs on any legit shell.   If this isn't the case that line should be changed to #!/bin/bash if it requires bash.

Comment 3 Nerijus Baliūnas 2014-09-25 22:10:40 UTC
It should not require bash. However, given the variety of shells out
there, it may well be that something shell-specific has crept in.

We would need to know what line in RKH had failed, so use of 'sh -x' or
the RKH '--debug' option will probably be required.

Comment 4 Wolfgang Rupprecht 2014-09-25 22:20:34 UTC
As per the initial bug report description, the line is line 22 of the cron wrapper:

/etc/cron.daily/rkhunter: 22: [: no: unexpected operator

Comment 5 Kevin Fenzi 2014-09-25 23:29:11 UTC
Oops. I missed that this was in the cron wrapper. ;( 

This is something in Fedora, not upstream (that I know of). 

I'll see what can be done to un-bash it.

Comment 6 Wolfgang Rupprecht 2014-09-25 23:43:02 UTC
I think the bug is that the test uses "==" instead of "=".   That is an easy mistake for someone familiar with C to make.

diff -uNrp /etc/cron.daily/rkhunter.\~1\~ /etc/cron.daily/rkhunter
--- /etc/cron.daily/rkhunter.~1~	2014-04-06 10:58:43.000000000 -0700
+++ /etc/cron.daily/rkhunter	2014-09-25 16:40:05.507697786 -0700
@@ -19,7 +19,7 @@ if [ ! -e /var/lock/subsys/rkhunter ]; t
   fi
 
   # If a diagnostic mode scan was requested, setup the parameters
-  if [ "$DIAG_SCAN" == "yes" ]; then
+  if [ "$DIAG_SCAN" = "yes" ]; then
     RKHUNTER_FLAGS="--checkall --skip-keypress --nocolors --quiet --appendlog --display-logfile"
   else
     RKHUNTER_FLAGS="--cronjob --nocolors --report-warnings-only"

Diff finished.  Thu Sep 25 16:42:21 2014

Comment 7 Kevin Fenzi 2014-09-26 16:03:43 UTC
Alright, with that change does all work as expected for you?

Comment 8 Wolfgang Rupprecht 2014-09-26 17:43:36 UTC
It looks ok now.  There is no gripe for the line 22 test and the rkhunter tests appear to be running correctly.

Comment 9 Kevin Fenzi 2014-09-26 17:45:27 UTC
ok. I can push out an updated package with this change. 

Did you need it in f20? Or can I just push to rawhide for now and update other branches as needed?

Comment 10 Wolfgang Rupprecht 2014-09-26 18:08:33 UTC
I'm fine with only a rawhide push.    Thanks!

Comment 11 Kevin Fenzi 2014-09-26 18:17:54 UTC
Great. Pushed and built in rawhide. ;) 

Thanks!


Note You need to log in before you can comment on or make changes to this bug.