Commit ed882c2
fix(restore): shell-quote restore_command arguments (cloudnative-pg#10518)
getRestoreWalConfig joined user-controlled backup status fields
(EndpointURL, DestinationPath, ServerName) with spaces into a single
restore_command string. PostgreSQL runs restore_command via system(),
and the POSIX shell word-splits unquoted whitespace, so a
DestinationPath like "s3://my bucket/wal" would be passed to
barman-cloud-wal-restore as separate arguments.
This bug predates cloudnative-pg#10506 but was unreachable for inputs containing
single quotes or backslashes because such values corrupted the config
file first. Now that the config file is well-formed, the shell layer
needs its own quoting.
Wrap each cmd element via github.com/kballard/go-shellquote before
passing the joined value through configfile.RenderPostgresConfiguration.
The result is two layered quoting passes: shell-safe single quotes
around any argument with whitespace or shell metacharacters, and the
standard config-file literal escape applied by the helper.
Related cloudnative-pg#10515
Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
Co-authored-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>1 parent 78dc751 commit ed882c2
2 files changed
Lines changed: 58 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
148 | 153 | | |
149 | 154 | | |
150 | 155 | | |
| |||
641 | 646 | | |
642 | 647 | | |
643 | 648 | | |
644 | | - | |
| 649 | + | |
645 | 650 | | |
646 | 651 | | |
647 | 652 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
226 | 233 | | |
227 | 234 | | |
228 | 235 | | |
229 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
230 | 277 | | |
0 commit comments