FAQ
In perl.git, the branch tonyc/127663-safe-inplace has been created

(commit)

- Log -----------------------------------------------------------------
commit e38b05d0b34a73140d5c3dac7de0453c20354638
Author: Tony Cook <tony@develop-help.com>
Date: Thu May 26 15:31:33 2016 +1000

     move most of the work code from do_close to io_close()

     (this commit will be rebased back to the top)

M doio.c

commit b2e6beef6fd440cdc3facf92437f0e4f3873c258
Author: Tony Cook <tony@develop-help.com>
Date: Mon May 23 15:59:44 2016 +1000

     (perl #127663) test that setuid is preserved with nested in-place editing

     This test fails previously.

M t/io/nargv.t

commit 43dcb48d85e2a2dcefb4ca04deb51d4888d47163
Author: Tony Cook <tony@develop-help.com>
Date: Tue May 24 09:06:18 2016 +1000

     (perl #127663) add more in-place edit tests

M t/run/switches.t

commit fa82dc5bf40d401eb8317e7ee315b75b763df9e2
Author: Tony Cook <tony@develop-help.com>
Date: Thu May 19 15:22:32 2016 +1000

     (perl #127663) all platforms no longer need a backup file

     Since we do the work without touching the original file.

M perl.c

commit d95c780ddc4e9848008dff697148425aa745e9ba
Author: Tony Cook <tony@develop-help.com>
Date: Wed May 18 16:02:52 2016 +1000

     make sure the Perl_my_mkstemp() name is always available

M doio.c
M util.h

commit 02519b08fff3b98164984cd1048da4402957bdad
Author: Tony Cook <tony@develop-help.com>
Date: Wed May 18 15:17:42 2016 +1000

     use internal drand48() to innoculate against quadratic behaviour in pp_sort

M pp_sort.c

commit 29e9138efed2c3d6538000811de99e2109155729
Author: Tony Cook <tony@develop-help.com>
Date: Wed May 18 15:08:50 2016 +1000

     use the "internal" random source to initialize hash randomization

M util.c

commit e55a4358a72acb2badf40d61da5a77c5aae4a329
Author: Tony Cook <tony@develop-help.com>
Date: Thu May 12 16:58:05 2016 +1000

     (perl #127663) add our own mkstemp() implementation

     this needs a couple of adjustments:

     - needs a wrapper that calls either the system mkstemp() with a fallback
     to Perl_my_mkstemp().

     Not based on any particular implementation, the BSD implementations
     tend to be wrappers around a megafunction that also does a few variations
     of mkstemp() and mkdtemp(), which we don't need (yet.)

     One implementation I found, part of the heimdal crypto library, was
     simpler, but horrible.

M doio.c
M embed.fnc
M proto.h
M util.c

commit 1b9c545b47ca905d74e811373f5407e1909286ad
Author: Tony Cook <tony@develop-help.com>
Date: Wed May 18 15:03:14 2016 +1000

     (perl #127663) create a separate random souce for internal use

M embedvar.h
M intrpvar.h
M perl.c
M util.h

commit 8d0829a1d5e4e75cd159ca4138551259fba5fe4b
Author: Tony Cook <tony@develop-help.com>
Date: Thu May 12 14:46:18 2016 +1000

     (perl #127663) ensure abandoned work files are cleaned up

     If the user code that's processing in-place edit files exits or dies,
     previously this would leave the in-place edit work file in place.

     This patch deletes the temp file, abandoning the edit, which is a change
     from the old in-place editing, so maybe this should do the normal
     success processing currently done in do_close().

M doio.c

commit b6bd523a28ce53aaa3651aabfd5b8f51ec9534c3
Author: Tony Cook <tony@develop-help.com>
Date: Thu May 12 11:31:19 2016 +1000

     (perl #127663) don't test renaming directories if rename() isn't available.

     Perl uses link() to implement rename() if the rename system call
     isn't available, but using link() on directories varies between
     unavailable and dangerous.

     Since we haven't had any reports that of this test failing, it may
     mean we don't need to fallback to link().

M t/io/fs.t

commit 18775039fb14d76dcc381d5f31422b6a45aaec91
Author: Tony Cook <tony@develop-help.com>
Date: Thu May 12 11:29:37 2016 +1000

     (perl #127663) use link when rename() isn't available

     I suspect this is unnecessary, since unrelated tests failed without
     rename(), but it's not a huge change.

     Also, if rename() is available, attempt use link() to create the backup
     so there's always some version of the original file. Falls back to
     rename() if the link() fails, since the filesystem might not support
     link().

M doio.c

commit 1b840589b75caa1e6805eeffdd3fa79ab64efb90
Author: Tony Cook <tony@develop-help.com>
Date: Mon May 9 14:59:56 2016 +1000

     (perl #127663) WIP, safer in-place editing

     Previously in-place editing opened the file then immediately
     *replaced* the file, so if an error occurs while writing the output,
     such as running out of space, the content of the original file is lost.

     This changes in-place editing to write to a work file which is renamed
     over the original only once the output file is successfully closed.

     It also fixes an issue with setting setuid/setgid file modes for
     recursive in-place editing.

     The implementation (beyond some TODO issues below) has at least one
     problem - if the user code changes directory between the file open and
     the close then the final clean-up stage is going to fail if the input
     name wasn't an absolute path.

     This might be fixable, but on some systems it may put the perl process
     in a difficult to recover from position - if the system doesn't
     implement getcwd() perl may change directory out of the original and not
     have a way to return to it.

     Now the TODO issues:

     - the code uses mkstemp() - solvable by adapting a BSD implementation if
     the system doesn't provide it.

     - the code uses rename() - I need to re-work the code to use link() /
     UNLINK() where rename() isn't available

     - perl -i.back -pe 'exit' foo # leaves an orphan work file, this might
     be messy to fix (the fix would be trashing the work file, not moving it
     over the original).

     - where rename() and link() are available it might be desirable to link
     the backup file to the original file then rename the temp over the
     original so there's no point where the original doesn't exist. This
     would need to fallback to rename/rename just in case the system supports
     link but the current filesystem doesn't.

     - tests - existing tests caught one problem, but it needs more.

M doio.c
M embed.fnc
M embed.h
M mg.c
M pod/perldiag.pod
M proto.h
-----------------------------------------------------------------------

--
Perl5 Master Repository

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-changes @
categoriesperl
postedMay 26, '16 at 5:33a
activeMay 26, '16 at 5:33a
posts1
users1
websiteperl.org

1 user in discussion

Tony Cook: 1 post

People

Translate

site design / logo © 2018 Grokbase