Bug 677377 - upgrade-cobbler.sh script cannot handle snippets with unusual filenames
Summary: upgrade-cobbler.sh script cannot handle snippets with unusual filenames
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Upgrades
Version: 540
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Milan Zázrivec
QA Contact: Martin Minar
URL:
Whiteboard:
Depends On:
Blocks: sat541-upgrades
TreeView+ depends on / blocked
 
Reported: 2011-02-14 14:49 UTC by Tasos Papaioannou
Modified: 2018-11-15 09:52 UTC (History)
6 users (show)

Fixed In Version: rhn-upgrade-5.4.0.23-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-06-16 17:30:57 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Tasos Papaioannou 2011-02-14 14:49:33 UTC
Description of problem:

The /etc/sysconfig/rhn/satellite-upgrade/upgrade-cobbler.sh upgrade script, used to upgrade snippets created in Satellite 5.3 to the necessary format for Satellite 5.4, cannot handle snippets with unusual filenames (containing spaces or other such characters).


Version-Release number of selected component (if applicable):

rhn-upgrade-5.4.0.21-1.el5sat

How reproducible:

100%

Steps to Reproduce:
1. Create kickstart snippet with a space in the name, e.g., "funky snippet 1" on Satellite 5.3 or 5.4.

2. Run the upgrade script:
/etc/sysconfig/rhn/satellite-upgrade/upgrade-cobbler.sh

3. See error:
/etc/sysconfig/rhn/satellite-upgrade/upgrade-cobbler.sh: line 28: $f: ambiguous redirect

Actual results:

/etc/sysconfig/rhn/satellite-upgrade/upgrade-cobbler.sh: line 28: $f: ambiguous redirect

Expected results:

No error.

Additional info:

The following line in the upgrade-cobbler.sh script uses the 'find' command without any options for handling unusual filenames:

find */* -type f 2>/dev/null | while read f; do

Running this command manually on the directory /var/lib/cobbler/backup/snippets_spacewalk/ yields:

# find /var/lib/cobbler/backup/snippets_spacewalk/*/*
/var/lib/cobbler/backup/snippets_spacewalk/1/funky snippet 1

The variable f therefore acquires the value:
/var/lib/cobbler/backup/snippets_spacewalk/1/funky snippet 1

When $f is redirected to sed:

        newf=$SNIPPET_DIR/$f
        # put #raw at the begining unless it's already there
        sed -e '1 {/^#raw$/b}' -e '1 {s/^/#raw\n/}' <$f >$newf


bash tries to redirect "funky snippet 1", which appears to be three separate filenames, when it should be redirecting "funky\ snippet\ 1". Using the -print0 option for 'find' seems to fix the issue:

# diff -pruN ./upgrade-cobbler-orig.sh ./upgrade-cobbler.sh 
--- ./upgrade-cobbler-orig.sh	2011-02-14 09:47:30.000000000 -0500
+++ ./upgrade-cobbler.sh	2011-02-14 09:47:43.000000000 -0500
@@ -22,7 +22,7 @@ SNIPPET_DIR=/var/lib/rhn/kickstarts/snip
 SNIPPET_BACKUP_DIR=/var/lib/cobbler/backup/snippets_spacewalk
 cp -aT $SNIPPET_DIR/ $SNIPPET_BACKUP_DIR/ 2>/dev/null
 pushd $SNIPPET_BACKUP_DIR >/dev/null
-find */* -type f 2>/dev/null | while read f; do
+find */* -type f -print0 2>/dev/null | while read f; do
         newf=$SNIPPET_DIR/$f
         # put #raw at the begining unless it's already there
         sed -e '1 {/^#raw$/b}' -e '1 {s/^/#raw\n/}' <$f >$newf

Comment 1 Milan Zázrivec 2011-04-07 11:42:50 UTC
satellite.git SATELLITE-5.4: c41eea3ab30dd40e130d73264fc5342172a26824

Comment 3 Tomas Lestach 2011-05-31 15:19:28 UTC
I created 'custom snippet', appropriate snippet file path is:
/var/lib/cobbler/snippets/spacewalk/1/custom snippet

Running:
# /etc/sysconfig/rhn/satellite-upgrade/upgrade-cobbler.sh
# echo $?
0
# rpm -qf /etc/sysconfig/rhn/satellite-upgrade/upgrade-cobbler.sh
rhn-upgrade-5.4.0.25-1.el6sat.noarch
#

Stage validated on Satellite-5.4.1-RHEL6-re20110530.0

Comment 4 Clifford Perry 2011-06-16 17:30:57 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2011-0876.html


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