run: fix bad escaping and memory ownership confusion
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 29 Nov 2023 13:13:33 +0000 (14:13 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 2 Dec 2023 08:47:45 +0000 (09:47 +0100)
commit9ce3440a6fb3fb785e0fa3a6fcf60af7ef652440
tree0003e6fdaa5616c5a91bbb8177919a7adbaf5dd5
parentcffa43255a4fdfa3611ded5e8b6f2305a17b3ba7
run: fix bad escaping and memory ownership confusion

arg_description was either set to arg_unit (i.e. a const char*), or to
char *description, the result of allocation in run(). But description
was decorated with _cleanup_, so it would be freed when going out of the
function. Nothing bad would happen, because the program would exit after
exiting from run(), but this is just all too messy.

Also, strv_join(" ") + shell_escape() is not a good way to escape command
lines. In particular, one the join has happened, we cannot distinguish
empty arguments, or arguments with whitespace, etc. We have a helper
function to do the escaping properly, so let's use that.

Fixup for 2c29813da3421b77eca5e5cdc3b9a863cad473b9.
src/run/run.c