chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tmpfiles: Fix file descriptor leak on error
[elogind.git]
/
src
/
tmpfiles
/
tmpfiles.c
diff --git
a/src/tmpfiles/tmpfiles.c
b/src/tmpfiles/tmpfiles.c
index f10f90845e08d9337bf6c006896a35467fba295c..d8fb07e59a1e0008bfc62915be066274da730a14 100644
(file)
--- a/
src/tmpfiles/tmpfiles.c
+++ b/
src/tmpfiles/tmpfiles.c
@@
-409,7
+409,7
@@
static int clean_item(Item *i) {
i->type != IGNORE_PATH)
return 0;
i->type != IGNORE_PATH)
return 0;
- if (!i->age_set
|| i->age <= 0
)
+ if (!i->age_set)
return 0;
n = now(CLOCK_REALTIME);
return 0;
n = now(CLOCK_REALTIME);
@@
-507,8
+507,10
@@
static int write_one_file(Item *i, const char *path) {
_cleanup_free_ char *unescaped;
unescaped = cunescape(i->argument);
_cleanup_free_ char *unescaped;
unescaped = cunescape(i->argument);
- if (unescaped == NULL)
+ if (unescaped == NULL) {
+ close_nointr_nofail(fd);
return log_oom();
return log_oom();
+ }
l = strlen(unescaped);
n = write(fd, unescaped, l);
l = strlen(unescaped);
n = write(fd, unescaped, l);
@@
-673,6
+675,10
@@
static int create_item(Item *i) {
case CREATE_FILE:
case TRUNCATE_FILE:
case CREATE_FILE:
case TRUNCATE_FILE:
+ r = write_one_file(i, i->path);
+ if (r < 0)
+ return r;
+ break;
case WRITE_FILE:
r = glob_item(i, write_one_file);
if (r < 0)
case WRITE_FILE:
r = glob_item(i, write_one_file);
if (r < 0)
@@
-1361,7
+1367,7
@@
int main(int argc, char *argv[]) {
for (j = optind; j < argc; j++) {
char *fragment;
for (j = optind; j < argc; j++) {
char *fragment;
- fragment = resolve_fragment(argv[j], (const char
**)
conf_file_dirs);
+ fragment = resolve_fragment(argv[j], (const char
**)
conf_file_dirs);
if (!fragment) {
log_error("Failed to find a %s file: %m", argv[j]);
r = EXIT_FAILURE;
if (!fragment) {
log_error("Failed to find a %s file: %m", argv[j]);
r = EXIT_FAILURE;
@@
-1375,8
+1381,7
@@
int main(int argc, char *argv[]) {
} else {
char **files, **f;
} else {
char **files, **f;
- r = conf_files_list_strv(&files, ".conf",
- (const char **) conf_file_dirs);
+ r = conf_files_list_strv(&files, ".conf", (const char **)conf_file_dirs);
if (r < 0) {
log_error("Failed to enumerate tmpfiles.d files: %s", strerror(-r));
r = EXIT_FAILURE;
if (r < 0) {
log_error("Failed to enumerate tmpfiles.d files: %s", strerror(-r));
r = EXIT_FAILURE;