summaryrefslogtreecommitdiff
path: root/src/journal/journalctl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-12-21 16:47:41 +0100
committerLennart Poettering <lennart@poettering.net>2022-12-23 15:04:19 +0100
commit72d95a18c10ffcc25e85019481a230a240e98564 (patch)
tree6e0705d4d26f216fb359376c0a22d65dc72332f9 /src/journal/journalctl.c
parent83802e9abdffdf9b55030c49afc86dc13bd7e54c (diff)
downloadsystemd-72d95a18c10ffcc25e85019481a230a240e98564.tar.gz
journalctl: port COMM= matching to path_extract_filename()
Diffstat (limited to 'src/journal/journalctl.c')
-rw-r--r--src/journal/journalctl.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 7805c9cd9d..dd28517924 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -46,6 +46,7 @@
#include "log.h"
#include "logs-show.h"
#include "memory-util.h"
+#include "missing_sched.h"
#include "mkdir.h"
#include "mount-util.h"
#include "mountpoint-util.h"
@@ -1119,11 +1120,11 @@ static int add_matches(sd_journal *j, char **args) {
if (executable_is_script(p, &interpreter) > 0) {
_cleanup_free_ char *comm = NULL;
- comm = strndup(basename(p), 15);
- if (!comm)
- return log_oom();
+ r = path_extract_filename(p, &comm);
+ if (r < 0)
+ return log_error_errno(r, "Failed to extract filename of '%s': %m", p);
- t = strjoin("_COMM=", comm);
+ t = strjoin("_COMM=", strshorten(comm, TASK_COMM_LEN-1));
if (!t)
return log_oom();