Re: [PATCH] gc: use temporary file for editing crontab

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2022-08-23 at 17:06:03, Derrick Stolee wrote:
> On 8/23/2022 5:12 AM, Johannes Schindelin wrote:
> > Hi brian,
> > 
> > On Tue, 23 Aug 2022, brian m. carlson wrote:
> 
> >> +	tmpedit = mks_tempfile_t(".git_cron_edit_tmpXXXXXX");
> >> +	if (!tmpedit)
> >> +		return error(_("failed to create crontab temporary file"));
> > 
> > It might make sense to use the same `goto out;` pattern here, to make it
> > easier to reason about the early exit even six years from now.
> > 
> > We do not even have to guard the `close_tempfile_gently()` behind an `if
> > (tempfile)` conditional because that function handles `NULL` parameters
> > gently.

I can do that.  I'll need to make sure we initialize the pointer to NULL
first.

> This is focused only on the cron integration, which is not used on Windows,
> so I'm not worried about that.

Correct.  The only place this could go wrong is Cygwin, but I believe it
has the proper behaviour (and if not, lots of stuff will be broken).

> I was initially worried that we lost the fclose(cron_in), but of course it
> is handled by the close_tempfile_gently() at the end.

Yup.  I originally called fclose here and glibc screamed at me about a
double-free, so the fclose definitely should be removed.  I'll mention
this in the commit message as well.

> Here's the crux of the matter: we are no longer using stdin but
> instead passing an argument to point to a file with our desired
> schedule. I tested that this worked on my machine, and I'm glad
> this use is the POSIX standard.
> 
> There is something wrong with this patch: it needs to update
> t/helper/test-crontab.c in order to pass t7900-maintenance.sh.

Will fix.

> While the memory release is nice, I also think it would be good to use
> delete_tempfile() so the temporary file is deleted within this method,
> not waiting until the end of the process to do that cleanup.

Sounds good.  I'll include that in a v2.
-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux