Menu

#5609 Script "webmin/setup.sh" and UNIX System V

2.013
open
nobody
None
5
2023-03-22
2023-01-27
No

The service script generation of ./stop-init has been changed in setup.sh with the commit "Fail proof way of stopping Webmin server" on 04/23/2022. Because of this change, "./stop-init" does not work on Unix V systems such as Solaris 11.

The cause lies in line 698:

echo " ((ps axf | grep \"$wadir\/miniserv\.pl\" | awk '{print \"kill -9 -- -\" \$1}' | bash) || kill -9 -- - \$pid || kill -9 \$pid) 2>/dev/null" >>$config_dir/.stop-init

and 703:

echo " (ps axf | grep \"$wadir\/miniserv\.pl\" | awk '{print \"kill -9 -- -\" \$1}' | bash) 2>/dev/null" >> $config_dir/.stop-init

1.) "ps axf" is not understood by UNIX System V systems. A similar command for System V would be "ps -eo pid,cmd" to have the PID first. This would be necessary for the rest of the command line.

2.) Is the double parenthesis on line 698 really necessary? It causes the following error on Solaris 11 systems:

  Stop the webmin server in /usr/local/webmin-2.013
  /usr/local/etc/webmin/stop: line 8: syntax error on line 19: `'' unmatched

Additional remark: the script "webmin/setup.sh" is defined in the first line with "#!/bin/sh". Why is "bash" then used in the two lines concerned?

BTW: Apart from this scripting problem: excellent software!!

Discussion

  • Jamie Cameron

    Jamie Cameron - 2023-01-28

    @iliajie I think you made these changes recently. Can you take a look and see how we can make sure to only depend on /bin/sh , and not assume that the ps command is from Linux?

     
  • Ilia

    Ilia - 2023-01-30

    1.) "ps axf" is not understood by UNIX System V

    That shouldn't matter as I meant to try force kill commands one by one. I see the bug here. It will be fixed it on the next release.

    2.) Is the double parenthesis on line 698 really necessary? It causes the following error on Solaris 11 systems:

    That is odd, but okay, I removed it.

    This is the stop script which will be generated on the new Webmin releases.You could replace Webmin installation directory (i.e. /usr/share/webmin) and give it a try now to make sure it works:

    #!/bin/sh
    if [ "$1" = "--kill" ]; then
      echo Force stopping Webmin server in /usr/share/webmin
    else
      echo Stopping Webmin server in /usr/share/webmin
    fi
    pidfile=`grep "^pidfile=" /etc/webmin/miniserv.conf | sed -e 's/pidfile=//g'`
    pid=`cat $pidfile 2>/dev/null`
    if [ "$pid" != "" ]; then
      kill $pid || exit 1
      touch /var/webmin/stop-flag
      if [ "$1" = "--kill" ]; then
        sleep 1
        (ps axf | grep "/usr/share/webmin\/miniserv\.pl" | awk '{print "kill -9 -- -" $1}' | bash ; kill -9 -- -$pid ; kill -9 $pid) 2>/dev/null
      fi
      exit 0
    else
      if [ "$1" = "--kill" ]; then
        (ps axf | grep "/usr/share/webmin\/miniserv\.pl" | awk '{print "kill -9 -- -" $1}' | bash ; kill -9 -- -$pid ; kill -9 $pid) 2>/dev/null
      fi
    fi
    
     
  • Wolfgang Voller

    Wolfgang Voller - 2023-03-22

    Feedback: Version 2.020 fixes this bug on Solaris 11. Thanks!

     
    • Ilia

      Ilia - 2023-03-22

      Good to hear! Thanks for your feedback!

       

Log in to post a comment.