Bug 1158851 - Cron cartridge: loading of environment variables underquoted
Summary: Cron cartridge: loading of environment variables underquoted
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: ImageStreams
Version: 2.2.0
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: Jason DeTiberus
QA Contact: libra bugs
URL:
Whiteboard:
: 1158868 (view as bug list)
Depends On: 1157830 1158868
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-30 11:25 UTC by Luke Meyer
Modified: 2014-12-10 13:24 UTC (History)
12 users (show)

Fixed In Version: openshift-origin-cartridge-cron-1.24.1.1-1
Doc Type: Bug Fix
Doc Text:
Due to a bug in the cron cartridge, environment variables were not properly quoted. This could result in variables being set incorrectly when loaded by gear cron jobs. This bug fix updates the cron cartridge script that handles running the jobs, and as a result, variables are now set correctly. After applying this update, a cartridge upgrade is required.
Clone Of: 1157830
Environment:
Last Closed: 2014-12-10 13:24:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1979 0 normal SHIPPED_LIVE Red Hat OpenShift Enterprise 2.2.2 bug fix and enhancement update 2014-12-10 18:23:46 UTC

Description Luke Meyer 2014-10-30 11:25:34 UTC
+++ This bug was initially created as a clone of Bug #1157830 +++

Description of problem:
The loading of environment variables (system and user defined) is underquoted, resulting in unwanted word splitting and filename expansion.

Version-Release number of selected component (if applicable):
OpenShift Online as of 10-27-2014.

How reproducible:
Always

Steps to Reproduce:
1. rhc env set NAME="John Doe"
2. Add cron cartridge to any OpenShift app
3. Create cron job .openshift/cron/minutely/env.sh as follows:

#! /bin/sh

env >/tmp/env.txt

4. Wait a minute
5. grep ^NAME= /tmp/env.txt

Actual results:
NAME=John

Expected results:
NAME=John Doe

Additional info:
Naturally the bug also appears on OpenShift Enterprise. Verified with OpenShift Enterprise 2.0.8.

The culprits seem to be the following lines in '/usr/libexec/openshift/cartridges/cron/bin/cron_runjobs.sh' of the cron cartridge:

local contents=$(< $1)

export $key=$(< $1)

which should instead read:

local contents="$(< $1)"

export $key="$(< $1)"

--- Additional comment from Vojtech Vitek on 2014-10-29 20:09:27 EDT ---

Hey Daniel, thanks for this bug report and the provided fix. Much appreciated!

--- Additional comment from Vojtech Vitek on 2014-10-29 20:12:24 EDT ---

CC'ing Enterprise guys per comment 0, since user verified this bug on OpenShift Enterprise 2.0.8.

--- Additional comment from Vojtech Vitek on 2014-10-29 21:04:40 EDT ---

Steps to reproduce:
```
rhc app create php php-5.3
rhc cartridge-add cron --app php
cd php
mkdir -p .openshift/cron/minutely
echo -e "#!/bin/sh\nenv>/tmp/env.txt" > .openshift/cron/minutely/env.sh 
chmod +x .openshift/cron/minutely/env.sh
git commit -ama
git push

rhc env set NAME="John Doe" --app php

#Bug:
rhc ssh php "cat /tmp/env.txt | grep NAME=Jo"
NAME=John

#Fix applied:
rhc ssh php "cat /tmp/env.txt | grep NAME=Jo"
NAME=John Doe
```

--- Additional comment from Vojtech Vitek on 2014-10-29 21:05:04 EDT ---

https://github.com/openshift/origin-server/pull/5915

Comment 2 Brenton Leanhardt 2014-10-30 12:57:31 UTC
*** Bug 1158868 has been marked as a duplicate of this bug. ***

Comment 4 Gaoyun Pei 2014-11-25 06:01:40 UTC
verify this bug on puddle 2.2/2014-11-24.3 with package openshift-origin-cartridge-cron-1.24.1.1-1.el6op.noarch

1. rhc app create test1 php-5.3 cron-1.4

2. Create a minutely cron job in .openshift/cron/minutely/env.sh as follow:

#! /bin/sh

env >/tmp/env.txt

3. rhc env set NAME="John Doe" -a test1
   
[root@broker test1]# rhc ssh test1 "cat /tmp/env.txt | grep NAME=Jo"
NAME=John Doe

Comment 6 errata-xmlrpc 2014-12-10 13:24:49 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2014-1979.html


Note You need to log in before you can comment on or make changes to this bug.