Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • I ISPConfig 3
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 586
    • Issues 586
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 47
    • Merge requests 47
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ISPConfig
  • ISPConfig 3
  • Issues
  • #6326
Closed
Open
Issue created Apr 04, 2022 by Mattia Rizzolo@mapreriContributor

Fails to call acme.sh on systems with /bin/sh pointing to a pure-POSIX shell

Summary

Using acme.sh on systems with /bin/sh → /bin/dash (for example) fail with this in the log:

Thu Mar 31 16:36:03 UTC 2022 31.03.2022-16:36 - DEBUG [letsencrypt.inc:430] - Create Let's Encrypt SSL Cert for: XXXX
Thu Mar 31 16:36:03 UTC 2022 31.03.2022-16:36 - DEBUG [letsencrypt.inc:431] - Let's Encrypt SSL Cert domains:
Thu Mar 31 16:36:03 UTC 2022 31.03.2022-16:36 - DEBUG [system.inc:1819] - exec: R=0 ; C=0 ; /root/.acme.sh/acme.sh --issue  -d XXXXX -d www.XXXXXX -w /usr/local/ispconfig/interface/acme --always-force-new-domain-key --keylength 4096; R=$? ; if [[ $R -eq 0 || $R -eq 2 ]] ; then /root/.acme.sh/acme.sh --install-cert  -d XXXXXXX -d www.XXXXXXXXX --key-file '/var/www/clients/client505/web2/ssl/XXXXXXXXX-le.key' --fullchain-file '/var/www/clients/client505/web2/ssl/XXXXXXX-le.crt' --reloadcmd 'systemctl force-reload apache2.service' --log '/var/log/ispconfig/acme.log'; C=$? ; fi ; if [[ $C -eq 0 ]] ; then exit $R ; else exit $C  ; fi
Thu Mar 31 16:36:07 UTC 2022 [Thu Mar 31 16:36:07 UTC 2022] Please add '--debug' or '--log' to check more details.
Thu Mar 31 16:36:07 UTC 2022 [Thu Mar 31 16:36:07 UTC 2022] See: https://github.com/acmesh-official/acme.sh/wiki/How-to-debug-acme.sh
Thu Mar 31 16:36:07 UTC 2022 sh: 1: [[: not found
Thu Mar 31 16:36:07 UTC 2022 sh: 1: 1: not found
Thu Mar 31 16:36:07 UTC 2022 sh: 1: [[: not found
Thu Mar 31 16:36:07 UTC 2022 31.03.2022-16:36 - DEBUG [system.inc:2399] - safe_exec cmd: which 'apache2ctl' 2> /dev/null - return code: 0
Thu Mar 31 16:36:07 UTC 2022 31.03.2022-16:36 - DEBUG [apache2 plugin.inc:1875] - Writing the vhost file: /etc/apache2/sites-available/XXXXXXXXX.vhost
Thu Mar 31 16:36:07 UTC 2022 31.03.2022-16:36 - DEBUG [apache2 plugin.inc:1993] - Apache status is: running
Thu Mar 31 16:36:07 UTC 2022 31.03.2022-16:36 - DEBUG [services.inc:56] - Calling function 'restartHttpd' from module 'web_module'.

(besides, note how this doesn't trigger any ERROR or WARNING, as such no notifications, and on the web panel the tick on "Let's Encrypt" doesn't get removed; however I'm not filing a different bug for this detail, nor am I fixing that)

Environment

Server OS + version: Ubuntu 20.04.4 (just installed, really)
ISPConfig version: 3.2.8p1 Software version of the related software:

root@web01 ~ # which sh         
/usr/bin/sh
root@web01 ~ # ls -l /usr/bin/sh
lrwxrwxrwx 1 root root 4 Mar 22 21:40 /usr/bin/sh -> dash

Proposed fix

That snippet that is also copied into the log use features that are not POSIX-compliant (the [[ and the || in them), that despite being supported by many shells (including bash) are not available in dash.

Since system() runs the code with /bin/sh, then you should not presume a specific shell in that.

My fix will remove those bashism.

Assignee
Assign to
Time tracking