iniset function fails if value contains pipe char

Bug #1258050 reported by Andrea Frittoli
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
devstack
Fix Released
Undecided
Andrea Frittoli

Bug Description

The iniset function uses sed and "|" as a separator.
If the value injected contains a "|" itself, the sed command won't work.

    else
        # Replace it
        sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=[ \t]*\).*$|\1$value|" "$file"
    fi

Changing the separator would not help.
A possible solution is to normalize the value against the separator used with a multichar string which is less likely to be used:

    else
        # Handle the case of "|" in value
        safevalue=$(echo $value | sed 's/|/__PIPE__/g')
        # Replace it
        sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=[ \t]*\).*$|\1$safevalue|" "$file"
        # Revert safevalue
        sed -i -e "/^\[$section\]/,/^\[.*\]/ s/__PIPE__/|/g" "$file"
    fi

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to devstack (master)

Fix proposed to branch: master
Review: https://review.openstack.org/60170

Changed in devstack:
assignee: nobody → Andrea Frittoli (andrea-frittoli)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to devstack (master)

Reviewed: https://review.openstack.org/60170
Committed: https://git.openstack.org/cgit/openstack-dev/devstack/commit/?id=cd7d956fbc30eae3c1694b187ea605a5f0d960d3
Submitter: Jenkins
Branch: master

commit cd7d956fbc30eae3c1694b187ea605a5f0d960d3
Author: Andrea Frittoli <email address hidden>
Date: Thu Dec 5 08:09:12 2013 +0000

    Handle the case of pipe char in value for iniset

    iniset did not handle the case of "|" in the value
    to be injected. Fix this by replacing | with \000 (NULL).

    Fixes bug #1258050

    Change-Id: I8882c2f3f177ebdfa0c66270dbbc7fd50f30b065

Changed in devstack:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.