]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #8953 from yuwata/bus-macro
authorLennart Poettering <lennart@poettering.net>
Fri, 11 May 2018 05:51:17 +0000 (22:51 -0700)
committerGitHub <noreply@github.com>
Fri, 11 May 2018 05:51:17 +0000 (22:51 -0700)
core: simplify dbus properties

1  2 
src/tmpfiles/tmpfiles.c

diff --combined src/tmpfiles/tmpfiles.c
index b4a9b877289c4c5b67c48b4fcda1cc530c793a8d,5190d7eb76d3a740291e5bb3be8ca05dd06f2c61..6e992ca3a90caf036fae82d65c4b865893d3f987
@@@ -60,7 -60,6 +60,7 @@@
  #include "string-table.h"
  #include "string-util.h"
  #include "strv.h"
 +#include "terminal-util.h"
  #include "umask-util.h"
  #include "user-util.h"
  #include "util.h"
@@@ -150,7 -149,6 +150,7 @@@ typedef enum DirectoryType 
          _DIRECTORY_TYPE_MAX,
  } DirectoryType;
  
 +static bool arg_cat_config = false;
  static bool arg_user = false;
  static bool arg_create = false;
  static bool arg_clean = false;
@@@ -1504,7 -1502,7 +1504,7 @@@ static int create_item(Item *i) 
  
                  if (IN_SET(i->type, CREATE_SUBVOLUME, CREATE_SUBVOLUME_INHERIT_QUOTA, CREATE_SUBVOLUME_NEW_QUOTA)) {
  
-                         if (btrfs_is_subvol(isempty(arg_root) ? "/" : arg_root) <= 0)
+                         if (btrfs_is_subvol(empty_to_root(arg_root)) <= 0)
  
                                  /* Don't create a subvolume unless the
                                   * root directory is one, too. We do
@@@ -2443,24 -2441,12 +2443,24 @@@ static int parse_line(const char *fname
          return 0;
  }
  
 +static int cat_config(char **config_dirs, char **args) {
 +        _cleanup_strv_free_ char **files = NULL;
 +        int r;
 +
 +        r = conf_files_list_with_replacement(arg_root, config_dirs, arg_replace, &files, NULL);
 +        if (r < 0)
 +                return r;
 +
 +        return cat_files(NULL, files, 0);
 +}
 +
  static void help(void) {
          printf("%s [OPTIONS...] [CONFIGURATION FILE...]\n\n"
                 "Creates, deletes and cleans up volatile and temporary files and directories.\n\n"
                 "  -h --help                 Show this help\n"
                 "     --user                 Execute user configuration\n"
                 "     --version              Show package version\n"
 +               "     --cat-config           Show configuration files\n"
                 "     --create               Create marked files/directories\n"
                 "     --clean                Clean up marked directories\n"
                 "     --remove               Remove marked files/directories\n"
@@@ -2476,7 -2462,6 +2476,7 @@@ static int parse_argv(int argc, char *a
  
          enum {
                  ARG_VERSION = 0x100,
 +                ARG_CAT_CONFIG,
                  ARG_USER,
                  ARG_CREATE,
                  ARG_CLEAN,
                  { "help",           no_argument,         NULL, 'h'                },
                  { "user",           no_argument,         NULL, ARG_USER           },
                  { "version",        no_argument,         NULL, ARG_VERSION        },
 +                { "cat-config",     no_argument,         NULL, ARG_CAT_CONFIG     },
                  { "create",         no_argument,         NULL, ARG_CREATE         },
                  { "clean",          no_argument,         NULL, ARG_CLEAN          },
                  { "remove",         no_argument,         NULL, ARG_REMOVE         },
                  case ARG_VERSION:
                          return version();
  
 +                case ARG_CAT_CONFIG:
 +                        arg_cat_config = true;
 +                        break;
 +
                  case ARG_USER:
                          arg_user = true;
                          break;
                          assert_not_reached("Unhandled option");
                  }
  
 -        if (!arg_clean && !arg_create && !arg_remove) {
 +        if (!arg_clean && !arg_create && !arg_remove && !arg_cat_config) {
                  log_error("You need to specify at least one of --clean, --create or --remove.");
                  return -EINVAL;
          }
  
 +        if (arg_replace && arg_cat_config) {
 +                log_error("Option --replace= is not supported with --cat-config");
 +                return -EINVAL;
 +        }
 +
          if (arg_replace && optind >= argc) {
                  log_error("When --replace= is given, some configuration items must be specified");
                  return -EINVAL;
@@@ -2702,9 -2677,19 +2702,9 @@@ static int read_config_files(char **con
          char **f;
          int r;
  
 -        r = conf_files_list_strv(&files, ".conf", arg_root, 0, (const char* const*) config_dirs);
 +        r = conf_files_list_with_replacement(arg_root, config_dirs, arg_replace, &files, &p);
          if (r < 0)
 -                return log_error_errno(r, "Failed to enumerate tmpfiles.d files: %m");
 -
 -        if (arg_replace) {
 -                r = conf_files_insert(&files, arg_root, config_dirs, arg_replace);
 -                if (r < 0)
 -                        return log_error_errno(r, "Failed to extend tmpfiles.d file list: %m");
 -
 -                p = path_join(arg_root, arg_replace, NULL);
 -                if (!p)
 -                        return log_oom();
 -        }
 +                return r;
  
          STRV_FOREACH(f, files)
                  if (p && path_equal(*f, p)) {
@@@ -2736,6 -2721,20 +2736,6 @@@ int main(int argc, char *argv[]) 
          log_parse_environment();
          log_open();
  
 -        umask(0022);
 -
 -        mac_selinux_init();
 -
 -        items = ordered_hashmap_new(&string_hash_ops);
 -        globs = ordered_hashmap_new(&string_hash_ops);
 -
 -        if (!items || !globs) {
 -                r = log_oom();
 -                goto finish;
 -        }
 -
 -        r = 0;
 -
          if (arg_user) {
                  r = user_config_paths(&config_dirs);
                  if (r < 0) {
                          log_debug("Looking for configuration files in (higher priority first):\n\t%s", t);
          }
  
 +        if (arg_cat_config) {
 +                r = cat_config(config_dirs, argv + optind);
 +                goto finish;
 +        }
 +
 +        umask(0022);
 +
 +        mac_selinux_init();
 +
 +        items = ordered_hashmap_new(&string_hash_ops);
 +        globs = ordered_hashmap_new(&string_hash_ops);
 +
 +        if (!items || !globs) {
 +                r = log_oom();
 +                goto finish;
 +        }
 +
          /* If command line arguments are specified along with --replace, read all
           * configuration files and insert the positional arguments at the specified
           * place. Otherwise, if command line arguments are specified, execute just