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

(commit)

- Log -----------------------------------------------------------------
commit 40f91904f7cc465c56dd0d2d1b92aaaab86a9f5f
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 c53e7862cda42cc2a1fdcb92b3c840111104bc77
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 821871ba94cc1d34f0f73602a74fbdde388d2b30
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 627ad774106388fc01d579d91252268bc1c03e11
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 8a3856606f6bd847dc7778806162ab4a88d9a776
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 15750838d887cb2518187e2fc1d52d1ee9c4e89e
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 2b09cd4dfe639563e6bf36c53c420cec1ba5a2e8
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 4744704acfa1d40d5e8d53df7c1f5ea21409c438
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 141de448a0d309e9defb58022e45b48055e2995f
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 b3bb8122d9df917c2312b5b5e757dd38aadbaaa1
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 b6b0c088359b2bac3f48fecc1164e85411978fd0
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 eb72e09fb7310e16d633fe8b895c3a304636477d
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 23, '16 at 11:41p
activeMay 23, '16 at 11:41p
posts1
users1
websiteperl.org

1 user in discussion

Tony Cook: 1 post

People

Translate

site design / logo © 2018 Grokbase