Beware global state in hooks

Martin Packman martin.packman at canonical.com
Mon Sep 16 18:53:46 UTC 2013


Be careful when touching process-global state when writing charm
hooks. Calling out to the juju tools such as config-get will inherit
the normal C environment, and juju may break in surprising ways if you
don't leave it how you found it.

Yolanda had this problem today, when trying to use setuid in a script.
What is the best way of handling that? For things like the working
directory, just doing try/finally and reverting the value is fine, or
in python invoking a subprocess in the desired location. To switch
user, forking and waiting for the fork to complete seems safest?

Martin



More information about the Juju mailing list