LCOV - code coverage report
Current view: top level - journal - journald-wall.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 0 23 0.0 %
Date: 2019-08-22 15:41:25 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : 
       3             : #include "alloc-util.h"
       4             : #include "format-util.h"
       5             : #include "journald-server.h"
       6             : #include "journald-wall.h"
       7             : #include "process-util.h"
       8             : #include "string-util.h"
       9             : #include "utmp-wtmp.h"
      10             : 
      11           0 : void server_forward_wall(
      12             :                 Server *s,
      13             :                 int priority,
      14             :                 const char *identifier,
      15             :                 const char *message,
      16             :                 const struct ucred *ucred) {
      17             : 
      18           0 :         _cleanup_free_ char *ident_buf = NULL, *l_buf = NULL;
      19             :         const char *l;
      20             :         int r;
      21             : 
      22           0 :         assert(s);
      23           0 :         assert(message);
      24             : 
      25           0 :         if (LOG_PRI(priority) > s->max_level_wall)
      26           0 :                 return;
      27             : 
      28           0 :         if (ucred) {
      29           0 :                 if (!identifier) {
      30           0 :                         get_process_comm(ucred->pid, &ident_buf);
      31           0 :                         identifier = ident_buf;
      32             :                 }
      33             : 
      34           0 :                 if (asprintf(&l_buf, "%s["PID_FMT"]: %s", strempty(identifier), ucred->pid, message) < 0) {
      35           0 :                         log_oom();
      36           0 :                         return;
      37             :                 }
      38             : 
      39           0 :                 l = l_buf;
      40             : 
      41           0 :         } else if (identifier) {
      42             : 
      43           0 :                 l = l_buf = strjoin(identifier, ": ", message);
      44           0 :                 if (!l_buf) {
      45           0 :                         log_oom();
      46           0 :                         return;
      47             :                 }
      48             :         } else
      49           0 :                 l = message;
      50             : 
      51           0 :         r = utmp_wall(l, "systemd-journald", NULL, NULL, NULL);
      52           0 :         if (r < 0)
      53           0 :                 log_debug_errno(r, "Failed to send wall message: %m");
      54             : }

Generated by: LCOV version 1.14