X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Finstall.c;h=e59e108c02459848e092d1fa9c667f646acb358b;hb=f5a3628cc7aa132bb0ee6be48f3cedc2d8838046;hp=e3db63769fc4a961564975aad601157151c5b2fe;hpb=10e87ee7f66b59a504c0ed2025463ba5faa69923;p=elogind.git diff --git a/src/install.c b/src/install.c index e3db63769..e59e108c0 100644 --- a/src/install.c +++ b/src/install.c @@ -60,6 +60,7 @@ Hashmap *will_install = NULL, *have_installed = NULL; static int help(void) { printf("%s [options]\n\n" + "Install init system units.\n\n" " -h --help Show this help\n" " --force Override existing links\n" " --system Install into system\n" @@ -69,7 +70,7 @@ static int help(void) { " enable [NAME...] Enable one or more units\n" " disable [NAME...] Disable one or more units\n" " test [NAME...] Test whether any of the specified units are enabled\n", - __progname); + program_invocation_short_name); return 0; } @@ -180,9 +181,6 @@ static bool unit_name_valid(const char *name) { /* This is a minimal version of unit_name_valid() from * unit-name.c */ - if (strchr(name, '/')) - return false; - if (!*name) return false; @@ -385,6 +383,9 @@ static int install_info_symlink_alias(InstallInfo *i, const char *config_path) { if ((r = create_symlink(i->path, alias_path)) != 0) goto finish; + + if (arg_action == ACTION_DISABLE) + rmdir_parents(alias_path, config_path); } r = 0; @@ -421,15 +422,8 @@ static int install_info_symlink_wants(InstallInfo *i, const char *config_path) { if ((r = create_symlink(i->path, alias_path)) != 0) goto finish; - if (arg_action == ACTION_DISABLE) { - char *t; - - /* Try to remove .wants dir if we don't need it anymore */ - if (asprintf(&t, "%s/%s.wants", config_path, *s) >= 0) { - rmdir(t); - free(t); - } - } + if (arg_action == ACTION_DISABLE) + rmdir_parents(alias_path, config_path); } r = 0; @@ -532,8 +526,6 @@ int main(int argc, char *argv[]) { zero(paths); - log_set_target(LOG_TARGET_CONSOLE); - log_set_max_level(LOG_INFO); log_parse_environment(); if ((r = parse_argv(argc, argv)) < 0) @@ -543,7 +535,7 @@ int main(int argc, char *argv[]) { goto finish; } - if ((r = lookup_paths_init(&paths, arg_where == WHERE_SYSTEM ? MANAGER_INIT : MANAGER_SESSION)) < 0) { + if ((r = lookup_paths_init(&paths, arg_where == WHERE_SYSTEM ? MANAGER_SYSTEM : MANAGER_SESSION)) < 0) { log_error("Failed to determine lookup paths: %s", strerror(-r)); goto finish; }