Re: Help testing release candidate / mc-4.8.28-rc1

2022-03-21 Thread Oswald Buddenhagen via mc-devel

On Mon, Mar 21, 2022 at 09:44:45AM +0300, Andrew Borodin wrote:

mc-wrapper.sh doesn't create a file.


i know, but i'm using my own function (for historical reasons):

mc ()
{
local tf=$(mktemp);
/usr/local/bin/mc -P $tf "$@" && test -r $tf && cd "$(<$tf)";
rm -f $tf
}

... which, *cannot* have ever worked. it's somewhat unsurprising that i 
didn't notice, as my kde-based workflows don't rely on it working.


still, it seemed beizarre that i did't notice for a whole two decades,
so i looked around ... and each of my two other machines has a different 
working version: one has tf=/tmp/mc-`whoami`/wd$$, which i presume is 
the oldest one, and one has tf=$XDG_RUNTIME_DIR/mc-wd-$$. so i suppose 
i'm sleepwalking.  :'-D


A workaround is to apply `mktemp -u` or even `mktemp -u -t`, but is it 
portable?


dunno. but it would be a mediocre idea anyway, and absolutely terrible 
without the O_EXCL (because symlink attacks).


but anyway, this is an entirely self-made problem. sorry for the noise.
___
mc-devel mailing list
https://mail.gnome.org/mailman/listinfo/mc-devel


Re: Help testing release candidate / mc-4.8.28-rc1

2022-03-21 Thread Andrew Borodin
On Sun, 20 Mar 2022 19:12:13 +0100 Oswald Buddenhagen via mc-devel 
 wrote:
> On Sun, Mar 20, 2022 at 06:59:32PM +0300, Andrew Borodin wrote:
> >On Sun, 20 Mar 2022 15:22:14 +0100 Oswald Buddenhagen via mc-devel 
> >
> > wrote:
> >> `mc -P $file` doesn't work any more when the file already exists 
> >> (which is of course the case after file=`mktemp`).
> >
> >Indeed.
> >
> >A following patch is proposed:
> >
> >diff --git a/src/main.c b/src/main.c
> >index 3a33dfb59..a4910349a 100644
> >--- a/src/main.c
> >+++ b/src/main.c
> >@@ -492,6 +492,10 @@ main (int argc, char *argv[])
> > 
> > last_wd_fd = open (mc_args__last_wd_file, O_WRONLY | O_CREAT | 
> > O_TRUNC | O_EXCL,
> >S_IRUSR | S_IWUSR);
> >+
> >+if (last_wd_fd == -1 && errno == EEXIST)
> >+last_wd_fd = open (mc_args__last_wd_file, O_WRONLY | O_TRUNC, 
> >S_IRUSR | S_IWUSR);
> >+
> > if (last_wd_fd != -1)
> > {
> > ssize_t ret1;
> >
> that seems overly complicated - why not just drop the O_EXCL? at least i 
> can't see an obvious
> reason for having it in the first place.

Ok.

> anyway, i wonder why i ran into this only recently, given that this behavior 
> is actually
> rather ancient. probably has something to do with me porting the wrapper 
> function from
> tempfile to mktemp (as debian started to complain about deprecation), though 
> the replacement
> itself couldn't have caused it.

mc-wrapper.sh doesn't create a file. It creates a file name only. then mc 
creates a file with
given file name, and everything works fine.

Wrapper patched to use mktemp creates a file, and mc tries to open an existing 
file and fails.
A workaround is to apply `mktemp -u` or even `mktemp -u -t`, but is it portable?

-- 
A.


___
mc-devel mailing list
https://mail.gnome.org/mailman/listinfo/mc-devel