juju-introspection.sh is full of bashisms

Bug #1770437 reported by Adam Collard
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
Medium
Tim Penhey
2.3
Fix Released
Medium
Tim Penhey
2.4
Fix Released
Medium
Tim Penhey

Bug Description

On a model deployed with Juju 2.2.8, backed by the OpenStack provider.

The application in question is a web app, which runs as an unprivileged user, where interactive shell usage is not normally required. As such the entry in /etc/passwd (passwd(5)) has no command interpreter set; in turn defaulting to /bin/sh which is a symlink to /bin/dash on Ubuntu.

$ juju ssh my-application/0
ubuntu@juju-deadbeef-my-model-1:~$ sudo -u unpriv -i
-sh: 31: /etc/profile.d/juju-introspection.sh: Syntax error: Bad function name
$

This is because Juju places bashisms in /etc/profile.d/juju-introspection.sh which is sourced by all sh(1) compatible shells - as per the top of /etc/profile:
---
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
---

This can be reproduced by simply adding a user with a shell set to dash

ubuntu@juju-deadbeef-my-model-1:~$ sudo adduser --shell=/bin/sh unpriv
ubuntu@juju-deadbeef-my-model-1:~$ sudo -u unpriv -i

Or the file could be made sh(1) compatible; the problem is with hyphens in function names.

e.g. https://github.com/juju/juju/blob/1cac709aab13075c1b7ffadc75359d7594236c74/worker/introspection/script.go#L68

Revision history for this message
Tim Penhey (thumper) wrote :

We could just use underscores instead of hyphens in the names.

Changed in juju:
status: New → Triaged
importance: Undecided → Medium
tags: added: introspection ui
tags: added: bitesize
Revision history for this message
Thomas Cuthbert (tcuthbert) wrote :

I hit this bug recently on a 2.3.8 environment. I was attempting to install spamassassin but the post-install hook keeps failing due to the juju-introspection file: https://pastebin.canonical.com/p/T6d4tv3y76/

Stuart Bishop (stub)
tags: added: canonical-is
Tim Penhey (thumper)
Changed in juju:
assignee: nobody → Tim Penhey (thumper)
status: Triaged → In Progress
milestone: none → 2.5-beta1
Revision history for this message
Tim Penhey (thumper) wrote :
Tim Penhey (thumper)
Changed in juju:
status: In Progress → Fix Committed
Revision history for this message
Tim Penhey (thumper) wrote :

The dashes have become underscores.

Changed in juju:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.