Hi Chris,
On Mar 10 21:08, Chris Denton wrote:
> Currently when starting a process from bash via a native symlink, argv[0] is
> set to the realpath of the executable and not to the link name. This patch
> fixes
> it so the path of the symlink is seen instead.
>
> The cause is a path conversion in perhaps_suffix which follows native
> symlinks. Hence the fix this patch uses is to add PC_SYM_NOFOLLOW_REP when
> calling path_conv::check to prevent that.
>
> Fixes: 1fd5e000ace55 ("import winsup-2000-02-17 snapshot")
This was a bit of a puzzler for me, given we added the PC_SYM_NOFOLLOW_REP
only 2011 with commit be371651146c ("* path.cc (path_conv::check): Don't
follow reparse point symlinks if PC_SYM_NOFOLLOW_REP flag is set.")
I think we should use this patch for the "Fixes:" info.
> Signed-off-by: SquallATF <[email protected]>
Hmm, on second thought, we can't do that.
Given you provide your own version of this patch, and given that this is
a trivial patch, I would prefer your personal Signed-off-by.
If you just agree here on the list, I will do the above changes manually.
No reason to send another patch version.
Ok?
Thanks,
Corinna
> ---
> winsup/cygwin/spawn.cc | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
> index 06b84236d..ef175e708 100644
> --- a/winsup/cygwin/spawn.cc
> +++ b/winsup/cygwin/spawn.cc
> @@ -43,7 +43,9 @@ perhaps_suffix (const char *prog, path_conv& buf, int& err,
> unsigned opt)
>
> err = 0;
> debug_printf ("prog '%s'", prog);
> - buf.check (prog, PC_SYM_FOLLOW | PC_NULLEMPTY | PC_POSIX, stat_suffixes);
> + buf.check (prog,
> + PC_SYM_FOLLOW | PC_SYM_NOFOLLOW_REP | PC_NULLEMPTY | PC_POSIX,
> + stat_suffixes);
>
> if (buf.isdir ())
> {
> --
> 2.48.1.windows.1
>
>
>
> ---- On Mon, 10 Mar 2025 19:15:08 +0000 Corinna Vinschen wrote ---
>
> > Hi Chris,
> >
> > On Mar 10 15:46, Chris Denton wrote:
> > > This upstreams the msys2 patch:
> > >
> https://github.com/msys2/MSYS2-packages/blob/6a02000fd93c6b2001220507e5369a726b6381c4/msys2-runtime/0021-Fix-native-symbolic-link-spawn-passing-wrong-arg0.patch
>
> > >
> > > Original msys2 issue:
> > > https://github.com/msys2/MSYS2-packages/issues/1327
> >
> > Sorry, but not like this. The commit message should describe the problem
> > and the chosen solution, not just point to some external websites.
> >
> > It's also missing a Fixes: and a Signed-off-by: line, the latter ideally
> > from the original author of the patch.
> >
> > > ---
> > > winsup/cygwin/spawn.cc | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
> > > index 06b84236d..b81ccefb7 100644
> > > --- a/winsup/cygwin/spawn.cc
> > > +++ b/winsup/cygwin/spawn.cc
> > > @@ -43,7 +43,7 @@ perhaps_suffix (const char *prog, path_conv& buf, int&
> err, unsigned opt)
> > >
> > > err = 0;
> > > debug_printf ("prog '%s'", prog);
> > > - buf.check (prog, PC_SYM_FOLLOW | PC_NULLEMPTY | PC_POSIX,
> stat_suffixes);
> > > + buf.check (prog, PC_SYM_FOLLOW | PC_SYM_NOFOLLOW_REP | PC_NULLEMPTY |
> PC_POSIX, stat_suffixes);
> >
> > Formatting should try to stick to max. 80 chars per line, please.
> >
> >
> > Thanks,
> > Corinna
> >