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 62151d99d0cfbf1041cf0ffaaa0461f1cf74d049..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) {
@@
-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) {
@@
-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) {
@@
-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);
@@
-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) {
@@
-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) {