Skip to content
Permalink
Browse files

[JENKINS-23273] Make some variables space safe by quoting them

  • Loading branch information
raul-arabaolaza committed Mar 30, 2017
1 parent d6732ac commit 322d0ee11dd26e369c4590fb389b4a411ed63840
Showing with 10 additions and 10 deletions.
  1. +10 −10 rpm/build/SPECS/jenkins.spec
@@ -82,10 +82,10 @@ rm -rf "%{buildroot}"
# files directive to use JENKINS_USER as owner.
if [ -f "/etc/sysconfig/%{name}" ]; then
logger -t %{name}.installer "Found previous config file /etc/sysconfig/%{name}"
. /etc/sysconfig/%{name}
stat --format=%U /var/cache/%{name} > /tmp/%{name}.installer.cacheowner
stat --format=%U /var/log/%{name} > /tmp/%{name}.installer.logowner
stat --format=%U ${JENKINS_HOME:-%{workdir}} > /tmp/%{name}.installer.workdirowner
. "/etc/sysconfig/%{name}"
stat --format=%U "/var/cache/%{name}" > "/tmp/%{name}.installer.cacheowner"
stat --format=%U "/var/log/%{name}" > "/tmp/%{name}.installer.logowner"
stat --format=%U ${JENKINS_HOME:-%{workdir}} > "/tmp/%{name}.installer.workdirowner"
else
logger -t %{name}.installer "No previous config file /etc/sysconfig/%{name} found"
fi
@@ -96,17 +96,17 @@ rm -rf "%{buildroot}"
function chownIfNecessary {
logger -t %{name}.installer "Checking ${2} ownership"
if [ -f "${1}" ] ; then
owner=$(cat $1)
rm -f $1
owner=$(cat "$1")
rm -f "$1"
logger -t %{name}.installer "Found previous owner of ${2}: ${owner} "
fi
if [ "${owner:-%{name}}" != "${JENKINS_USER:-%{name}}" ] ; then
logger -t %{name}.installer "Previous owner of ${2} is different than configured JENKINS_USER... Doing a recursive chown of ${2} "
chown -R ${JENKINS_USER:-%{name}} $2
chown -R ${JENKINS_USER:-%{name}} "$2"
elif [ "${JENKINS_USER:-%{name}}" != "%{name}" ] ; then
# User has changed ownership of files and JENKINS_USER, chown only the folder
logger -t %{name}.installer "Configured JENKINS_USER is different than default... Doing a non recursive chown of ${2} "
chown ${JENKINS_USER:-%{name}} $2
chown ${JENKINS_USER:-%{name}} "$2"
else
logger -t %{name}.installer "No chown needed for ${2} "
fi
@@ -118,8 +118,8 @@ function chownIfNecessary {
# the existing semantics
. /etc/sysconfig/%{name}
if test x"$JENKINS_INSTALL_SKIP_CHOWN" != "xtrue"; then
chownIfNecessary "/tmp/%{name}.installer.cacheowner" /var/cache/%{name}
chownIfNecessary "/tmp/%{name}.installer.logowner" /var/log/%{name}
chownIfNecessary "/tmp/%{name}.installer.cacheowner" "/var/cache/%{name}"
chownIfNecessary "/tmp/%{name}.installer.logowner" "/var/log/%{name}"
chownIfNecessary "/tmp/%{name}.installer.workdirowner" ${JENKINS_HOME:-%{workdir}}
fi

0 comments on commit 322d0ee

Please sign in to comment.
You can’t perform that action at this time.