]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: port COMM= matching to path_extract_filename()
authorLennart Poettering <lennart@poettering.net>
Wed, 21 Dec 2022 15:47:41 +0000 (16:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 23 Dec 2022 14:04:19 +0000 (15:04 +0100)
src/journal/journalctl.c

index 7805c9cd9db22d6d204468f193249a2b9fe29c6d..dd285179247fd4baaaae531a3cd0c1bd163b41fa 100644 (file)
@@ -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();