← Commit list

051665ef6

Gray Wolf
Gray Wolf
2020-07-11
SUCCESS Duration: 151s

Subject

crontab: Fix -e with editors saving using renaming strategy

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

miscutils/crontab.c+5 -1
@@ -165,8 +165,12 @@ int crontab_main(int argc UNUSED_PARAM, char **argv)
close(fd);
xlseek(src_fd, 0, SEEK_SET);
}
- close_on_exec_on(src_fd); /* don't want editor to see this fd */
+ close(src_fd);
edit_file(pas, tmp_fname);
+ /* The src_fd needs to be reopened to handle editors that do
+ * save the buffer as new file and rename it to tmp_fname (so
+ * for example vim). */
+ src_fd = xopen3(tmp_fname, O_RDONLY, 0600);
/* fall through */
case 0: /* Replace (no -l, -e, or -r were given) */