chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
install: create_symlink() check unlink() return value
[elogind.git]
/
src
/
shared
/
install.c
diff --git
a/src/shared/install.c
b/src/shared/install.c
index 233d64b6e95c082f45deb0a19932f999f9255262..6334833812a688ba24010f0eb2bdbcb2f465a8f4 100644
(file)
--- a/
src/shared/install.c
+++ b/
src/shared/install.c
@@
-204,7
+204,7
@@
static int remove_marked_symlinks_fd(
d = fdopendir(fd);
if (!d) {
d = fdopendir(fd);
if (!d) {
-
close_nointr_nofail
(fd);
+
safe_close
(fd);
return -errno;
}
return -errno;
}
@@
-244,7
+244,7
@@
static int remove_marked_symlinks_fd(
p = path_make_absolute(de->d_name, path);
if (!p) {
p = path_make_absolute(de->d_name, path);
if (!p) {
-
close_nointr_nofail
(nfd);
+
safe_close
(nfd);
return -ENOMEM;
}
return -ENOMEM;
}
@@
-344,7
+344,7
@@
static int remove_marked_symlinks(
r = q;
} while (deleted);
r = q;
} while (deleted);
-
close_nointr_nofail
(fd);
+
safe_close
(fd);
return r;
}
return r;
}
@@
-367,7
+367,7
@@
static int find_symlinks_fd(
d = fdopendir(fd);
if (!d) {
d = fdopendir(fd);
if (!d) {
-
close_nointr_nofail
(fd);
+
safe_close
(fd);
return -errno;
}
return -errno;
}
@@
-403,7
+403,7
@@
static int find_symlinks_fd(
p = path_make_absolute(de->d_name, path);
if (!p) {
p = path_make_absolute(de->d_name, path);
if (!p) {
-
close_nointr_nofail
(nfd);
+
safe_close
(nfd);
return -ENOMEM;
}
return -ENOMEM;
}
@@
-469,8
+469,6
@@
static int find_symlinks_fd(
return 1;
}
}
return 1;
}
}
-
- return r;
}
static int find_symlinks(
}
static int find_symlinks(
@@
-556,7
+554,7
@@
int unit_file_mask(
UnitFileScope scope,
bool runtime,
const char *root_dir,
UnitFileScope scope,
bool runtime,
const char *root_dir,
- char *
files[]
,
+ char *
*files
,
bool force,
UnitFileChange **changes,
unsigned *n_changes) {
bool force,
UnitFileChange **changes,
unsigned *n_changes) {
@@
-575,7
+573,7
@@
int unit_file_mask(
STRV_FOREACH(i, files) {
_cleanup_free_ char *path = NULL;
STRV_FOREACH(i, files) {
_cleanup_free_ char *path = NULL;
- if (!unit_name_is_valid(*i,
true
)) {
+ if (!unit_name_is_valid(*i,
TEMPLATE_VALID
)) {
if (r == 0)
r = -EINVAL;
continue;
if (r == 0)
r = -EINVAL;
continue;
@@
-625,7
+623,7
@@
int unit_file_unmask(
UnitFileScope scope,
bool runtime,
const char *root_dir,
UnitFileScope scope,
bool runtime,
const char *root_dir,
- char *
files[]
,
+ char *
*files
,
UnitFileChange **changes,
unsigned *n_changes) {
UnitFileChange **changes,
unsigned *n_changes) {
@@
-643,7
+641,7
@@
int unit_file_unmask(
STRV_FOREACH(i, files) {
char *path;
STRV_FOREACH(i, files) {
char *path;
- if (!unit_name_is_valid(*i,
true
)) {
+ if (!unit_name_is_valid(*i,
TEMPLATE_VALID
)) {
if (r == 0)
r = -EINVAL;
continue;
if (r == 0)
r = -EINVAL;
continue;
@@
-690,7
+688,7
@@
int unit_file_link(
UnitFileScope scope,
bool runtime,
const char *root_dir,
UnitFileScope scope,
bool runtime,
const char *root_dir,
- char *
files[]
,
+ char *
*files
,
bool force,
UnitFileChange **changes,
unsigned *n_changes) {
bool force,
UnitFileChange **changes,
unsigned *n_changes) {
@@
-719,7
+717,7
@@
int unit_file_link(
fn = basename(*i);
if (!path_is_absolute(*i) ||
fn = basename(*i);
if (!path_is_absolute(*i) ||
- !unit_name_is_valid(fn,
true
)) {
+ !unit_name_is_valid(fn,
TEMPLATE_VALID
)) {
if (r == 0)
r = -EINVAL;
continue;
if (r == 0)
r = -EINVAL;
continue;
@@
-861,7
+859,7
@@
static int install_info_add(
if (!name)
name = basename(path);
if (!name)
name = basename(path);
- if (!unit_name_is_valid(name,
true
))
+ if (!unit_name_is_valid(name,
TEMPLATE_VALID
))
return -EINVAL;
if (hashmap_get(c->have_installed, name) ||
return -EINVAL;
if (hashmap_get(c->have_installed, name) ||
@@
-1010,7
+1008,7
@@
static int unit_file_load(
f = fdopen(fd, "re");
if (!f) {
f = fdopen(fd, "re");
if (!f) {
-
close_nointr_nofail
(fd);
+
safe_close
(fd);
return -ENOMEM;
}
return -ENOMEM;
}
@@
-1172,7
+1170,9
@@
static int create_symlink(
if (!force)
return -EEXIST;
if (!force)
return -EEXIST;
- unlink(new_path);
+ r = unlink(new_path);
+ if (r < 0 && errno != ENOENT)
+ return -errno;
if (symlink(old_path, new_path) >= 0) {
add_file_change(changes, n_changes, UNIT_FILE_UNLINK, new_path, NULL);
if (symlink(old_path, new_path) >= 0) {
add_file_change(changes, n_changes, UNIT_FILE_UNLINK, new_path, NULL);
@@
-1235,7
+1235,7
@@
static int install_info_symlink_wants(
if (q < 0)
return q;
if (q < 0)
return q;
- if (!unit_name_is_valid(dst,
true
)) {
+ if (!unit_name_is_valid(dst,
TEMPLATE_VALID
)) {
r = -EINVAL;
continue;
}
r = -EINVAL;
continue;
}
@@
-1272,7
+1272,7
@@
static int install_info_symlink_requires(
if (q < 0)
return q;
if (q < 0)
return q;
- if (!unit_name_is_valid(dst,
true
)) {
+ if (!unit_name_is_valid(dst,
TEMPLATE_VALID
)) {
r = -EINVAL;
continue;
}
r = -EINVAL;
continue;
}
@@
-1462,7
+1462,7
@@
int unit_file_enable(
UnitFileScope scope,
bool runtime,
const char *root_dir,
UnitFileScope scope,
bool runtime,
const char *root_dir,
- char *
files[]
,
+ char *
*files
,
bool force,
UnitFileChange **changes,
unsigned *n_changes) {
bool force,
UnitFileChange **changes,
unsigned *n_changes) {
@@
-1502,7
+1502,7
@@
int unit_file_disable(
UnitFileScope scope,
bool runtime,
const char *root_dir,
UnitFileScope scope,
bool runtime,
const char *root_dir,
- char *
files[]
,
+ char *
*files
,
UnitFileChange **changes,
unsigned *n_changes) {
UnitFileChange **changes,
unsigned *n_changes) {
@@
-1543,7
+1543,7
@@
int unit_file_reenable(
UnitFileScope scope,
bool runtime,
const char *root_dir,
UnitFileScope scope,
bool runtime,
const char *root_dir,
- char *
files[]
,
+ char *
*files
,
bool force,
UnitFileChange **changes,
unsigned *n_changes) {
bool force,
UnitFileChange **changes,
unsigned *n_changes) {
@@
-1675,7
+1675,7
@@
UnitFileState unit_file_get_state(
if (root_dir && scope != UNIT_FILE_SYSTEM)
return -EINVAL;
if (root_dir && scope != UNIT_FILE_SYSTEM)
return -EINVAL;
- if (!unit_name_is_valid(name,
true
))
+ if (!unit_name_is_valid(name,
TEMPLATE_VALID
))
return -EINVAL;
r = lookup_paths_init_from_scope(&paths, scope);
return -EINVAL;
r = lookup_paths_init_from_scope(&paths, scope);
@@
-1820,7
+1820,7
@@
int unit_file_preset(
UnitFileScope scope,
bool runtime,
const char *root_dir,
UnitFileScope scope,
bool runtime,
const char *root_dir,
- char *
files[]
,
+ char *
*files
,
bool force,
UnitFileChange **changes,
unsigned *n_changes) {
bool force,
UnitFileChange **changes,
unsigned *n_changes) {
@@
-1845,7
+1845,7
@@
int unit_file_preset(
STRV_FOREACH(i, files) {
STRV_FOREACH(i, files) {
- if (!unit_name_is_valid(*i,
true
))
+ if (!unit_name_is_valid(*i,
TEMPLATE_VALID
))
return -EINVAL;
r = unit_file_query_preset(scope, *i);
return -EINVAL;
r = unit_file_query_preset(scope, *i);
@@
-1949,7
+1949,7
@@
int unit_file_get_list(
if (ignore_file(de->d_name))
continue;
if (ignore_file(de->d_name))
continue;
- if (!unit_name_is_valid(de->d_name,
true
))
+ if (!unit_name_is_valid(de->d_name,
TEMPLATE_VALID
))
continue;
if (hashmap_get(h, de->d_name))
continue;
if (hashmap_get(h, de->d_name))