]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #12926 from keszybz/urlify-logs
authorLennart Poettering <lennart@poettering.net>
Wed, 10 Jul 2019 22:00:34 +0000 (00:00 +0200)
committerGitHub <noreply@github.com>
Wed, 10 Jul 2019 22:00:34 +0000 (00:00 +0200)
Urlify CONFIG_FILE and improve SYSTEMD_LOG_LOCATION

1  2 
meson.build
src/basic/log.c
src/core/selinux-access.c
src/network/netdev/netdev.h

diff --combined meson.build
index 4d40451fa6ac3ef63599f6f493d3c6bb31a93c17,bffa9c2d3e835395f137d5bb77e8e7f4aa707809..14a56c29c8541a967f55d45db59520421f30e290
@@@ -29,6 -29,10 +29,10 @@@ substs.set('PROJECT_VERSION',      meso
  # This is to be used instead of meson.source_root(), as the latter will return
  # the wrong result when systemd is being built as a meson subproject
  project_source_root = meson.current_source_dir()
+ relative_source_path = run_command('realpath',
+                                    '--relative-to=@0@'.format(meson.current_build_dir()),
+                                    project_source_root).stdout().strip()
+ conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
  
  want_ossfuzz = get_option('oss-fuzz')
  want_libfuzzer = get_option('llvm-fuzz')
@@@ -113,6 -117,7 +117,6 @@@ pkgconfiglibdir = get_option('pkgconfig
  polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
  polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
  polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
 -varlogdir = join_paths(localstatedir, 'log')
  xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
  rpmmacrosdir = get_option('rpmmacrosdir')
  if rpmmacrosdir != 'no'
@@@ -271,6 -276,7 +275,6 @@@ substs.set('systemenvgeneratordir'
  substs.set('userenvgeneratordir',                             userenvgeneratordir)
  substs.set('systemshutdowndir',                               systemshutdowndir)
  substs.set('systemsleepdir',                                  systemsleepdir)
 -substs.set('VARLOGDIR',                                       varlogdir)
  substs.set('CERTIFICATEROOT',                                 get_option('certificate-root'))
  substs.set('SYSTEMCTL',                                       join_paths(rootbindir, 'systemctl'))
  substs.set('RANDOM_SEED',                                     join_paths(randomseeddir, 'random-seed'))
@@@ -787,7 -793,6 +791,7 @@@ conf.set_quoted('GETTEXT_PACKAGE', meso
  
  substs.set('SUSHELL', get_option('debug-shell'))
  substs.set('DEBUGTTY', get_option('debug-tty'))
 +conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
  
  enable_debug_hashmap = false
  enable_debug_mmap_cache = false
@@@ -1368,7 -1373,6 +1372,7 @@@ config_h = configure_file
  meson_apply_m4 = find_program('tools/meson-apply-m4.sh')
  
  includes = include_directories('src/basic',
 +                               'src/boot',
                                 'src/shared',
                                 'src/systemd',
                                 'src/journal',
diff --combined src/basic/log.c
index c484ff57f60f03580e033c814fb1af76cb8200e1,a30ffb9d8701465aa8a20c01e412c2ef6e8a103c..31ecbd1d1bdbf1852bb17bbad97b46c6b1f18ad4
@@@ -351,7 -351,13 +351,13 @@@ static int write_to_console
                  get_log_colors(LOG_PRI(level), &on, &off, NULL);
  
          if (show_location) {
-                 (void) snprintf(location, sizeof location, "(%s:%i) ", file, line);
+                 const char *lon = "", *loff = "";
+                 if (show_color) {
+                         lon = ANSI_HIGHLIGHT_YELLOW4;
+                         loff = ANSI_NORMAL;
+                 }
+                 (void) snprintf(location, sizeof location, "%s%s:%i%s: ", lon, file, line, loff);
                  iovec[n++] = IOVEC_MAKE_STRING(location);
          }
  
@@@ -1110,11 -1116,11 +1116,11 @@@ void log_parse_environment_realm(LogRea
  
          e = getenv("SYSTEMD_LOG_COLOR");
          if (e && log_show_color_from_string(e) < 0)
 -                log_warning("Failed to parse bool '%s'. Ignoring.", e);
 +                log_warning("Failed to parse log color '%s'. Ignoring.", e);
  
          e = getenv("SYSTEMD_LOG_LOCATION");
          if (e && log_show_location_from_string(e) < 0)
 -                log_warning("Failed to parse bool '%s'. Ignoring.", e);
 +                log_warning("Failed to parse log location '%s'. Ignoring.", e);
  }
  
  LogTarget log_get_target(void) {
@@@ -1232,18 -1238,29 +1238,29 @@@ int log_syntax_internal
          if (unit)
                  unit_fmt = getpid_cached() == 1 ? "UNIT=%s" : "USER_UNIT=%s";
  
-         if (config_file)
-                 return log_struct_internal(
-                                 LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
-                                 error,
-                                 file, line, func,
-                                 "MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
-                                 "CONFIG_FILE=%s", config_file,
-                                 "CONFIG_LINE=%u", config_line,
-                                 LOG_MESSAGE("%s:%u: %s", config_file, config_line, buffer),
-                                 unit_fmt, unit,
-                                 NULL);
-         else if (unit)
+         if (config_file) {
+                 if (config_line > 0)
+                         return log_struct_internal(
+                                         LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
+                                         error,
+                                         file, line, func,
+                                         "MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
+                                         "CONFIG_FILE=%s", config_file,
+                                         "CONFIG_LINE=%u", config_line,
+                                         LOG_MESSAGE("%s:%u: %s", config_file, config_line, buffer),
+                                         unit_fmt, unit,
+                                         NULL);
+                 else
+                         return log_struct_internal(
+                                         LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
+                                         error,
+                                         file, line, func,
+                                         "MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
+                                         "CONFIG_FILE=%s", config_file,
+                                         LOG_MESSAGE("%s: %s", config_file, buffer),
+                                         unit_fmt, unit,
+                                         NULL);
+         } else if (unit)
                  return log_struct_internal(
                                  LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
                                  error,
index 960ba6cc6df24d2801ddddaab49580ef826a53bc,fa57f6411444dbe659a66af33049430e42e0e339..cb136322fe1f9adae5cdfa8df37d030973b322e6
@@@ -17,7 -17,6 +17,7 @@@
  #include "alloc-util.h"
  #include "audit-fd.h"
  #include "bus-util.h"
 +#include "errno-util.h"
  #include "format-util.h"
  #include "log.h"
  #include "path-util.h"
@@@ -127,7 -126,7 +127,7 @@@ _printf_(2, 3) static int log_callback(
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wformat-nonliteral"
          log_internalv(LOG_AUTH | callback_type_to_priority(type),
-                       0, __FILE__, __LINE__, __FUNCTION__,
+                       0, PROJECT_FILE, __LINE__, __FUNCTION__,
                        fmt2, ap);
  #pragma GCC diagnostic pop
          va_end(ap);
@@@ -159,7 -158,7 +159,7 @@@ static int access_init(sd_bus_error *er
                  /* Return an access denied error, if we couldn't load
                   * the AVC but enforcing mode was on, or we couldn't
                   * determine whether it is one. */
 -                return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Failed to open the SELinux AVC: %s", strerror(saved_errno));
 +                return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Failed to open the SELinux AVC: %s", strerror_safe(saved_errno));
          }
  
          selinux_set_callback(SELINUX_CB_AUDIT, (union selinux_callback) audit_callback);
index d63b1912d86f4ce295409c53ed1c443447c4c334,e8a00cd4b74ae963e2939c4daee131cdad8b4beb..732b563d67627a4d4a4fab9df45a00489c033784
@@@ -50,7 -50,6 +50,7 @@@ typedef enum NetDevKind 
          NETDEV_KIND_L2TP,
          NETDEV_KIND_MACSEC,
          NETDEV_KIND_NLMON,
 +        NETDEV_KIND_XFRM,
          _NETDEV_KIND_MAX,
          _NETDEV_KIND_TUNNEL, /* Used by config_parse_stacked_netdev() */
          _NETDEV_KIND_INVALID = -1
@@@ -193,8 -192,8 +193,8 @@@ const struct ConfigPerfItem* network_ne
  #define log_netdev_full(netdev, level, error, ...)                      \
          ({                                                              \
                  const NetDev *_n = (netdev);                            \
-                 _n ? log_object_internal(level, error, __FILE__, __LINE__, __func__, "INTERFACE=", _n->ifname, NULL, NULL, ##__VA_ARGS__) : \
-                         log_internal(level, error, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
+                 _n ? log_object_internal(level, error, PROJECT_FILE, __LINE__, __func__, "INTERFACE=", _n->ifname, NULL, NULL, ##__VA_ARGS__) : \
+                         log_internal(level, error, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \
          })
  
  #define log_netdev_debug(netdev, ...)       log_netdev_full(netdev, LOG_DEBUG, 0, ##__VA_ARGS__)