fix native symlink spawn passing wrong arg0

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: be37165114 ("* path.cc (path_conv::check): Don't follow reparse point symlinks if PC_SYM_NOFOLLOW_REP flag is set.")
Signed-off-by: Chris Denton <chris@chrisdenton.dev>
This commit is contained in:
Chris Denton authored and Corinna Vinschen committed 2025-03-17 19:58:40 +01:00
1 parent 5ec497dc80
commit f74dc93c63
1 file changed
+3 -1
+3 -1
View File
@@ -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 ())
{