coredump: really extract container cmdline (#5167)

Fixes:
```
root# systemd-nspawn -D ./cont/ --register=no /bin/sh -c '/bin/sh -c "kill -ABRT \$\$"'
...
Container cont failed with error code 134.

root# journalctl MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1 -o verbose | grep -i container_cmdline
...prints nothing...
...should be COREDUMP_CONTAINER_CMDLINE=systemd-nspawn -D ./cont/ --register=no /bin/sh -c /bin/sh -c "kill -ABRT \$\$"
```

Also, fixes CID #1368263
```
==352== 130 bytes in 1 blocks are definitely lost in loss record 1 of 2
==352==    at 0x4C2ED5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==352==    by 0x4ED8581: greedy_realloc (alloc-util.c:57)
==352==    by 0x4ECAAD5: get_process_cmdline (process-util.c:147)
==352==    by 0x10E385: get_process_container_parent_cmdline (coredump.c:645)
==352==    by 0x112949: process_kernel (coredump.c:1240)
==352==    by 0x113003: main (coredump.c:1297)
==352==
```
This commit is contained in:
Evgeny Vereshchagin 2017-01-31 19:04:20 +03:00 committed by Zbigniew Jędrzejewski-Szmek
parent aa475dc227
commit d3cba4eaf6

View file

@ -642,7 +642,11 @@ static int get_process_container_parent_cmdline(pid_t pid, char** cmdline) {
if (r < 0)
return r;
return get_process_cmdline(container_pid, 0, false, cmdline);
r = get_process_cmdline(container_pid, 0, false, cmdline);
if (r < 0)
return r;
return 1;
}
static int change_uid_gid(const char *context[]) {