chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
systemctl: fix broken list-unit-files with --root
[elogind.git]
/
src
/
shared
/
install.c
diff --git
a/src/shared/install.c
b/src/shared/install.c
index c32d6599a68ef1906ebd949efb62d9c973722708..3ef995a9285acd661ec22056810d93de97f230d8 100644
(file)
--- a/
src/shared/install.c
+++ b/
src/shared/install.c
@@
-45,8
+45,6
@@
typedef struct {
Hashmap *have_installed;
} InstallContext;
Hashmap *have_installed;
} InstallContext;
-#define _cleanup_install_context_done_ _cleanup_(install_context_done)
-
static int in_search_path(const char *path, char **search) {
_cleanup_free_ char *parent = NULL;
int r;
static int in_search_path(const char *path, char **search) {
_cleanup_free_ char *parent = NULL;
int r;
@@
-966,6
+964,9
@@
static int config_parse_also(
if (r < 0)
return r;
}
if (r < 0)
return r;
}
+ if (!isempty(state))
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Trailing garbage, ignoring.");
return 0;
}
return 0;
}
@@
-1058,7
+1059,7
@@
static int unit_file_load(
assert(path);
if (!isempty(root_dir))
assert(path);
if (!isempty(root_dir))
- path = strappenda
3
(root_dir, "/", path);
+ path = strappenda(root_dir, "/", path);
fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|(allow_symlink ? 0 : O_NOFOLLOW));
if (fd < 0)
fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|(allow_symlink ? 0 : O_NOFOLLOW));
if (fd < 0)
@@
-1158,7
+1159,7
@@
static int unit_file_can_install(
const char *name,
bool allow_symlink) {
const char *name,
bool allow_symlink) {
- _cleanup_
install_context_done_
InstallContext c = {};
+ _cleanup_
(install_context_done)
InstallContext c = {};
InstallInfo *i;
int r;
InstallInfo *i;
int r;
@@
-1495,7
+1496,7
@@
int unit_file_enable(
unsigned *n_changes) {
_cleanup_lookup_paths_free_ LookupPaths paths = {};
unsigned *n_changes) {
_cleanup_lookup_paths_free_ LookupPaths paths = {};
- _cleanup_
install_context_done_
InstallContext c = {};
+ _cleanup_
(install_context_done)
InstallContext c = {};
char **i;
_cleanup_free_ char *config_path = NULL;
int r;
char **i;
_cleanup_free_ char *config_path = NULL;
int r;
@@
-1534,7
+1535,7
@@
int unit_file_disable(
unsigned *n_changes) {
_cleanup_lookup_paths_free_ LookupPaths paths = {};
unsigned *n_changes) {
_cleanup_lookup_paths_free_ LookupPaths paths = {};
- _cleanup_
install_context_done_
InstallContext c = {};
+ _cleanup_
(install_context_done)
InstallContext c = {};
char **i;
_cleanup_free_ char *config_path = NULL;
_cleanup_set_free_free_ Set *remove_symlinks_to = NULL;
char **i;
_cleanup_free_ char *config_path = NULL;
_cleanup_set_free_free_ Set *remove_symlinks_to = NULL;
@@
-1594,7
+1595,7
@@
int unit_file_set_default(
unsigned *n_changes) {
_cleanup_lookup_paths_free_ LookupPaths paths = {};
unsigned *n_changes) {
_cleanup_lookup_paths_free_ LookupPaths paths = {};
- _cleanup_
install_context_done_
InstallContext c = {};
+ _cleanup_
(install_context_done)
InstallContext c = {};
_cleanup_free_ char *config_path = NULL;
char *path;
int r;
_cleanup_free_ char *config_path = NULL;
char *path;
int r;
@@
-1856,7
+1857,7
@@
int unit_file_preset(
UnitFileChange **changes,
unsigned *n_changes) {
UnitFileChange **changes,
unsigned *n_changes) {
- _cleanup_
install_context_done_
InstallContext plus = {}, minus = {};
+ _cleanup_
(install_context_done)
InstallContext plus = {}, minus = {};
_cleanup_lookup_paths_free_ LookupPaths paths = {};
_cleanup_free_ char *config_path = NULL;
char **i;
_cleanup_lookup_paths_free_ LookupPaths paths = {};
_cleanup_free_ char *config_path = NULL;
char **i;
@@
-1924,7
+1925,7
@@
int unit_file_preset_all(
UnitFileChange **changes,
unsigned *n_changes) {
UnitFileChange **changes,
unsigned *n_changes) {
- _cleanup_
install_context_done_
InstallContext plus = {}, minus = {};
+ _cleanup_
(install_context_done)
InstallContext plus = {}, minus = {};
_cleanup_lookup_paths_free_ LookupPaths paths = {};
_cleanup_free_ char *config_path = NULL;
char **i;
_cleanup_lookup_paths_free_ LookupPaths paths = {};
_cleanup_free_ char *config_path = NULL;
char **i;
@@
-2016,14
+2017,15
@@
int unit_file_preset_all(
return r;
}
return r;
}
-static void unit
filelist_free(UnitFileList *
*f) {
- if (!
*
f)
+static void unit
_file_list_free_one(UnitFileList
*f) {
+ if (!f)
return;
return;
- free(
(*f)
->path);
- free(
*
f);
+ free(
f
->path);
+ free(f);
}
}
-#define _cleanup_unitfilelist_free_ _cleanup_(unitfilelist_free)
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(UnitFileList*, unit_file_list_free_one);
int unit_file_get_list(
UnitFileScope scope,
int unit_file_get_list(
UnitFileScope scope,
@@
-2041,6
+2043,12
@@
int unit_file_get_list(
if (root_dir && scope != UNIT_FILE_SYSTEM)
return -EINVAL;
if (root_dir && scope != UNIT_FILE_SYSTEM)
return -EINVAL;
+ if (root_dir) {
+ r = access(root_dir, F_OK);
+ if (r < 0)
+ return -errno;
+ }
+
r = lookup_paths_init_from_scope(&paths, scope, root_dir);
if (r < 0)
return r;
r = lookup_paths_init_from_scope(&paths, scope, root_dir);
if (r < 0)
return r;
@@
-2062,8
+2070,9
@@
int unit_file_get_list(
}
for (;;) {
}
for (;;) {
- _cleanup_
unitfilelist_free_
UnitFileList *f = NULL;
+ _cleanup_
(unit_file_list_free_onep)
UnitFileList *f = NULL;
struct dirent *de;
struct dirent *de;
+ _cleanup_free_ char *path = NULL;
errno = 0;
de = readdir(d);
errno = 0;
de = readdir(d);
@@
-2113,7
+2122,11
@@
int unit_file_get_list(
goto found;
}
goto found;
}
- r = unit_file_can_install(&paths, root_dir, f->path, true);
+ path = path_make_absolute(de->d_name, *i);
+ if (!path)
+ return -ENOMEM;
+
+ r = unit_file_can_install(&paths, root_dir, path, true);
if (r == -EINVAL || /* Invalid setting? */
r == -EBADMSG || /* Invalid format? */
r == -ENOENT /* Included file not found? */)
if (r == -EINVAL || /* Invalid setting? */
r == -EBADMSG || /* Invalid format? */
r == -ENOENT /* Included file not found? */)