On Wed, Mar 29, 2023 at 08:37:00AM -0300, Jesse Smith wrote: > > Given subsequent discussion, could we instead use canonicalize_file_name > > or realpath here instead? That would give us the "correct" path without > > pidof having to think hard about symlinks et al. > > I'm open to the possibility. I'm curious as to what you see as the pros > vs cons of changing the approach used by pidof?
Markus' orginal report suggested this was a regression since Bullseye sysvinit-utils | 2.96-7+deb11u1 | stable | amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, s390x rather than a proposal to change behaviour. I think I have found the offending commit: 0b695c7e0b1cac60ed77c56f224e296f023b652e uses memset *after* realpath which wipes the canonical resolved path. I suggest this fix as a starting point. Mark
>From 346cc4a8a91f908c8a57a16fb041c44809517183 Mon Sep 17 00:00:00 2001 From: Mark Hindley <m...@hindley.org.uk> Date: Wed, 29 Mar 2023 13:57:24 +0100 Subject: [PATCH] Fix following of executable symlinks. Fixes regression introduced in 0b695c7e0b1cac60ed77c56f224e296f023b652e --- src/killall5.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/killall5.c b/src/killall5.c index b0728fab..787c4226 100644 --- a/src/killall5.c +++ b/src/killall5.c @@ -739,10 +739,8 @@ PIDQ_HEAD *pidof(char *prog) return NULL; /* Try to stat the executable. */ - if ( (prog[0] == '/') && ( realpath(prog, real_path) ) ) { - memset(&real_path[0], 0, sizeof(real_path)); + if ( (prog[0] == '/') && ( realpath(prog, real_path) ) ) dostat++; - } /* Get basename of program. */ if ((s = strrchr(prog, '/')) == NULL) -- 2.39.2