juju-introspection.sh is full of bashisms

Bug #1770437 reported by Adam Collard on 2018-05-10
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
juju
Medium
Tim Penhey
2.3
Medium
Tim Penhey
2.4
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

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
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) on 2018-07-23
tags: added: canonical-is
Tim Penhey (thumper) on 2018-08-03
Changed in juju:
assignee: nobody → Tim Penhey (thumper)
status: Triaged → In Progress
milestone: none → 2.5-beta1
Tim Penhey (thumper) on 2018-08-03
Changed in juju:
status: In Progress → Fix Committed
Tim Penhey (thumper) wrote :

The dashes have become underscores.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers