Github user neykov commented on the issue:

    https://github.com/apache/brooklyn-library/pull/76
  
    +1 makes sense
    Still can't explain to myself why I used the `@` delimited, but then didn't 
escape the password for it. I had a good reason not to use `/` but can't 
remember now.
    
    Looking at @geomacy's exmples above I think adding single quote to the 
escape list is needed as well. Something like:
    ```
    sed -i'' -e 's/^\(\s*password\s*=\s*\).*$/\1te'sty/g' mymysql.cnf
    ```
    where the new password is `te'sty` will break it as well.
    
    A new line is another potential failure point. But I'm fine not coding 
around this one.
    
    Taking a step back, is `sed` the only option for updating the password? Can 
we delete the line (with sed) and then append it by other means safely? The 
only way I could think of dealing with random strings and not going through 
escape hell is base64'ing it so it goes through bash unaffected. Something like:
    ```
    cat > new_password.tmp <<EOF
    base64'ed password from java
    EOF
    echo -n "password=" >> mysql.cnf
    base64 --decode new_password.tmp >> mysql.cnf
    ```



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to