]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #30867 from dtardon/udev-conf-dropins
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 11 Jan 2024 21:37:23 +0000 (06:37 +0900)
committerGitHub <noreply@github.com>
Thu, 11 Jan 2024 21:37:23 +0000 (06:37 +0900)
Allow dropins for udev.conf

1  2 
man/rules/meson.build
src/shared/conf-parser.c
src/shared/conf-parser.h

diff --combined man/rules/meson.build
index c43bffde693850ac56dfc6b9c49c7296ae9dd603,50493754db19e697e928b03f7d894ec402d0942c..1e8747e4ef4ab971267595195a85a5e35fb279fd
@@@ -1054,8 -1054,6 +1054,8 @@@ manpages = 
   ['systemd-socket-activate', '1', [], ''],
   ['systemd-socket-proxyd', '8', [], ''],
   ['systemd-soft-reboot.service', '8', [], ''],
 + ['systemd-ssh-generator', '8', [], ''],
 + ['systemd-ssh-proxy', '1', [], ''],
   ['systemd-stdio-bridge', '1', [], ''],
   ['systemd-storagetm.service', '8', ['systemd-storagetm'], 'ENABLE_STORAGETM'],
   ['systemd-stub',
   ['timesyncd.conf', '5', ['timesyncd.conf.d'], 'ENABLE_TIMESYNCD'],
   ['tmpfiles.d', '5', [], ''],
   ['udev', '7', [], ''],
-  ['udev.conf', '5', [], ''],
+  ['udev.conf', '5', ['udev.conf.d'], ''],
   ['udev_device_get_syspath',
    '3',
    ['udev_device_get_action',
diff --combined src/shared/conf-parser.c
index fcc7783d572c6d557f4ff752eac1f6f3852efa79,8eea22353537468fbbb7c0d2e8d7e8b99970409f..e34ebcca6eacbebefe35e779f91427bb3d71affa
@@@ -598,10 -598,11 +598,11 @@@ static int config_parse_many_files
          return 0;
  }
  
- /* Parse one main config file located in /etc/systemd and its drop-ins, which is what all systemd daemons
+ /* Parse one main config file located in /etc/$pkgdir and its drop-ins, which is what all systemd daemons
   * do. */
- int config_parse_config_file(
+ int config_parse_config_file_full(
                  const char *conf_file,
+                 const char *pkgdir,
                  const char *sections,
                  ConfigItemLookup lookup,
                  const void *table,
          int r;
  
          assert(conf_file);
+         assert(pkgdir);
  
          /* build the dropin dir list */
          dropin_dirs = new0(char*, strv_length(conf_paths) + 1);
          STRV_FOREACH(p, conf_paths) {
                  char *d;
  
-                 d = strjoin(*p, "systemd/", conf_file, ".d");
+                 d = strjoin(*p, pkgdir, "/", conf_file, ".d");
                  if (!d) {
                          if (flags & CONFIG_PARSE_WARN)
                                  return log_oom();
          if (r < 0)
                  return r;
  
-         const char *sysconf_file = strjoina(PKGSYSCONFDIR, "/", conf_file);
+         const char *sysconf_file = strjoina(SYSCONF_DIR, "/", pkgdir, "/", conf_file);
  
          return config_parse_many_files(STRV_MAKE_CONST(sysconf_file), dropins,
                                         sections, lookup, table, flags, userdata, NULL);
@@@ -795,12 -797,12 +797,12 @@@ bool stats_by_path_equal(Hashmap *a, Ha
          return true;
  }
  
 -static void config_section_hash_func(const ConfigSection *c, struct siphash *state) {
 +void config_section_hash_func(const ConfigSection *c, struct siphash *state) {
          siphash24_compress_string(c->filename, state);
          siphash24_compress_typesafe(c->line, state);
  }
  
 -static int config_section_compare_func(const ConfigSection *x, const ConfigSection *y) {
 +int config_section_compare_func(const ConfigSection *x, const ConfigSection *y) {
          int r;
  
          r = strcmp(x->filename, y->filename);
@@@ -1088,7 -1090,6 +1090,7 @@@ int config_parse_string
                  void *userdata) {
  
          char **s = ASSERT_PTR(data);
 +        int r;
  
          assert(filename);
          assert(lvalue);
  
          if (isempty(rvalue)) {
                  *s = mfree(*s);
 -                return 0;
 +                return 1;
          }
  
          if (FLAGS_SET(ltype, CONFIG_PARSE_STRING_SAFE) && !string_is_safe(rvalue)) {
                  return 0;
          }
  
 -        return free_and_strdup_warn(s, empty_to_null(rvalue));
 +        r = free_and_strdup_warn(s, empty_to_null(rvalue));
 +        if (r < 0)
 +                return r;
 +
 +        return 1;
  }
  
  int config_parse_dns_name(
diff --combined src/shared/conf-parser.h
index 72020b7d699621929381c89fb374bd4e8dae7a71,4e0054de5e2d43bd8b330a6da278ca7caef6498f..30573564791672731e2fd66776dcab3e05c73700
@@@ -93,14 -93,25 +93,25 @@@ int config_parse
                  void *userdata,
                  struct stat *ret_stat);     /* possibly NULL */
  
- int config_parse_config_file(
+ int config_parse_config_file_full(
                  const char *conf_file,
+                 const char *pkgdir,
                  const char *sections,       /* nulstr */
                  ConfigItemLookup lookup,
                  const void *table,
                  ConfigParseFlags flags,
                  void *userdata);
  
+ static inline int config_parse_config_file(
+                 const char *conf_file,
+                 const char *sections,       /* nulstr */
+                 ConfigItemLookup lookup,
+                 const void *table,
+                 ConfigParseFlags flags,
+                 void *userdata) {
+         return config_parse_config_file_full(conf_file, "systemd", sections, lookup, table, flags, userdata);
+ }
  int config_parse_many(
                  const char* const* conf_files,  /* possibly empty */
                  const char* const* conf_file_dirs,
@@@ -137,11 -148,7 +148,11 @@@ static inline ConfigSection* config_sec
  DEFINE_TRIVIAL_CLEANUP_FUNC(ConfigSection*, config_section_free);
  
  int config_section_new(const char *filename, unsigned line, ConfigSection **ret);
 +
 +void config_section_hash_func(const ConfigSection *c, struct siphash *state);
 +int config_section_compare_func(const ConfigSection *x, const ConfigSection *y);
  extern const struct hash_ops config_section_hash_ops;
 +
  int _hashmap_by_section_find_unused_line(
                  HashmapBase *entries_by_section,
                  const char *filename,