From: mmaslano Date: Fri, 17 Aug 2007 13:00:52 +0000 (+0200) Subject: Crontab is stat instead of fstat and crontab is reopened for X-Git-Tag: v4.2~75 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7317e34dc022a81814f89be731a0fa13eaf9bd23;p=cronie Crontab is stat instead of fstat and crontab is reopened for reading new stdin. This change should: Allowed editors such as 'gedit' which do not modify original file, but which rename(2) a temp file to original, to be used by crontab -e (bug 129170). --- diff --git a/crontab.c b/crontab.c index 6b3ab10..b18601a 100644 --- a/crontab.c +++ b/crontab.c @@ -502,8 +502,8 @@ edit_cmd(void) { } (void)signal(SIGHUP, SIG_DFL); (void)signal(SIGINT, SIG_DFL); - (void)signal(SIGQUIT, SIG_DFL); - if (fstat(t, &statbuf) < 0) { + (void)signal(SIGQUIT, SIG_DFL); + if (stat(Filename, &statbuf) < 0) { perror("fstat"); goto fatal; } @@ -513,6 +513,13 @@ edit_cmd(void) { goto remove; } fprintf(stderr, "%s: installing new crontab\n", ProgramName); + fclose(NewCrontab); + NewCrontab=fopen(Filename,"r+"); + if( NewCrontab == 0L ) + { + perror("fopen"); + goto fatal; + } switch (replace_cmd()) { case 0: break;